/* ==================================================
   ADA Command Center — design system
   One stylesheet for the sign-in page and the app.
   ================================================== */

:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f1f2ee;
  --surface-3: #e9ebe6;
  --text: #15201b;
  --muted: #5f6b65;
  --faint: #8a948f;
  --line: #e1e4df;
  --line-strong: #cfd4ce;
  --accent: #1d6b52;
  --accent-strong: #145640;
  --accent-soft: #e0efe8;
  --on-accent: #ffffff;
  --warn: #92560a;
  --warn-soft: #fcf0dc;
  --bad: #a3322a;
  --bad-soft: #f9e2df;
  --ok: #1d6b3a;
  --ok-soft: #e0f1e5;
  --info: #28538f;
  --info-soft: #e3ecf8;
  --sidebar: #0f1e19;
  --sidebar-2: #16291f;
  --sidebar-text: #b7c7bf;
  --sidebar-strong: #ffffff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.05), 0 2px 10px rgba(16, 24, 20, 0.04);
  --shadow-lg: 0 18px 50px rgba(16, 24, 20, 0.22);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --sidebar-width: 252px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1411;
    --surface: #151d19;
    --surface-2: #1b2520;
    --surface-3: #222e28;
    --text: #e8eeea;
    --muted: #a0aca6;
    --faint: #76827c;
    --line: #26322c;
    --line-strong: #33413a;
    --accent: #5cc49c;
    --accent-strong: #7ed3b1;
    --accent-soft: #19332a;
    --on-accent: #06140e;
    --warn: #e9b766;
    --warn-soft: #3a2e19;
    --bad: #f0877d;
    --bad-soft: #3c211f;
    --ok: #7dd39c;
    --ok-soft: #1a3324;
    --info: #8ab4f0;
    --info-soft: #1b2a40;
    --sidebar: #0a110e;
    --sidebar-2: #121c17;
    --shadow: none;
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1411; --surface: #151d19; --surface-2: #1b2520; --surface-3: #222e28; --text: #e8eeea; --muted: #a0aca6;
  --faint: #76827c; --line: #26322c; --line-strong: #33413a; --accent: #5cc49c; --accent-strong: #7ed3b1; --accent-soft: #19332a;
  --on-accent: #06140e; --warn: #e9b766; --warn-soft: #3a2e19; --bad: #f0877d; --bad-soft: #3c211f; --ok: #7dd39c; --ok-soft: #1a3324;
  --info: #8ab4f0; --info-soft: #1b2a40; --sidebar: #0a110e; --sidebar-2: #121c17; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- app layout ---------- */

.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 18px 12px;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--sidebar-strong); }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #2f8f6c, #1d6b52); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: 0.06em;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--sidebar-text); }

.nav-group { margin-top: 14px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #6f8479; padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 8px 10px; margin: 1px 0; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; font-size: 14px; font-weight: 500;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--sidebar-2); color: var(--sidebar-strong); }
.nav-item[aria-current="page"] { background: #1f3a2f; color: var(--sidebar-strong); box-shadow: inset 3px 0 0 #5cc49c; }
.nav-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #c9772b; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; font-size: 12px; color: #6f8479; }
.sidebar-foot .safe { display: flex; align-items: center; gap: 6px; color: #9fcab6; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 600; font-size: 15px; color: var(--muted); }
.topbar-title strong { color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.menu-button { display: none; }

.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px; }
.user-chip .who { font-size: 13px; font-weight: 600; line-height: 1.1; }
.user-chip .role { font-size: 11px; color: var(--muted); }

.page { width: 100%; max-width: 1320px; margin: 0 auto; padding: 26px 28px 60px; }
.view { min-height: 50vh; }
.lead-text { color: var(--muted); margin: 0 0 22px; }
.section-title { margin-top: 30px; }
.page-tabs { margin: 4px 0 20px; }

/* ---------- building blocks ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head .more { margin-left: auto; font-size: 13px; }
.panel-body { padding: 14px 18px; }
.panel-empty { padding: 22px 18px; color: var(--muted); font-size: 14px; display: flex; gap: 10px; align-items: center; }

.stack { display: grid; gap: 16px; }
.stack-tight { gap: 6px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.grid-3 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }

.tiles, .kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); margin-bottom: 22px; }
.tile, .kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile-value, .kpi-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile-label, .kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.tile-attention .tile-value, .kpi-attention .kpi-value { color: var(--warn); }
.kpi { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; position: relative; }
button.kpi { font: inherit; text-align: left; cursor: pointer; }
button.kpi:hover { border-color: var(--line-strong); }
.kpi-head { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.kpi-head .icon { width: 16px; height: 16px; }
.kpi-hint { font-size: 12px; color: var(--faint); }
.kpi-off .kpi-value { font-size: 15px; font-weight: 600; color: var(--faint); padding: 8px 0 3px; letter-spacing: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; line-height: 1.6;
}
.badge-off { background: var(--bad-soft); color: var(--bad); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }

.notice, .alert {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px;
  background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.notice { display: block; }
.notice strong { color: var(--warn); }
.alert .icon { margin-top: 2px; color: var(--warn); }
.alert-danger { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-danger .icon { color: var(--bad); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-info .icon { color: var(--info); }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-ok .icon { color: var(--ok); }
.alert-title { font-weight: 600; }
.alert-detail { font-size: 13px; color: var(--muted); }
.alert .btn { margin-left: auto; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.empty { color: var(--muted); padding: 36px 24px; text-align: center; }
.nowrap { white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent);
  padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 13px; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--surface); margin-bottom: 16px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; color: var(--muted); font: inherit; font-size: 14px; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.segmented .count { margin-left: 6px; font-size: 12px; color: var(--faint); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .segmented { margin-bottom: 0; }
.toolbar select, .inline-select, .field input, .field select, .field textarea, .composer textarea, .modal textarea, .modal input[type="text"], .modal input[type="url"], .input {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; min-width: 0;
}
.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }

/* ---------- drafts / cards ---------- */

.draft-head { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.draft-title { font-weight: 700; font-size: 16px; }
.draft-meta { color: var(--muted); font-size: 13px; }
.message { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 280px; overflow-y: auto; font-size: 14px; }
.draft-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 12px; }
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.draft-trail { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel .table-wrap { border: 0; border-radius: 0; box-shadow: none; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num, td.mono, td.nowrap, th { white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.cell-error { color: var(--bad); max-width: 380px; }
tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

/* ---------- lists / activity ---------- */

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows .row-main { min-width: 0; flex: 1; }
.rows .row-title { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.rows .row-meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.rows .row-side { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-top: 7px; flex: none; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-bad { background: var(--bad); } .dot-info { background: var(--info); }

/* bars (analytics) */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(90px, 200px) 1fr 48px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; min-width: 2px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.spark { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding-top: 8px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.spark-bar { width: 100%; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.spark-label { font-size: 11px; color: var(--faint); }

/* ---------- loading ---------- */

.skeleton { border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton-line { height: 14px; margin: 10px 0; }
.skeleton-kpi { height: 104px; border-radius: var(--radius); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- modal, drawer, toasts ---------- */

.modal-backdrop, .drawer-backdrop { position: fixed; inset: 0; background: rgba(8, 14, 11, 0.5); z-index: 40; }
.modal-backdrop { display: grid; place-items: center; padding: 16px; z-index: 45; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; width: min(640px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h2 { margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.modal textarea { width: 100%; min-height: 80px; }
.drawer { position: absolute; top: 0; right: 0; height: 100%; width: min(760px, 100%); background: var(--surface); padding: 24px; overflow-y: auto; box-shadow: var(--shadow-lg); }
.drawer-close { float: right; }
pre.json { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 60; max-width: min(440px, calc(100% - 36px)); }
.toast { background: var(--text); color: var(--bg); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; }
.toast-bad { background: var(--bad); color: #fff; }

/* ---------- forms (support, content, actions) ---------- */

details.card > summary { cursor: pointer; font-weight: 600; }
details.card { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 14px 0 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field textarea, .composer textarea { min-height: 90px; resize: vertical; width: 100%; }
.composer { display: grid; gap: 8px; margin: 12px 0 18px; }
.thread { display: grid; gap: 10px; margin-bottom: 16px; }
.msg { border-radius: var(--radius-sm); padding: 10px 12px; border: 1px solid var(--line); }
.msg-in { background: var(--surface-2); }
.msg-note { background: var(--warn-soft); }
.msg-out { background: var(--accent-soft); }
.msg-head { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.ticket-subject { font-weight: 700; font-size: 17px; margin: 4px 0; overflow-wrap: anywhere; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 4px 0; }
.checks .toggle { color: var(--text); font-size: 14px; }
.hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.guard { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--info-soft); font-size: 13px; }
.guard .icon { color: var(--info); margin-top: 1px; }

/* ---------- ADA Command (chat) ---------- */

.chat { display: grid; grid-template-rows: 1fr auto; height: calc(100vh - 60px - 26px - 40px); min-height: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.chat-log { overflow-y: auto; padding: 24px clamp(14px, 4vw, 48px); display: flex; flex-direction: column; gap: 18px; }
.chat-empty { margin: auto; max-width: 620px; text-align: center; }
.chat-empty .brand-mark { width: 48px; height: 48px; font-size: 15px; margin: 0 auto 12px; border-radius: 13px; }
.chat-empty h1 { font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.bubble { max-width: min(860px, 100%); }
.bubble-user { align-self: flex-end; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-ada { align-self: flex-start; display: flex; gap: 12px; width: 100%; }
.bubble-ada .brand-mark { width: 30px; height: 30px; font-size: 10px; border-radius: 8px; flex: none; }
.bubble-ada .answer { min-width: 0; flex: 1; display: grid; gap: 12px; }
.answer-text { font-size: 15px; }
.answer .table-wrap { box-shadow: none; }
.answer-block-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.answer-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--faint); }
.mini-stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.mini-stat { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); text-align: left; font: inherit; color: inherit; }
button.mini-stat { cursor: pointer; }
.mini-stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-stat .l { font-size: 12px; color: var(--muted); }
.chat-input { border-top: 1px solid var(--line); padding: 14px clamp(14px, 4vw, 48px) 16px; background: var(--surface); }
.chat-box { display: flex; gap: 10px; align-items: flex-end; border: 1px solid var(--line-strong); border-radius: 14px; padding: 8px 8px 8px 14px; background: var(--surface); }
.chat-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-box textarea { flex: 1; border: 0; outline: none; resize: none; font: inherit; font-size: 15px; background: transparent; color: var(--text); max-height: 160px; min-height: 24px; padding: 6px 0; }
.chat-foot { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--faint); }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; } .typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- Action Center ---------- */

.action-card { display: grid; grid-template-columns: 4px 1fr; gap: 0; padding: 0; overflow: hidden; }
.action-card .stripe { background: var(--faint); }
.action-card.p-URGENT .stripe { background: var(--bad); }
.action-card.p-HIGH .stripe { background: var(--warn); }
.action-card.p-NORMAL .stripe { background: var(--info); }
.action-card .content { padding: 16px 18px; min-width: 0; }
.action-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.action-grid { display: grid; grid-template-columns: minmax(130px, 190px) 1fr; gap: 6px 18px; margin: 12px 0; font-size: 13px; }
.action-grid dt { color: var(--muted); font-size: 12px; }
.action-grid dd { margin: 0; overflow-wrap: anywhere; }
.todo { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.todo strong { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }

/* ---------- integrations / settings ---------- */

.integration { display: flex; gap: 14px; align-items: flex-start; }
.integration .icon-wrap { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); color: var(--muted); flex: none; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.yes { color: var(--ok); font-weight: 700; }
.no { color: var(--faint); }

/* ---------- sign-in page ---------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-side { background: radial-gradient(1200px 600px at -10% -20%, #24634c 0%, transparent 60%), var(--sidebar); color: var(--sidebar-text); padding: 48px clamp(28px, 5vw, 64px); display: flex; flex-direction: column; }
.auth-side h1 { color: #fff; font-size: clamp(26px, 3vw, 34px); margin-top: auto; }
.auth-side p { max-width: 460px; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 auto; display: grid; gap: 10px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; }
.auth-points .icon { color: #7ed3b1; margin-top: 3px; }
.auth-main { display: grid; place-items: center; padding: 40px 20px; }
.auth-card { width: min(420px, 100%); }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.auth-card form { display: grid; gap: 14px; margin-top: 22px; }
.auth-card .field input { padding: 10px 12px; font-size: 15px; }
.auth-card .btn { padding: 10px 16px; font-size: 15px; }
.form-error { color: var(--bad); font-size: 14px; min-height: 20px; }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: min(280px, 86vw); transform: translateX(-100%); transition: transform 0.18s ease; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(8, 14, 11, 0.45); z-index: 45; }
  .menu-button { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .page { padding: 18px 16px 48px; }
  .user-chip .who, .user-chip .role { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; }
  .auth-side h1 { margin-top: 18px; }
  .auth-points { margin-bottom: 0; }
  .chat { height: calc(100vh - 60px - 18px - 30px); }
}

@media (max-width: 560px) {
  .events li { grid-template-columns: 1fr; gap: 2px; }
  .topbar .toggle span { display: none; }
  .bar { grid-template-columns: minmax(70px, 120px) 1fr 40px; }
}
.auth-brand { padding: 0; }

/* long words (file names, links) wrap instead of widening the page */
.stack > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.alert > div { min-width: 0; overflow-wrap: anywhere; }

/* the phone menu button only on small screens; panels keep their own height */
.topbar .menu-button { display: none; }
.grid-2, .grid-3 { align-items: start; }
.spark { height: auto; }
.spark-col { justify-content: flex-end; }

@media (max-width: 960px) {
  .topbar .menu-button { display: inline-flex; }
  .topbar-title .crumb { display: none; }
  .topbar { flex-wrap: nowrap; }
  .topbar-actions { gap: 6px; flex-wrap: nowrap; }
}

.topbar-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 560px) {
  .topbar .badge-off .label { display: none; }
  .topbar { gap: 8px; padding: 10px 12px; }
  .user-chip { padding: 3px; gap: 4px; }
}

/* ADA Command answers: a title, and summaries that keep their line breaks */
.answer-title { font-weight: 700; font-size: 16px; }
.answer-text { white-space: pre-line; }

/* ADA Command: a requested action waiting for confirmation */
.action-request { margin-top: 4px; }
.action-request .panel-head { gap: 8px; flex-wrap: wrap; }
.action-request .action-grid { padding: 0 16px; }
.action-request .todo, .action-request > p, .action-request > .draft-actions { margin: 8px 16px 12px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check-row input { margin-top: 3px; }
@media (max-width: 600px) { .action-grid { grid-template-columns: 1fr; gap: 2px; } .action-grid dd { margin-bottom: 6px; } }

/* Outreach review (migration 016): which text was sent, and the versions of a text */
.choices { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin: 12px 0; display: grid; gap: 8px; }
.choices legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.choice input { margin-top: 3px; }
.version { margin: 12px 0; display: grid; gap: 6px; }
.message-sent { border-left: 4px solid var(--warn); }
.btn-danger-text { color: var(--bad); }
