/* Joskitech Relay — interface styles
   Navy carries the brand, orange marks what needs attention, amber marks internal notes.
   Channel hexagons ("jacks") are the one signature element; everything else stays quiet. */

@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex"; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --navy-950: #08132A;
  --navy-900: #0E1B33;
  --navy-800: #172846;
  --navy-700: #24395F;
  --navy-600: #3A5079;
  --navy-100: #E5EAF3;
  --orange: #F2801F;
  --orange-600: #CF650A;
  --orange-100: #FFEFDF;

  --canvas: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --surface-3: #EDF0F5;
  --line: #E1E6ED;
  --line-strong: #C9D1DD;
  --text: #0E1B33;
  --text-2: #48566E;
  --text-3: #7A869A;
  --bubble-out: #172846;
  --bubble-out-text: #F4F7FC;
  --note: #FFF6DC;
  --note-line: #EDD38A;
  --note-text: #5A4500;
  --ok: #1B8A60;
  --ok-bg: #E4F5EE;
  --warn: #A86300;
  --warn-bg: #FFF3DC;
  --danger: #C93838;
  --danger-bg: #FCEBEB;
  --link: #2453C9;

  --r-s: 6px;
  --r: 8px;
  --r-l: 12px;
  --pop: 0 14px 34px -12px rgba(14, 27, 51, .32), 0 2px 6px rgba(14, 27, 51, .08);
  --ring: 0 0 0 3px rgba(242, 128, 31, .38);
  --rail: 60px;
  --primary-bg: #0E1B33;
  --primary-hover: #24395F;
  --primary-fg: #FFFFFF;
  --badge-navy-fg: #24395F;
  --accent-line: #0E1B33;
  --font: "Plex", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --canvas: #0A1222;
  --surface: #101B30;
  --surface-2: #0D172A;
  --surface-3: #18253D;
  --line: #22314C;
  --line-strong: #2F4163;
  --text: #E7ECF4;
  --text-2: #A9B4C7;
  --text-3: #7D899D;
  --bubble-out: #26406D;
  --bubble-out-text: #F4F7FC;
  --note: #33290F;
  --note-line: #5E4C19;
  --note-text: #F1DFA8;
  --ok-bg: #0F2E24;
  --warn-bg: #33250C;
  --danger-bg: #351717;
  --link: #8FB0FF;
  --navy-100: #1B2A45;
  --orange-100: #3A2410;
  --primary-bg: #E7ECF4;
  --primary-hover: #FFFFFF;
  --primary-fg: #0E1B33;
  --badge-navy-fg: #BFD0F0;
  --accent-line: #F2801F;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0A1222;
    --surface: #101B30;
    --surface-2: #0D172A;
    --surface-3: #18253D;
    --line: #22314C;
    --line-strong: #2F4163;
    --text: #E7ECF4;
    --text-2: #A9B4C7;
    --text-3: #7D899D;
    --bubble-out: #26406D;
    --bubble-out-text: #F4F7FC;
    --note: #33290F;
    --note-line: #5E4C19;
    --note-text: #F1DFA8;
    --ok-bg: #0F2E24;
    --warn-bg: #33250C;
    --danger-bg: #351717;
    --link: #8FB0FF;
    --navy-100: #1B2A45;
    --orange-100: #3A2410;
    --primary-bg: #E7ECF4;
    --primary-hover: #FFFFFF;
    --primary-fg: #0E1B33;
    --badge-navy-fg: #BFD0F0;
    --accent-line: #F2801F;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.45 var(--font);
  color: var(--text);
  background: var(--canvas);
  font-feature-settings: "tnum" 0;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -.005em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 .75em; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, kbd, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-s); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.i { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.i-sm { width: 15px; height: 15px; }

/* ── App shell ─────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; height: 100vh; height: 100dvh; }
.main { min-width: 0; overflow: auto; }
.page-inbox .main { overflow: hidden; }

.rail {
  background: var(--navy-900);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px; position: relative; z-index: 30;
}
.rail-mark { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 12px; }
.rail-mark svg { width: 30px; height: 30px; }
.rail-link {
  position: relative; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 10px;
  color: #A5B3CB; background: none; border: 0; cursor: pointer;
}
.rail-link:hover { color: #fff; background: rgba(255, 255, 255, .07); text-decoration: none; }
.rail-link.is-active { color: #fff; background: rgba(255, 255, 255, .1); }
.rail-link.is-active::before {
  content: ""; position: absolute; left: -9px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--orange);
}
.rail-link .i { width: 20px; height: 20px; }
.rail-badge {
  position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--orange); color: #fff;
  font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums;
}
.rail-spacer { flex: 1; }
.rail-me { position: relative; margin-top: 6px; }
.rail-me .avatar { width: 34px; height: 34px; font-size: 12px; }
.rail-me .presence { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--navy-900); }

.presence { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); }
.presence.online { background: #2FBF7F; }
.presence.away { background: #E0A100; }
.presence.offline { background: #8A95A8; }

.impersonation {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px;
  background: var(--orange); color: #fff; border-radius: 999px; box-shadow: var(--pop); font-weight: 500;
}
.impersonation button { background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 999px; padding: 5px 12px; font: inherit; cursor: pointer; }

/* ── Pages ─────────────────────────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 28px 64px; }
.page-wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 12px; min-height: 40px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; display: flex; align-items: center; gap: 10px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13px; margin-bottom: 8px; }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a {
  padding: 9px 0 10px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.is-active { color: var(--text); border-color: var(--orange); }

.settings { display: grid; grid-template-columns: 200px 1fr; gap: 32px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { padding: 7px 10px; border-radius: var(--r-s); color: var(--text-2); }
.settings-nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.settings-nav a.is-active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line); }
.settings-nav .sep { height: 1px; background: var(--line); margin: 8px 10px; }
.settings-body { min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin-right: auto; }
.panel-flush { padding: 0; overflow: hidden; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.cluster { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url],
input[type=tel], input[type=datetime-local], input[type=time], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-s);
  padding: 8px 10px; min-height: 36px; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: var(--ring); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r-s); background: var(--surface); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; color: var(--text); }
.check input { width: 16px; height: 16px; accent-color: var(--accent-line); margin: 0; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.error-text { color: var(--danger); font-size: 13px; }
.help { font-size: 12.5px; color: var(--text-3); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--accent-line); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; font: 500 13.5px/1 var(--font); white-space: nowrap;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-s);
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-accent:hover { background: var(--orange-600); border-color: var(--orange-600); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; background: none; color: var(--text-2); border-radius: var(--r-s); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.is-on { color: var(--orange); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ── Data display ──────────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--text-3);
  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 .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.row-link { color: var(--text); font-weight: 500; }
.table td.actions { text-align: right; white-space: nowrap; }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-person .who { min-width: 0; }
.cell-person .who > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-accent { background: var(--orange-100); color: var(--orange-600); }
.badge-navy { background: var(--navy-100); color: var(--badge-navy-fg); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--text-3)); }
.chip button { border: 0; background: none; padding: 0; margin-left: 2px; color: var(--text-3); cursor: pointer; line-height: 0; }
.chip button:hover { color: var(--danger); }

.avatar {
  --h: 220;
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  background: hsl(var(--h) 42% 89%); color: hsl(var(--h) 45% 27%);
  font-size: 12px; font-weight: 600; letter-spacing: .02em; user-select: none;
}
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 55% 85%); }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* The channel jack: a flat-top hexagon in the channel's colour. */
.jack {
  --c: #64748B;
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 20px; background: var(--c); color: #fff;
  clip-path: polygon(25% 2%, 75% 2%, 100% 50%, 75% 98%, 25% 98%, 0 50%);
}
.jack .i { width: 11px; height: 11px; stroke-width: 2.5; }
.jack-sm { width: 17px; height: 15px; }
.jack-sm .i { width: 9px; height: 9px; }
.jack-lg { width: 34px; height: 30px; }
.jack-lg .i { width: 16px; height: 16px; }
.jack-xl { width: 46px; height: 40px; }
.jack-xl .i { width: 20px; height: 20px; }
.with-jack { position: relative; display: inline-block; }
.with-jack .jack { position: absolute; right: -6px; bottom: -4px; box-shadow: 0 0 0 2px var(--surface); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.kpi { padding: 16px 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .label { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--navy-700); border-radius: 3px; }
.meter.is-high > span { background: var(--orange); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .i { width: 28px; height: 28px; color: var(--line-strong); margin-bottom: 10px; }
.empty p { margin: 0 0 14px; }

.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 14px; color: var(--text-3); }

.code-block {
  position: relative; background: var(--navy-950); color: #DCE6F8; border-radius: var(--r);
  padding: 14px 16px; font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; white-space: pre;
}
.code-block .copy { position: absolute; top: 8px; right: 8px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--text-3); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--surface-3); color: var(--text-2); margin-bottom: 16px; }
.alert .i { margin-top: 1px; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }

/* ── Popovers, toasts, dialogs ─────────────────────────────────────────── */
.menu {
  position: absolute; z-index: 60; min-width: 220px; max-height: 360px; overflow: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--pop);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item.is-active { background: var(--surface-3); text-decoration: none; }
.menu-item .meta { margin-left: auto; color: var(--text-3); font-size: 12px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-head { padding: 6px 10px 4px; font-size: 12px; color: var(--text-3); }

.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r);
  background: var(--navy-900); color: #fff; box-shadow: var(--pop); max-width: min(560px, 92vw);
  animation: toast-in .2s ease-out;
}
.toast.error { background: var(--danger); }
.toast button { margin-left: 6px; background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; line-height: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

dialog.modal {
  border: 0; padding: 0; border-radius: var(--r-l); background: var(--surface); color: var(--text);
  box-shadow: var(--pop); width: min(520px, 94vw);
}
dialog.modal::backdrop { background: rgba(8, 19, 42, .45); }
.modal-head { display: flex; align-items: center; padding: 16px 20px 0; }
.modal-head h2 { margin-right: auto; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }

/* ── Inbox ─────────────────────────────────────────────────────────────── */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) 320px; height: 100vh; height: 100dvh; }
.inbox.no-profile { grid-template-columns: 340px minmax(0, 1fr); }
.inbox.no-profile .profile { display: none; }

.list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.views { display: flex; gap: 2px; }
.view-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: var(--r-s);
  background: none; color: var(--text-2); font: 500 13px/1 var(--font); cursor: pointer;
}
.view-btn:hover { background: var(--surface-3); color: var(--text); }
.view-btn.is-active { background: var(--primary-bg); color: var(--primary-fg); }
.view-btn .count { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 400; }
.list-tools { display: flex; gap: 6px; }
.list-tools select { min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.search { position: relative; }
.search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.search input { padding-left: 32px; min-height: 34px; background: var(--surface-2); }
.list-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.list-more { padding: 12px; text-align: center; }

.conv {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: start;
  padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; color: inherit;
}
.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv.is-active { background: var(--navy-100); }
.conv.is-active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent-line); }
.conv .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.is-unread .who { font-weight: 600; }
.conv .when { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.conv.is-unread .when { color: var(--orange-600); font-weight: 500; }
.conv .preview {
  grid-column: 2 / 3; color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv .preview .you { color: var(--text-3); }
.conv .side { grid-column: 3; grid-row: 2; display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.conv .avatar-col { grid-row: 1 / span 2; }
.unread-pill {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--orange); color: #fff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.prio { width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); }
.prio-high { background: var(--orange); }
.prio-urgent { background: var(--danger); }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.thread-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 61px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.thread-title { min-width: 0; margin-right: auto; display: flex; align-items: center; gap: 10px; }
.thread-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title .sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-actions { display: flex; align-items: center; gap: 6px; }
.viewers { display: flex; align-items: center; }
.viewers .avatar { width: 24px; height: 24px; font-size: 10px; margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.assign-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; }
.assign-btn span { overflow: hidden; text-overflow: ellipsis; }

.messages { flex: 1; overflow-y: auto; padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain; }
.day-sep { align-self: center; margin: 14px 0 8px; font-size: 12px; color: var(--text-3); }
.msg { display: flex; gap: 8px; max-width: min(640px, 78%); margin-top: 6px; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble {
  padding: 8px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  overflow-wrap: anywhere; line-height: 1.45;
}
.msg .bubble .text { white-space: pre-wrap; }
.msg.in .bubble { border-bottom-left-radius: 4px; }
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); border-color: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg.out .bubble a { color: #BFD3FF; }
.msg.bot .bubble { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.msg.cont { margin-top: 2px; }
.msg .meta { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.msg.out .meta { justify-content: flex-end; }
.msg .stack { display: flex; flex-direction: column; min-width: 0; }
.msg.out .stack { align-items: flex-end; }
.msg .meta .st-read { color: var(--orange); }
.msg .meta .st-failed { color: var(--danger); }
.msg .failed-line { display: flex; gap: 8px; align-items: center; color: var(--danger); font-size: 12px; margin-top: 3px; }
.msg .tpl { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; opacity: .8; margin-bottom: 3px; }
.msg.note { align-self: stretch; max-width: none; }
.msg.note .bubble { background: var(--note); border-color: var(--note-line); color: var(--note-text); border-radius: 10px; flex: 1; }
.msg.note .note-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; margin-bottom: 2px; }
.mention { font-weight: 600; }
.event { align-self: center; font-size: 12px; color: var(--text-3); margin: 8px 0; text-align: center; max-width: 80%; }
.attachment { display: block; margin-bottom: 4px; }
.attachment img { display: block; max-width: 280px; max-height: 260px; border-radius: 10px; }
.attachment audio, .attachment video { max-width: 280px; display: block; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(127,127,127,.12); color: inherit; }
.typing-line { padding: 0 22px 6px; font-size: 12px; color: var(--text-3); min-height: 20px; }
.load-older { align-self: center; margin-bottom: 8px; }

.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 14px 12px; }
.composer-modes { display: flex; gap: 2px; margin-bottom: 8px; }
.mode-btn { border: 0; background: none; padding: 5px 10px; border-radius: var(--r-s); font: 500 13px/1 var(--font); color: var(--text-3); cursor: pointer; }
.mode-btn.is-active { color: var(--text); background: var(--surface-3); }
.mode-btn[data-mode="note"].is-active { background: var(--note); color: var(--note-text); }
.composer-box { border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.composer-box:focus-within { border-color: var(--orange); box-shadow: var(--ring); }
.composer.is-note .composer-box { background: var(--note); border-color: var(--note-line); }
.composer textarea { border: 0; background: transparent; box-shadow: none; min-height: 64px; max-height: 260px; resize: none; padding: 10px 12px; }
.composer textarea:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px 6px; }
.composer-bar .spacer { flex: 1; }
.composer-hint { font-size: 12px; color: var(--text-3); margin-right: 8px; }
.pending-file { display: inline-flex; align-items: center; gap: 6px; margin: 0 12px 4px; padding: 4px 8px; border-radius: 6px; background: var(--surface-3); font-size: 12.5px; }
.window-closed { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r); background: var(--warn-bg); color: var(--warn); margin-bottom: 8px; font-size: 13px; }
.window-closed .btn { margin-left: auto; }

.thread-empty { flex: 1; display: grid; place-items: center; color: var(--text-3); text-align: center; padding: 24px; }
.thread-empty .jacks { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; opacity: .9; }

.profile { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; min-height: 0; }
.profile-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); text-align: center; }
.profile-head .avatar-lg { margin-bottom: 8px; }
.profile-head h2 { font-size: 15px; }
.profile-head .contact-line { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.profile-sec { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.profile-sec h3 { font-size: 12.5px; font-weight: 600; color: var(--text-3); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.profile-sec h3 .count { font-weight: 400; }
.profile-sec h3 a, .profile-sec h3 button { margin-left: auto; font-weight: 500; }
.idents { display: flex; flex-direction: column; gap: 6px; }
.ident { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.ident span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv select { min-height: 28px; padding: 2px 26px 2px 8px; font-size: 13px; }
.mini-list { display: flex; flex-direction: column; gap: 8px; }
.mini-item { display: flex; gap: 8px; align-items: baseline; font-size: 13px; min-width: 0; color: inherit; }
.mini-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item .r { color: var(--text-3); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
a.mini-item:hover { text-decoration: none; }
a.mini-item:hover .t { text-decoration: underline; }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-input input { border: 0; padding: 2px 4px; min-height: 24px; width: 90px; background: none; font-size: 12.5px; }
.tag-input input:focus { box-shadow: none; }

.pane-back { display: none; }

/* ── Builders (rules, audiences, journey steps) ────────────────────────── */
.builder { display: flex; flex-direction: column; gap: 8px; }
.builder-row { display: grid; grid-template-columns: 170px 150px minmax(0, 1fr) 32px; gap: 8px; align-items: center; }
.builder-row.wide { grid-template-columns: 200px minmax(0, 1fr) 32px; }
.builder-match { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.builder-match select { width: auto; min-height: 30px; padding: 2px 28px 2px 8px; }
.step-list { display: flex; flex-direction: column; gap: 0; counter-reset: step; }
.step {
  position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding-bottom: 14px;
}
.step::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-bg); color: var(--primary-fg); font-size: 12px; font-weight: 600; position: relative; z-index: 1;
}
.step::after { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.step:last-child::after { display: none; }
.step-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.step-card .step-top { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.step-card .step-top select { max-width: 240px; }
.step-card .step-top .spacer { flex: 1; }
.step-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.step-fields textarea { min-height: 70px; }
.trigger-card { border-left: 3px solid var(--orange); }

/* ── Auth ──────────────────────────────────────────────────────────────── */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); min-height: 100vh; min-height: 100dvh; }
.auth-art {
  position: relative; overflow: hidden; background: var(--navy-900); color: #E8EEF8;
  display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px;
}
.auth-art .brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; color: #fff; }
.auth-art .brand svg { width: 34px; height: 34px; }
.auth-art .claim { font-size: 30px; line-height: 1.2; font-weight: 600; letter-spacing: -.015em; max-width: 15ch; color: #fff; }
.auth-art .foot { color: #8E9CB7; font-size: 13px; }
.relay-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.relay-art .line { stroke: #2C4371; stroke-width: 1.5; fill: none; }
.relay-art .pulse { stroke: var(--orange); stroke-width: 2; fill: none; stroke-dasharray: 10 400; animation: pulse 3.6s linear infinite; }
@keyframes pulse { from { stroke-dashoffset: 410; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .relay-art .pulse { animation: none; display: none; } .toast { animation: none; } }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 22px; margin-bottom: 20px; }
.auth-card .alt { margin-top: 18px; color: var(--text-2); font-size: 13.5px; }
.auth-card .btn-primary { width: 100%; min-height: 40px; }
.checks { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; }
.checks li { display: flex; gap: 8px; align-items: center; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--danger); }

/* ── Reports ───────────────────────────────────────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.bars .bar { flex: 1; min-width: 3px; background: var(--navy-700); border-radius: 3px 3px 0 0; position: relative; }
.bars .bar:hover { background: var(--orange); }
.bars .bar.zero { background: var(--surface-3); height: 2px !important; }
.bars-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ── Plans ─────────────────────────────────────────────────────────────── */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.plan.is-current { border-color: var(--accent-line); box-shadow: inset 0 0 0 1px var(--accent-line); }
.plan .price { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 13px; font-weight: 400; color: var(--text-3); }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.plan ul li { display: flex; gap: 8px; align-items: center; }
.plan ul .i { width: 15px; height: 15px; color: var(--ok); }
.plan ul .off { color: var(--text-3); }
.plan ul .off .i { color: var(--text-3); }
.plan form { margin-top: auto; }
.cycle-toggle { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 8px; gap: 2px; }
.cycle-toggle a { padding: 5px 12px; border-radius: 6px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.cycle-toggle a.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); text-decoration: none; }

.channel-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.channel-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-weight: 500;
}
.channel-tile:hover { border-color: var(--line-strong); background: var(--surface-2); text-decoration: none; }
.channel-tile .gated { margin-left: auto; color: var(--text-3); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .i { color: var(--text-3); width: 16px; height: 16px; margin-top: 1px; }
.timeline .when { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.timeline a { overflow-wrap: anywhere; }

/* ── Print (invoices) ──────────────────────────────────────────────────── */
.invoice { max-width: 760px; margin: 32px auto; background: #fff; color: #0E1B33; padding: 48px; border: 1px solid var(--line); border-radius: var(--r-l); }
.invoice table { width: 100%; border-collapse: collapse; margin: 24px 0; }
.invoice th, .invoice td { text-align: left; padding: 10px 0; border-bottom: 1px solid #E1E6ED; }
.invoice .total { font-size: 18px; font-weight: 600; }
@media print { body { background: #fff; } .no-print { display: none !important; } .invoice { border: 0; margin: 0; padding: 0; } }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1240px) {
  .inbox { grid-template-columns: 300px minmax(0, 1fr); }
  .inbox .profile {
    display: none; position: fixed; right: 0; top: 0; bottom: 0; width: 320px; z-index: 40; box-shadow: var(--pop);
  }
  .inbox.show-profile .profile { display: block; }
}
@media (max-width: 900px) {
  .settings { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .settings-nav .sep { display: none; }
  .split, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .builder-row { grid-template-columns: 1fr 1fr; }
  .builder-row > :nth-child(3) { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  :root { --rail: 52px; }
  .page { padding: 16px 16px 48px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .thread { display: none; }
  .inbox.has-active .list { display: none; }
  .inbox.has-active .thread { display: flex; }
  .pane-back { display: inline-grid; }
  .msg { max-width: 92%; }
  .thread-actions .hide-sm, .assign-btn span { display: none; }
  .thread-head { gap: 6px; padding: 8px 10px; }
  .table th, .table td { padding: 9px 10px; }
  .hide-sm { display: none !important; }
}
.copy-field input { flex: 1; min-width: 0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 55% 85%); }
}
