/* Site Pro app styles. Mobile-first, installable, dark-mode aware. */
:root {
  --brand: #0B2A4A; --brand-dark: #061A30; --accent: #E0161E; --accent-dark: #B8121A; --ink: #0B2A4A;
  --text: #1c2433; --muted: #5b6577; --bg: #f3f6fa; --card: #ffffff; --line: #dde3ec;
  --ok: #157347; --warn: #9a5b00; --err: #b42318; --info: #0B5FAE;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px -14px rgba(16,24,40,.25);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --side: 240px; --tab-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --text: #e7ecf3; --muted: #a3adbf; --bg: #0f1520; --card: #182234; --line: #2a3446; --brand: #9cc0ea; --info: #9cc0ea; --ok: #3fbf7f; --warn: #f0b34a; --err: #ff7b6e; }
}
:root[data-theme="dark"] { --text: #e7ecf3; --muted: #a3adbf; --bg: #0f1520; --card: #182234; --line: #2a3446; --brand: #9cc0ea; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--text); background: var(--bg); overscroll-behavior-y: none; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; } h2 { font-size: 1.15rem; font-weight: 750; } h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.boot { display: grid; place-items: center; min-height: 60vh; color: var(--muted); gap: 8px; }
.ico { flex: none; vertical-align: middle; }
.fine { font-size: .85rem; color: var(--muted); }
.error { color: var(--err); font-weight: 600; }
.pre { white-space: pre-wrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.block { display: block; }
.linklike { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { margin-bottom: 8px; }

/* shell */
.shell { min-height: 100vh; }
.side { display: none; }
.main { padding: 12px 12px calc(var(--tab-h) + var(--safe-b) + 12px); max-width: 1180px; margin: 0 auto; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); box-shadow: 0 -6px 20px -12px rgba(16,24,40,.35); }
.tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tab-h); font: inherit; font-size: .7rem; font-weight: 700; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; }
.tabbar .on { color: var(--brand); }
.side-brand { display: flex; align-items: center; gap: 10px; }
.side-brand .mark { width: 40px; height: 40px; display: block; }
.side-brand b { display: block; line-height: 1.1; } .side-brand small { color: var(--muted); font-size: .78rem; }
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; }
.sheet { background: var(--card); width: 100%; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + var(--safe-b)); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sheet-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 12px; background: var(--bg); color: var(--text); text-decoration: none; font-size: .78rem; font-weight: 700; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); font-size: .85rem; }
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--side) 1fr; }
  .side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; padding: 18px 14px; background: var(--card); border-right: 1px solid var(--line); }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; }
  .side-nav a:hover { background: var(--bg); } .side-nav a.on { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
  .side-nav a b { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; }
  .side-foot { margin-top: auto; display: grid; gap: 8px; font-size: .85rem; }
  .who small { display: block; color: var(--muted); }
  .net::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--ok); } .net.off::before { background: var(--err); }
  .main { padding: 24px 28px; }
  .tabbar, .sheet-back { display: none; }
}
.banner { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: .9rem; font-weight: 600; }
.banner.warn { background: #fff4e0; color: #7a4a00; } .banner.info { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }

/* page */
.page { display: grid; gap: 14px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.page-title { display: flex; align-items: center; gap: 8px; } .page-title .sub { color: var(--muted); font-size: .9rem; margin: 2px 0 0; }
.back { display: inline-flex; padding: 6px; border-radius: 8px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cols { display: grid; gap: 14px; } @media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; align-items: start; } }
.cols > div { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.main, .page, .cols > div, .card, .card-body, .page-title, .page-actions, .card-actions, .table-wrap { min-width: 0; max-width: 100%; }
.card-head { flex-wrap: wrap; }
.dl dd, .pre, .transcript { min-width: 0; overflow-wrap: anywhere; }
.card-body { padding: 14px 16px; display: grid; gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; } .stat-v { font-size: 1.6rem; font-weight: 800; } .stat-l { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 44px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); } .tabs b { background: var(--bg); border-radius: 999px; padding: 0 6px; font-size: .75rem; }
.search { position: relative; } .search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); } .search input { padding-left: 38px; }
.list { display: grid; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; cursor: pointer; min-height: 56px; }
.row:hover { border-color: var(--brand); }
.row-main { flex: 1; min-width: 0; } .row-title { font-weight: 700; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .row-sub { color: var(--muted); font-size: .88rem; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); display: grid; gap: 6px; justify-items: center; } .empty h3 { color: var(--text); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; } .dl dt { color: var(--muted); font-size: .85rem; padding-top: 2px; } .dl dd { margin: 0; }
.transcript { white-space: pre-wrap; font: .9rem/1.5 var(--font); margin: 0; }
.mini { padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; } .mini:first-child { border-top: 0; } .mini small { color: var(--muted); }
.msg-inbound { border-left: 3px solid var(--brand); padding-left: 10px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.cov-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); } .cov-row:first-child { border-top: 0; } .cov-row b { flex: 1 0 140px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; } .table th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); } .table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; } .btn-warn { background: #f0b34a; border-color: #f0b34a; color: #1a1200; } .btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; } .btn-sm { min-height: 36px; padding: 4px 10px; font-size: .88rem; } .btn-lg { min-height: 54px; font-size: 1.05rem; width: 100%; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--bg); color: var(--muted); }
.badge-ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); } .badge-warn { background: #fff4e0; color: #7a4a00; } .badge-err { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.badge-info, .badge-brand { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.field { display: grid; gap: 4px; font-size: .9rem; } .field .label { font-weight: 600; } .field .hint { color: var(--muted); font-size: .8rem; } .field .error { font-size: .8rem; }
.input { font: inherit; font-size: 16px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); min-height: 44px; width: 100%; }
.input:focus { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.input:disabled { opacity: .7; }
textarea.input { resize: vertical; min-height: 80px; }
.grid-2 { display: grid; gap: 10px; } .grid-3 { display: grid; gap: 8px; grid-template-columns: 1fr 2fr 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; } .check input { width: 20px; height: 20px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; } .toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; } .toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + .track { background: var(--ok); } .toggle input:checked + .track::after { transform: translateX(16px); }
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

/* modal + toasts */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: up .18s ease-out; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 16px; overflow-y: auto; display: grid; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
@media (min-width: 640px) { .modal-back { align-items: center; padding: 20px; } .modal { max-width: 640px; border-radius: 16px; } }
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); z-index: 70; display: grid; gap: 8px; pointer-events: none; }
@media (min-width: 900px) { .toasts { left: auto; right: 20px; bottom: 20px; width: 360px; } }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); animation: up .18s ease-out; }
.toast-err { background: var(--err); } .toast-info { background: var(--brand); }

ul.checks li { padding: 8px 0; border-top: 1px solid var(--line); } ul.checks li:first-child { border-top: 0; } ul.checks li.bad b { color: var(--err); }
.steps li.bad { border-color: var(--err); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; display: grid; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
