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

/* ===== THEME VARIABLES ===== */

:root {
  /* Light theme (default) */
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-hover: 0 2px 6px rgba(0,0,0,.1);
  --radius: 6px;

  --header-bg: #1f2937;
  --header-text: #f9fafb;
  --header-link: #d1d5db;
  --header-link-hover: #ffffff;

  --status-open: #b45309;
  --status-ok: #15803d;
  --status-rework: #0369a1;
  --status-ignored: var(--text-muted);

  --danger: #b91c1c;
  --danger-hover: #991b1b;

  --warning-bg: #fef3c7;
  --warning-border: #fcd34d;
  --warning-text: #92400e;

  --error-bg: #fee2e2;
  --error-text: #991b1b;

  --success-bg: #d4edda;
  --success-text: #155724;

  --btn-cancel-bg: #6b7280;
  --btn-cancel-hover: #4b5563;
  --btn-cancel-text: #ffffff;

  --badge-queued-bg: #e5e7eb;
  --badge-queued-text: #374151;
  --badge-running-bg: #fef3c7;
  --badge-running-text: #92400e;
  --badge-done-bg: #d4edda;
  --badge-done-text: #155724;
  --badge-failed-bg: #fee2e2;
  --badge-failed-text: #991b1b;
  --badge-cancelled-bg: #e5e7eb;
  --badge-cancelled-text: #4b5563;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-text: #ffffff;

    --bg: #0f172a;
    --surface: #1f2937;
    --surface-2: #111827;
    --surface-3: #374151;
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --border: #374151;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-hover: 0 2px 6px rgba(0,0,0,.4);

    --header-bg: #020617;
    --header-text: #f9fafb;
    --header-link: #d1d5db;
    --header-link-hover: #ffffff;

    --status-open: #fbbf24;
    --status-ok: #4ade80;
    --status-rework: #38bdf8;
    --status-ignored: var(--text-muted);

    --danger: #f87171;
    --danger-hover: #fca5a5;

    --warning-bg: #451a03;
    --warning-border: #78350f;
    --warning-text: #fcd34d;

    --error-bg: #450a0a;
    --error-text: #fca5a5;

    --success-bg: #052e16;
    --success-text: #86efac;

    --btn-cancel-bg: #4b5563;
    --btn-cancel-hover: #374151;
    --btn-cancel-text: #f9fafb;

    --badge-queued-bg: #374151;
    --badge-queued-text: #e5e7eb;
    --badge-running-bg: #451a03;
    --badge-running-text: #fcd34d;
    --badge-done-bg: #052e16;
    --badge-done-text: #86efac;
    --badge-failed-bg: #450a0a;
    --badge-failed-text: #fca5a5;
    --badge-cancelled-bg: #374151;
    --badge-cancelled-text: #e5e7eb;
  }
}

html[data-theme="light"] {
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text: #ffffff;

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #d1d5db;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-hover: 0 2px 6px rgba(0,0,0,.1);

  --header-bg: #1f2937;
  --header-text: #f9fafb;
  --header-link: #d1d5db;
  --header-link-hover: #ffffff;

  --status-open: #b45309;
  --status-ok: #15803d;
  --status-rework: #0369a1;
  --status-ignored: var(--text-muted);

  --danger: #b91c1c;
  --danger-hover: #991b1b;

  --warning-bg: #fef3c7;
  --warning-border: #fcd34d;
  --warning-text: #92400e;

  --error-bg: #fee2e2;
  --error-text: #991b1b;

  --success-bg: #d4edda;
  --success-text: #155724;

  --btn-cancel-bg: #6b7280;
  --btn-cancel-hover: #4b5563;
  --btn-cancel-text: #ffffff;

  --badge-queued-bg: #e5e7eb;
  --badge-queued-text: #374151;
  --badge-running-bg: #fef3c7;
  --badge-running-text: #92400e;
  --badge-done-bg: #d4edda;
  --badge-done-text: #155724;
  --badge-failed-bg: #fee2e2;
  --badge-failed-text: #991b1b;
  --badge-cancelled-bg: #e5e7eb;
  --badge-cancelled-text: #4b5563;
}

html[data-theme="dark"] {
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-text: #ffffff;

  --bg: #0f172a;
  --surface: #1f2937;
  --surface-2: #111827;
  --surface-3: #374151;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --border: #374151;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-hover: 0 2px 6px rgba(0,0,0,.4);

  --header-bg: #020617;
  --header-text: #f9fafb;
  --header-link: #d1d5db;
  --header-link-hover: #ffffff;

  --status-open: #fbbf24;
  --status-ok: #4ade80;
  --status-rework: #38bdf8;
  --status-ignored: var(--text-muted);

  --danger: #f87171;
  --danger-hover: #fca5a5;

  --warning-bg: #451a03;
  --warning-border: #78350f;
  --warning-text: #fcd34d;

  --error-bg: #450a0a;
  --error-text: #fca5a5;

  --success-bg: #052e16;
  --success-text: #86efac;

  --btn-cancel-bg: #4b5563;
  --btn-cancel-hover: #374151;
  --btn-cancel-text: #f9fafb;

  --badge-queued-bg: #374151;
  --badge-queued-text: #e5e7eb;
  --badge-running-bg: #451a03;
  --badge-running-text: #fcd34d;
  --badge-done-bg: #052e16;
  --badge-done-text: #86efac;
  --badge-failed-bg: #450a0a;
  --badge-failed-text: #fca5a5;
  --badge-cancelled-bg: #374151;
  --badge-cancelled-text: #e5e7eb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-box {
  background: var(--surface); padding: 2rem; border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 380px;
  border: 1px solid var(--border);
}
.login-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: .75rem; }
.login-box h1 { font-size: 1.4rem; font-weight: 600; }
.login-theme { display: flex; align-items: center; gap: .35rem; }
.login-box label { display: block; margin-bottom: .25rem; color: var(--text-muted); font-size: .9rem; }
.login-box input { width: 100%; padding: .5rem; margin-bottom: .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.login-box button { width: 100%; padding: .6rem; background: var(--accent); color: var(--accent-text); border: none; border-radius: var(--radius); cursor: pointer; font-size: 1rem; }
.login-box button:hover { background: var(--accent-hover); }

/* Header */
header {
  background: var(--header-bg); color: var(--header-text); padding: .75rem 1rem;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: .75rem;
}
header h1 { font-size: 1.2rem; font-weight: 600; }
header nav a { color: var(--header-link); margin-right: 1rem; font-size: .9rem; }
header nav a:hover { color: var(--header-link-hover); text-decoration: none; }
.header-left, .header-right { display: flex; align-items: center; gap: .75rem; }
.header-right { flex-wrap: wrap; }
.header-right form { display: inline; }
.header-right button { background: transparent; border: 1px solid var(--header-link); color: var(--header-text); padding: .25rem .5rem; border-radius: var(--radius); cursor: pointer; font-size: .8rem; }
.header-right button:hover { background: rgba(255,255,255,.1); }
.header-username { font-size: .85rem; color: var(--header-link); }

.theme-label { font-size: .75rem; color: var(--header-link); white-space: nowrap; }
.theme-select {
  background: rgba(255,255,255,.12);
  color: var(--header-text);
  border: 1px solid var(--header-link);
  border-radius: var(--radius);
  padding: .2rem .4rem;
  font-size: .8rem;
  cursor: pointer;
}
.login-theme .theme-label { color: var(--text-muted); }
.login-theme .theme-select { background: var(--surface-2); color: var(--text); border-color: var(--border); }

/* Dropdown options must stay readable in dark mode (OS/browser dropdowns often ignore dark variables) */
.theme-select option,
.login-theme .theme-select option {
  color: #111827;
  background: #ffffff;
}

/* Main */
main { padding: .5rem; max-width: 100%; margin: 0 auto; }

/* Dashboard */
.dashboard { margin-bottom: 1.25rem; }
.dash-heading { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; color: var(--text-muted); }
.dash-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
}
.dash-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem .5rem; box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  transition: background .1s, box-shadow .1s; min-height: 75px;
}
.dash-card:hover { background: var(--surface-2); box-shadow: var(--shadow-hover); text-decoration: none; }
.dash-num { font-size: 1.4rem; font-weight: 700; line-height: 1.2; color: var(--text); }
.dash-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }

/* Category section */
.category-section { margin-bottom: 1.25rem; }
.category-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
}
.cat-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem .75rem; box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  transition: background .1s, box-shadow .1s;
}
.cat-card:hover { background: var(--surface-2); box-shadow: var(--shadow-hover); text-decoration: none; }
.cat-name { font-weight: 600; font-size: .95rem; margin-bottom: .3rem; }
.cat-counts { font-size: .78rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .2rem .6rem; }
.cat-num { color: var(--text); font-weight: 600; }

/* Category header bar */
.category-header-bar {
  display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem;
  flex-wrap: wrap;
}
.back-link { font-size: .9rem; padding: .3rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.back-link:hover { background: var(--surface-2); text-decoration: none; }
.current-cat-label { font-weight: 600; font-size: 1.1rem; }
.breadcrumb-sep { color: var(--text-muted); font-size: .85rem; }
.breadcrumb-current { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Toolbar / Filter */
.toolbar { margin-bottom: 1rem; }
.filter-form {
  display: flex; flex-direction: column;
  gap: .5rem; align-items: stretch;
  background: var(--surface); padding: .75rem; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border);
}
.filter-form label { font-size: .85rem; display: flex; align-items: center; gap: .25rem; color: var(--text-muted); flex-wrap: wrap; }
.filter-form select, .filter-form input[type="text"] {
  padding: .4rem .5rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; background: var(--surface); color: var(--text); width: 100%;
}
.filter-form button { padding: .5rem .9rem; background: var(--accent); color: var(--accent-text); border: none; border-radius: var(--radius); cursor: pointer; font-size: .9rem; }
.filter-form button:hover { background: var(--accent-hover); }
.chk input { margin-right: .2rem; }

/* Status badges */
.status-open { color: var(--status-open); font-weight: 600; }
.status-ok { color: var(--status-ok); font-weight: 600; }
.status-rework { color: var(--status-rework); font-weight: 600; }
.status-ignored { color: var(--status-ignored); }

/* Pagination */
.pagination { margin-top: 1rem; display: flex; gap: .5rem; align-items: center; justify-content: center; font-size: .85rem; flex-wrap: wrap; }
.pagination a { padding: .3rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }

/* Legacy cards (kept for compatibility, now neutral) */
.item-list { margin-bottom: 1rem; }

.item-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: .75rem; overflow: hidden; box-shadow: var(--shadow);
}
.card-missing { border-left: 3px solid var(--text-muted); }
.card-changed { border-left: 3px solid var(--text-muted); }

.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .65rem; background: var(--surface-2); border-bottom: 1px solid var(--border); gap: .5rem;
}
.card-title { font-weight: 600; font-size: .9rem; word-break: break-word; flex: 1; }
.card-status { font-size: .78rem; white-space: nowrap; font-weight: 600; }

.flag-changed-inline { font-size: .7rem; padding: .1rem .4rem; border-radius: var(--radius); background: var(--error-bg); color: var(--error-text); font-weight: 600; white-space: nowrap; }
.flag-missing-inline { font-size: .7rem; padding: .1rem .4rem; border-radius: var(--radius); background: var(--warning-bg); color: var(--warning-text); font-weight: 600; white-space: nowrap; }

.card-folder-line {
  padding: .35rem .65rem; font-size: .75rem; color: var(--text-muted); word-break: break-all;
  border-bottom: 1px solid var(--border); cursor: help;
}

.card-field-row {
  display: flex; align-items: center; gap: .5rem; padding: .35rem .65rem;
}
.card-label { font-size: .8rem; font-weight: 500; min-width: 48px; color: var(--text-muted); }
.card-select {
  flex: 1; padding: .4rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .85rem; background: var(--surface); min-height: 36px; color: var(--text);
}

.card-checkboxes {
  display: flex; flex-wrap: wrap; gap: .3rem .6rem; padding: .3rem .65rem;
}
.chk-label {
  display: flex; align-items: center; gap: .25rem; font-size: .8rem; cursor: pointer;
}
.chk-label input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

.card-inline { padding: .25rem .65rem; }
.card-input {
  padding: .4rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; width: 100%; background: var(--surface); color: var(--text);
}

.card-actions {
  display: flex; gap: .5rem; padding: .5rem .65rem; border-top: 1px solid var(--border);
}
.card-save {
  flex: 1; padding: .55rem; background: var(--accent); color: var(--accent-text); border: none;
  border-radius: var(--radius); font-size: .9rem; cursor: pointer; font-weight: 600;
}
.card-save:hover { background: var(--accent-hover); }
.card-detail {
  padding: .55rem .9rem; background: var(--surface); color: var(--accent); border: 1px solid var(--accent);
  border-radius: var(--radius); font-size: .85rem; text-align: center; display: inline-flex; align-items: center;
}

/* Series index navigation */
.series-index-list { margin-bottom: 1rem; }
.series-index-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .6rem .75rem; margin-bottom: .4rem;
  text-decoration: none; color: var(--text); gap: .75rem;
  transition: background .1s, box-shadow .1s;
}
.series-index-row:hover {
  background: var(--surface-2); box-shadow: var(--shadow-hover); text-decoration: none;
}
.series-index-name {
  font-weight: 600; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.series-index-counts {
  display: flex; flex-wrap: wrap; gap: .2rem .6rem;
  font-size: .78rem; color: var(--text-muted); white-space: nowrap;
  justify-content: flex-end;
}

/* Series detail */
.series-detail-header {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem .75rem;
  margin-bottom: .75rem;
}
.series-detail-title {
  font-size: 1.2rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

.series-bulk-form { margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bulk-label { font-size: .85rem; color: var(--text-muted); }
.bulk-done-btn {
  padding: .45rem .9rem; background: var(--accent); color: var(--accent-text); border: none;
  border-radius: var(--radius); cursor: pointer; font-size: .85rem;
}
.bulk-done-btn:hover { background: var(--accent-hover); }
#bulk-scope { padding: .3rem .4rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; background: var(--surface); color: var(--text); }

/* Season groups */
.season-list { margin-bottom: 1rem; }
.season-group { margin-bottom: 1rem; }
.season-heading {
  font-size: 1rem; font-weight: 700; color: var(--text-muted);
  margin: .75rem 0 .4rem; padding-bottom: .2rem;
  border-bottom: 1px solid var(--border);
}

/* Detail page */
.meta-info { background: var(--surface); padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; box-shadow: var(--shadow); border: 1px solid var(--border); }
.meta-info p { margin-bottom: .3rem; font-size: .9rem; color: var(--text-muted); }
.meta-info strong { color: var(--text); }
.warning { color: var(--status-open); font-weight: 600; }

.edit-form { background: var(--surface); padding: 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.edit-form label { display: block; margin-top: .75rem; font-weight: 600; font-size: .9rem; color: var(--text); }
.edit-form input[type="text"], .edit-form textarea, .edit-form select {
  width: 100%; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius); margin-top: .25rem; font-size: .9rem; background: var(--surface); color: var(--text);
}
.edit-form textarea { min-height: 80px; }
.edit-form input[type="checkbox"] { margin-right: .5rem; transform: scale(1.2); }

.form-actions { margin-top: 1.5rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.form-actions button { padding: .5rem 1.5rem; background: var(--accent); color: var(--accent-text); border: none; border-radius: var(--radius); cursor: pointer; font-size: 1rem; }
.form-actions button:hover { background: var(--accent-hover); }
.btn-cancel { padding: .5rem 1.5rem; background: var(--btn-cancel-bg); color: var(--btn-cancel-text); border-radius: var(--radius); display: inline-block; font-size: 1rem; }
.btn-cancel:hover { background: var(--btn-cancel-hover); text-decoration: none; }

/* Scan page */
.scan-btn { padding: .75rem 2rem; background: var(--accent); color: var(--accent-text); border: none; border-radius: var(--radius); cursor: pointer; font-size: 1.1rem; margin-top: 1rem; }
.scan-btn:hover { background: var(--accent-hover); }
.note { font-size: .85rem; color: var(--text-muted); }

.scan-running-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; color: var(--warning-text); }
.scan-running-warning strong { font-size: 1.05rem; }
.scan-stuck-warning { padding: 0.75rem; background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: var(--radius); color: var(--warning-text); margin: 1rem 0; }
.scan-cleaned-info { padding: 0.75rem; background: var(--success-bg); border: 1px solid var(--success-text); border-radius: var(--radius); color: var(--success-text); margin-bottom: 0.75rem; }

/* Scan result */
.scan-summary { background: var(--surface); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; list-style: none; border: 1px solid var(--border); }
.scan-summary li { padding: .3rem 0; font-size: 1rem; color: var(--text); }
.error-list { background: var(--error-bg); padding: 1rem; border-radius: var(--radius); list-style: none; margin-bottom: 1rem; }
.error-list li { padding: .2rem 0; color: var(--error-text); }
.btn-back { display: inline-block; padding: .5rem 1.5rem; background: var(--accent); color: var(--accent-text); border-radius: var(--radius); }
.btn-back:hover { background: var(--accent-hover); text-decoration: none; }

.root-list { list-style: none; padding: 0; margin: 1rem 0; }
.root-item { display: flex; gap: 0.75rem; align-items: center; padding: 0.35rem 0.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.3rem; box-shadow: var(--shadow); flex-wrap: wrap; }
.root-label { font-weight: 600; font-size: 0.9rem; min-width: 140px; }
.root-path { font-family: monospace; font-size: 0.82rem; color: var(--text-muted); flex: 1; }
.root-exists { font-size: 0.75rem; color: var(--status-ok); font-weight: 600; }
.root-missing-label { font-size: 0.75rem; color: var(--danger); font-weight: 600; }
.root-missing { opacity: 0.6; }
.job-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-top: 0.5rem; border: 1px solid var(--border); }
.job-table th, .job-table td { padding: 0.5rem; text-align: left; font-size: 0.85rem; border-bottom: 1px solid var(--border); color: var(--text); }
.job-table th { background: var(--surface-2); font-weight: 600; }

.empty-state { text-align: center; padding: 2rem 1rem; color: var(--text-muted); font-size: .9rem; }
.no-data { color: var(--text-muted); font-size: .85rem; padding: .5rem 0; }

/* A-Z navigation */
.az-nav { display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0; padding: .5rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.az-letter { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .85rem; text-decoration: none; border: 1px solid var(--border); }
.az-letter:hover { background: var(--accent); color: var(--accent-text); border-color: var(--accent); text-decoration: none; }
.az-letter-empty { background: var(--surface); color: var(--text-muted); cursor: default; border-color: var(--border); }
.letter-section { margin: 1rem 0; }
.letter-heading { font-size: 1.1rem; font-weight: 700; color: var(--text-muted); margin-bottom: .5rem; border-bottom: 1px solid var(--border); padding-bottom: .25rem; }

/* Compact Excel-like list rows */
.compact-list { display: flex; flex-direction: column; gap: 0.25rem; }
.compact-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.5rem; box-shadow: var(--shadow);
}
.compact-form { display: contents; }
.status-form { display: flex; justify-content: flex-start; }
.row-title { display: flex; flex-direction: column; min-width: 0; }
.row-main-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.row-filename { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-status { display: flex; justify-content: flex-start; }
.row-select { padding: 0.25rem 0.4rem; font-size: 0.9rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.row-checks { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; font-size: 0.85rem; align-items: center; color: var(--text-muted); }
.row-chk { display: inline-flex; align-items: center; gap: 0.2rem; cursor: pointer; white-space: nowrap; }
.row-chk input { margin: 0; width: 18px; height: 18px; }
.row-note { display: flex; }
.row-input { width: 100%; padding: 0.25rem 0.5rem; font-size: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.row-actions { display: flex; gap: 0.3rem; justify-content: flex-start; }
.row-save, .row-detail { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 0.9rem; cursor: pointer; }
.row-save:hover, .row-detail:hover { background: var(--surface-3); }
.row-editor { grid-column: 1 / -1; font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; padding-left: 0.1rem; }
.editor-name { color: var(--accent); font-weight: 600; }

/* ===== DESKTOP BREAKPOINTS ===== */

@media (min-width: 700px) {
  main { padding: 1rem; max-width: 100%; }

  header { flex-wrap: nowrap; gap: 1rem; }
  header h1 { font-size: 1.3rem; }
  header nav a { margin-right: 1.25rem; }

  .dash-cards { grid-template-columns: repeat(4, 1fr); gap: .75rem; }
  .dash-card { padding: 1rem .5rem; min-height: 85px; }
  .dash-num { font-size: 1.8rem; }

  .category-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

  .filter-form {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: .75rem;
  }
  .filter-form label { flex-wrap: nowrap; }
  .filter-form select, .filter-form input[type="text"] { width: auto; min-width: 140px; }
  .filter-form button { width: auto; }

  .series-detail-header {
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
  }
  .series-detail-title { max-width: 70%; font-size: 1.35rem; }

  .series-index-row { padding: .75rem 1rem; }

  .compact-row {
    grid-template-columns: minmax(220px, 2.5fr) 100px minmax(180px, 1.5fr) minmax(180px, 1.5fr) 80px;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
  }
  .status-form { justify-content: center; }
  .row-status { justify-content: center; }
  .row-actions { justify-content: flex-end; }

  .edit-form { padding: 1.5rem; max-width: 900px; }
}

@media (min-width: 1000px) {
  main { padding: 1.25rem; max-width: 1200px; }

  .category-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

  .compact-row {
    grid-template-columns: minmax(260px, 3fr) 110px minmax(220px, 1.5fr) minmax(240px, 2fr) 90px;
    gap: 0.75rem;
  }
}

@media (min-width: 1200px) {
  main { max-width: 1400px; }
}

/* ===== MOBILE FINE-TUNING ===== */

@media (max-width: 699px) {
  header h1 { font-size: 1rem; }
  header nav a { margin-right: .5rem; font-size: .8rem; }

  .filter-form button { width: 100%; }

  .dash-cards { gap: .4rem; }
  .dash-card { padding: .5rem .3rem; min-height: 60px; }
  .dash-num { font-size: 1.3rem; }

  .category-cards { gap: .4rem; }
  .cat-card { padding: .6rem; }

  .row-chk { white-space: normal; }
}
