:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f6; --text: #14181f; --muted: #5b6574; --line: #e1e5ec;
  --accent: #2557d6; --accent-ink: #ffffff; --accent-soft: #e8eefc;
  --a-fg: #146c34; --a-bg: #e1f4e8; --b-fg: #8f5200; --b-bg: #fff0d1; --c-fg: #4b5563; --c-bg: #eceef2;
  --danger: #b42318; --danger-bg: #fdecea; --ok: #146c34;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171b22; --surface-2: #1f2430; --text: #eef1f6; --muted: #98a2b3; --line: #2a303b;
  --accent: #7ba0ff; --accent-ink: #0a1022; --accent-soft: #1d2a4a;
  --a-fg: #6fdc97; --a-bg: #14301f; --b-fg: #f5c05a; --b-bg: #3a2a0c; --c-fg: #b4bcc9; --c-bg: #262c37;
  --danger: #ff8d82; --danger-bg: #3a1714; --ok: #6fdc97;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #171b22; --surface-2: #1f2430; --text: #eef1f6; --muted: #98a2b3; --line: #2a303b;
    --accent: #7ba0ff; --accent-ink: #0a1022; --accent-soft: #1d2a4a;
    --a-fg: #6fdc97; --a-bg: #14301f; --b-fg: #f5c05a; --b-bg: #3a2a0c; --c-fg: #b4bcc9; --c-bg: #262c37;
    --danger: #ff8d82; --danger-bg: #3a1714; --ok: #6fdc97;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* Layout: phone first (bottom tab bar), laptop gets a left rail. */
.shell { min-height: 100dvh; padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px); }
.topbar {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  padding: calc(var(--safe-t) + 12px) 16px 10px; border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 14px; }
.content { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tab-h);
  background: none; border: 0; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
@media (min-width: 900px) {
  .shell { padding: 0 0 0 220px; }
  .tabs { top: 0; right: auto; width: 220px; grid-template-columns: 1fr; align-content: start; gap: 4px; padding: 20px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 48px; padding: 0 14px; border-radius: 12px; font-size: 16px; }
  .tab[aria-current="page"] { background: var(--accent-soft); }
  .topbar-inner, .content { max-width: 820px; }
}

/* Cards and text */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.card.done { opacity: .72; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.why { font-size: 15px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge.A { background: var(--a-bg); color: var(--a-fg); }
.badge.B { background: var(--b-bg); color: var(--b-fg); }
.badge.C, .badge.none { background: var(--c-bg); color: var(--c-fg); }
.badge.follow { background: var(--accent-soft); color: var(--accent); }
.badge.wait { background: var(--b-bg); color: var(--b-fg); }
.badge.status { background: var(--surface-2); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }

.message { background: var(--surface-2); border-radius: 12px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--accent); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "▾"; margin-left: 6px; }
details[open] > summary::after { content: "▴"; }

/* Buttons: 44 px minimum tap size */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.wa { background: #1faa59; color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.quiet { background: transparent; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 auto; }

/* Forms */
.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 15px; }
.hint { color: var(--muted); font-size: 14px; }
input[type="text"], input[type="search"], input[type="number"], input[type="url"], input[type="tel"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { min-height: 44px; border: 0; background: transparent; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .wide { grid-column: 1 / -1; }

.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 14px; }
.notice { border-radius: 12px; padding: 12px 14px; background: var(--b-bg); color: var(--b-fg); font-size: 15px; }
.notice.bad { background: var(--danger-bg); color: var(--danger); }
.notice.good { background: var(--a-bg); color: var(--a-fg); }
.empty { text-align: center; padding: 40px 16px; display: grid; gap: 8px; justify-items: center; }
.empty .big { font-size: 40px; }
.empty h2 { font-size: 18px; }

/* Skeleton loaders */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel.line { height: 14px; } .skel.title { height: 22px; width: 60%; } .skel.block { height: 64px; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } .btn:active { transform: none; } .progress > div { transition: none; } }

/* Toasts and banner */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); z-index: 30; display: grid; gap: 8px; justify-items: center; padding: 0 12px; pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 20px; left: 220px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #1b2230; color: #fff; padding: 6px 8px 6px 16px; border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); max-width: 560px; }
.toast button { min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: #9db8ff; font-weight: 700; cursor: pointer; }
.offline { position: sticky; top: 0; z-index: 50; background: #b45309; color: #fff; text-align: center; padding: calc(var(--safe-t) + 8px) 12px 8px; font-size: 14px; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(10, 14, 22, .55); }
.dialog-body { padding: 20px; display: grid; gap: 14px; }
.dialog-body h2 { font-size: 20px; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(420px, 100%); text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; }
.code { font-size: 36px; font-weight: 800; letter-spacing: .25em; text-align: center; padding: 10px 0; }
.list-item { display: grid; gap: 6px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.reportrow { font-size: 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--line); }
