:root {
  --bg: #0A1622;
  --side: #0D1D2C;
  --surface: #0F2131;
  --surface-2: #102233;
  --raised: #16304A;
  --line: #1E3A55;
  --line-2: #2A4B6C;
  --text: #E8EEF4;
  --text-2: #D5DFE9;
  --text-3: #C4D2E0;
  --muted: #9FB3C8;
  --eyebrow: #8DA3B9;
  --accent: #F5B544;
  --accent-ink: #0A1622;
  --accent-soft: rgba(245, 181, 68, 0.12);
  --ok: #6FE0AE;
  --ok-soft: rgba(79, 211, 154, 0.12);
  --info: #7CC0FF;
  --bad: #FFB4A8;
  --bad-soft: rgba(255, 120, 100, 0.10);
  --warn-line: #6B5226;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; font-size: 14px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--info); text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; }
.brand-mark.sm { width: 34px; height: 34px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: var(--text-3); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.04); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.block { width: 100%; height: 44px; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: transparent; color: var(--text-3); display: inline-grid; place-items: center; }
.seg { display: flex; background: var(--surface-2); border: 1px solid #22405E; border-radius: 10px; padding: 3px; }
.seg button { height: 30px; padding: 0 11px; border-radius: 8px; border: none; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: #1D3A58; color: var(--text); }

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; }
.signin-card { width: 100%; max-width: 400px; padding: 28px; display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.signin-card .brand { margin-bottom: 10px; }
.label { font-size: 13px; color: var(--muted); }
.signin-card input { height: 46px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 14px; font-size: 16px; }
.error { margin: 0; min-height: 18px; color: var(--bad); font-size: 13px; }
.note { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--warn-line); color: #F3DDB4; font-size: 13px; line-height: 1.5; }
.small-link { font-size: 13px; text-align: center; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: calc(12px + env(safe-area-inset-top, 0px)) 28px 12px; background: rgba(10,22,34,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.main { max-width: 1240px; margin: 0 auto; padding: 24px 28px 60px; display: flex; flex-direction: column; gap: 22px; }

.eyebrow { margin: 0; font-size: 11.5px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--eyebrow); }
h2.section { margin: 0 0 12px; font-family: var(--display); font-size: 19px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
h2.section small { font-family: var(--sans); font-size: 12.5px; font-weight: 400; color: var(--muted); }
.panel { padding: 18px 20px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .v { font-family: var(--display); font-size: 30px; font-weight: 600; letter-spacing: -.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.kpi.alert { border-color: #7a3b33; }
.kpi.alert .v { color: var(--bad); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }
.chart { width: 100%; height: auto; display: block; }
.chart, .chart * { stroke: none; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--eyebrow); font-size: 11px; font-family: var(--sans); }
.chart .bar { fill: var(--accent); }
.chart .bar.photo { fill: #7CC0FF; }
.chart .hit { fill: transparent; }
.chart .hit:hover + .bar, .chart g.day:hover .bar { opacity: .8; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: #1D3A58; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 1.5; color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.4); }

.hbar { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr 44px; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.hbar .track { height: 10px; border-radius: 5px; background: rgba(255,255,255,.05); overflow: hidden; }
.hbar .track, .hbar .fill { display: block; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-3); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: var(--eyebrow); padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.when { white-space: nowrap; color: var(--muted); font-size: 12.5px; }
td.q { color: var(--text); min-width: 240px; white-space: pre-line; }
.sub { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); font-size: 13.5px; padding: 8px 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; stroke-width: 2.4; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.miss { background: rgba(255,255,255,.06); color: var(--text-3); }
.badge.ed { background: var(--accent-soft); color: var(--accent); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.problem { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.problem:last-child { border-bottom: none; }
.problem svg { color: var(--bad); margin-top: 2px; }
.problem .msg { color: var(--text); font-size: 13.5px; word-break: break-word; }
.problem .cause { color: #F3DDB4; font-size: 13px; margin-top: 4px; }
.problem .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ok-line { display: flex; align-items: center; gap: 8px; color: var(--ok); font-size: 13.5px; }

.who-edit { display: inline-flex; gap: 6px; align-items: center; }
.who-edit input { height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 8px; font-size: 14px; width: 170px; }
.rename { background: none; border: none; color: var(--eyebrow); padding: 2px; vertical-align: -3px; }
.rename svg { width: 14px; height: 14px; }
.help { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .top { padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .main { padding: 16px 16px 48px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 24px; }
  .panel { padding: 14px; }
  /* tables turn into stacked rows on a phone */
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: none; padding: 3px 0; text-align: right; }
  table.stack td::before { content: attr(data-l); color: var(--eyebrow); font-size: 12px; text-align: left; flex-shrink: 0; }
  table.stack td.q { display: block; text-align: left; font-weight: 500; padding-bottom: 6px; min-width: 0; }
  table.stack td.q::before { content: none; }
  .hbar { grid-template-columns: minmax(100px, 1fr) 1.4fr 36px; }
}

/* person view */
.link { background: none; border: none; padding: 0; color: var(--text); font-weight: 600; text-align: left; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { color: var(--accent); }
.details { margin-top: 8px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
td.net { min-width: 180px; }
body.sheet-open { overflow: hidden; }
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(4,10,16,.7); display: flex; justify-content: center; align-items: flex-start; padding: calc(20px + env(safe-area-inset-top, 0px)) 16px 20px; overflow-y: auto; }
.sheet { width: 100%; max-width: 880px; background: var(--surface-2); }
.sheet-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 6px; background: var(--surface-2); border-radius: 16px 16px 0 0; }
.sheet-head h2 { margin: 0; }
.sheet-body { padding: 4px 20px 22px; display: flex; flex-direction: column; gap: 22px; }
.sheet-body h3 { margin: 0 0 8px; }
.sheet-body h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); margin-left: 6px; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv > span:first-child { color: var(--muted); flex-shrink: 0; }
.kv > span:last-child { text-align: right; }
.ua { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.ua .mono { display: block; margin-top: 6px; word-break: break-all; color: var(--text-3); }
@media (max-width: 900px) { table.stack td.net { display: block; text-align: left; } table.stack td.net::before { display: block; margin-bottom: 2px; } .sheet-bg { padding: env(safe-area-inset-top, 0px) 0 0; } .sheet { border-radius: 0; min-height: 100%; border: none; } }

/* People page */
.kpi.tap { cursor: pointer; -webkit-tap-highlight-color: transparent; transition: border-color .15s, background .15s; }
@media (hover: hover) { .kpi.tap:hover { border-color: var(--accent); background: var(--surface-2); } }
.back { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; color: var(--muted); font-size: 13.5px; font-weight: 500; margin-bottom: -8px; }
.back:hover { color: var(--text); }
.page-title { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 600; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.search { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); max-width: 420px; }
.search input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-size: 15px; color: var(--text); }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.person { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; cursor: pointer; transition: border-color .15s, background .15s; }
.person:hover { border-color: var(--accent); background: var(--surface-2); }
.person-head { display: flex; align-items: center; gap: 12px; }
.person-head > svg { color: var(--eyebrow); margin-left: auto; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--raised); color: var(--accent); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 16px; flex-shrink: 0; }
.person-name { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.name-line { display: flex; align-items: center; gap: 4px; min-width: 0; }
.name-line b { font-weight: 600; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-name .sub { margin-top: 2px; }
.stats { display: grid; grid-auto-flow: column; justify-content: space-between; gap: 8px; }
.stat { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.stat b { font-family: var(--display); font-size: 18px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.stat b.bad { color: var(--bad); }
@media (max-width: 900px) { .people { grid-template-columns: 1fr; } .page-title { font-size: 22px; } }

/* settings */
.settings-sheet { max-width: 480px; }
.select { display: block; width: 100%; height: 46px; margin-top: 8px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; font-size: 16px; }

/* Manual updates */
.upd-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.upd-banner > svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.upd-banner.has { border-color: var(--accent); }
@media (hover: hover) { .upd-banner:hover { border-color: var(--accent); background: var(--surface-2); } }
.upd-count { margin: 6px 0 0; color: var(--accent); font-weight: 600; font-size: 14px; }
.upd-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.upd { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.upd-head { display: flex; gap: 6px; flex-wrap: wrap; }
.upd-title { margin: 4px 0 0; font-family: "Space Grotesk", system-ui, sans-serif; font-size: 16.5px; font-weight: 600; line-height: 1.3; color: var(--text); }
.upd-ed { margin: 0; font-size: 13.5px; color: var(--text-3); }
.upd .sub { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.upd .cause { margin: 0; font-size: 12.5px; color: var(--bad); }
.upd-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.upd-actions .btn { height: 40px; }
.urow { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.urow:last-of-type { border-bottom: none; }
.urow > span:first-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.urow .sub { font-size: 12.5px; color: var(--muted); }
.urow > .btn, .urow > span:last-child { flex-shrink: 0; text-align: right; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn.warn { border-color: #7a3b33; color: var(--bad); }
