/* Same brand tokens as the customer dashboard (backend/app/static/app.css)
 * and the marketing site (frontend/src/utils/brandTheme.js) — "Refined
 * Terracotta". Previously this app deliberately used a different accent
 * (blue) to avoid reading as the same surface as the customer app; that
 * decision was reversed on 2026-07-21 in favor of leaning into the brand
 * everywhere. The differentiator is now the INTERNAL badge + noindex, not a
 * different hue — a clearer signal than an accidental color anyway. */
:root {
  --bg: #141413;
  --surface: #1c1c1a;
  --surface-2: #26261f;
  --border: #34342c;
  --text: #faf9f5;
  --text-dim: #b0aea5;
  --text-faint: #85837a;
  --accent: #d97757;
  --accent-dim: #c2603f;
  --accent-soft: rgba(217, 119, 87, .12);
  --ok: #788c5d;
  --ok-soft: rgba(120, 140, 93, .12);
  --warn: #e8b04b;
  --warn-soft: rgba(232, 176, 75, .12);
  --danger: #cf5f4a;
  --danger-soft: rgba(207, 95, 74, .12);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0,0,0,.4);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 220px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2eee2;
    --surface: #f7f3e9;
    --surface-2: #e6e0d1;
    --border: #d8d1bf;
    --text: #2d2924;
    --text-dim: #5f584d;
    --text-faint: #8b8377;
    --shadow: 0 4px 20px rgba(45,41,36,.10);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

input, button, select { font: inherit; }

/* --- login --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.login-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--danger); border: 1px solid var(--danger); border-radius: 999px;
  padding: 3px 9px; margin-bottom: 12px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.login-card label { display: block; margin-top: 14px; font-size: 13px; color: var(--text-dim); }
.login-card input {
  display: block; width: 100%; margin-top: 5px; padding: 9px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
}
.login-card button {
  margin-top: 18px; width: 100%; padding: 10px; background: var(--accent); border: none;
  border-radius: var(--radius-sm); color: #fff; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: var(--accent-dim); }
.error { margin-top: 12px; color: var(--danger); font-size: 13px; }

/* --- app shell: sidebar + content (Part A: five zones, not one flat page) --- */
.app { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  font-weight: 700; letter-spacing: .03em; padding: 4px 8px 18px; font-size: 15px;
}
.sidebar-brand .badge {
  display: block; font-size: 10px; font-weight: 700; color: var(--danger);
  border: 1px solid var(--danger); border-radius: 999px; padding: 2px 7px;
  margin-top: 6px; width: fit-content;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.zone-btn {
  display: flex; align-items: center; gap: 10px; text-align: left; background: none; border: none;
  color: var(--text-dim); padding: 10px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px;
}
.zone-btn .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0;
}
.zone-btn.alert .dot { background: var(--danger); }
.zone-btn:hover { background: var(--surface-2); color: var(--text); }
.zone-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.zone-btn.active .dot { background: var(--accent); }
.sidebar-who {
  border-top: 1px solid var(--border); padding-top: 12px; font-size: 12px; color: var(--text-dim);
}
.sidebar-who .link-btn { display: block; margin-top: 4px; }

.content { flex: 1; min-width: 0; padding: 24px 28px; max-width: 1160px; }
.zone-header { margin-bottom: 20px; }
.zone-header h1 { margin: 0 0 4px; font-size: 20px; }
.zone-header p { margin: 0; color: var(--text-dim); font-size: 13px; }

.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; }

.grid-3 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 .wide { grid-column: 1 / -1; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
  text-transform: none; letter-spacing: 0; margin-left: 8px;
}
.pill.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.pill.alarm { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.pill.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.pill.unknown { color: var(--text-faint); }
.pill.accent { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.placeholder {
  color: var(--text-faint); font-size: 13px; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); padding: 14px; text-align: center;
}

/* near-live strip (Monitor zone) */
.live-strip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0;
}
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* stat tiles (Business zone) */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat-tile .n { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-tile .l { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; margin-top: 4px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 14px; }
.bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.bar:hover { opacity: 1; }
/* Stepped height classes, not inline style="height:...%" — this app's CSP
 * (style-src 'self', no unsafe-inline) silently drops inline style
 * attributes, so app.js picks the nearest one of these instead. */
.bar-h-0   { height: 2%; }   .bar-h-5   { height: 5%; }   .bar-h-10  { height: 10%; }
.bar-h-15  { height: 15%; }  .bar-h-20  { height: 20%; }  .bar-h-25  { height: 25%; }
.bar-h-30  { height: 30%; }  .bar-h-35  { height: 35%; }  .bar-h-40  { height: 40%; }
.bar-h-45  { height: 45%; }  .bar-h-50  { height: 50%; }  .bar-h-55  { height: 55%; }
.bar-h-60  { height: 60%; }  .bar-h-65  { height: 65%; }  .bar-h-70  { height: 70%; }
.bar-h-75  { height: 75%; }  .bar-h-80  { height: 80%; }  .bar-h-85  { height: 85%; }
.bar-h-90  { height: 90%; }  .bar-h-95  { height: 95%; }  .bar-h-100 { height: 100%; }

.state-ok { color: var(--ok); }
.state-bad { color: var(--danger); }
.kb-sync-result { margin: -4px 0 8px; }
.call-view-btn { margin-left: auto; }
.mt-sm { margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; }
tr.bad td { color: var(--danger); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

.split { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.client-list-pane, .client-detail-pane {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.search-input {
  width: 100%; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); margin-bottom: 10px;
}
#client-list, .plain-list { list-style: none; margin: 8px 0 0; padding: 0; }
#client-list li, .plain-list li {
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-dim);
}
#client-list li:hover, .plain-list li:hover { background: var(--surface-2); }
#client-list li.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.li-sub { display: block; font-size: 11px; color: var(--text-faint); margin-top: 1px; }

.section { margin-bottom: 20px; }
.section h3 { font-size: 13px; text-transform: uppercase; color: var(--text-dim); margin: 0 0 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.row input, .row select { padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
button.action {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: var(--radius-sm); cursor: pointer;
}
button.action:hover { border-color: var(--accent); color: var(--accent); }
button.action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.action.primary:hover { background: var(--accent-dim); }
button.action.danger:hover { border-color: var(--danger); color: var(--danger); }
button.action:disabled { opacity: .5; cursor: default; }

pre.result { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; font: 12px var(--mono); overflow-x: auto; max-height: 260px; }

/* call browser (Support zone) */
.call-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); }
.call-row-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.call-row-head .muted { color: var(--text-faint); font-size: 12px; }
.call-transcript { margin-top: 10px; font-size: 13px; white-space: pre-wrap; border-top: 1px solid var(--border); padding-top: 10px; }
.call-transcript.empty { color: var(--text-faint); font-style: italic; }
audio { width: 100%; margin-top: 10px; }
.tag-chip {
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-dim); margin-right: 4px;
}

/* people zone */
.new-password-box {
  background: var(--ok-soft); border: 1px solid var(--ok); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-top: 8px; font: 13px var(--mono); word-break: break-all;
}
.new-password-box .warn-line { display: block; font: 12px -apple-system, sans-serif; color: var(--text-dim); margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 16px; box-shadow: var(--shadow); font-size: 13px; z-index: 100;
}
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.err { border-color: var(--danger); color: var(--danger); }
