/* Vibe admin panel. Dark first (near-black layers, one violet accent), light
   theme via the top-bar switch. Served with a strict CSP: no inline styles,
   no external fonts; Plus Jakarta Sans is vendored. */
@font-face { font-family: Jakarta; src: url(./vendor/PlusJakartaSans-Regular.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: Jakarta; src: url(./vendor/PlusJakartaSans-SemiBold.ttf); font-weight: 500 600; font-display: swap; }
@font-face { font-family: Jakarta; src: url(./vendor/PlusJakartaSans-Bold.ttf); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0a0a0b; --rail: #0f1013; --card: #15161b; --card-2: #1c1d24; --line: #262730; --line-2: #31323d;
  --text: #f4f4f6; --text-2: #b8b9c9; --muted: #8b8d9e;
  --accent: #a66bff; --accent-strong: #9333ea; --accent-soft: rgba(147, 51, 234, .18); --accent-ink: #e9dcff;
  --bubble: #1f2028; --bubble-me: #3a1f6b; --wall: #101116;
  --good: #34c77b; --good-soft: rgba(52, 199, 123, .14); --warn: #f3b44c; --warn-soft: rgba(243, 180, 76, .14);
  --bad: #ff6b6f; --bad-soft: rgba(255, 107, 111, .14);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --cmp: #4a4c5a; --grid: #23242c;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
  --pop: 0 24px 60px rgba(0,0,0,.4);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f9; --rail: #ffffff; --card: #ffffff; --card-2: #f6f6fb; --line: #e5e6ee; --line-2: #d9dae5;
  --text: #121317; --text-2: #4b4d5c; --muted: #6b6d7e;
  --accent: #7b3ff2; --accent-strong: #7b3ff2; --accent-soft: #efe6ff; --accent-ink: #4b1fa8;
  --bubble: #ffffff; --bubble-me: #efe3ff; --wall: #eceaf3;
  --good: #12805c; --good-soft: #e3f6ee; --warn: #a15c00; --warn-soft: #fff3dc; --bad: #c0262d; --bad-soft: #fde8e8;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --cmp: #c9cad6; --grid: #ececf3;
  --shadow: 0 1px 2px rgba(18,19,23,.05), 0 6px 20px rgba(18,19,23,.04);
  --pop: 0 24px 60px rgba(18,19,23,.18);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Jakarta, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1 { font-size: 22px; line-height: 1.2; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
h3 { font-size: 13px; margin: 0; font-weight: 600; color: var(--text-2); }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.boot { padding: 40px; color: var(--muted); }
.mt { margin-top: 16px; }
.pad { padding: 14px; margin: 0; }
.sub-h { margin: 16px 0 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.scroll { overflow-x: auto; }
.ico { flex: none; display: block; }

/* ------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail { background: var(--rail); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; z-index: 40; }
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 10px 18px; font-weight: 700; font-size: 19px; line-height: 1.1; color: var(--text); }
.logo i { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #b476ff, #7b3ff2); display: grid; place-items: center; font-style: normal; font-size: 16px; color: #fff; flex: none; }
.logo small { font-size: 12px; font-weight: 600; color: var(--muted); }
.nav { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; color: var(--text-2); font-weight: 500; }
.nav:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.nav.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav .cnt { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.nav .cnt.acc { background: var(--accent-strong); }
.rail .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.rail .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.rail .me-t { min-width: 0; flex: 1; }
.rail .me b { display: block; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }

.main { padding: 20px 28px 64px; min-width: 0; max-width: 1440px; width: 100%; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.hello { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.hello small { display: block; color: var(--text-2); font-size: 13px; margin-top: 2px; }
.hello .face { flex: none; }
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 9px 14px; min-width: 300px; color: var(--muted); cursor: text; text-align: left; }
.search:hover { border-color: var(--line-2); }
kbd { font: 600 11.5px/1 Jakarta, system-ui, sans-serif; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 3px 6px; color: var(--text-2); background: var(--card-2); }
.search kbd { margin-left: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--bad); font-weight: 700; font-size: 14px; }
.pill:hover { text-decoration: none; border-color: var(--line-2); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--text-2); flex: none; padding: 0; position: relative; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); text-decoration: none; }
.icon-btn.sm { width: 32px; height: 32px; }
.menu-btn { display: none; }
.bell .nb { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--accent-strong); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; box-shadow: 0 0 0 2px var(--bg); }

/* ------------------------------------------------------------- cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.card-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-right: 14px; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.slot { min-width: 0; display: grid; gap: 16px; align-content: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.prefs-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

/* Today: safety review */
.goal { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.goal p { margin: 2px 0 0; }
.ring { position: relative; width: 52px; height: 52px; flex: none; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; }
.ring-bg { stroke: var(--line-2); }
.ring-fg { stroke: var(--accent); transition: stroke-dasharray .4s; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); background: var(--card-2); border-radius: 14px; padding: 14px 10px; text-align: center; color: var(--text); display: grid; gap: 8px; justify-items: center; }
a.tile:hover { border-color: var(--line-2); text-decoration: none; }
.tile .ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; }
.ic.bad { background: var(--bad-soft); color: var(--bad); }
.ic.warn { background: var(--warn-soft); color: var(--warn); }
.ic.acc { background: var(--accent-soft); color: var(--accent); }
.tile b { font-size: 22px; line-height: 1; }
.tile span { font-size: 13px; color: var(--text-2); }
.live { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 12px; }
.live.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.live.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.live b { display: block; font-size: 26px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.live span { font-size: 13px; color: var(--text-2); }
.stamp { margin: 12px 0 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 8px; vertical-align: middle; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,199,123,.5); } 70% { box-shadow: 0 0 0 8px rgba(52,199,123,0); } 100% { box-shadow: 0 0 0 0 rgba(52,199,123,0); } }

/* question tiles */
.qt { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
a.qt:hover { border-color: var(--line-2); text-decoration: none; }
.qt .ask { font-size: 13.5px; color: var(--text-2); }
.qt .val { font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.qt .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.qt .note { font-size: 12.5px; color: var(--muted); }
.qt .foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-top: auto; padding-top: 4px; }
.qt.warn .val { color: var(--warn); }
.delta { font-size: 12.5px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); font-weight: 500; }
.rule { font-size: 12px; font-weight: 600; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 2px 8px; align-self: flex-start; }
.mini { flex: none; display: block; }

/* ------------------------------------------------------------- charts */
.cv { display: block; width: 100%; height: auto; overflow: visible; }
.cv .gl { stroke: var(--grid); stroke-width: 1; }
.cv .ax { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.cv .lbl { fill: var(--text-2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cv .hl { fill: var(--text-2); font-size: 12.5px; }
[data-tip] { cursor: default; }
[data-tip]:hover { opacity: .85; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin: 0 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tbl-btn { border: 1px solid var(--line); background: transparent; color: var(--text-2); border-radius: 8px; font-size: 12px; font-weight: 600; padding: 3px 9px; white-space: nowrap; }
.tbl-btn:hover { color: var(--text); border-color: var(--line-2); }
.ctable { display: none; width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.ctable.show { display: table; }
.ctable th, .ctable td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.ctable th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.ctable th:first-child, .ctable td:first-child { text-align: left; }
.tip { position: fixed; z-index: 80; pointer-events: none; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 10px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); display: none; max-width: 260px; }
.tip b { display: block; font-size: 13px; }
.tip span { display: block; color: var(--text-2); }
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; }
.heat .l { color: var(--muted); display: flex; align-items: center; justify-content: center; }
.heat .l.d { justify-content: flex-start; }
.heat .c { aspect-ratio: 1.3; border-radius: 4px; }
.scale { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.scale i { width: 120px; height: 8px; border-radius: 99px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 8%, var(--card)), var(--accent)); }
.seg100 { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 7px 10px; align-items: center; font-size: 12.5px; }
.seg100 .bar { display: flex; gap: 2px; height: 26px; }
.seg100 .bar div { border-radius: 4px; display: flex; align-items: center; padding-left: 6px; font-size: 11.5px; font-weight: 600; color: #fff; overflow: hidden; white-space: nowrap; min-width: 2px; }

/* ------------------------------------------------------------- tabs, chips, tags */
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { flex: 1; border: 0; background: none; padding: 12px 10px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; display: flex; justify-content: center; gap: 6px; align-items: center; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .on { color: var(--text); border-bottom-color: var(--accent); background: linear-gradient(to top, var(--accent-soft), transparent 75%); }
.tabs em { font-style: normal; font-size: 11.5px; background: var(--accent-strong); color: #fff; border-radius: 99px; padding: 0 7px; }
.filters { display: flex; align-items: center; flex-wrap: wrap; margin: -4px 0 12px; }
.filters .chips { padding: 4px 0; }
.chip-sep { width: 14px; flex: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; }
.card > .chips:first-child { padding: 0 0 12px; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card-2); color: var(--text-2); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 0 7px; font-size: 11.5px; font-weight: 600; line-height: 20px; background: var(--card-2); color: var(--text-2); white-space: nowrap; vertical-align: middle; }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.acc { background: var(--accent-soft); color: var(--accent-ink); }

/* avatars */
.av { width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 21px; position: relative; flex: none; background: var(--card-2); color: var(--text); font-weight: 700; line-height: 1; user-select: none; }
.av.init { background: var(--accent-soft); color: var(--accent-ink); }
.av .g { position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%; background: var(--card); border: 1.5px solid var(--line-2); font-size: 9.5px; font-weight: 700; display: grid; place-items: center; color: var(--text-2); }

/* ------------------------------------------------------------- buttons and forms */
.btn { border: 1px solid var(--line-2); background: var(--card-2); color: var(--text); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.acc { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.acc:hover { filter: brightness(1.08); }
.btn.red { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 9px; }
.btn.wide { width: 100%; margin-top: 18px; padding: 11px; }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 0; white-space: nowrap; }
input, select, textarea { color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="checkbox"]:not(.sw) { accent-color: var(--accent-strong); width: 16px; height: 16px; }
input[type="search"] { min-width: 220px; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.sw { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; padding: 0; border: 0; vertical-align: middle; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw:checked { background: var(--accent-strong); }
.sw:checked::after { transform: translateX(16px); }
.sw:disabled { opacity: .45; cursor: not-allowed; }
.setrow { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.setrow:last-child { border-bottom: 0; }
.setrow > div:first-child { flex: 1 1 220px; }

/* ------------------------------------------------------------- tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--card-2); }
.tbl input[type="number"] { width: 110px; }
.prefs { width: 100%; border-collapse: collapse; font-size: 14px; }
.prefs th { text-align: center; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.prefs th:first-child { text-align: left; }
.prefs td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
.prefs td:first-child { text-align: left; }
.prefs tr.grp td { font-size: 12.5px; font-weight: 700; color: var(--text-2); padding-top: 16px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.pager.center { justify-content: center; margin: 0; }
.pager.center:not(:empty) { padding: 12px; }
.feedback-text { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 520px; }
.kv2 { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13.5px; margin-top: 14px; }

/* ------------------------------------------------------------- notifications */
.npanel { position: fixed; z-index: 65; width: min(400px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow-y: auto; background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--pop); }
.npanel .nh { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.npanel .nh button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 0; }
.npanel .nf { display: block; text-align: center; padding: 11px; border-top: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.nitem { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); position: relative; }
.nitem:hover { background: var(--card-2); text-decoration: none; }
.nitem .ni { grid-row: 1 / span 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; }
.nitem b { font-weight: 600; font-size: 14px; line-height: 1.35; }
.nitem .ns { grid-column: 2 / span 2; font-size: 12.5px; color: var(--muted); }
.nitem .nt { font-size: 12px; color: var(--muted); white-space: nowrap; }
.nitem.unread { background: linear-gradient(90deg, var(--accent-soft), transparent 60%); }
.nitem.unread::before { content: ""; position: absolute; left: 5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.ngroup { font-size: 12.5px; color: var(--muted); padding: 12px 14px 6px; font-weight: 600; }
.nlist .empty-in { padding: 30px 18px; }
.phone-n { background: var(--card-2); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 2px 10px; max-width: 360px; }
.phone-n i { grid-row: 1 / span 3; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #b476ff, #7b3ff2); color: #fff; font-style: normal; font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.phone-n .pa { font-size: 12px; color: var(--muted); }
.phone-n b { font-size: 14px; font-weight: 600; }
.phone-n span:last-child { font-size: 13.5px; color: var(--text-2); }

/* ------------------------------------------------------------- palette, toast, modal */
.pal-back { position: fixed; inset: 0; background: rgba(5,5,8,.55); backdrop-filter: blur(3px); display: none; z-index: 70; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.pal-back.show { display: flex; }
.pal { width: min(620px, 92vw); background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--pop); overflow: hidden; }
.pal input { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 16px 18px; font-size: 16px; outline: none; }
.pal .res { max-height: 360px; overflow-y: auto; padding: 6px; }
.pal .res > div { display: flex; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.pal .res > div.on, .pal .res > div[data-i]:hover { background: var(--accent-soft); }
.pal .res .pic { width: 26px; height: 26px; border-radius: 8px; background: var(--card-2); display: grid; place-items: center; color: var(--text-2); flex: none; }
.pal .res .pl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal .res small { margin-left: auto; color: var(--muted); white-space: nowrap; }
.pal .res > .grp { font-size: 12px; color: var(--muted); padding: 8px 12px 2px; cursor: default; background: none; }
.pal .res > .none { cursor: default; padding: 14px 12px; }
.pal .foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 160%); background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 14px; display: flex; gap: 14px; align-items: center; font-size: 14px; font-weight: 500; transition: transform .25s; z-index: 90; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); }
.toast button { border: 0; background: none; color: #c9a8ff; font-weight: 700; padding: 0; }
:root[data-theme="light"] .toast button { color: #c9a8ff; }
.modal-back { position: fixed; inset: 0; background: rgba(5,5,8,.55); display: grid; place-items: center; padding: 16px; z-index: 75; }
.modal { background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; width: 100%; max-width: 440px; box-shadow: var(--pop); }
.modal ul { padding-left: 18px; }
.modal .row.end { margin-top: 16px; }
.form label, .auth label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.form input, .form select { width: 100%; }

/* ------------------------------------------------------------- states */
.error { padding: 10px 14px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); margin: 10px 0; font-size: 14px; }
.notice { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
a.notice:hover { text-decoration: none; filter: brightness(1.1); }
.empty { text-align: center; padding: 40px 20px; display: grid; justify-items: center; gap: 6px; max-width: 560px; margin: 24px auto; }
.empty p { max-width: 380px; margin: 0 0 10px; }
.empty-ic { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 4px; }
.empty-ic.bad { background: var(--bad-soft); color: var(--bad); }
.empty-in { text-align: center; padding: 24px 12px; }
.empty-in p { margin: 4px auto 0; max-width: 360px; }
.locked { display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); padding: 8px 0; }
.locked .ico { margin-top: 2px; color: var(--muted); }
.locked.bad .ico { color: var(--bad); }
.locked p { margin: 2px 0 0; }
.skel { display: grid; gap: 10px; margin-top: 14px; }
.skel span { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--card-2), var(--line), var(--card-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skel span:nth-child(2) { width: 80%; } .skel span:nth-child(3) { width: 55%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ------------------------------------------------------------- sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth input { width: 100%; }
.auth-logo { padding: 0 0 12px; }
.auth h2 { margin-top: 4px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 12px; margin: 10px 0; }
.qr svg { width: 200px; height: 200px; display: block; }

/* ------------------------------------------------------------- narrow screens */
@media (max-width: 1240px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live.five, .live.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; left: 0; top: 0; width: 256px; transform: translateX(-100%); transition: transform .2s; box-shadow: none; }
  .rail.open { transform: none; box-shadow: var(--pop); }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5,5,8,.5); }
  .menu-btn { display: grid; }
  .main { padding: 14px 16px 60px; }
  .search { min-width: 0; flex: 1; }
  .g-2, .g-3, .prefs-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .heat { gap: 2px; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .g-4, .kpis { grid-template-columns: minmax(0, 1fr); }
  .hello small { display: none; }
  .hello .face { display: none; }
  .search span, .search kbd { display: none; }
  .search { flex: 0; min-width: 40px; padding: 9px 11px; }
  .live, .live.five, .live.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { gap: 6px; }
  .heat .l:not(.d) { font-size: 0; }
  h1 { font-size: 20px; }
  input[type="search"] { min-width: 0; flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
.warn-card { border-color: var(--warn); }
.tbl td.nw { white-space: nowrap; }

/* ------------------------------------------------------------- v4: shared bits (insights.js) */
.seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); max-width: 100%; overflow-x: auto; scrollbar-width: none; flex: none; }
.seg button { border: 0; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
.tbl.dense th { font-size: 12px; padding: 7px 8px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.tbl.dense td { padding: 6px 8px; vertical-align: middle; }
.tbl.rows40 tbody tr { height: 40px; }
.tbl.rows40 td { padding-top: 4px; padding-bottom: 4px; }
.tbl th button { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-align: inherit; }
.tbl th button:hover { color: var(--text); }
.tbl th button.on { color: var(--accent-ink); }
.tbl.dense tr.click:focus-visible td { background: var(--card-2); }
.tbl td.muted { color: var(--muted); }
.bad-t { color: var(--bad); }
.warn-t { color: var(--warn); }
.pc { display: inline-flex; align-items: center; gap: 9px; min-width: 0; max-width: 240px; vertical-align: middle; }
.pc-t { display: grid; min-width: 0; line-height: 1.2; }
.pc-t b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-t small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.pc .av .g { width: 14px; height: 14px; font-size: 8px; right: -3px; bottom: -3px; }
.rc { display: inline-grid; justify-items: end; gap: 3px; min-width: 52px; }
.rb { display: block; width: 52px; height: 3px; border-radius: 99px; background: var(--grid); overflow: hidden; }
.rb > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.rb.wide { width: auto; height: 6px; align-self: center; }

/* Behaviour */
.bh-filters { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: -4px 0 12px; }
.bh-f { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.bh-l { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bh-note { font-size: 12px; color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.bh-search { position: relative; }
.bh-find { width: 120px; padding: 5px 10px; font-size: 13px; border-radius: 9px; }
input[type="search"].bh-find { min-width: 0; }
.bh-sugg { position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; min-width: 220px; background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--pop); padding: 4px; display: grid; }
.bh-sugg button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 7px; font-size: 13px; }
.bh-sugg button:hover { background: var(--accent-soft); }
.bh-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.bh-tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.bh-tabs a:hover { color: var(--text); text-decoration: none; }
.bh-tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.bh-hint { margin: -4px 0 10px; }
.bh-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.bh-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.ins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ins { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 12px; padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ins.warn { border-left-color: var(--warn); }
.ins.good { border-left-color: var(--good); }
.ins-k { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.ins.warn .ins-k { color: var(--warn); }
.ins.good .ins-k { color: var(--good); }
.ins-t { font-size: 14px; font-weight: 700; line-height: 1.35; }
.ins-d { font-size: 12.5px; color: var(--text-2); margin: 0; }
.ins-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 24px; }
.ins-a { font-size: 12.5px; color: var(--text); font-weight: 500; margin: 2px 0 0; }
.ins-a::before { content: "→ "; color: var(--muted); }
.ins-h .btn { flex: none; padding: 2px 5px 2px 9px; gap: 2px; font-size: 12px; border-radius: 8px; }

.pair { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.pair i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.bh-pairs td b { font-weight: 600; }
.mf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.mf-side { display: grid; gap: 6px; }
.mf-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mf-h b { font-size: 13px; font-weight: 600; }
.mf-bars { display: grid; grid-template-columns: 80px minmax(0, 1fr) 48px; gap: 4px 10px; align-items: center; font-size: 12.5px; color: var(--text-2); }
.mf-bars b { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.mf-take { grid-column: 1 / -1; margin: 0; font-size: 13px; font-weight: 600; color: var(--accent-ink); }

.wm-top { display: flex; gap: 28px; margin-bottom: 10px; }
.wm-top b, .big-n b { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wm-top span, .big-n span { font-size: 12.5px; color: var(--text-2); }
.two { display: flex; gap: 2px; height: 12px; }
.two i { border-radius: 4px; min-width: 3px; }
.two-l { margin: 6px 0 10px; }
.wm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.wm-grid b { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wm-grid span { font-size: 12px; color: var(--text-2); }
.big-n { margin-bottom: 8px; }

.top5 { list-style: none; margin: 0; padding: 0; counter-reset: top; }
.top5 li { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; cursor: pointer; counter-increment: top; }
.top5 li::before { content: counter(top); width: 14px; color: var(--muted); font-size: 12px; text-align: right; flex: none; }
.top5 li:hover, .top5 li:focus-visible { background: var(--card-2); }
.top5 .pc { flex: 1; max-width: none; }
.top5-v { text-align: right; line-height: 1.15; flex: none; }
.top5-v b { display: block; font-variant-numeric: tabular-nums; }
.top5-v small { font-size: 11px; color: var(--muted); }

.bh-ctry td.cn { white-space: nowrap; font-weight: 500; }
.bh-ctry .fl { margin-right: 7px; }
.bh-ctry tr.total td { background: var(--card-2); font-weight: 600; border-bottom: 2px solid var(--line-2); }
.bh-ctry th:first-child, .bh-ctry td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.bh-ctry tr.total td:first-child { background: var(--card-2); }
.bh-ctry tr.click:hover td:first-child { background: var(--card-2); }
.bh-ctry td.num { font-variant-numeric: tabular-nums; }
.good-t { color: var(--good); }
.gm-lead { margin: -2px 0 10px; font-size: 13.5px; color: var(--text-2); }
.gm-lead b { color: var(--text); font-weight: 600; }
.gm-lead b.good-t { color: var(--good); } .gm-lead b.bad-t { color: var(--bad); }
.gm th.gm-g { text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.gm th.gm-sep, .gm td.gm-sep { border-left: 1px solid var(--line); }
.gm thead tr:first-child th[rowspan] { vertical-align: bottom; }
.gm a.gm-a { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--line-2); }
.gm a.gm-a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.gm td.good-t a.gm-a { color: var(--good); } .gm td.bad-t a.gm-a { color: var(--bad); }
.gm td.gm-pct { position: relative; min-width: 76px; }
.gm td.gm-pct span { position: relative; z-index: 1; }
.gm td.gm-pct i { position: absolute; left: 6px; bottom: 5px; height: 3px; max-width: calc(100% - 12px); border-radius: 2px; background: var(--accent); opacity: .7; }
.pp-hint { display: block; margin: 6px 0 0; font-size: 12px; text-align: left; white-space: normal; line-height: 1.35; }

.boards { margin-bottom: 12px; }
.bh-lh { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px 8px; flex-wrap: wrap; }
.tbl td .big { font-size: 14px; font-weight: 700; }
.tbl .rk { width: 32px; }

.stat4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.stat4 b { display: block; font-size: 22px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat4 span { font-size: 12.5px; color: var(--text-2); }
.heat.hc { grid-template-columns: 116px repeat(24, minmax(0, 1fr)); }
.heat.hc .l.d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; justify-content: flex-start; font-size: 12px; color: var(--text-2); }
.heat.hc .c { aspect-ratio: auto; height: 22px; }
.heat.hc .c.pk { box-shadow: inset 0 0 0 2px var(--text); }
.fb { list-style: none; margin: 0; padding: 0; }
.fb li { display: grid; grid-template-columns: 86px minmax(0, 1fr) 150px 52px; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.fb li:last-child { border-bottom: 0; }
.fb .tag { justify-self: start; }
.fb-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-p { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; min-width: 0; color: var(--text-2); font-size: 12.5px; text-align: left; }
.fb-p span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.fb-p:hover span { color: var(--text); text-decoration: underline; }
.fb-w { text-align: right; font-size: 12px; }

/* People */
.pp { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.pp.collapsed { grid-template-columns: minmax(0, 1fr); }
.pp.collapsed .pp-rail { display: none; }
.pp-rail { padding: 12px 12px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
.pp-rh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.pp-rh .pp-done { display: none; }
.pp-g { padding: 8px 0; border-top: 1px solid var(--line); }
.pp-rh + .pp-g { border-top: 0; }
.pp-g h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.pp-opts { display: flex; flex-wrap: wrap; gap: 4px 3px; }
.pp-o { border: 1px solid var(--line); background: var(--card-2); color: var(--text-2); border-radius: 99px; padding: 2px 7px; font-size: 12px; font-weight: 500; }
.pp-o:hover { color: var(--text); border-color: var(--line-2); }
.pp-o.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.pp-clist { display: grid; gap: 1px; margin-bottom: 6px; }
.pp-c { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 2px 2px; border-radius: 6px; cursor: pointer; }
.pp-c:hover { background: var(--card-2); }
.pp-c input[type="checkbox"]:not(.sw) { width: 14px; height: 14px; margin: 0; flex: none; }
.pp-cn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-c small { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
input[type="search"].pp-cs { width: 100%; min-width: 0; padding: 5px 9px; font-size: 12.5px; border-radius: 8px; }
.pp-rail select { width: 100%; padding: 6px 9px; font-size: 13px; }
.pp-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pp-count { font-weight: 600; white-space: nowrap; }
.pp-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex: 1; min-width: 0; }
.fchip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.fchip button { border: 0; background: none; color: inherit; padding: 2px; border-radius: 50%; display: grid; place-items: center; }
.fchip button:hover { background: rgba(127, 127, 127, .2); }
.pp-find { display: flex; align-items: center; gap: 6px; color: var(--muted); margin-left: auto; }
.pp-find input[type="search"] { min-width: 0; width: 210px; padding: 6px 10px; font-size: 13px; }
.pp-fbtn { display: none; }
.pp.collapsed .pp-fbtn { display: inline-flex; }
.pp-table .pager { padding: 0 12px 12px; }
.pp-table.busy { opacity: .6; transition: opacity .15s; }
.pp-t td.pcell { max-width: 250px; min-width: 150px; }
.pp-t th:first-child, .pp-t td:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; }
.pp-t tr.click:hover td:first-child { background: var(--card-2); }
.rc > span { white-space: nowrap; }
.on-dot { color: var(--good); font-weight: 600; }
.on-dot::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--good); margin-right: 5px; vertical-align: 1px; }
.pp-scrim { display: none; }

/* Audit */
.ad { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--text-2); }
.ad i { font-style: normal; color: var(--muted); }
.audit-note { margin-left: auto; }

@media (max-width: 1240px) {
  .bh-21, .bh-12 { grid-template-columns: minmax(0, 1fr); }
  .fb li { grid-template-columns: 80px minmax(0, 1fr) 120px 44px; }
}
@media (max-width: 900px) {
  .pp, .pp.collapsed { grid-template-columns: minmax(0, 1fr); }
  .pp .pp-rail, .pp.collapsed .pp-rail { display: none; }
  .pp .pp-rail.open { display: block; position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 82vh; z-index: 61; border-radius: 16px 16px 0 0; box-shadow: var(--pop); }
  .pp-rail.open .pp-hide { display: none; }
  .pp-rail.open .pp-done { display: inline; }
  .pp-scrim.show { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(5,5,8,.5); }
  .pp-fbtn, .pp.collapsed .pp-fbtn { display: inline-flex; }
  .pp-find { margin-left: 0; flex: 1 1 100%; order: 5; }
  .pp-find input[type="search"] { flex: 1; width: auto; }
  .mf { grid-template-columns: minmax(0, 1fr); }
  .bh-filters { gap: 8px 14px; }
}
@media (max-width: 560px) {
  .top > a.icon-btn { display: none; }
  .ins-grid { grid-template-columns: minmax(0, 1fr); }
  .fb li { grid-template-columns: minmax(0, 1fr) auto; }
  .fb li .tag { grid-column: 1 / -1; }
  .wm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bh-f { flex-wrap: wrap; }
  .audit-note { margin-left: 0; }
}
