:root {
  color-scheme: light;
  --page: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efeb;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6e69;
  --accent: #2a78d6;
  --accent-soft: #e6f0fb;
  --critical: #d03b3b;
  --critical-text: #b42f2f;
  --critical-soft: #fbeaea;
  --old: #8a3b12;
  --new: #1d6b3a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9c9b93;
    --accent: #3987e5;
    --accent-soft: #17283d;
    --critical: #d03b3b;
    --critical-text: #f08080;
    --critical-soft: #3a1c1c;
    --old: #f0a77d;
    --new: #7fd29c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111110;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #33332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9c9b93;
  --accent: #3987e5;
  --accent-soft: #17283d;
  --critical: #d03b3b;
  --critical-text: #f08080;
  --critical-soft: #3a1c1c;
  --old: #f0a77d;
  --new: #7fd29c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
h1 { font-size: 18px; margin: 0; font-weight: 650; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.error, .alert-text { color: var(--critical-text); }
button { font: inherit; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.primary {
  font-weight: 600; padding: 10px 18px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; cursor: pointer; white-space: nowrap;
}
.primary:disabled { opacity: 0.6; cursor: default; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.mark {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 14px;
}
.mark.small { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; margin: 0; }

/* sign-in */
.signin-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin-card {
  width: 100%; max-width: 380px; padding: 32px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 6%);
}
.signin-card p { margin: 6px 0 0; }
.signin-card form { display: grid; gap: 6px; margin-top: 18px; }
.signin-card label { font-size: 13px; color: var(--text-2); margin-top: 8px; }
.signin-card .primary { margin-top: 16px; }
.small-link { margin-top: 12px; font-size: 13px; justify-self: start; }
.qr { width: 190px; height: 190px; margin: 12px 0 4px; background: #fff; border-radius: 8px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.key-line { font-size: 13px; overflow-wrap: anywhere; }

/* app */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 10px; }
.who { display: flex; align-items: center; gap: 14px; color: var(--text-2); }
main { max-width: 1040px; margin: 0 auto; padding: 20px 24px 48px; }

.search {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
}
.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; min-width: 0; font-size: 16px; padding: 12px 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; }
.filters label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.filters input, .filters select { padding: 6px 9px; font-size: 13px; }
.status { margin: 16px 2px 6px; }
.progress { height: 3px; margin-top: 14px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress-bar { width: 30%; height: 100%; border-radius: 3px; background: var(--accent); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
@media (prefers-reduced-motion: reduce) { .progress-bar { animation: none; width: 100%; opacity: 0.5; } }
.primary:disabled { cursor: progress; }

.timeline { display: grid; gap: 8px; }
.day { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 2px 2px; }
.entry { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.entry.outside { border-color: var(--critical); box-shadow: inset 3px 0 0 var(--critical); }
.entry.open { box-shadow: 0 4px 16px rgb(0 0 0 / 6%); }
.entry.outside.open { box-shadow: inset 3px 0 0 var(--critical), 0 4px 16px rgb(0 0 0 / 6%); }
.entry-head {
  width: 100%; display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: start;
  text-align: left; background: none; border: 0; padding: 12px 14px; color: inherit; cursor: pointer;
}
.entry-head:hover { background: var(--surface-2); }
.entry-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 2px; }
.entry-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.entry-summary { font-weight: 550; overflow-wrap: anywhere; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13px; color: var(--text-2); }
.who-name { font-weight: 600; color: var(--text); }
.chip {
  font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.chip.alert { background: var(--critical-soft); color: var(--critical-text); }
.entry-detail { padding: 0 14px 14px 118px; border-top: 1px solid var(--border); }
.entry-detail p { margin: 10px 0 0; }
.ids { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; }
.table-scroll { overflow-x: auto; margin-top: 12px; }
table.changes { border-collapse: collapse; width: 100%; font-size: 13px; }
.changes th, .changes td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.changes th { font-size: 12px; color: var(--text-2); font-weight: 600; }
.changes td.mono { min-width: 170px; overflow-wrap: normal; word-break: break-word; }
.changes td.old { color: var(--old); }
.changes td.new { color: var(--new); }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  main { padding: 14px 16px 36px; }
  .search-row { flex-direction: column; }
  .entry-head { grid-template-columns: 1fr; gap: 4px; }
  .entry-detail { padding: 0 14px 14px; }
  .filters label { flex: 1 1 140px; }
  .filters input, .filters select { flex: 1; min-width: 0; }
}
