/* Theodoras House · stats dashboard */
:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f3f0ea;
  --border: #e8e3da;
  --text: #1c2a2e;
  --text-2: #56646a;
  --text-3: #8a9599;
  --accent: #c65f35;
  --accent-ink: #ffffff;
  --bar-bg: #e7efe9;
  --line: #1c2a2e;
  --grid: #eeebe5;
  --s-call: #c65f35;
  --s-wa: #1baf7a;
  --s-viber: #6250d6;
  --good: #1f7a45;
  --bad: #b3372b;
  --shadow: 0 1px 2px rgba(28, 42, 46, .04);
  --sans: "Manrope", system-ui, -apple-system, sans-serif;
  --head: "Commissioner", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121718;
    --surface: #1a2022;
    --surface-2: #212829;
    --border: #2a3234;
    --text: #eef0ec;
    --text-2: #b4bdbd;
    --text-3: #87908f;
    --accent: #d9683c;
    --bar-bg: #23332d;
    --line: #e9e6df;
    --grid: #263032;
    --s-call: #d9683c;
    --s-wa: #199e70;
    --s-viber: #9085e9;
    --good: #4cc27c;
    --bad: #f07a6c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121718;
  --surface: #1a2022;
  --surface-2: #212829;
  --border: #2a3234;
  --text: #eef0ec;
  --text-2: #b4bdbd;
  --text-3: #87908f;
  --accent: #d9683c;
  --bar-bg: #23332d;
  --line: #e9e6df;
  --grid: #263032;
  --s-call: #d9683c;
  --s-wa: #199e70;
  --s-viber: #9085e9;
  --good: #4cc27c;
  --bad: #f07a6c;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
button, select, input { font: inherit; color: inherit; }
.wrap { max-width: 1340px; margin: 0 auto; padding: 22px 16px 60px; }
@media (min-width: 700px) { .wrap { padding: 32px 28px 70px; } }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand__mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--head); font-weight: 500; font-size: 16px; }
.brand__sub { color: var(--text-3); font-weight: 500; }
.top__right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.updated { color: var(--text-3); font-size: 13px; margin-right: 4px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); padding: 0 10px 0 4px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
.period { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; height: 38px; box-shadow: var(--shadow); }
.period select { appearance: none; border: 0; background: transparent; font-weight: 600; padding: 0 10px; height: 100%; cursor: pointer; text-align: center; }
.period select:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.icon-btn { border: 0; background: transparent; height: 100%; min-width: 34px; cursor: pointer; color: var(--text-2); font-size: 18px; display: inline-grid; place-items: center; text-decoration: none; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.round { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--text); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.range { margin: 10px 0 18px; color: var(--text-3); font-size: 13px; }

.notice { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; color: var(--text-2); }
.notice b { color: var(--text); }
.notice.err { border-left-color: var(--bad); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }

/* KPI strip */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 16px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1180px) { .kpis { grid-template-columns: repeat(8, 1fr); } }
.kpi { padding: 16px 18px 14px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 0; }
.kpi__label { color: var(--text-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.kpi__label i { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.kpi__value { font-family: var(--head); font-size: 25px; font-weight: 500; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi__sub { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--good); }
.down { color: var(--bad); }

/* chart */
.chart-card { padding: 18px 20px 12px; margin-bottom: 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px 18px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.legend { list-style: none; display: flex; gap: 14px; flex-wrap: wrap; margin: 0; padding: 0; color: var(--text-2); font-size: 12.5px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.lg-line { width: 16px; height: 2px; background: var(--line); border-radius: 2px; }
.lg-box { width: 10px; height: 10px; border-radius: 3px; }
.s-call { background: var(--s-call); }
.s-wa { background: var(--s-wa); }
.s-viber { background: var(--s-viber); }
.chart { position: relative; height: 340px; touch-action: pan-y; }
.chart text.ptitle { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11.5px; font-family: var(--sans); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .vline { stroke: var(--line); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart .dot { fill: var(--surface); stroke: var(--line); stroke-width: 2; }
.chart .seg-call { fill: var(--s-call); }
.chart .seg-wa { fill: var(--s-wa); }
.chart .seg-viber { fill: var(--s-viber); }
.chart .gap { stroke: var(--surface); stroke-width: 1; }
.empty { display: grid; place-items: center; height: 100%; color: var(--text-3); text-align: center; padding: 20px; }
.table-view { margin-top: 6px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--text-3); font-size: 12.5px; padding: 4px 0; }
.table-view .scroll { max-height: 260px; overflow: auto; margin-top: 6px; }
.table-view table { width: 100%; border-collapse: collapse; }
.table-view th, .table-view td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.table-view th { color: var(--text-3); font-weight: 500; position: sticky; top: 0; background: var(--surface); }

/* tooltip */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.12); font-size: 13px; min-width: 170px; }
.tip h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.tip div { display: flex; justify-content: space-between; gap: 18px; padding: 1px 0; }
.tip span { display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.tip b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.tip i.l { height: 2px; width: 12px; background: var(--line); }

/* tables */
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 980px) { .grid { grid-template-columns: 1fr 1fr; } }
.tcard, #buttons, #people { padding: 6px 20px 16px; min-width: 0; }
.tabs { display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--border); margin: 0 -20px 6px; padding: 0 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 12px 0 10px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.card-title { margin: 0; padding: 12px 0 10px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--border); margin: 0 -20px 6px; padding-left: 20px; padding-right: 20px; }
table.t { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.t th { font-weight: 500; color: var(--text-3); font-size: 12px; text-align: right; padding: 8px 0 6px 8px; line-height: 1.2; vertical-align: bottom; }
table.t th button { border: 0; background: none; padding: 0; cursor: pointer; color: inherit; font: inherit; text-align: right; }
table.t th button[aria-sort="descending"] { color: var(--text); font-weight: 600; }
table.t th button[aria-sort="descending"]::after { content: " ↓"; }
table.t th:first-child { text-align: left; padding-left: 0; }
table.t td { padding: 3px 0 3px 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td.n { padding-left: 0; text-align: left; }
table.t td.z { color: var(--text-3); }
table.t td.hot { color: var(--accent); font-weight: 600; }
.bar { position: relative; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border-radius: 8px; overflow: hidden; }
.bar::before { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--bar-bg); border-radius: 8px; }
.bar > * { position: relative; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .flag { font-size: 15px; line-height: 1; }
.more { border: 0; background: none; color: var(--text-3); text-decoration: underline; cursor: pointer; padding: 8px 0 0; font-size: 12.5px; }
.cnote { color: var(--text-3); font-size: 12.5px; margin: 10px 0 0; }
.tload { color: var(--text-3); padding: 24px 0; text-align: center; }
.col-name { width: auto; }
.col-num { width: 84px; }
@media (max-width: 520px) { .col-num { width: 66px; } table.t th { font-size: 11px; } }

.foot { color: var(--text-3); font-size: 12.5px; margin: 22px 2px 0; max-width: 900px; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px 28px; box-shadow: var(--shadow); }
.login h1 { font-family: var(--head); font-weight: 500; font-size: 26px; margin: 18px 0 18px; }
.login label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login input { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); padding: 0 14px; font-size: 16px; }
.login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login button { width: 100%; height: 46px; margin-top: 14px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; font-size: 15px; }
.login button:disabled { opacity: .6; }
.login__err { color: var(--bad); min-height: 20px; margin: 10px 0 0; font-size: 13px; }
.login__note { color: var(--text-2); }

@media (forced-colors: active) {
  .chart .seg-call, .chart .seg-wa, .chart .seg-viber { fill: CanvasText; }
}
.col-num { width: 104px; }
table.t th { white-space: nowrap; }
@media (max-width: 520px) { .col-num { width: 70px; } table.t th { white-space: normal; } }

/* login: show / hide password */
.pw { position: relative; }
.login .pw input { padding-right: 50px; }
.login .pw__eye { position: absolute; top: 0; right: 0; width: 48px; height: 46px; margin: 0 !important; border: 0; background: none !important; color: var(--text-3) !important; cursor: pointer; display: grid; place-items: center; border-radius: 12px; }
.pw__eye:hover { color: var(--text) !important; }
.pw__eye:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.pw__eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw__eye .eye-off { display: none; }
.pw__eye[aria-pressed="true"] .eye-open { display: none; }
.pw__eye[aria-pressed="true"] .eye-off { display: block; }
