:root {
  --bg: #f6f5f1; --card: #ffffff; --ink: #1c1b18; --muted: #6b6860; --line: #e4e1d8;
  --accent: #e8590c; --accent-ink: #fff; --good: #2b8a3e; --bad: #c92a2a; --warn: #e67700;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151513; --card: #1f1e1b; --ink: #f1efe8; --muted: #a09c91; --line: #34322d; --shadow: none; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: env(safe-area-inset-bottom, 0px); }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 17px; }
.brand span { font-weight: 500; color: var(--muted); }
.pill { border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--good); color: #fff; }
.pill.paused { background: var(--bad); }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 12px; scrollbar-width: none; position: sticky; top: 52px; z-index: 4; background: var(--bg); }
.tabs button { flex: none; border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 18px; text-align: center; }
.count:empty { display: none; }
main { max-width: 760px; margin: 0 auto; padding: 4px 16px 48px; }
h2 { font-size: 15px; margin: 22px 0 8px; letter-spacing: -.01em; }
h2 small { color: var(--muted); font-weight: 500; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.tile { background: var(--card); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .v { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.tile .l { color: var(--muted); font-size: 12px; }
.tile.alert .v { color: var(--bad); }
.stack { display: grid; gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.card h3 { margin: 0 0 2px; font-size: 16px; }
.meta { color: var(--muted); font-size: 13px; }
.say { margin: 10px 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 0 8px 8px 0; }
.mail { white-space: pre-wrap; font-size: 14px; margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.mail .subj { font-weight: 700; margin-bottom: 8px; }
.theirs { white-space: pre-wrap; font-size: 14px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; margin: 8px 0; max-height: 220px; overflow: auto; }
textarea, input[type="text"], input[type="number"], select { width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
textarea { min-height: 160px; resize: vertical; }
input[type="number"] { width: 90px; }
.actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.row-actions { justify-content: space-between; margin: 0; }
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 700; cursor: pointer; background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.btn:disabled { opacity: .5; cursor: default; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); text-transform: uppercase; letter-spacing: .03em; }
.tag.interested, .tag.paid, .tag.ok { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.tag.failed, .tag.error, .tag.no { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.tag.needs_human, .tag.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.controls { display: grid; gap: 12px; }
.controls label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { justify-content: flex-start !important; }
.table-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
a { color: var(--accent); }
#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100% - 32px); }
