/* VeneraCall UI. Colors are roles defined once here (light, then dark); pages use the roles. */
:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #efeeeb;
  --border: #dedcd6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7b7a75;
  --accent: #3b3fd8;
  --accent-ink: #ffffff;
  --accent-soft: #e8e9fb;
  --good: #0a7a3d;
  --good-soft: #dff3e6;
  --warn: #8a5a00;
  --warn-soft: #fbeccb;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  /* chart series: fixed by meaning, never by rank */
  --s-in: #2a78d6;
  --s-missed: #eb6834;
  --s-out: #1baf7a;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 8px 24px rgb(0 0 0 / .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8f8e86;
    --accent: #8f93ff;
    --accent-ink: #0b0b0b;
    --accent-soft: #26274a;
    --good: #5fd08f;
    --good-soft: #15301f;
    --warn: #f0be55;
    --warn-soft: #3a2c0c;
    --bad: #ff8a80;
    --bad-soft: #3d1a17;
    --s-in: #3987e5;
    --s-missed: #d95926;
    --s-out: #199e70;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; letter-spacing: -.01em; }
h2 { font-size: 16px; line-height: 1.4; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  overflow-x: auto; font: 13px/1.55 var(--mono); margin: 8px 0 0; }
pre code { background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* ---- App shell ---- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column;
  gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); padding: 4px 8px 12px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.side-foot .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 24px 32px 64px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--text-2); margin-top: 4px; }
.btn.menu-btn { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .side-top { display: flex; align-items: center; justify-content: space-between; }
  .brand { padding: 4px 8px; }
  .btn.menu-btn { display: inline-flex; }
  .side:not(.open) .nav, .side:not(.open) .side-foot { display: none; }
  .main { padding: 16px 16px 48px; }
}

/* ---- Building blocks ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid > .card, .features > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; background: var(--warn-soft); color: var(--warn); border: 1px solid transparent; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 14px/1.2 var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.icon { padding: 6px; min-width: 36px; }
.btn.icon.sm { min-width: 30px; padding: 4px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=url],
input[type=search], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 14px/1.4 var(--font); }
textarea { min-height: 72px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters .field { flex: 1 1 140px; max-width: 220px; }
.hint { font-size: 12px; color: var(--text-3); }
.status-line { font-size: 13px; color: var(--text-2); min-height: 20px; }
.status-line.error, .error-text { color: var(--bad); }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; color: var(--text-2); padding: 7px 12px; font: 500 13px/1.2 var(--font); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
th.num { text-align: right; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.dir { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dir svg { width: 15px; height: 15px; }
.dir.in svg { color: var(--s-in); } .dir.out svg { color: var(--s-out); } .dir.missed svg { color: var(--s-missed); }

.empty { text-align: center; padding: 32px 16px; color: var(--text-2); }
.empty h3 { font-size: 16px; color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }
.skeleton { height: 14px; border-radius: 6px; background: var(--surface-2); margin: 10px 0; }

dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text);
  width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px;
  border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 60; max-width: calc(100vw - 32px); }

.secret-box { border: 1px dashed var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; }
.secret-box code { background: none; word-break: break-all; font-size: 14px; }
.pair-code { font: 700 34px/1.2 var(--mono); letter-spacing: .08em; }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); }
.steps li + li { margin-top: 4px; }

/* ---- Dashboard ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-3); }
.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.dot.in { background: var(--s-in); } .dot.out { background: var(--s-out); } .dot.missed { background: var(--s-missed); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--text); fill-opacity: .06; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px; z-index: 5; min-width: 130px; }
.tip b { display: block; margin-bottom: 4px; font-size: 13px; }
.tip div { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tip div span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }

/* ---- Calls ---- */
.row-detail td { background: var(--surface-2); }
.row-detail audio { width: 100%; max-width: 520px; height: 36px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }

/* ---- Live call card ---- */
.call-live { position: fixed; right: 16px; bottom: 16px; width: min(340px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--s-in); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; z-index: 50; }
.call-live h3 { font-size: 17px; }
.call-live table { font-size: 12px; margin-top: 8px; }
.call-live td { padding: 4px 6px 4px 0; }
.call-live .x { position: absolute; top: 8px; right: 8px; }

/* ---- Public pages ---- */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; max-width: 1120px; width: 100%; margin: 0 auto; }
.top .brand { padding: 0; }
.hero { max-width: 1120px; margin: 0 auto; padding: 56px 24px 40px; width: 100%; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.1; letter-spacing: -.02em; max-width: 18ch; }
.hero p.lead { font-size: 18px; color: var(--text-2); max-width: 58ch; margin: 16px 0 24px; }
.features { max-width: 1120px; margin: 0 auto; padding: 8px 24px 56px; width: 100%; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.features h3 { font-size: 16px; margin-bottom: 4px; }
.features p { color: var(--text-2); font-size: 14px; }
.auth { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(400px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.foot { margin-top: auto; padding: 20px 24px; color: var(--text-3); font-size: 13px; text-align: center; }

/* ---- Docs ---- */
.docs { max-width: 1120px; margin: 0 auto; padding: 16px 24px 64px; width: 100%; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; }
.docs nav { position: sticky; top: 16px; align-self: start; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.docs nav a { color: var(--text-2); padding: 4px 8px; border-radius: 6px; }
.docs nav a:hover { background: var(--surface-2); text-decoration: none; }
.docs section { padding-top: 8px; margin-bottom: 36px; }
.docs h2 { font-size: 21px; margin-bottom: 8px; }
.docs h3 { font-size: 15px; margin: 20px 0 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.docs p, .docs li { color: var(--text-2); max-width: 75ch; }
.docs p + p { margin-top: 8px; }
.docs table { margin-top: 8px; }
.docs td:first-child { white-space: nowrap; }
.method { font: 700 11px/1 var(--mono); padding: 4px 6px; border-radius: 5px; background: var(--good-soft); color: var(--good); }
.method.post, .method.put, .method.patch { background: var(--accent-soft); color: var(--accent); }
.method.delete { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 860px) { .docs { grid-template-columns: minmax(0, 1fr); } .docs nav { position: static; flex-direction: row; flex-wrap: wrap; } }

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .seg button { transition: background-color .12s ease, color .12s ease; }
}
