/* TekBryte Client Portal — single stylesheet, light + dark. Brand: blue #0193FD, lime #B8F43D. */

:root {
  --brand-blue: #0193fd;
  --brand-lime: #b8f43d;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --link: #0068c0;
  --primary: #0071c9;
  --primary-hover: #005fa8;
  --primary-text: #ffffff;
  --focus: #0193fd;
  --ok: #15803d;      --ok-bg: #e9f8ee;      --ok-line: #b5e5c4;
  --warn: #a35a00;    --warn-bg: #fff6e5;    --warn-line: #f5d494;
  --bad: #c62828;     --bad-bg: #fdecec;     --bad-line: #f5bdbd;
  --info: #0b62b0;    --info-bg: #eaf4ff;    --info-line: #b9dafb;
  --neutral: #475569; --neutral-bg: #eef2f7; --neutral-line: #d5dde8;
  --sev-critical: #8f1d5f; --sev-critical-bg: #fbe8f2;
  --sev-high: #c62828;     --sev-high-bg: #fdecec;
  --sev-medium: #a35a00;   --sev-medium-bg: #fff3dc;
  --sev-low: #0b62b0;      --sev-low-bg: #e8f2fd;
  --sev-info: #475569;     --sev-info-bg: #eef2f7;
  --side-bg: #0b1422;
  --side-text: #c4cfdc;
  --side-muted: #7d8ea3;
  --side-hover: #142238;
  --side-active: #15304f;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, .12);
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c131d; --surface: #121b27; --surface-2: #0f1722; --surface-3: #1a2533;
    --line: #223042; --line-strong: #314358; --text: #e6edf5; --text-2: #c3cfdc; --muted: #8b9bb0;
    --link: #5cb8ff; --primary: #0a7fd9; --primary-hover: #1990ec; --focus: #4db3ff;
    --ok: #7fd99a; --ok-bg: #11291b; --ok-line: #1f5134;
    --warn: #f5b84a; --warn-bg: #2a2010; --warn-line: #5c4415;
    --bad: #ff8080; --bad-bg: #2d1416; --bad-line: #5e2328;
    --info: #74bfff; --info-bg: #0f2337; --info-line: #1e4a73;
    --neutral: #a9b6c6; --neutral-bg: #1a2533; --neutral-line: #2b3b4f;
    --sev-critical: #ff8fcf; --sev-critical-bg: #331429;
    --sev-high: #ff8080; --sev-high-bg: #2d1416;
    --sev-medium: #f5b84a; --sev-medium-bg: #2a2010;
    --sev-low: #74bfff; --sev-low-bg: #0f2337;
    --sev-info: #a9b6c6; --sev-info-bg: #1a2533;
    --side-bg: #070d16; --side-hover: #101b2b; --side-active: #142a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c131d; --surface: #121b27; --surface-2: #0f1722; --surface-3: #1a2533;
  --line: #223042; --line-strong: #314358; --text: #e6edf5; --text-2: #c3cfdc; --muted: #8b9bb0;
  --link: #5cb8ff; --primary: #0a7fd9; --primary-hover: #1990ec; --focus: #4db3ff;
  --ok: #7fd99a; --ok-bg: #11291b; --ok-line: #1f5134;
  --warn: #f5b84a; --warn-bg: #2a2010; --warn-line: #5c4415;
  --bad: #ff8080; --bad-bg: #2d1416; --bad-line: #5e2328;
  --info: #74bfff; --info-bg: #0f2337; --info-line: #1e4a73;
  --neutral: #a9b6c6; --neutral-bg: #1a2533; --neutral-line: #2b3b4f;
  --sev-critical: #ff8fcf; --sev-critical-bg: #331429;
  --sev-high: #ff8080; --sev-high-bg: #2d1416;
  --sev-medium: #f5b84a; --sev-medium-bg: #2a2010;
  --sev-low: #74bfff; --sev-low-bg: #0f2337;
  --sev-info: #a9b6c6; --sev-info-bg: #1a2533;
  --side-bg: #070d16; --side-hover: #101b2b; --side-active: #142a45;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 620; }
h4 { font-size: 14px; font-weight: 620; margin: 14px 0 6px; }
p { margin: 0 0 12px; }
code, pre, .mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
pre.code { background: var(--surface-3); border: 1px solid var(--line); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre; margin: 0 0 12px; }
pre.code code { background: none; padding: 0; }
pre.code.wrap { white-space: pre-wrap; word-break: break-all; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip:focus { left: 8px; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand a { display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-blue), #0063b8); color: #fff; font-weight: 750; font-size: 17px;
  box-shadow: inset 0 -3px 0 var(--brand-lime);
}
.brand-logo { max-height: 36px; width: auto; }
.brand-mark-img { width: 38px; height: 38px; flex: none; object-fit: contain; }
.topbar .t-brand .brand-mark-img { width: 30px; height: 30px; }
.auth-side .brand-mark-img { width: 44px; height: 44px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 15.5px; font-weight: 650; letter-spacing: .01em; }
.brand-text small { color: var(--side-muted); font-size: 12px; }
.nav { padding: 12px 10px; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--side-text);
  text-decoration: none; font-size: 14.5px; position: relative; margin-bottom: 1px;
}
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; font-weight: 560; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-lime); }
.nav a .count { margin-left: auto; background: var(--brand-blue); color: #fff; font-size: 11.5px; font-weight: 650; border-radius: 10px; padding: 0 7px; line-height: 18px; margin-top: -2px; margin-bottom: -2px; }
.nav a .count.alert { background: #d33b3b; }
.side-foot { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.06); }
.side-user { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 6px; border-radius: 8px; }
.side-user:hover { background: var(--side-hover); text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #1d3a5c; color: #d8ecff; font-size: 13px; font-weight: 650;
}
.side-user .who { min-width: 0; line-height: 1.2; }
.side-user .who strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who small { color: var(--side-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.side-actions { display: flex; gap: 6px; margin-top: 8px; }
.side-actions button, .side-actions a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: transparent;
  border: 1px solid rgba(255,255,255,.1); color: var(--side-text); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.side-actions button:hover, .side-actions a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.side-actions form { flex: 1; display: flex; }
.side-actions form button { width: 100%; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(2,8,20,.45); z-index: 40; }
  .topbar {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--side-bg); color: #fff;
    position: sticky; top: 0; z-index: 30;
  }
  .topbar .menu-btn { background: none; border: 0; color: #fff; padding: 6px; margin-left: -6px; cursor: pointer; }
  .topbar .t-brand { font-weight: 650; display: flex; align-items: center; gap: 9px; }
  .topbar .t-brand .brand-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
  .content { padding: 20px 16px 40px; }
}

/* ------------------------------------------------------------------ page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin: 6px 0 0; max-width: 720px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--link); }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ref { font-family: var(--mono); font-size: 13px; color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 15.5px; }
.card-head .meta { color: var(--muted); font-size: 13px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 18px; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.split > aside .card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 18px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px;
  box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; position: relative;
}
a.stat:hover { border-color: var(--line-strong); text-decoration: none; }
.stat .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.stat .value { font-size: 28px; font-weight: 680; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat.attn { border-color: var(--bad-line); }
.stat.attn .value { color: var(--bad); }
.stat.good .value { color: var(--ok); }

/* severity strip */
.sevbar { display: block; width: 100%; height: 10px; border-radius: 6px; overflow: hidden; margin: 12px 0 10px; }
.sevbar .track { fill: var(--surface-3); }
.sevbar .s-critical { fill: var(--sev-critical); }
.sevbar .s-high { fill: var(--sev-high); }
.sevbar .s-medium { fill: var(--sev-medium); }
.sevbar .s-low { fill: var(--sev-low); }
.sevbar .s-info { fill: var(--sev-info); }
.sevlegend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); }
.sevlegend a, .sevlegend span { display: inline-flex; align-items: center; gap: 6px; color: inherit; }
.sevlegend b { font-variant-numeric: tabular-nums; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.s-critical { background: var(--sev-critical); } .dot.s-high { background: var(--sev-high); }
.dot.s-medium { background: var(--sev-medium); } .dot.s-low { background: var(--sev-low); } .dot.s-info { background: var(--sev-info); }
.dot.h-ok { background: var(--ok); } .dot.h-warning { background: var(--warn); } .dot.h-critical { background: var(--bad); }
.dot.h-unknown, .dot.h-stale { background: var(--muted); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent;
}
.badge.sev-critical { color: var(--sev-critical); background: var(--sev-critical-bg); }
.badge.sev-high { color: var(--sev-high); background: var(--sev-high-bg); }
.badge.sev-medium { color: var(--sev-medium); background: var(--sev-medium-bg); }
.badge.sev-low { color: var(--sev-low); background: var(--sev-low-bg); }
.badge.sev-info { color: var(--sev-info); background: var(--sev-info-bg); }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.neutral { color: var(--neutral); background: var(--neutral-bg); }
.badge.outline { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.badge.lime { background: var(--brand-lime); color: #1b2a05; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .primary { font-weight: 560; color: var(--text); }
.table .primary:hover { color: var(--link); }
.table .sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.nowrap { white-space: nowrap; }
.table td.actions { text-align: right; white-space: nowrap; }
.table select { width: auto; min-width: 140px; padding-top: 6px; padding-bottom: 6px; font-size: 13.5px; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; min-width: 180px; }
.card > .table-wrap .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 18px; }
.card > .table-wrap .table th:last-child, .card > .table-wrap .table td:last-child { padding-right: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* definition list */
.dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 9px 14px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 560;
  cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--bad); border-color: var(--bad-line); background: var(--surface); }
.btn-danger:hover { background: var(--bad-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }
form.inline { display: inline; }

/* ------------------------------------------------------------------ forms */
.form .field { margin-bottom: 16px; }
.form .row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form .row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 700px) { .form .row, .form .row-3 { grid-template-columns: 1fr; gap: 0; } }
label, .label { display: block; font-weight: 580; font-size: 14px; margin-bottom: 6px; color: var(--text); }
label .opt { color: var(--muted); font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
input[type=url], input[type=tel], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.4;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
textarea { min-height: 110px; resize: vertical; }
textarea.tall { min-height: 220px; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=file] { font: inherit; font-size: 14px; color: var(--text-2); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-size: 13px; padding: 6px 12px; margin-right: 10px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-3); color: var(--text); cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); margin-top: 5px; }
.field-error { font-size: 13px; color: var(--bad); margin-top: 5px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }
.code-input { font-family: var(--mono); font-size: 22px !important; letter-spacing: .3em; text-align: center; padding: 12px !important; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .f { min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 200px; }
.filters label { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.filters select, .filters input { padding: 7px 10px; font-size: 14px; }
.filters select { padding-right: 30px; }

/* ------------------------------------------------------------------ alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid; margin-bottom: 16px; font-size: 14px; }
.alert .icon { margin-top: 1px; }
.alert p:last-child { margin-bottom: 0; }
.alert.success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.alert.error { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.alert.warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.alert.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.alert .body { color: var(--text-2); }
.alert strong { color: inherit; }
.flash-stack { margin-bottom: 4px; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 560; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--brand-blue); }
.tabs .count { background: var(--surface-3); color: var(--text-2); border-radius: 10px; font-size: 11.5px; padding: 0 7px; line-height: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg a { padding: 6px 12px; font-size: 13.5px; color: var(--text-2); border-right: 1px solid var(--line-strong); }
.seg a:last-child { border-right: 0; }
.seg a.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.seg a:hover { text-decoration: none; background: var(--surface-3); }

/* ------------------------------------------------------------------ empty state & lists */
.empty { text-align: center; padding: 38px 20px; color: var(--muted); }
.empty .icon { width: 34px; height: 34px; margin: 0 auto 10px; stroke-width: 1.5; color: var(--line-strong); }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty.compact { padding: 14px 0; }
.empty p { margin: 0 auto 14px; max-width: 420px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 560; color: var(--text); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list a.title:hover { color: var(--link); }
.list .meta { font-size: 12.5px; color: var(--muted); }
.health-row .detail { font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------------ conversation */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.msg.staff { border-left: 3px solid var(--brand-blue); }
.msg.internal { background: var(--warn-bg); border-color: var(--warn-line); border-left: 3px solid var(--warn); }
.msg-head { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.msg.internal .msg-head { border-bottom-color: var(--warn-line); }
.msg-head .who { font-weight: 600; }
.msg-head .when { color: var(--muted); font-size: 13px; margin-left: auto; }
.msg-body { padding: 14px 16px; overflow-wrap: anywhere; font-size: 14.5px; }
.msg-files { padding: 0 16px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 13px; color: var(--text-2); background: var(--surface-2); max-width: 100%;
}
.file-chip:hover { border-color: var(--line-strong); text-decoration: none; color: var(--text); }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip small { color: var(--muted); }
.reply-box { margin-top: 18px; }
.card.internal-mode { background: var(--warn-bg); border-color: var(--warn-line); }

/* prose for formatted text */
.prose { font-size: 14.5px; color: var(--text-2); overflow-wrap: anywhere; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 3px; }
.prose > :last-child { margin-bottom: 0; }
.prose h4:first-child { margin-top: 0; }
.section-title { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.section + .section { margin-top: 22px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 17px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.staff::before { background: var(--brand-blue); }
.timeline .t-when { color: var(--muted); font-size: 12.5px; }
.timeline .t-note { margin-top: 5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }

/* pagination */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }

/* ------------------------------------------------------------------ auth pages */
body.auth { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-side {
  background: radial-gradient(circle at 20% 15%, rgba(1,147,253,.35), transparent 45%), radial-gradient(circle at 85% 90%, rgba(184,244,61,.18), transparent 40%), var(--side-bg);
  color: #dbe6f2; padding: 44px 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-side .brand-line { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 650; font-size: 18px; }
.auth-side h2 { color: #fff; font-size: 30px; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; max-width: 440px; }
.auth-side h2 em { font-style: normal; color: var(--brand-lime); }
.auth-side ul { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 12px; max-width: 430px; }
.auth-side li { display: flex; gap: 11px; align-items: flex-start; font-size: 15px; color: #c4d2e2; }
.auth-side li .icon { color: var(--brand-lime); margin-top: 2px; }
.auth-side .fine { font-size: 12.5px; color: #7d8ea3; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.auth-card .card-body { padding: 26px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 14px; }
.auth-mobile-brand { display: none; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-mobile-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 26px; font-size: 17px; }
}
.qr { background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); width: 210px; height: 210px; margin: 6px auto 14px; }
.secret { font-family: var(--mono); font-size: 14px; letter-spacing: .08em; background: var(--surface-3); padding: 8px 10px; border-radius: 7px; word-break: break-all; text-align: center; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; padding: 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 9px; }
.codes code { background: none; font-size: 15px; text-align: center; letter-spacing: .06em; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 16px; }
.steps.steps-from-3 { counter-reset: s 2; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; margin-bottom: 12px; font-size: 14.5px; color: var(--text-2); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 23px; height: 23px; border-radius: 50%; background: var(--brand-lime); color: #1b2a05; font-weight: 700; font-size: 12.5px; display: grid; place-items: center; }

/* installer */
body.install .content { margin: 0 auto; }
.install-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 18px; }

/* key reveal */
.reveal { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 8px; padding: 12px; display: flex; gap: 10px; align-items: center; }
.reveal code { flex: 1; background: none; font-size: 13.5px; word-break: break-all; }

/* misc */
.kpi-inline { display: flex; gap: 22px; flex-wrap: wrap; }
.kpi-inline div { font-size: 13px; color: var(--muted); }
.kpi-inline b { display: block; font-size: 20px; color: var(--text); font-weight: 650; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.notice-bar { background: var(--info-bg); border: 1px solid var(--info-line); color: var(--text-2); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.danger-zone { border-color: var(--bad-line); }
.hash { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.error-page { text-align: center; padding: 50px 20px; }
.error-page .code { font-size: 54px; font-weight: 750; color: var(--line-strong); letter-spacing: -.03em; line-height: 1; }
.error-page h1 { margin: 12px 0 8px; }
.error-page p { color: var(--muted); max-width: 480px; margin: 0 auto 18px; }

@media print {
  .sidebar, .topbar, .actions, .btn, .reply-box, form { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
