/* ============================================================
   MENTALICS — Shared component library
   Load AFTER wt-tokens.css on every page.
   ============================================================ */

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .04s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost     { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger    { background: var(--neg); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-navy      { background: var(--navy-2); color: var(--on-navy); }
.btn-navy:hover { background: var(--navy-3); }
.btn-sm { font-size: 12px; padding: 7px 12px; border-radius: var(--r-sm); }
.btn-lg { font-size: 15px; padding: 13px 22px; }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ─── Inputs ─── */
.input, .select, .textarea {
  font-family: var(--font-sans); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 10px 12px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%235f6878' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 11px; color: var(--text-muted); }

/* Toggle */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 38px; height: 22px; background: var(--border-2); border-radius: 999px; transition: background .15s; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track + .knob { transform: translateX(16px); }

/* Checkbox */
.cbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.cbox input, .ms-opt input { appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--border-2); border-radius: 4px; background: var(--surface); cursor: pointer; position: relative; transition: border-color .15s, background .15s; flex-shrink: 0; }
.cbox input:checked, .ms-opt input:checked { background: var(--accent); border-color: var(--accent); }
.cbox input:checked::after, .ms-opt input:checked::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 9px; border: 2px solid #fff; border-top: 0; border-left: 0; transform: rotate(45deg); }

/* ─── Pills / chips / badges ─── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; line-height: 1.55; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-muted { background: var(--neu-bg); color: var(--neu-ink); }
.pill-accent { background: var(--accent-tint); color: var(--accent-ink); }

/* platform pills */
.pl { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.pl-twitter   { background: var(--p-twitter-bg);   color: var(--p-twitter-ink); }
.pl-instagram { background: var(--p-instagram-bg); color: var(--p-instagram-ink); }
.pl-tiktok    { background: var(--p-tiktok-bg);    color: var(--p-tiktok-ink); }
.pl-youtube   { background: var(--p-youtube-bg);   color: var(--p-youtube-ink); }
.pl-linkedin  { background: var(--p-linkedin-bg);  color: var(--p-linkedin-ink); }
.pl-facebook  { background: var(--p-facebook-bg);  color: var(--p-facebook-ink); }

/* keyword pill */
.kw { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 500; background: var(--accent-tint); color: var(--accent-ink); }

/* verdict badge */
.verdict {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
}
.verdict-clean { background: var(--pos-bg); color: var(--pos-ink); }
.verdict-risk  { background: var(--neg-bg); color: var(--neg-ink); }
.verdict-analyzing { background: var(--accent-tint); color: var(--accent-ink); }
.verdict-analyzing .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: wt-pulse 1.5s ease-out infinite; }
@keyframes wt-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 55%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* sentiment badge: label + signed score + theme */
.sent {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.sent .score { font-family: var(--font-mono); font-weight: 700; }
.sent .theme { font-weight: 500; opacity: .75; }
.sent-pos { background: var(--pos-bg); color: var(--pos-ink); }
.sent-neg { background: var(--neg-bg); color: var(--neg-ink); }
.sent-neu { background: var(--neu-bg); color: var(--neu-ink); }
.sent-off { background: var(--sent-off-bg); color: var(--sent-off-ink); }

/* status badge (mono, admin) */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 7px; border-radius: var(--r-sm); font-weight: 600;
}
.badge-ok    { background: var(--pos-bg); color: var(--pos-ink); }
.badge-warn  { background: var(--warn-bg); color: var(--warn-ink); }
.badge-err   { background: var(--neg-bg); color: var(--neg-ink); }
.badge-info  { background: var(--accent-tint); color: var(--accent-ink); }
.badge-muted { background: var(--neu-bg); color: var(--neu-ink); }

/* channel scope badge */
.scope { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.scope-guardian { background: var(--accent-tint); color: var(--accent-ink); }
.scope-influencer { background: #ede9fe; color: #5b21b6; }
.scope-both { background: var(--pos-bg); color: var(--pos-ink); }

/* ─── Cards ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--s-6); }

/* KPI */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px 20px; box-shadow: var(--shadow-card); }
.kpi .val { font-size: 32px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; line-height: 1.05; }
.kpi .key { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.kpi .delta { font-family: var(--font-mono); font-size: 11px; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--pos); }
.kpi .delta.down { color: var(--neg); }

/* ─── Tables ─── */
.t-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.t-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.t-table td { padding: 12px 14px; border-bottom: 1px solid var(--divider); font-size: 13px; color: var(--text); vertical-align: middle; }
.t-table tr:last-child td { border-bottom: 0; }
.t-table tbody tr:hover td { background: color-mix(in oklab, var(--accent) 3%, var(--surface)); }
.t-table .mono { font-family: var(--font-mono); font-size: 12px; }

/* ─── Filter bar ─── */
.filterbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filterbar .select { width: auto; min-width: 150px; }

/* ─── Slide-over modal ─── */
.sheet-scrim { position: fixed; inset: 0; background: rgba(11,18,32,.45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 90; }
.sheet-scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 92vw); background: var(--surface); box-shadow: var(--shadow-pop); transform: translateX(100%); transition: transform .26s cubic-bezier(.4,0,.2,1); z-index: 91; display: flex; flex-direction: column; }
.sheet.open { transform: translateX(0); }
.sheet header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.sheet header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.sheet .body { padding: 22px; overflow-y: auto; flex: 1; }
.sheet .x { width: 32px; height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); cursor: pointer; display: grid; place-items: center; color: var(--text-muted); }
.sheet .x:hover { background: var(--surface-2); color: var(--ink); }

/* ─── Tabs (app) ─── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { appearance: none; background: transparent; border: 0; padding: 16px 18px; cursor: pointer; font-family: var(--font-sans); font-size: 14.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; transition: color .15s, border-color .15s, background .15s; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button .lock { width: 13px; height: 13px; opacity: .5; }
.tabs button.locked { color: var(--text-subtle); }
.tabs button.locked:hover { color: var(--text-muted); }

/* ─── Navbar (top app/marketing bar) ───
   Three sizes via one component. Add .navbar-sticky to pin it.
   On marketing surfaces use .navbar-navy for the dark variant. */
.navbar { display: flex; align-items: center; gap: 20px; height: 64px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.navbar-sticky { position: sticky; top: 0; z-index: var(--z-topbar); backdrop-filter: saturate(1.4) blur(8px); background: color-mix(in oklab, var(--surface) 86%, transparent); }
.navbar .nb-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 16px; color: var(--ink); letter-spacing: -0.02em; flex-shrink: 0; text-decoration: none; }
.navbar .nb-brand svg { width: 26px; height: 26px; }
.navbar .nb-links { display: flex; align-items: center; gap: 2px; }
.navbar .nb-links a { position: relative; padding: 8px 13px; border-radius: var(--r-md); font-size: 14px; font-weight: 600; color: var(--text-muted); text-decoration: none; white-space: nowrap; transition: color .15s, background .15s; }
.navbar .nb-links a:hover { color: var(--ink); background: var(--surface-2); }
.navbar .nb-links a.on { color: var(--accent); }
.navbar .nb-links a.on::after { content: ""; position: absolute; left: 13px; right: 13px; bottom: -2px; height: 2px; border-radius: 2px; background: var(--accent); }
.navbar .nb-spacer { flex: 1; }
.navbar .nb-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.navbar .nb-icon { width: 38px; height: 38px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--text-muted); cursor: pointer; position: relative; transition: background .15s, color .15s, border-color .15s; }
.navbar .nb-icon:hover { background: var(--surface-2); color: var(--ink); border-color: var(--border-2); }
.navbar .nb-icon svg { width: 18px; height: 18px; }
.navbar .nb-icon .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--neg); border: 1.5px solid var(--surface); }
.navbar .nb-burger { display: none; }
/* dark / marketing variant */
.navbar-navy { background: var(--navy); border-bottom-color: color-mix(in oklab, var(--on-navy) 12%, transparent); }
.navbar-navy .nb-brand { color: var(--on-navy); }
.navbar-navy .nb-links a { color: var(--on-navy-muted); }
.navbar-navy .nb-links a:hover { color: var(--on-navy); background: color-mix(in oklab, var(--on-navy) 8%, transparent); }
.navbar-navy .nb-links a.on { color: var(--on-navy); }
.navbar-navy .nb-links a.on::after { background: linear-gradient(90deg,#7fa0ff,#7fe0ff); }
.navbar-navy .nb-icon { background: transparent; border-color: color-mix(in oklab, var(--on-navy) 18%, transparent); color: var(--on-navy-muted); }
.navbar-navy .nb-icon:hover { color: var(--on-navy); background: color-mix(in oklab, var(--on-navy) 8%, transparent); }
.navbar-navy.navbar-sticky { background: color-mix(in oklab, var(--navy) 84%, transparent); }
/* tablet: condense — hide labels, tighten spacing */
.navbar-tablet { height: 60px; padding: 0 18px; gap: 12px; }
.navbar-tablet .nb-links a { padding: 8px 10px; font-size: 13.5px; }
.navbar-tablet .nb-actions .label-hide { display: none; }
/* mobile: brand + burger + one action; links collapse */
.navbar-mobile { height: 56px; padding: 0 16px; gap: 12px; }
.navbar-mobile .nb-links { display: none; }
.navbar-mobile .nb-burger { display: grid; }

/* ─── Misc ─── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); border: 1px dashed var(--border-2); border-radius: var(--r-lg); background: var(--surface); }
.divider { height: 1px; background: var(--divider); }
.mono { font-family: var(--font-mono); }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.avatar { border-radius: 50%; background: var(--navy-2); color: var(--on-navy); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; width: 36px; height: 36px; font-size: 13px; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-group { display: inline-flex; }
.avatar-group .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-group .avatar:first-child { margin-left: 0; }
[hidden] { display: none !important; }

/* ════════════════════════════════════════════════════════════
   EXTENDED LIBRARY  ·  forms · overlays · feedback · data-viz · patterns
   Everything Mentalics surfaces are built from. Reuse these
   classes — do not re-roll a one-off. Load after the base above.
   ════════════════════════════════════════════════════════════ */

/* ─── Form sizing & layout ─── */
.input-sm, .select-sm { font-size: 13px; padding: 7px 10px; }
.input-lg, .select-lg { font-size: 15px; padding: 12px 14px; }
.field-row { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px dashed var(--border); }
.field-row:last-child { border-bottom: 0; }
.field-row .ttl { font-weight: 600; color: var(--ink); font-size: 13px; }
.field-row .ttl .sub { display: block; font-weight: 400; font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* input group with leading icon / addon */
.input-group { display: flex; align-items: stretch; }
.input-group .input, .input-group .select { border-radius: 0; }
.input-group > :first-child { border-top-left-radius: var(--r-md); border-bottom-left-radius: var(--r-md); }
.input-group > :last-child  { border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); }
.input-group > * + * { margin-left: -1px; }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.input-group .input:focus { z-index: 2; }

/* search input */
.search { position: relative; display: inline-flex; align-items: center; width: 100%; }
.search svg { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--text-subtle); pointer-events: none; }
.search .input { padding-left: 34px; }

/* validation states */
.input.is-error, .select.is-error, .textarea.is-error { border-color: var(--neg); }
.input.is-error:focus { box-shadow: 0 0 0 3px color-mix(in oklab, var(--neg) 25%, transparent); }
.input.is-valid { border-color: var(--pos); }
.field .err { font-size: 11px; color: var(--neg-ink); }
.field .ok  { font-size: 11px; color: var(--pos-ink); }

/* radio */
.radio { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.radio input { appearance: none; width: 17px; height: 17px; border: 1.5px solid var(--border-2); border-radius: 50%; background: var(--surface); cursor: pointer; position: relative; transition: border-color .15s; }
.radio input:checked { border-color: var(--accent); }
.radio input:checked::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }

/* segmented control / subtabs */
.segmented { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); }
.segmented button { border: 0; background: transparent; padding: 7px 14px; border-radius: var(--r-sm); font-family: var(--font-sans); font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: color .15s, background .15s; }
.segmented button:hover { color: var(--ink); }
.segmented button.on, .segmented button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }
.subtabs { /* alias kept for product parity */ display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); }
.subtabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.subtabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

/* range slider */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 999px; background: var(--surface-3); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 1px 3px rgba(11,18,32,.3); border: 2px solid var(--surface); }
.range::-moz-range-thumb { width: 17px; height: 17px; border: 2px solid var(--surface); border-radius: 50%; background: var(--accent); cursor: pointer; }

/* removable tag / keyword pill */
.kw-tag { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: var(--r-pill); background: var(--accent-tint); color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.kw-tag button { border: 0; background: none; cursor: pointer; color: inherit; opacity: .6; font-size: 14px; line-height: 1; padding: 0; }
.kw-tag button:hover { opacity: 1; }

/* ─── Dropdown menu (popover) ─── */
.menu { min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px; }
.menu .item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--text); cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-family: var(--font-sans); }
.menu .item:hover { background: var(--surface-2); color: var(--ink); }
.menu .item svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu .item.danger { color: var(--neg-ink); }
.menu .item.danger:hover { background: var(--neg-bg); }
.menu .item .right { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); }
.menu .sep { height: 1px; background: var(--divider); margin: 6px 4px; }
.menu .label { padding: 6px 10px 4px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-subtle); }

/* ─── Accordion ─── */
.accordion { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.accordion details { border-bottom: 1px solid var(--divider); }
.accordion details:last-child { border-bottom: 0; }
.accordion summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 15px 18px; font-weight: 600; font-size: 14px; color: var(--ink); }
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary .chev { margin-left: auto; width: 16px; height: 16px; color: var(--text-muted); transition: transform .2s var(--ease-out); }
.accordion details[open] summary .chev { transform: rotate(180deg); }
.accordion .ac-body { padding: 0 18px 16px; font-size: 13.5px; color: var(--text-muted); line-height: 1.6; }

/* ─── Tooltip ─── */
.tip { position: relative; display: inline-flex; }
.tip[data-tip]::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); background: var(--navy); color: var(--on-navy); font-size: 12px; font-weight: 500; padding: 6px 10px; border-radius: var(--r-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: var(--z-tooltip); box-shadow: var(--shadow-raised); }
.tip[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Alert / banner ─── */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid; font-size: 13.5px; line-height: 1.5; }
.alert .ico { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert .ttl { font-weight: 700; }
.alert .body { color: var(--text); }
.alert-info  { background: var(--accent-tint); border-color: var(--accent-tint-2); color: var(--accent-ink); }
.alert-ok    { background: var(--pos-bg); border-color: color-mix(in oklab, var(--pos) 30%, transparent); color: var(--pos-ink); }
.alert-warn  { background: var(--warn-bg); border-color: color-mix(in oklab, var(--warn) 30%, transparent); color: var(--warn-ink); }
.alert-err   { background: var(--neg-bg); border-color: color-mix(in oklab, var(--neg) 30%, transparent); color: var(--neg-ink); }

/* ─── Toast ─── */
.toast { display: flex; align-items: center; gap: 10px; background: var(--navy); color: var(--on-navy); padding: 12px 16px; border-radius: var(--r-lg); box-shadow: var(--shadow-pop); font-size: 13.5px; max-width: 380px; }
.toast .ico { width: 18px; height: 18px; flex-shrink: 0; }
.toast .ico.ok { color: #7ee2a8; } .toast .ico.err { color: #ff9d96; }
.toast .x { margin-left: auto; cursor: pointer; opacity: .6; background: none; border: 0; color: inherit; }
.toast .x:hover { opacity: 1; }
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: var(--z-toast); }

/* ─── Modal dialog (centered) ─── */
.modal-scrim { position: fixed; inset: 0; background: rgba(11,18,32,.5); display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: var(--z-modal); padding: 24px; }
.modal-scrim.open { opacity: 1; pointer-events: auto; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-pop); transform: scale(.97); transition: transform .2s var(--ease-out); overflow: hidden; }
.modal-scrim.open .modal { transform: scale(1); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.modal .body { padding: 22px; font-size: 14px; color: var(--text); line-height: 1.55; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ─── Breadcrumb ─── */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text-subtle); }
.breadcrumb .cur { color: var(--ink); font-weight: 600; }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pagination .pg { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--border-2); background: var(--surface); border-radius: var(--r-md); cursor: pointer; font-size: 13px; color: var(--text); display: inline-grid; place-items: center; }
.pagination .pg.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .pg:hover:not(.active) { background: var(--surface-2); }

/* ─── Stepper / wizard ─── */
.wizard { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.wstep { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px; }
.wstep .n { font-family: var(--font-mono); font-size: 11px; color: var(--accent); font-weight: 600; }
.wstep h6 { margin: 6px 0; font-size: 13px; color: var(--ink); }
.wstep p { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.stepbar { display: flex; align-items: center; gap: 0; }
.stepbar .st { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.stepbar .st .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--text-muted); }
.stepbar .st.done .num { background: var(--pos); color: #fff; }
.stepbar .st.on .num { background: var(--accent); color: #fff; }
.stepbar .st.on { color: var(--ink); font-weight: 600; }
.stepbar .bar { flex: 1; height: 2px; background: var(--border-2); margin: 0 12px; min-width: 24px; }

/* ─── Progress · meter · quota ─── */
.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s var(--ease-out); }
.progress.pos .fill { background: var(--pos); } .progress.warn .fill { background: var(--warn); } .progress.neg .fill { background: var(--neg); }
.quota { display: flex; align-items: center; gap: 14px; }
.quota .bar { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; max-width: 220px; }
.quota .bar .fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* ─── Skeleton & spinner ─── */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; border-radius: var(--r-sm); animation: wt-shimmer 1.4s infinite; }
@keyframes wt-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: wt-spin .7s linear infinite; }
@keyframes wt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner, .verdict-analyzing .dot { animation: none; } }

/* ════ DATA VISUALISATION ════ */
/* Shared chart frame + legend + axis. SVG plots set stroke to a --c-* token. */
.chart { width: 100%; display: block; }
.chart-line { height: 220px; }
.chart-line .grid line { stroke: var(--chart-grid); stroke-dasharray: 2 4; }
.chart-line .axis  { stroke: var(--chart-axis); stroke-width: 1.5; }
.chart-line .series { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-bar rect { rx: 3; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.legend .it { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.axis-label { font-family: var(--font-mono); font-size: 10px; fill: var(--chart-label); }

/* donut */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-svg { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.donut-svg svg { width: 100%; height: 100%; display: block; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center .dc-num { display: block; font-weight: 800; font-size: 22px; color: var(--ink); letter-spacing: -0.025em; line-height: 1; }
.donut-center .dc-lbl { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.donut-legend .row { display: grid; grid-template-columns: 12px 1fr auto; gap: 9px; align-items: center; font-size: 13px; color: var(--text); }
.donut-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .pct { font-family: var(--font-mono); font-weight: 700; color: var(--ink); }

/* horizontal bars (share-of-voice) */
.sov { display: flex; flex-direction: column; gap: 14px; }
.sov .row { display: grid; grid-template-columns: 92px 1fr 48px; gap: 12px; align-items: center; font-size: 13px; }
.sov .lbl { color: var(--ink); font-weight: 500; }
.sov .track { height: 9px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.sov .fill { height: 100%; border-radius: 999px; background: var(--accent); }
.sov .num { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-align: right; }

/* ════ DASHBOARD PATTERNS ════ */
/* Panel — the standard dashboard surface */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-card); }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.panel .sub { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }

/* metric grid (inside a sheet / panel) */
.metric-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.metric-grid > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 12px; text-align: center; box-shadow: var(--shadow-card); }
.metric-grid .m-num { display: block; font-family: var(--font-sans); font-weight: 800; font-size: 24px; color: var(--ink); letter-spacing: -0.025em; line-height: 1.05; }
.metric-grid .m-key { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 5px; text-transform: uppercase; letter-spacing: .07em; }

/* feed post card */
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; cursor: pointer; transition: border-color .15s, box-shadow .15s; box-shadow: var(--shadow-card); }
.post-card:hover { border-color: var(--accent); box-shadow: var(--shadow-raised); }
.pc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pc-au { font-weight: 700; color: var(--ink); font-size: 14px; }
.pc-time { color: var(--text-subtle); font-size: 12px; margin-left: auto; }
.pc-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pc-text { margin: 0; font-size: 14px; color: var(--text); line-height: 1.55; }
.pc-metrics { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }

/* alarm card — left status rail */
.alarm-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--neg); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-card); }
.ac-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ac-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }

/* chat bubbles */
.chat-log { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: var(--r-lg); font-size: 13.5px; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot  { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-subtle); animation: wt-blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes wt-blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }

/* AI-reasoning callout (slide-over) */
.sd-reason { background: var(--accent-tint); border: 1px solid var(--accent-tint-2); border-radius: var(--r-md); padding: 16px; }
.sd-reason.analyzing { background: var(--surface-2); border-color: var(--border); }
.sd-reason h5 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-ink); }
.sd-reason.analyzing h5 { color: var(--text-muted); }
.sd-reason p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text); }

/* gate / locked plan state */
.gate { text-align: center; padding: 56px 24px; }
.gate .lock { width: 48px; height: 48px; color: var(--text-subtle); margin: 0 auto 16px; }
.gate h3 { margin: 0 0 8px; font-size: 20px; color: var(--ink); }
.gate p { margin: 0 0 20px; color: var(--text-muted); max-width: 44ch; margin-inline: auto; }

/* ─── Multi-select (checkbox dropdown with chips) ─── */
.multiselect { position: relative; width: 100%; }
.ms-control { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 42px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md); cursor: pointer; font-family: var(--font-sans); text-align: left; transition: border-color .15s, box-shadow .15s; }
.multiselect.open .ms-control, .ms-control:focus-visible { outline: 0; border-color: var(--accent); box-shadow: var(--shadow-focus); }
.ms-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; align-items: center; }
.ms-ph { color: var(--text-subtle); font-size: 14px; }
.ms-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-tint); color: var(--accent-ink); border-radius: var(--r-pill); padding: 3px 8px; font-size: 12px; font-weight: 600; }
.ms-chip button { border: 0; background: none; color: inherit; cursor: pointer; opacity: .6; font-size: 13px; line-height: 1; padding: 0; }
.ms-chip button:hover { opacity: 1; }
.ms-chev { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; transition: transform .2s var(--ease-out); }
.multiselect.open .ms-chev { transform: rotate(180deg); }
.ms-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: 6px; z-index: var(--z-dropdown); display: none; max-height: 248px; overflow: auto; }
.multiselect.open .ms-menu { display: block; }
.ms-opt { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 13px; color: var(--text); cursor: pointer; }
.ms-opt:hover { background: var(--surface-2); }

/* ─── AI chat (Ask Mentalics AI) ─── */
.ai-chat { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 18px; box-shadow: var(--shadow-card); }
.ai-chat > header { display: flex; align-items: center; gap: 10px; }
.ai-chat .ai-ico { width: 32px; height: 32px; border-radius: var(--r-md); background: var(--grad); display: grid; place-items: center; flex-shrink: 0; }
.ai-chat .ai-ico svg { width: 18px; height: 18px; }
.ai-chat .ai-name { font-weight: 700; color: var(--ink); font-size: 14px; line-height: 1.2; }
.ai-chat .ai-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); letter-spacing: .04em; }
.ai-thread { display: flex; flex-direction: column; gap: 12px; max-height: 320px; overflow-y: auto; padding: 2px; }
.ai-sources { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ai-source { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border-2); color: var(--text-muted); }
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.suggest-chip { font-size: 12px; padding: 6px 11px; border-radius: var(--r-pill); border: 1px solid var(--border-2); background: var(--surface); color: var(--text); cursor: pointer; font-family: var(--font-sans); transition: border-color .15s, color .15s, background .15s; }
.suggest-chip:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-tint); }
.ai-composer { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border-2); border-radius: var(--r-lg); padding: 10px 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.ai-composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.ai-composer textarea { border: 0; outline: 0; resize: none; font-family: var(--font-sans); font-size: 14px; line-height: 1.5; background: none; color: var(--ink); width: 100%; min-height: 24px; }
.ai-composer textarea::placeholder { color: var(--text-subtle); }
.ai-composer .row { display: flex; align-items: center; gap: 8px; }
.ai-tool { width: 32px; height: 32px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--text-muted); cursor: pointer; }
.ai-tool:hover { background: var(--surface-2); color: var(--ink); }
.ai-tool svg { width: 16px; height: 16px; }
.ai-composer .send { margin-left: auto; }

/* ─── Form section (long forms) ─── */
.form-section { padding: 22px 0; border-bottom: 1px solid var(--border); }
.form-section:first-child { padding-top: 0; }
.form-section:last-child { border-bottom: 0; padding-bottom: 0; }
.form-section .fs-head { margin-bottom: 16px; }
.form-section .fs-head h4 { margin: 0 0 3px; font-size: 15px; font-weight: 700; color: var(--ink); }
.form-section .fs-head p { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.save-bar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-raised); margin-top: 18px; }
.save-bar .status { font-size: 13px; color: var(--text-muted); }

/* ─── Mobile: bottom tab bar ─── */
.bottom-nav { display: flex; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; font-size: 10px; font-weight: 600; color: var(--text-muted); text-decoration: none; border-radius: var(--r-sm); }
.bottom-nav a svg { width: 20px; height: 20px; }
.bottom-nav a.on { color: var(--accent); }
