/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  /* color */
  --bg:               #f7f8fa;
  --surface:          #ffffff;
  --surface-sunken:   #f1f3f7;
  --surface-elevated: #ffffff;
  --border:           #e6e8ee;
  --border-strong:    #d4d7e0;
  --accent:           #2563eb;
  --accent-hover:     #1d4ed8;
  --accent-soft:      #eff4ff;
  --accent-fg:        #1e40af;
  --text:             #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;
  --success:          #15803d;
  --success-bg:       #f0fdf4;
  --success-border:   #bbf7d0;
  --warning:          #c2410c;
  --warning-bg:       #fff7ed;
  --warning-border:   #fed7aa;
  --danger:           #b91c1c;
  --danger-bg:        #fef2f2;
  --danger-border:    #fecaca;

  /* type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;

  /* radius */
  --radius-sm:  6px;
  --radius:     8px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* shadow */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 2px 4px -2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 24px -6px rgba(15, 23, 42, .10), 0 4px 6px -4px rgba(15, 23, 42, .04);

  /* motion */
  --tr-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr:      200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* layout */
  --sidebar-w: 240px;
  --content-max: 1180px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

a { color: var(--accent); text-decoration: none; transition: color var(--tr-fast); }
a:hover { color: var(--accent-hover); }

code, pre { font-family: var(--font-mono); }
code { font-size: .85em; background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; }

button { font-family: inherit; }

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 20;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
}
.sidebar-brand .logo svg { width: 18px; height: 18px; }
.sidebar-brand .brand-text { line-height: 1.15; }
.sidebar-brand .brand-text .name { font-weight: 700; font-size: .95rem; }
.sidebar-brand .brand-text .sub  { font-size: .72rem; color: var(--text-muted); }

.sidebar-nav {
  padding: .75rem .5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .8rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--tr-fast), color var(--tr-fast);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-link:hover { background: var(--surface-sunken); color: var(--text); }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-fg);
  font-weight: 600;
}
.nav-link.active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-muted);
}
.sidebar-footer .status-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .35rem .6rem;
  background: var(--surface-sunken);
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.logout-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .75rem;
  font-size: .78rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: .3rem .4rem;
  border-radius: var(--radius-sm);
  transition: color var(--tr-fast), background var(--tr-fast);
}
.logout-link:hover { color: var(--danger); background: var(--danger-bg); }
.logout-link svg { width: 14px; height: 14px; opacity: .7; }

/* ── Main ───────────────────────────────────────────────────────────────── */
main {
  padding: 2rem 2.5rem 4rem;
  max-width: var(--content-max);
  width: 100%;
}

.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.015em; }
.page-header .subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }

h2 {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin: 2rem 0 .85rem;
}

/* ── Mobile toggle (hidden on desktop) ──────────────────────────────────── */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem;
  box-shadow: var(--shadow-sm);
}
.mobile-toggle svg { width: 20px; height: 20px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-xs);
  margin-bottom: 1rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .9rem;
  margin-bottom: 1.25rem;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: .25rem;
  transition: transform var(--tr), box-shadow var(--tr);
  position: relative;
  overflow: hidden;
}
.metric:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.metric-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .35rem;
}
.metric-label svg { width: 13px; height: 13px; opacity: .7; }

.metric-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.metric-value.small { font-size: 1rem; font-weight: 600; }
.metric-value.tiny  { font-size: .85rem; font-weight: 600; word-break: break-all; }

.metric-sub {
  font-size: .76rem;
  color: var(--text-secondary);
  margin-top: .15rem;
}

.metric-sub.muted { color: var(--text-muted); }

.metric .corner-badge {
  position: absolute;
  top: .85rem;
  right: 1rem;
}

/* ── Status dots ────────────────────────────────────────────────────────── */
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  position: relative;
}
.dot-green {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .15);
}
.dot-green::after {
  content: ''; position: absolute; inset: 0;
  border-radius: 50%; background: #22c55e;
  animation: pulse 2s ease-out infinite;
}
.dot-red    { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .15); }
.dot-yellow { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .15); }

@keyframes pulse {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(2.5); opacity: 0;  }
}

.status-row { display: flex; align-items: center; gap: .55rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .68rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-warning { background: var(--warning-bg);  color: var(--warning); border: 1px solid var(--warning-border); }
.badge-success { background: var(--success-bg);  color: var(--success); border: 1px solid var(--success-border); }
.badge-info    { background: var(--accent-soft); color: var(--accent-fg); border: 1px solid #c7dcff; }

/* ── Sparkline ──────────────────────────────────────────────────────────── */
.sparkline {
  width: 100%;
  height: 36px;
  margin-top: .5rem;
  color: var(--accent);
  overflow: visible;
}
.sparkline-empty { color: var(--border-strong); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
  transition: background var(--tr-fast), border-color var(--tr-fast), color var(--tr-fast), transform var(--tr-fast);
  white-space: nowrap;
  position: relative;
}
.btn:hover    { transform: translateY(-1px); }
.btn:active   { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-secondary:hover { background: var(--surface-sunken); color: var(--text); border-color: var(--border-strong); }

.btn-danger {
  background: var(--surface);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  padding: .35rem .55rem;
}
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-sm svg { width: 13px; height: 13px; }

.btn-spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* htmx loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator   { display: inline-flex; }
.btn.htmx-request .btn-text    { opacity: .5; }
.btn.htmx-request .btn-spinner { display: inline-flex; }
.btn-spinner { display: none; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .88rem;
  line-height: 1.5;
  border: 1px solid;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: #14532d; }
.alert-error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: #7f1d1d; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: #7c2d12; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-sunken);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  width: fit-content;
  flex-wrap: wrap;
}
.tab-btn {
  padding: .45rem .95rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 6px;
  transition: background var(--tr-fast), color var(--tr-fast);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--surface);
  color: var(--accent-fg);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}

.field small {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.field input, .field textarea, .field select {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: .88rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.field input.invalid { border-color: var(--danger); }
.field input.invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Single-line checkbox row inside .field-row (overrides the 2-col grid) */
.field-row:has(> label.check) {
  display: flex;
  gap: .5rem;
  margin: .3rem 0;
}
label.check {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
  font-size: .92rem;
  color: var(--text);
}
label.check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Dynamic list rows ──────────────────────────────────────────────────── */
.list-item {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: .5rem;
}
.list-item input {
  flex: 1;
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .88rem;
}
.list-item input:focus { outline: none; border-color: var(--accent); }

/* ── Data tables (schedule + URLs + history) ────────────────────────────── */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: .5rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .55rem .6rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table td input {
  width: 100%;
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .84rem;
  background: var(--surface);
}
.data-table td input:focus { outline: none; border-color: var(--accent); }

/* legacy aliases (still used by config tabs) */
.schedule-table, .url-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.schedule-table th, .url-table th {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: .5rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.schedule-table td, .url-table td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
}
.schedule-table tr:last-child td, .url-table tr:last-child td { border-bottom: none; }
.schedule-table td input, .url-table td input {
  width: 100%;
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .84rem;
}
.schedule-table td input:focus, .url-table td input:focus { outline: none; border-color: var(--accent); }

/* ── Action area ────────────────────────────────────────────────────────── */
.action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: .25rem;
}

.action-output {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-top: .75rem;
  overflow-x: auto;
}
.action-ok {
  color: var(--success);
  font-size: .85rem;
  margin-top: .75rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* ── Diff viewer ────────────────────────────────────────────────────────── */
.diff-view {
  background: #0f172a;
  color: #cbd5e1;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 460px;
  overflow-y: auto;
  margin-top: .5rem;
}
.diff-add  { color: #4ade80; display: inline; }
.diff-del  { color: #f87171; display: inline; }
.diff-hunk { color: #93c5fd; font-style: italic; display: inline; }
.diff-ctx  { color: #cbd5e1; display: inline; }

.text-preview {
  background: var(--surface-sunken);
  color: var(--text);
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  max-height: 460px;
  overflow-y: auto;
  margin-top: .5rem;
  border: 1px solid var(--border);
}

.snapshot-img {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: .5rem;
  display: block;
  cursor: zoom-in;
}

/* ── History rows ───────────────────────────────────────────────────────── */
.history-row {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}
.history-row:first-child { padding-top: 0; }
.history-row:last-child { border-bottom: none; }

.history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
}
.history-meta .ts {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.history-meta .url {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  word-break: break-all;
}
.history-meta .summary {
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.summary-add { color: var(--success); }
.summary-del { color: var(--danger); }

.history-actions {
  display: flex;
  gap: .4rem;
  margin-top: .65rem;
  flex-wrap: wrap;
}

.history-content { margin-top: .5rem; }

/* Site-snapshot row variant */
.history-row--site { background: var(--accent-soft); border-radius: var(--radius); padding: 1rem; margin-bottom: .5rem; }
.history-row--removed { background: var(--warning-bg); border-radius: var(--radius); padding: 1rem; margin-bottom: .5rem; }
.url-badge { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; font-size: .85rem; padding: .2rem .6rem; border-radius: 99px; }
.url-badge--site { background: var(--accent); color: #fff; }
.url-badge--removed { background: var(--warning); color: #fff; }

/* Site snapshot grid */
.site-snap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: .75rem;
}
.site-snap-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.site-snap-url {
  font-size: .75rem;
  font-family: var(--font-mono);
  padding: .4rem .6rem;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}
.site-snap-thumb { display: block; width: 100%; cursor: zoom-in; }
.site-snap-nopng {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .8rem;
}

/* ── Logs viewer ────────────────────────────────────────────────────────── */
.log-view {
  background: #0f172a;
  color: #cbd5e1;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.55;
  white-space: pre;
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
}
.log-line { display: block; }
.log-info  { color: #cbd5e1; }
.log-warn  { color: #fbbf24; }
.log-error { color: #f87171; font-weight: 500; }
.log-time  { color: #64748b; }

/* ── Modal (screenshot zoom) ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 2rem;
  cursor: zoom-out;
}
.modal-backdrop.open { display: flex; }
.modal-backdrop img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 50;
  pointer-events: none;
}
.toast {
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  pointer-events: auto;
  animation: toastIn .25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  min-width: 220px;
}
.toast.out { animation: toastOut .2s ease forwards; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toastIn  {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

/* ── Loading skeleton ───────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 25%, #e8eaf0 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 4px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Misc helpers ───────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: .5rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mb-3 { margin-bottom: .75rem; }
.hidden { display: none !important; }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-title h3 { font-size: .95rem; font-weight: 600; }
.card-title .meta { font-size: .78rem; color: var(--text-muted); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform var(--tr);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: flex; }
  main { padding: 4rem 1.25rem 3rem; }
}

@media (max-width: 600px) {
  .field-row { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-value { font-size: 1.2rem; }
  .page-header h1 { font-size: 1.25rem; }
  main { padding: 4rem 1rem 3rem; }
  .schedule-table, .url-table, .data-table { font-size: .8rem; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
}

/* ── Tag input (rescue keywords) ─────────────────────────────────────────── */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-height: 1.8rem;
  padding: .35rem .5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tag-input:empty::before {
  content: "(sin palabras configuradas)";
  color: var(--text-muted);
  font-size: .82rem;
  font-style: italic;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .15rem .55rem;
  background: var(--accent-soft, rgba(99, 102, 241, .15));
  color: var(--accent, #6366f1);
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 500;
}
.tag button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 .15rem;
  opacity: .65;
}
.tag button:hover { opacity: 1; }

/* ── Exclude URL button ─────────────────────────────────────────────────── */
.exclude-btn { opacity: .4; transition: opacity var(--tr-fast), background var(--tr-fast); }
.exclude-btn:hover { opacity: 1; background: var(--danger-bg); }
