:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #16191d;
  --muted: #5f6b78;
  --line: #e1e5ea;
  --accent: #00a35a;
  --accent-text: #ffffff;
  --orange: #ff8000;
  --blue: #2fa8e0;
  --error: #c4302b;
  --chip: #eef1f4;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181c;
    --card: #1c2228;
    --text: #e8edf2;
    --muted: #9aa8b6;
    --line: #2c353f;
    --accent: #00c46a;
    --accent-text: #0b1210;
    --error: #ff6b63;
    --chip: #252d36;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181c;
  --card: #1c2228;
  --text: #e8edf2;
  --muted: #9aa8b6;
  --line: #2c353f;
  --accent: #00c46a;
  --accent-text: #0b1210;
  --error: #ff6b63;
  --chip: #252d36;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.15rem; margin: 0; letter-spacing: 0.01em; }
h2 { font-size: 1rem; margin: 0 0 0.75rem; }
code { font-size: 0.9em; background: var(--chip); padding: 0.05em 0.35em; border-radius: 5px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.brand { display: flex; align-items: center; gap: 0.6rem; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.dots i:nth-child(1) { background: var(--orange); }
.dots i:nth-child(2) { background: var(--accent); }
.dots i:nth-child(3) { background: var(--blue); }

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 1rem max(16px, calc((100vw - 1100px) / 2));
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
}
.top-actions { display: flex; gap: 0.5rem; }

.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  max-width: 1100px; margin: 16px auto; padding: 0 16px;
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; min-width: 0; }
.wide { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
}

.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.narrow { width: min(380px, 100%); display: grid; gap: 0.9rem; }

label { display: grid; gap: 0.3rem; margin-bottom: 0.85rem; font-weight: 500; }
label small { font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], input:not([type]) {
  width: 100%; padding: 0.55rem 0.7rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="file"] { max-width: 100%; color: var(--muted); }
.switch { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.switch input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

button {
  font: inherit; font-weight: 600; border-radius: 9px; padding: 0.5rem 0.95rem;
  border: 1px solid var(--line); background: var(--chip); color: var(--text); cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.ghost { background: transparent; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
button:disabled { opacity: 0.55; cursor: default; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.msg { min-height: 1.4em; margin: 0.6rem 0 0; }
.msg.ok { color: var(--accent); }
.error, .msg.bad { color: var(--error); }
.steps { margin: 0.3rem 0 0.6rem; padding-left: 1.2rem; }

.status-line { margin: 0 0 0.9rem; }
.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.count { background: var(--chip); border-radius: 10px; padding: 0.6rem 0.8rem; }
.count b { display: block; font-size: 1.35rem; }
.count span { color: var(--muted); font-size: 0.85rem; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.section-head h2 { margin: 0; }
.section-head input { max-width: 260px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0.8rem; }
.filters button { padding: 0.3rem 0.7rem; font-weight: 500; font-size: 0.88rem; }
.filters button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
td .sub { display: block; color: var(--muted); font-size: 0.82rem; }
td.actions { white-space: nowrap; text-align: right; }
td.actions input { width: 9rem; padding: 0.25rem 0.45rem; font-size: 0.85rem; }
.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--chip); }
.badge.synced { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.badge.present { background: color-mix(in srgb, var(--blue) 18%, transparent); color: var(--blue); }
.badge.pending, .badge.unresolved { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.badge.unmatched, .badge.error { background: color-mix(in srgb, var(--error) 16%, transparent); color: var(--error); }

.log { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; font-size: 0.88rem; }
.log li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.log time { color: var(--muted); margin-right: 0.4rem; font-variant-numeric: tabular-nums; }
.log .warn { color: var(--orange); }
.log .error { color: var(--error); }

/* Phones: each film is a small card rather than a table row. */
@media (max-width: 560px) {
  thead { display: none; }
  table, tbody { display: block; }
  tr { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
  td { border: 0; padding: 0; }
  td:nth-child(1) { grid-column: 1 / -1; }
  td:nth-child(2) { color: var(--muted); font-size: 0.85rem; }
  td.actions { grid-column: 1 / -1; text-align: left; }
}
