/* ============================================================================
   Meetily Enterprise — Admin Console mockup
   Calm, dense, neutral-by-default surface where one disciplined indigo
   (#3e63dd) carries every primary action; all other selection/hover is a
   translucent grey wash — never indigo. Palette: Radix Colors + Inter.
   Component metrics follow the design system exactly (28px nav, 32px rows,
   32px controls, 20px status pills, 4px controls / 8px framed surfaces).
   ============================================================================ */

:root {
  /* --- Accent (Radix indigo) — light --- */
  --color-accent-3: #edf2fe;
  --color-accent-7: #abbdf9;
  --color-accent-8: #8da4ef;
  --color-accent-9: #3e63dd;   /* PRIMARY ACCENT */
  --color-accent-10: #3358d4;  /* CTA hover */
  --color-accent-11: #3a5bc7;  /* accent text */
  --color-accent-12: #1f2d5c;
  --color-accent-tint: #f7f9ff;

  /* --- Gray ramp (custom neutral) — light --- */
  --color-gray-1: #ffffff;
  --color-gray-2: #fcfcfc;
  --color-gray-3: #f9f9f9;
  --color-gray-4: #f1f1f1;
  --color-gray-5: #ebebeb;
  --color-gray-6: #d6d6d6;
  --color-gray-7: #cccccc;
  --color-gray-8: #b3b3b3;
  --color-gray-9: #999999;
  --color-gray-11: #666666;
  --color-gray-12: #333333;

  /* --- Semantic — light --- */
  --color-danger: #e5484d;  --color-danger-bg: #feebec; --color-danger-fg: #ce2c31;
  --color-success: #30a46c; --color-success-bg: #e6f6eb; --color-success-fg: #218358;
  --color-warning: #f76b15; --color-warning-bg: #ffefd6; --color-warning-fg: #cc4e00;

  /* --- Shadows --- */
  --shadow-light: 0 2px 4px 0 rgb(0 0 0 / .039), 0 0 4px 0 rgb(0 0 0 / .078);
  --shadow-strong: 2px 4px 16px 0 rgb(0 0 0 / .161), 0 2px 4px 0 rgb(0 0 0 / .078);

  /* --- Surfaces --- */
  --surface-hover: rgb(0 0 0 / .039);

  /* --- Radius --- */
  --radius-card: 8px;     /* framed surfaces: cards, panels, modals, menus */
  --radius-control: 4px;  /* buttons, inputs, nav items, tags */
  --radius-pill: 999px;   /* status pills only */

  /* --- Metrics --- */
  --row-height: 34px;
  --nav-item-height: 34px;
  --control-height: 36px;

  /* --- Semantic aliases mapped onto the token ramp --- */
  --bg: var(--color-gray-2);
  --panel: var(--color-gray-1);
  --panel-2: var(--color-gray-4);
  --line: var(--color-gray-5);
  --line-strong: var(--color-gray-6);
  --text: var(--color-gray-12);
  --muted: var(--color-gray-11);
  --faint: var(--color-gray-9);
  --accent: var(--color-accent-9);
  --accent-soft: var(--color-accent-3);
  --accent-tint: var(--color-accent-tint);
  --green: var(--color-success-fg); --green-soft: var(--color-success-bg);
  --red: var(--color-danger-fg);    --red-soft: var(--color-danger-bg);
  --amber: var(--color-warning-fg);  --amber-soft: var(--color-warning-bg);
}

/* --- Dark theme: re-bind the same token names --- */
html.dark {
  --color-accent-3: #182449;
  --color-accent-7: #3a4f97;
  --color-accent-8: #435db1;
  --color-accent-9: #3e63dd;
  --color-accent-10: #5472e4;
  --color-accent-11: #9eb1ff;
  --color-accent-12: #d6e1ff;
  --color-accent-tint: #141726;

  --color-gray-1: #1a1a1a;
  --color-gray-2: #242424;
  --color-gray-3: #222222;
  --color-gray-4: #282828;
  --color-gray-5: #2e2e2e;
  --color-gray-6: #525252;
  --color-gray-7: #565656;
  --color-gray-8: #666666;
  --color-gray-9: #818181;
  --color-gray-11: #b3b3b3;
  --color-gray-12: #ebebeb;

  --color-danger-bg: #3b1219; --color-danger-fg: #ff9592;
  --color-success-bg: #132d21; --color-success-fg: #3dd68c;
  --color-warning-bg: #331e0b; --color-warning-fg: #ffa057;

  --shadow-light: 0 2px 4px 0 rgb(0 0 0 / .04), 0 0 4px 0 rgb(0 0 0 / .08);
  --shadow-strong: 2px 4px 16px 0 rgb(0 0 0 / .16), 0 2px 4px 0 rgb(0 0 0 / .08);
  --surface-hover: rgb(255 255 255 / .102);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font: 400 15px/1.55 "Inter", ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); display: flex; height: 100dvh; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- sidebar ---------- */
aside { width: 236px; height: 100dvh; overflow-y: auto; background: var(--panel-2); border-right: 1px solid var(--line); padding: 14px 12px; flex-shrink: 0; display: flex; flex-direction: column; }

/* Meetily product brand lockup */
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; }
.brand-mark { width: 26px; height: 26px; flex-shrink: 0; display: block; }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name { font-size: 14px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.brand-name small { display: block; font-size: 10px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; margin-top: 1px; }

.ws { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-control); cursor: pointer; position: relative; }
.ws:hover { background: var(--surface-hover); }
.ws-logo { width: 22px; height: 22px; border-radius: var(--radius-control); background: var(--color-gray-12); color: var(--color-gray-1); font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ws b { font-size: 13px; font-weight: 600; display: block; line-height: 1.2; }
.ws small { color: var(--muted); font-size: 11px; }
.ws .chev { margin-left: auto; color: var(--faint); }
.nav-search { margin: 10px 0 6px; }
.nav-search input { width: 100%; height: var(--control-height); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 0 10px; font: inherit; color: var(--text); }
.nav-search input::placeholder { color: var(--color-gray-8); }
.nav-label { font-size: 11px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 14px 8px 4px; }
aside nav a { display: flex; align-items: center; gap: 10px; height: var(--nav-item-height); padding: 0 10px; border-radius: var(--radius-control); color: var(--muted); text-decoration: none; margin-bottom: 2px; cursor: pointer; font-weight: 500; }
aside nav a svg { color: var(--faint); flex-shrink: 0; }
/* active nav = translucent grey wash + primary text, never indigo, never a raised card */
aside nav a.active { background: var(--surface-hover); color: var(--text); }
aside nav a.active svg { color: var(--text); }
aside nav a:hover:not(.active) { background: var(--surface-hover); }
.soon { font-size: 10px; background: var(--color-gray-5); color: var(--muted); border-radius: var(--radius-control); padding: 1px 5px; margin-left: auto; font-weight: 500; }
.me { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--line); cursor: pointer; border-radius: var(--radius-control); }
.me:hover { background: var(--surface-hover); }
.me small { color: var(--muted); }

.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: #fff; background: var(--accent); flex-shrink: 0; }

/* ---------- main ---------- */
/* main is the only vertical scroll container; the shell itself never scrolls */
main { flex: 1; min-width: 0; height: 100dvh; overflow-y: auto; padding: 0 40px 40px; }
main > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
/* fixed top nav: header sticks to the top of the scroll area */
header.page { position: sticky; top: 0; z-index: 20; background: var(--bg); display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; padding: 28px 0 18px; border-bottom: 1px solid var(--line); }
header.page h2 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
header.page .page-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
header.page .page-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
header.page .page-sub { color: var(--faint); font-size: 12px; white-space: nowrap; }

/* hamburger — hidden on desktop, shown in the mobile breakpoint */
.icon-btn.nav-toggle { display: none; }
.nav-backdrop { display: none; }

/* header icon button (theme toggle) */
.icon-btn { width: var(--control-height); height: var(--control-height); display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: var(--radius-control); cursor: pointer; padding: 0; flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.org-menu { position: absolute; left: 8px; top: 42px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); min-width: 208px; padding: 4px; display: none; z-index: 30; box-shadow: var(--shadow-strong); }
.org-menu.open { display: block; }
.org-menu div { display: flex; align-items: center; min-height: var(--row-height); padding: 8px 10px; border-radius: var(--radius-control); color: var(--muted); cursor: pointer; }
.org-menu div:hover { background: var(--surface-hover); color: var(--text); }

section.screen { display: none; }
section.screen.active { display: block; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 18px 20px; }
.card.click { cursor: pointer; transition: border-color .12s; }
.card.click:hover { border-color: var(--line-strong); }
.card .label { color: var(--faint); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.card .value { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
th, td { text-align: left; padding: 0 16px; border-bottom: 1px solid var(--color-gray-4); font-size: 13.5px; vertical-align: middle; }
td { height: 52px; }
th { height: 40px; color: var(--faint); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; background: var(--color-gray-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.rowclick { cursor: pointer; }
tr.rowclick:hover td { background: var(--surface-hover); }
td .avatar { margin-right: 8px; vertical-align: middle; }

/* status pill = 20px, rounded-pill, 4px leading dot in the text color */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 8px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; }
.pill::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; flex: none; }
.pill.on  { background: var(--green-soft); color: var(--green); }
.pill.off { background: var(--red-soft); color: var(--red); }
/* role/label = rectangular 4px tag, no status dot */
.pill.lead { border-radius: var(--radius-control); background: var(--accent-soft); color: var(--color-accent-11); }
.pill.lead::before { display: none; }

/* ---------- buttons ---------- */
button { font: inherit; font-weight: 500; height: var(--control-height); display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--radius-control); padding: 0 12px; cursor: pointer; }
button:hover { background: var(--surface-hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--color-accent-10); border-color: var(--color-accent-10); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; }
button.ghost:hover { background: var(--surface-hover); color: var(--text); border-color: transparent; }
button.danger { color: var(--red); }
button.danger:hover { background: var(--red-soft); border-color: var(--color-danger); }

/* ---------- panels / rows ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 22px 24px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.panel p.hint { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }

.row { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--color-gray-4); gap: 16px; }
.row:last-child { border-bottom: 0; }
.row .name b { display: block; font-weight: 500; }
.row .name small { color: var(--muted); }
.row.rowclick { cursor: pointer; margin: 0 -10px; padding: 13px 10px; border-radius: var(--radius-control); border-bottom: 1px solid var(--color-gray-4); }
.row.rowclick:hover { background: var(--surface-hover); }

/* toggle = the org's boolean control; ON uses the sanctioned accent fill */
.toggle { width: 34px; height: 20px; border-radius: var(--radius-pill); background: var(--color-gray-6); position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: .15s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 16px; }

.key-box { display: flex; align-items: center; gap: 10px; background: var(--color-gray-2); border: 1px dashed var(--color-gray-6); border-radius: var(--radius-control); padding: 8px 12px; font-family: ui-monospace, "SF Mono", monospace; font-size: 13px; letter-spacing: .04em; flex-wrap: wrap; }

.radio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.radio-grid label { border: 1px solid var(--line); border-radius: var(--radius-card); padding: 14px 14px; cursor: pointer; display: block; background: var(--panel); }
.radio-grid label:hover { border-color: var(--line-strong); }
/* selected radio = the sanctioned accent-3 tint + accent border (active-card pattern) */
.radio-grid label.sel { border-color: var(--accent); background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent); }
.radio-grid b { display: block; margin-bottom: 1px; font-weight: 500; }
.radio-grid small { color: var(--muted); }

.banner { background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--panel)); color: var(--amber); border-radius: var(--radius-control); padding: 8px 12px; font-size: 12.5px; margin-bottom: 14px; }
.savebar { position: sticky; bottom: 16px; display: none; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 9px 14px; margin-top: 14px; box-shadow: var(--shadow-strong); }
.savebar.show { display: flex; }
.savebar span { color: var(--muted); }

input[type="text"], input[type="email"], select {
  font: inherit; height: var(--control-height); background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--radius-control); padding: 0 10px; width: 100%;
}
input::placeholder { color: var(--color-gray-8); }
/* inputs get a border-color change on focus, NOT a ring */
input:focus, select:focus { outline: none; border-color: var(--accent); }
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--faint); font-size: 11px; font-weight: 500; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }

textarea { font: inherit; width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: var(--radius-control); padding: 9px 10px; resize: vertical; min-height: 92px; }
textarea::placeholder { color: var(--color-gray-8); }
textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- support: ticket form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.ticket-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } .ticket-foot button { flex: 1 1 100%; } }

/* ---------- AI chat bubble ---------- */
#chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 70; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; border: none; padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-strong); cursor: pointer; }
#chat-fab:hover { background: var(--color-accent-10); }
#chat-fab svg { width: 22px; height: 22px; }
#chat-fab .i-close { display: none; }
#chat-fab.open .i-chat { display: none; }
#chat-fab.open .i-close { display: block; }

#chat-panel { position: fixed; right: 22px; bottom: 84px; z-index: 70; width: 360px; max-width: calc(100vw - 44px); height: 470px; max-height: calc(100dvh - 120px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-strong); display: none; flex-direction: column; overflow: hidden; }
#chat-panel.open { display: flex; }
/* keep the FAB out of the way while the sticky savebar is showing */
body.savebar-open #chat-fab, body.savebar-open #chat-panel { display: none; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head b { font-size: 14px; font-weight: 600; display: block; line-height: 1.2; }
.chat-head small { color: var(--faint); font-size: 11px; }
.chat-head .icon-btn { margin-left: auto; width: 28px; height: 28px; border: none; background: transparent; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
.chat-msg.bot { align-self: flex-start; background: var(--panel-2); color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; }
.chat-input button.primary { width: 36px; padding: 0; flex-shrink: 0; }
.chat-input button svg { width: 16px; height: 16px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; z-index: 120; }
.overlay.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); width: 440px; max-width: 92vw; max-height: 84vh; overflow: auto; padding: 26px; box-shadow: var(--shadow-strong); }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 88px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--color-gray-12); color: var(--color-gray-1); border-radius: var(--radius-control); padding: 9px 14px; font-size: 12.5px; box-shadow: var(--shadow-strong); animation: pop .18s ease-out; }
.toast.warn { background: var(--amber); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- charts ---------- */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 8px; }
.chart .bar { flex: 1; background: var(--color-gray-5); border-radius: var(--radius-control) var(--radius-control) 0 0; cursor: pointer; }
.chart .bar:hover, .chart .bar.hot { background: var(--accent); }
.chart-x { display: flex; gap: 8px; color: var(--muted); font-size: 11px; margin-top: 6px; }
.chart-x div { flex: 1; text-align: center; }
.tabs { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 2px; gap: 2px; margin-right: 8px; }
.tabs button { height: auto; border: 0; background: transparent; color: var(--muted); padding: 3px 10px; }
.tabs button.sel { background: var(--panel); color: var(--text); border-radius: var(--radius-control); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- branding preview ---------- */
.brand-preview { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.brand-logo { width: 34px; height: 34px; border-radius: var(--radius-control); display: flex; align-items: center; justify-content: center; font-size: 16px; background: var(--accent); color: #fff; font-weight: 600; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch.sel { border-color: var(--text); }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: none; align-items: center; justify-content: center; }
#login.open { display: flex; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 32px; width: 360px; max-width: 92vw; box-shadow: var(--shadow-strong); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.login-brand .brand-mark { width: 32px; height: 32px; }
.login-brand b { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.login-brand b span { color: var(--accent); font-weight: 500; }
.login-card p { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.login-card a { color: var(--accent); text-decoration: none; }

/* wide content (tables) scrolls inside its own box, never the page body */
.table-wrap { width: 100%; overflow-x: auto; }
.table-wrap table { min-width: 560px; }

/* toolbar-style panel header (title + filter + action) that wraps gracefully */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.panel-head > :first-child { flex: 1 1 240px; }
.panel-head input[type="text"] { width: 220px; }

/* larger hit targets on touch devices */
@media (pointer: coarse) {
  button, .icon-btn, input[type="text"], input[type="email"], select { min-height: 44px; }
  aside nav a { min-height: 40px; }
  .toggle { transform: scale(1.1); }
}

/* ---------- responsive: sidebar becomes a slide-in drawer ---------- */
@media (max-width: 860px) {
  aside {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 90;
    width: 264px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-strong);
  }
  aside.open { transform: none; }
  .nav-backdrop.open { display: block; position: fixed; inset: 0; z-index: 85; background: rgba(0,0,0,.45); }
  .icon-btn.nav-toggle { display: inline-flex; }
  main { padding: 0 18px 32px; }
  header.page { margin-bottom: 16px; padding: 16px 0 14px; }
  header.page h2 { font-size: 17px; }
  header.page .page-sub { display: none; }
  .panel { padding: 16px 16px; }
  .modal { padding: 20px; }
  /* stacked toolbar: filter and action go full-width under the title */
  .panel-head > :first-child { flex: 1 1 100%; }
  .panel-head input[type="text"] { flex: 1 1 100%; width: auto; }
  .panel-head > button { flex: 1 1 auto; }
  .login-card { padding: 24px; }
  .cards { gap: 12px; margin-bottom: 16px; }
}

/* ---------- responsive: extra-small phones ---------- */
@media (max-width: 480px) {
  main { padding: 0 14px 28px; }
  header.page { margin-bottom: 14px; padding: 14px 0 12px; }
  /* force single-column stat cards */
  .cards { grid-template-columns: 1fr; }
  .radio-grid { grid-template-columns: 1fr; }
  .card .value { font-size: 22px; }
  /* larger tap spacing */
  aside nav a { min-height: 44px; margin-bottom: 4px; }
  .org-menu div { min-height: 44px; }
  .row { padding: 15px 0; }
  /* chat + toasts hug the screen edges */
  #chat-fab { right: 16px; bottom: 16px; }
  #chat-panel { right: 12px; left: 12px; width: auto; max-width: none; bottom: 78px; height: calc(100dvh - 150px); }
  #toasts { left: 12px; right: 12px; bottom: 80px; }
}

/* ---------- demo configurator ---------- */
.nav-hidden { display: none !important; }

.setup-overlay { position: fixed; inset: 0; z-index: 95; background: var(--bg); display: none; overflow-y: auto; padding: 36px 20px; }
.setup-overlay.open { display: block; }
.setup-card { max-width: 1000px; margin: 0 auto; position: relative; }
.setup-close { position: absolute; top: 0; right: 0; }
.setup-head { margin-bottom: 22px; padding-right: 44px; }
.setup-sub { color: var(--muted); font-size: 13px; margin-top: 8px; }
.setup-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.setup-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 820px) { .setup-grid { grid-template-columns: 1fr; } }

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 620px) { .feature-grid { grid-template-columns: 1fr; } }
.feature-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); cursor: pointer; user-select: none; font-weight: 500; }
.feature-item:hover { background: var(--surface-hover); }
.feature-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.feature-item .cbox { width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid var(--color-gray-8); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: .12s; }
.feature-item input:checked + .cbox { background: var(--accent); border-color: var(--accent); }
.feature-item input:checked + .cbox::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px); }
.feature-item.locked { opacity: .7; cursor: default; }
.feature-item .lock { margin-left: auto; font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; }

.cust-row { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--color-gray-4); }
.cust-row:last-child { border-bottom: 0; }
.cust-main { flex: 1; min-width: 0; }
.cust-main b { display: block; font-weight: 500; }
.cust-main > small { color: var(--muted); }
.cust-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.cust-chip { font-size: 10px; background: var(--panel-2); color: var(--muted); border-radius: 4px; padding: 1px 6px; }
.cust-note { display: block; color: var(--faint); font-size: 12px; margin-top: 6px; font-style: italic; }
.cust-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.cust-actions button { height: 28px; padding: 0 10px; font-size: 12px; }
.cust-empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* requested-feature builder (in the setup) + WIP placeholder screens */
.req-add { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--color-gray-4); }
.req-add-title { font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.req-add-title span { font-weight: 400; color: var(--faint); }
.req-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.req-list:empty { display: none; }
.req-chip { display: inline-flex; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 2px 3px 2px 4px; font-size: 12px; }
.req-chip button { height: auto; width: auto; border: none; background: transparent; color: inherit; font: inherit; font-size: 12px; line-height: 1; cursor: pointer; border-radius: var(--radius-control); display: inline-flex; align-items: center; }
.req-chip .req-edit { padding: 3px 5px; gap: 6px; }
.req-chip .req-edit:hover { background: var(--surface-hover); }
.req-chip .cat { color: var(--faint); font-size: 11px; }
.req-chip [data-rm] { width: 20px; height: 20px; justify-content: center; padding: 0; color: var(--muted); font-size: 15px; }
.req-chip [data-rm]:hover { background: var(--surface-hover); color: var(--red); }
.req-form { display: flex; gap: 8px; flex-wrap: wrap; }
.req-form #req-name { flex: 2 1 200px; }
.req-form #req-cat { flex: 1 1 130px; }
.req-form button { flex-shrink: 0; }
.wip { text-align: center; padding: 56px 20px; color: var(--muted); }
.wip svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 14px; }
.wip b { display: block; font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.wip p { max-width: 380px; margin: 0 auto; font-size: 13px; }
