/* MSG Automation — design system v2 (premium, responsive, light + dark) */
:root {
  color-scheme: light;
  --bg: #f4f5f3; --surface: #ffffff; --surface-2: #f8f9f7; --surface-3: #eef0ed; --hover: #f2f4f1;
  --line: #e5e8e3; --line-2: #eef0ec;
  --text: #0d1311; --text-2: #4a5451; --text-3: #858d8a;
  --brand: #10b981; --brand-strong: #059669; --brand-ink: #03291c; --brand-soft: rgba(16,185,129,.11); --brand-ring: rgba(16,185,129,.28);
  --danger: #e5484d; --danger-soft: rgba(229,72,77,.1); --warn: #c27803; --warn-soft: rgba(217,119,6,.12); --info: #2f6fdc; --info-soft: rgba(47,111,220,.1);
  --series-1: #2a78d6; --series-2: #1baf7a; --grid: #eceeea;
  --chat-bg: #efeae2; --bubble-in: #ffffff; --bubble-out: #d9fdd3; --bubble-text: #111b21;
  --sidebar: #0c1311; --sidebar-2: #111a17; --sidebar-text: #a7b3af; --sidebar-line: rgba(255,255,255,.07);
  --r-xl: 20px; --r-lg: 16px; --r: 12px; --r-sm: 9px;
  --sh-1: 0 1px 2px rgba(13,19,17,.05);
  --sh-2: 0 1px 2px rgba(13,19,17,.04), 0 6px 20px -8px rgba(13,19,17,.12);
  --sh-3: 0 24px 60px -18px rgba(13,19,17,.28), 0 2px 8px rgba(13,19,17,.06);
  --ease: cubic-bezier(.2,.8,.2,1);
  --topbar-h: 64px; --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #090e0d; --surface: #101715; --surface-2: #131c19; --surface-3: #1a2421; --hover: #17201d;
    --line: #212c28; --line-2: #1a2320;
    --text: #e9efec; --text-2: #a3aeaa; --text-3: #6c7874;
    --brand: #22c993; --brand-strong: #19b383; --brand-ink: #022117; --brand-soft: rgba(34,201,147,.12); --brand-ring: rgba(34,201,147,.3);
    --danger: #f0676b; --danger-soft: rgba(240,103,107,.13); --warn: #f0a83a; --warn-soft: rgba(240,168,58,.13); --info: #5b93ef; --info-soft: rgba(91,147,239,.14);
    --series-1: #3987e5; --series-2: #199e70; --grid: #1e2825;
    --chat-bg: #0b1311; --bubble-in: #1b2522; --bubble-out: #0d4a37; --bubble-text: #e9efec;
    --sidebar: #070b0a; --sidebar-2: #0b1110;
    --sh-1: 0 1px 2px rgba(0,0,0,.3); --sh-2: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.5); --sh-3: 0 30px 70px -20px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090e0d; --surface: #101715; --surface-2: #131c19; --surface-3: #1a2421; --hover: #17201d;
  --line: #212c28; --line-2: #1a2320;
  --text: #e9efec; --text-2: #a3aeaa; --text-3: #6c7874;
  --brand: #22c993; --brand-strong: #19b383; --brand-ink: #022117; --brand-soft: rgba(34,201,147,.12); --brand-ring: rgba(34,201,147,.3);
  --danger: #f0676b; --danger-soft: rgba(240,103,107,.13); --warn: #f0a83a; --warn-soft: rgba(240,168,58,.13); --info: #5b93ef; --info-soft: rgba(91,147,239,.14);
  --series-1: #3987e5; --series-2: #199e70; --grid: #1e2825;
  --chat-bg: #0b1311; --bubble-in: #1b2522; --bubble-out: #0d4a37; --bubble-text: #e9efec;
  --sidebar: #070b0a; --sidebar-2: #0b1110;
  --sh-1: 0 1px 2px rgba(0,0,0,.3); --sh-2: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.5); --sh-3: 0 30px 70px -20px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; background: var(--bg); color: var(--text); letter-spacing: -.006em; overflow-x: hidden; }
h1, h2, h3, h4 { font-family: "Plus Jakarta Sans", "Inter", sans-serif; letter-spacing: -.022em; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--brand-ring); }
[hidden] { display: none !important; }
.ic { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

/* ---------- boot splash ---------- */
#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 200; }
#boot .boot-mark { width: 64px; height: 64px; border-radius: 18px; animation: breathe 1.4s var(--ease) infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.92); opacity: .7; } }

/* ---------- auth screens ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--bg); }
.auth-art {
  position: relative; overflow: hidden; color: #eafff6; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at -10% -20%, #16a37a 0%, transparent 55%), radial-gradient(900px 700px at 120% 120%, #0d5c45 0%, transparent 55%), #06110d;
}
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); pointer-events: none; }
.auth-art > * { position: relative; z-index: 1; }
.auth-logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; font-family: "Plus Jakarta Sans", sans-serif; }
.auth-logo img { width: 40px; height: 40px; border-radius: 11px; }
.auth-art h1 { font-size: clamp(30px, 3.4vw, 46px); line-height: 1.08; font-weight: 800; max-width: 520px; color: #fff; }
.auth-art h1 span { background: linear-gradient(90deg, #6ff0bf, #c9ffe9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-art p.lead { color: #a9cfc2; font-size: 15.5px; line-height: 1.6; max-width: 460px; margin: 18px 0 0; }
.auth-feats { display: grid; gap: 12px; margin-top: 30px; max-width: 440px; }
.auth-feat { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); font-size: 13.5px; color: #d5efe6; backdrop-filter: blur(6px); }
.auth-feat .ic { color: #6ff0bf; }
.auth-foot { font-size: 12px; color: #6d9486; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; animation: rise .45s var(--ease); }
.auth-card .mobile-logo { display: none; }
.auth-card h2 { font-size: 26px; font-weight: 800; }
.auth-card .sub { color: var(--text-2); margin: 8px 0 26px; line-height: 1.5; }
.auth-card .btn-block { width: 100%; justify-content: center; padding: 13px; font-size: 14.5px; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 22px; color: var(--text-2); font-size: 13.5px; }
.auth-switch button { background: none; border: none; color: var(--brand-strong); font-weight: 650; padding: 0; }
.auth-err { background: var(--danger-soft); color: var(--danger); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; font-weight: 550; }
.pending-orb { width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 22px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); position: relative; }
.pending-orb::before, .pending-orb::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--brand-ring); animation: ripple 2.2s var(--ease) infinite; }
.pending-orb::after { animation-delay: 1.1s; }
.pending-orb .ic { width: 34px; height: 34px; }
@keyframes ripple { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-card .mobile-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; font-weight: 750; font-family: "Plus Jakarta Sans", sans-serif; font-size: 16px; }
  .auth-card .mobile-logo img { width: 38px; height: 38px; border-radius: 11px; }
}

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px 14px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-line);
}
.ws { display: flex; align-items: center; gap: 11px; padding: 6px 8px 14px; border-bottom: 1px solid var(--sidebar-line); margin-bottom: 4px; }
.ws.ws-click { cursor: pointer; border-radius: 12px; transition: background .15s; }
.ws.ws-click:hover { background: rgba(255,255,255,.05); }
.ws .ic { color: #6f7e79; }
.ws img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 8px 20px -8px rgba(16,185,129,.6); }
.ws-name { color: #fff; font-weight: 700; font-size: 14.5px; font-family: "Plus Jakarta Sans", sans-serif; line-height: 1.2; }
.ws-sub { font-size: 11.5px; color: #6f7e79; margin-top: 2px; }
.conn { display: inline-flex; align-items: center; gap: 7px; margin: 6px 8px 4px; padding: 6px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650; color: #8ee9c3; background: rgba(34,201,147,.1); border: 1px solid rgba(34,201,147,.2); cursor: pointer; width: fit-content; }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c993; box-shadow: 0 0 0 3px rgba(34,201,147,.22); animation: pulse 1.8s infinite; }
.conn.down { color: #ffb3b5; background: rgba(240,103,107,.12); border-color: rgba(240,103,107,.25); }
.conn.down .dot { background: #f0676b; box-shadow: 0 0 0 3px rgba(240,103,107,.22); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.nav-group { font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #56635f; margin: 14px 10px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border-radius: 10px; border: none; background: none;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 560; text-align: left; position: relative; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(34,201,147,.13); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #22c993; }
.nav-item.active .ic { color: #3fe0a8; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #22c993; color: #03291c; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.nav-badge.red { background: #f0676b; color: #fff; }
.side-spacer { flex: 1; }
.install-card { margin: 10px 4px; padding: 14px; border-radius: 14px; background: linear-gradient(135deg, rgba(34,201,147,.16), rgba(34,201,147,.04)); border: 1px solid rgba(34,201,147,.2); color: #cfeee2; font-size: 12.5px; line-height: 1.45; }
.install-card b { color: #fff; display: block; font-size: 13px; margin-bottom: 3px; }
.install-card button { margin-top: 10px; width: 100%; justify-content: center; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 1px solid var(--sidebar-line); background: rgba(255,255,255,.03); cursor: pointer; transition: background .15s; }
.user-card:hover { background: rgba(255,255,255,.06); }
.user-card .u-name { color: #fff; font-weight: 650; font-size: 13px; }
.user-card .u-role { font-size: 11px; color: #6f7e79; text-transform: capitalize; }
.user-card .ic { margin-left: auto; color: #6f7e79; }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #fff; flex-shrink: 0; letter-spacing: 0; text-transform: uppercase; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line-2);
}
.topbar .tb-title { display: none; font-weight: 750; font-size: 16.5px; font-family: "Plus Jakarta Sans", sans-serif; }
.topbar .tb-logo { display: none; width: 32px; height: 32px; border-radius: 9px; }
.searchbtn { display: flex; align-items: center; gap: 10px; flex: 0 1 380px; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); color: var(--text-3); font-size: 13.5px; box-shadow: var(--sh-1); transition: border-color .15s; }
.searchbtn:hover { border-color: color-mix(in srgb, var(--text-3) 45%, var(--line)); }
.searchbtn kbd { margin-left: auto; }
.tb-spacer { flex: 1; }
.iconbtn { position: relative; width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); display: grid; place-items: center; box-shadow: var(--sh-1); transition: background .15s, color .15s; flex-shrink: 0; }
.iconbtn:hover { background: var(--hover); color: var(--text); }
.iconbtn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.iconbtn .pip { position: absolute; top: 7px; right: 8px; min-width: 9px; height: 9px; border-radius: 999px; background: var(--danger); border: 2px solid var(--surface); }
.tb-avatar { display: none; border: none; background: none; padding: 0; }
kbd { font-family: ui-monospace, "SF Mono", monospace; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line); color: var(--text-2); }

.content { width: 100%; max-width: 1320px; margin: 0 auto; padding: 26px 28px 80px; animation: rise .35s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 25px; font-weight: 800; }
.page-head p { margin: 5px 0 0; color: var(--text-2); font-size: 13.5px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 620; font-size: 13.5px; box-shadow: var(--sh-1); transition: transform .12s var(--ease), background .12s, border-color .12s, box-shadow .12s; white-space: nowrap;
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover { background: var(--hover); border-color: color-mix(in srgb, var(--text-3) 35%, var(--line)); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-brand { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 92%, #fff) 0%, var(--brand-strong) 100%); border-color: var(--brand-strong); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px -6px var(--brand-ring); text-shadow: 0 1px 0 rgba(0,0,0,.08); }
.btn-brand:hover { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%); border-color: var(--brand-strong); filter: brightness(1.04); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-solid-danger:hover { background: var(--danger); filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--hover); border-color: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-icon { padding: 7px; }

.field { margin-bottom: 15px; }
.field > label, .label { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=file]), .field select, .field textarea, select.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.field input[type=file] { width: 100%; padding: 14px; border: 1.5px dashed var(--line); border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 550; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand-strong); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }
.input-icon input { padding-left: 36px !important; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select { cursor: pointer; }
.select-sm { padding: 6px 28px 6px 10px; font-size: 12.5px; border-radius: 8px; border: 1px solid var(--line); background-color: var(--surface); }

/* switch */
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); transition: background .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand-strong); border-color: var(--brand-strong); }
.switch input:checked + span::after { transform: translateX(18px); }

/* segmented tabs */
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--line-2); gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { border: none; background: none; padding: 6px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 620; color: var(--text-2); white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
.seg .count { font-size: 11px; color: var(--text-3); font-weight: 700; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.panel { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 20px; margin-bottom: 18px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h3 { font-size: 15.5px; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.panel-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; font-weight: 500; }
.panel.flush .panel-head { padding: 18px 20px 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.grid-2 > .panel { margin-bottom: 0; }
.stack { display: grid; gap: 18px; margin-bottom: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 16px 16px 15px; cursor: pointer; position: relative; overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s; text-align: left; width: 100%; color: inherit;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--line); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.stat-ic.blue { background: var(--info-soft); color: var(--info); } .stat-ic.amber { background: var(--warn-soft); color: var(--warn); } .stat-ic.red { background: var(--danger-soft); color: var(--danger); } .stat-ic.gray { background: var(--surface-3); color: var(--text-2); }
.stat .go { color: var(--text-3); opacity: 0; transition: opacity .18s, transform .18s; }
.stat:hover .go { opacity: 1; transform: translateX(2px); }
.stat-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; margin-top: 14px; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -.03em; font-family: "Plus Jakarta Sans", sans-serif; margin-top: 2px; line-height: 1.1; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-value.red { color: var(--danger); }

.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 24px 26px; margin-bottom: 18px; color: #e8fff6;
  background: radial-gradient(700px 300px at 0% 0%, rgba(34,201,147,.55), transparent 60%), radial-gradient(500px 300px at 100% 100%, rgba(13,92,69,.9), transparent 60%), #07130f;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; box-shadow: var(--sh-2);
}
.hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px); background-size: 20px 20px; mask-image: linear-gradient(90deg, transparent, #000 60%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero h2 { font-size: 24px; font-weight: 800; color: #fff; }
.hero p { margin: 6px 0 0; color: #a8d4c4; font-size: 13.5px; }
.hero-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; font-size: 12px; font-weight: 650; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: #d9f5ea; cursor: pointer; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: #3fe0a8; }
.chip.warn .dot { background: #f0a83a; } .chip.bad .dot { background: #f0676b; }
.hero .btn { background: #fff; color: #05291d; border-color: #fff; box-shadow: none; }
.hero .btn:hover { background: #eafff6; }
.hero .btn.ghostw { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-3); font-size: 11.5px; font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; background: var(--surface-2); }
th:first-child { border-top-left-radius: 10px; } th:last-child { border-top-right-radius: 10px; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
td.td-actions { text-align: right; white-space: nowrap; }
td.td-actions .btn + .btn { margin-left: 4px; }
.cell-main { font-weight: 650; }
.cell-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who > div { min-width: 0; }
.clip { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; }
.badge.green { background: var(--brand-soft); color: var(--brand-strong); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.gray { background: var(--surface-3); color: var(--text-2); }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { display: inline-block; background: var(--surface-3); border: 1px solid var(--line-2); padding: 2px 8px; border-radius: 6px; font-size: 11.5px; margin: 0 4px 3px 0; color: var(--text-2); font-weight: 600; }

.empty { text-align: center; padding: 46px 20px; color: var(--text-3); }
.empty .e-ic { width: 52px; height: 52px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.empty .e-ic .ic { width: 24px; height: 24px; }
.empty b { color: var(--text); font-size: 14.5px; display: block; }
.empty p { margin: 5px 0 0; font-size: 13px; }

.banner { display: flex; gap: 11px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; margin-bottom: 16px; background: var(--info-soft); color: var(--text-2); border: 1px solid color-mix(in srgb, var(--info) 18%, transparent); }
.banner > .ic { color: var(--info); margin-top: 1px; }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 22%, transparent); } .banner.warn > .ic { color: var(--warn); }
.banner.red { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); } .banner.red > .ic { color: var(--danger); }
.banner.green { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 22%, transparent); } .banner.green > .ic { color: var(--brand-strong); }
.banner b { color: var(--text); }
.banner .grow { flex: 1; }

.progress { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-strong)); transition: width .4s var(--ease); }

/* list rows (feeds, people, devices) */
.rows { display: grid; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); min-width: 0; }
.row:last-child { border-bottom: none; }
.row.wrap { flex-wrap: wrap; }
.row.wrap .grow { min-width: 55%; }
.row.click { cursor: pointer; border-radius: 10px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; transition: background .12s; }
.row.click:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .r-title { font-weight: 650; font-size: 13.5px; display: flex; align-items: center; gap: 7px; min-width: 0; }
.row .r-title span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.dir-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.dir-ic .ic { width: 14px; height: 14px; }
.dir-ic.in { background: var(--info-soft); color: var(--info); } .dir-ic.out { background: var(--brand-soft); color: var(--brand-strong); }

/* checklist */
.todo { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.todo:last-child { border-bottom: none; }
.todo .tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line); flex-shrink: 0; }
.todo.done .tick { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.todo .tick .ic { width: 13px; height: 13px; stroke-width: 3; }
.todo.done .t-label { color: var(--text-3); text-decoration: line-through; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: Inter, sans-serif; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar-a { fill: var(--series-1); } .chart .bar-b { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 4%, transparent); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--text); }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2); border-radius: 10px; padding: 9px 11px; font-size: 12px; min-width: 130px; z-index: 5; transform: translate(-50%, -100%); white-space: nowrap; }
.tooltip .tt-h { font-weight: 700; margin-bottom: 5px; color: var(--text); }
.tooltip .tt-r { display: flex; align-items: center; gap: 7px; color: var(--text-2); margin-top: 2px; }
.tooltip .tt-r i { width: 8px; height: 8px; border-radius: 2px; }
.tooltip .tt-r b { margin-left: auto; color: var(--text); padding-left: 12px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 9px; cursor: pointer; font-size: 13px; }
.hbar:hover { background: var(--surface-2); }
.hbar .track { height: 10px; border-radius: 0 4px 4px 0; background: var(--surface-3); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); }
.hbar .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- live chat ---------- */
.lc { display: grid; grid-template-columns: 330px minmax(0, 1fr) 290px; height: calc(100dvh - var(--topbar-h) - 52px); min-height: 480px; border: 1px solid var(--line-2); border-radius: var(--r-xl); overflow: hidden; background: var(--surface); box-shadow: var(--sh-2); }
.content.chat-mode { max-width: none; padding: 18px 22px 22px; }
.lc-list { border-right: 1px solid var(--line-2); display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.lc-list-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line-2); }
.lc-list-head h3 { font-size: 17px; font-weight: 800; display: flex; align-items: center; justify-content: space-between; }
.lc-list-head .input-icon { margin-top: 12px; }
.lc-list-head .seg { margin-top: 10px; width: 100%; }
.lc-list-head .seg button { flex: 1; justify-content: center; }
.lc-threads { flex: 1; overflow-y: auto; }
.thread { display: flex; gap: 11px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--line-2); transition: background .12s; position: relative; }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--brand-soft); }
.thread.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand-strong); }
.thread .grow { flex: 1; min-width: 0; }
.thread .t-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.thread .t-name { font-weight: 680; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .t-time { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.thread.unread .t-time { color: var(--brand-strong); font-weight: 700; }
.thread .t-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 3px; }
.thread .t-prev { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread.unread .t-prev { color: var(--text); font-weight: 560; }
.unread-pill { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: var(--brand-strong); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; flex-shrink: 0; }
.flag-pill { color: var(--danger); display: inline-flex; }
.flag-pill .ic { width: 14px; height: 14px; }

.lc-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); position: relative; }
.lc-thread::before { content: ""; position: absolute; inset: 0; opacity: .5; background-image: radial-gradient(color-mix(in srgb, var(--text) 7%, transparent) 1px, transparent 1px); background-size: 18px 18px; pointer-events: none; }
.lc-head { position: relative; z-index: 1; display: flex; align-items: center; gap: 11px; padding: 11px 16px; background: var(--surface); border-bottom: 1px solid var(--line-2); min-height: 64px; }
.lc-head .grow { flex: 1; min-width: 0; }
.lc-head b { font-size: 14.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-head .sub { font-size: 12px; color: var(--text-3); }
.lc-back { display: none; }
.lc-msgs { position: relative; z-index: 1; flex: 1; overflow-y: auto; padding: 18px 6% 10px; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; margin: 12px 0 8px; font-size: 11.5px; font-weight: 650; color: var(--text-2); background: var(--surface); padding: 4px 11px; border-radius: 8px; box-shadow: var(--sh-1); }
.bubble { max-width: min(78%, 560px); padding: 7px 10px 6px; border-radius: 10px; font-size: 14px; line-height: 1.45; color: var(--bubble-text); box-shadow: 0 1px .5px rgba(0,0,0,.1); white-space: pre-wrap; word-wrap: break-word; animation: pop .18s var(--ease); position: relative; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 3px; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 3px; }
.bubble.gap { margin-top: 8px; }
.bubble.failed { outline: 1.5px solid color-mix(in srgb, var(--danger) 55%, transparent); }
.b-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; font-size: 10.5px; opacity: .62; margin-top: 3px; white-space: nowrap; }
.b-meta .ic { width: 13px; height: 13px; }
.b-src { display: flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; color: var(--brand-strong); margin-bottom: 2px; }
.b-src .ic { width: 11px; height: 11px; }
.sys-note { align-self: center; font-size: 11.5px; color: var(--danger); background: var(--surface); padding: 5px 11px; border-radius: 8px; margin: 6px 0; display: inline-flex; gap: 6px; align-items: center; box-shadow: var(--sh-1); max-width: 85%; }
.sys-note .ic { width: 13px; height: 13px; }
.lc-composer { position: relative; z-index: 1; padding: 10px 12px; background: var(--surface); border-top: 1px solid var(--line-2); }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-row textarea { flex: 1; resize: none; max-height: 140px; min-height: 44px; padding: 11px 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface-2); font-size: 14px; line-height: 1.4; outline: none; }
.composer-row textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); background: var(--surface); }
.sendbtn { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--brand-strong); color: #fff; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 6px 16px -6px var(--brand-ring); transition: transform .12s; }
.sendbtn:active { transform: scale(.94); }
.sendbtn:disabled { opacity: .5; }
.window-note { font-size: 11.5px; color: var(--text-3); margin: 6px 4px 0; display: flex; align-items: center; gap: 6px; }
.window-note .ic { width: 13px; height: 13px; }
.lc-info { border-left: 1px solid var(--line-2); padding: 22px 18px; overflow-y: auto; background: var(--surface); }
.lc-info .who-big { text-align: center; padding-bottom: 18px; border-bottom: 1px solid var(--line-2); margin-bottom: 16px; }
.lc-info .who-big .avatar { margin: 0 auto 10px; width: 64px; height: 64px; font-size: 22px; }
.lc-info .who-big b { font-size: 16px; display: block; }
.info-sec { margin-bottom: 16px; }
.info-sec .label { color: var(--text-3); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.info-sec .val { font-size: 13.5px; color: var(--text); line-height: 1.5; }
.lc-empty { display: grid; place-items: center; text-align: center; color: var(--text-3); position: relative; z-index: 1; height: 100%; }
.lc-info-close { display: none; }

/* ---------- modal / sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(5,10,8,.5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.overlay.open { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-xl); width: 100%; max-width: 540px; max-height: 88dvh; overflow-y: auto; padding: 24px; box-shadow: var(--sh-3); transform: translateY(12px) scale(.98); transition: transform .22s var(--ease); }
.modal.wide { max-width: 720px; }
.overlay.open .modal { transform: none; }
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 4px; padding-right: 30px; }
.modal .modal-sub { color: var(--text-2); font-size: 13px; margin-bottom: 18px; line-height: 1.5; }
.modal-x { position: sticky; float: right; top: 0; margin: -6px -6px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.sheet-grip { display: none; }

/* command palette */
.palette { position: fixed; inset: 0; z-index: 90; background: rgba(5,10,8,.45); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette-box { width: 100%; max-width: 580px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3); overflow: hidden; animation: rise .18s var(--ease); }
.palette-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line-2); }
.palette-in input { flex: 1; border: none; outline: none; background: none; padding: 16px 0; font-size: 15.5px; }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.p-group { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .07em; padding: 10px 10px 4px; }
.p-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 13.5px; }
.p-item .ic { color: var(--text-3); }
.p-item small { color: var(--text-3); margin-left: auto; font-size: 12px; }
.p-item.sel { background: var(--brand-soft); }
.p-item.sel .ic { color: var(--brand-strong); }

/* notifications popover */
.popover { position: fixed; z-index: 85; top: calc(var(--topbar-h) - 6px); right: 20px; width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-3); overflow: hidden; animation: rise .18s var(--ease); }
.popover-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); font-weight: 750; display: flex; justify-content: space-between; align-items: center; }
.popover-body { max-height: 60vh; overflow-y: auto; padding: 6px 12px; }

/* toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 13px; background: #0f1714; color: #ecf5f1; font-size: 13.5px; font-weight: 520; box-shadow: var(--sh-3); border: 1px solid rgba(255,255,255,.08); animation: toastIn .28s var(--ease); }
.toast .ic { color: #3fe0a8; }
.toast.error .ic { color: #ff8a8d; }
.toast .t-act { margin-left: auto; background: rgba(255,255,255,.1); border: none; color: #fff; padding: 5px 10px; border-radius: 8px; font-size: 12px; font-weight: 650; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* mobile tab bar + more sheet */
.tabbar { display: none; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 14px; }
.more-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 12px; font-weight: 620; color: var(--text); text-align: center; position: relative; }
.more-tile .ic { width: 22px; height: 22px; color: var(--brand-strong); }
.more-tile .nav-badge { position: absolute; top: 6px; right: 8px; margin: 0; }
.menu-list { display: grid; border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; }
.menu-list button { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: none; background: var(--surface); border-bottom: 1px solid var(--line-2); text-align: left; font-size: 14px; font-weight: 560; }
.menu-list button:last-child { border-bottom: none; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list .ic { color: var(--text-2); }
.menu-list .danger { color: var(--danger); } .menu-list .danger .ic { color: var(--danger); }

/* devices */
.device-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.device-ic.pending { background: var(--warn-soft); color: var(--warn); }
.device-ic.ok { background: var(--brand-soft); color: var(--brand-strong); }

.chat-test { border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; height: 420px; }
.chat-test .lc-msgs { background: var(--chat-bg); padding: 14px; }
.chat-test .lc-composer { border-top: 1px solid var(--line-2); }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--surface-3) 25%, var(--hover) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-3) 35%, transparent); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); background-clip: padding-box; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) {
  .lc { grid-template-columns: 300px minmax(0, 1fr); }
  .lc-info { position: absolute; right: 0; top: 0; bottom: 0; width: 320px; z-index: 6; box-shadow: var(--sh-3); transform: translateX(105%); transition: transform .25s var(--ease); }
  .lc { position: relative; }
  .lc.info-open .lc-info { transform: none; }
  .lc-info-close { display: grid; position: absolute; top: 10px; right: 10px; }
}
@media (max-width: 1100px) {
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .grid-2 > .panel { margin-bottom: 0; }
}
@media (max-width: 900px) {
  :root { --topbar-h: 58px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 14px; padding-top: var(--safe-t); height: calc(var(--topbar-h) + var(--safe-t)); gap: 10px; }
  .topbar .tb-title, .topbar .tb-logo { display: block; }
  .searchbtn { flex: 0 0 40px; width: 40px; padding: 0; justify-content: center; }
  .searchbtn span, .searchbtn kbd { display: none; }
  .tb-avatar { display: block; }
  .tb-theme { display: none; }
  .content { padding: 16px 14px calc(var(--tabbar-h) + var(--safe-b) + 28px); }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head h2 { display: none; }
  .page-head p { margin-top: 0; }
  .page-head.keep h2 { display: block; font-size: 21px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.5) blur(16px); -webkit-backdrop-filter: saturate(1.5) blur(16px); border-top: 1px solid var(--line-2);
  }
  .tab { border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10.5px; font-weight: 650; color: var(--text-3); position: relative; }
  .tab .ic { width: 22px; height: 22px; }
  .tab.active { color: var(--brand-strong); }
  .tab.active .ic { stroke-width: 2.3; }
  .tab .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; font-size: 10px; border: 2px solid var(--surface); }
  body.in-thread .tabbar, body.in-thread .topbar { display: none; }
  .content.chat-mode { padding: 0; }
  .lc { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--topbar-h) - var(--safe-t) - var(--tabbar-h) - var(--safe-b)); border-radius: 0; border: none; box-shadow: none; min-height: 0; }
  body.in-thread .lc { height: 100dvh; }
  .lc-thread { display: none; }
  .lc.show-thread .lc-list { display: none; }
  .lc.show-thread .lc-thread { display: flex; }
  .lc-head { padding-top: calc(10px + var(--safe-t)); }
  .lc-back { display: grid; }
  .lc-msgs { padding: 14px 10px 8px; }
  .bubble { max-width: 86%; }
  .lc-composer { padding-bottom: calc(10px + var(--safe-b)); }
  .lc-info { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { margin-top: 10px; }
  .hero { padding: 20px; border-radius: var(--r-lg); }
  .hero h2 { font-size: 20px; }
  .panel { padding: 16px; border-radius: 14px; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  #toasts { left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); align-items: stretch; }
  .toast { max-width: none; }
  .popover { right: 12px; top: calc(var(--topbar-h) + var(--safe-t) - 4px); }
  /* modals become bottom sheets */
  .overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none !important; border-radius: 22px 22px 0 0; max-height: 92dvh; padding: 10px 18px calc(22px + var(--safe-b)); transform: translateY(100%); transition: transform .28s var(--ease); border-bottom: none; }
  .sheet-grip { display: block; width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 2px auto 14px; }
  .modal-actions { position: sticky; bottom: calc(-22px - var(--safe-b)); background: var(--surface); padding: 12px 0 calc(4px + var(--safe-b)); margin-bottom: calc(-22px - var(--safe-b)); }
  .modal-actions .btn { flex: 1; justify-content: center; padding: 12px; }
  .palette { padding-top: calc(10px + var(--safe-t)); }
  /* tables become cards */
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { border: 1px solid var(--line-2); border-radius: 14px; padding: 6px 14px; margin-bottom: 10px; background: var(--surface); }
  table.rtable tbody tr:hover { background: var(--surface); }
  table.rtable td { border: none; padding: 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; border-bottom: 1px solid var(--line-2); }
  table.rtable td:last-child { border-bottom: none; }
  table.rtable td::before { content: attr(data-label); font-size: 11.5px; font-weight: 650; color: var(--text-3); text-align: left; flex-shrink: 0; }
  table.rtable td[data-label=""]::before { display: none; }
  table.rtable td.td-actions { justify-content: flex-end; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
  table.rtable td.td-actions .btn + .btn { margin-left: 0; }
  table.rtable td.td-first { justify-content: flex-start; text-align: left; font-size: 14.5px; }
  table.rtable td.td-first::before { display: none; }
  table.rtable .clip { max-width: 60vw; white-space: normal; }
  .panel.flush table.rtable { padding: 12px; display: block; }
  .hbar { grid-template-columns: 96px 1fr 30px; }
}
@media (min-width: 901px) { .only-mobile { display: none !important; } }
@media (max-width: 900px) { .only-desktop { display: none !important; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- v3: composer tools, private notes, saved-reply picker ---------- */
.composer-tools { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; overflow-x: auto; }
.ctool { display: inline-flex; align-items: center; gap: 5px; border: none; background: none; color: var(--text-3); font-size: 12.5px; font-weight: 620; padding: 5px 9px; border-radius: 8px; white-space: nowrap; }
.ctool .ic { width: 15px; height: 15px; }
.ctool:hover { background: var(--hover); color: var(--text); }
.ctool.on { background: var(--brand-soft); color: var(--brand-strong); }
.lc-composer.note-mode .ctool.on { background: rgba(245, 180, 0, .16); color: #9a6b00; }
.lc-composer.note-mode textarea { background: #fff8e1; border-color: #f2d78a; color: #3d2f00; }
:root[data-theme="dark"] .lc-composer.note-mode textarea { background: #2b2410; border-color: #6b5615; color: #f5e6b8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lc-composer.note-mode textarea { background: #2b2410; border-color: #6b5615; color: #f5e6b8; } }
.sendbtn.note { background: #d39e00; box-shadow: none; }
.note-bubble { align-self: center; max-width: min(86%, 560px); background: #fff4cc; color: #3d2f00; border: 1px dashed #e6c35c; border-radius: 10px; padding: 8px 11px 6px; font-size: 13.5px; line-height: 1.45; margin: 6px 0; white-space: pre-wrap; }
:root[data-theme="dark"] .note-bubble { background: #2b2410; color: #f5e6b8; border-color: #6b5615; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note-bubble { background: #2b2410; color: #f5e6b8; border-color: #6b5615; } }
.sr-picker { position: absolute; left: 0; right: 52px; bottom: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-3); padding: 6px; z-index: 5; max-height: 260px; overflow-y: auto; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 8px; cursor: pointer; min-width: 0; }
.sr-item:hover { background: var(--brand-soft); }
.sr-item .tag { flex-shrink: 0; margin: 0; }
.lc-list-head .seg button { padding: 6px 8px; font-size: 12px; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ---------- AI assistant ---------- */
.ai-btn { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-radius: 11px; border: 1px solid transparent; color: #fff; font-weight: 650; font-size: 13.5px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #10b981); box-shadow: 0 6px 18px -8px rgba(124,58,237,.6); transition: transform .12s, filter .12s; }
.ai-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.ai-btn .ic { width: 17px; height: 17px; }
.ai-orb { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #7c3aed, #10b981); flex-shrink: 0; }
.ai-orb.lg { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px; }
.ai-orb.lg .ic { width: 26px; height: 26px; }
.ai-orb.sm { width: 28px; height: 28px; border-radius: 9px; }
.ai-orb.sm .ic { width: 15px; height: 15px; }
.ai-panel { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
.ai-backdrop { position: absolute; inset: 0; background: rgba(5,10,8,.35); opacity: 0; transition: opacity .2s; }
.ai-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--sh-3); display: flex; flex-direction: column; transform: translateX(104%); transition: transform .24s var(--ease); }
.ai-panel.open { pointer-events: auto; }
.ai-panel.open .ai-backdrop { opacity: 1; }
.ai-panel.open .ai-sheet { transform: none; }
.ai-head { display: flex; align-items: center; gap: 11px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--line-2); padding-top: calc(14px + var(--safe-t)); }
.ai-head b { font-size: 15px; }
.ai-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.ai-foot { padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line-2); background: var(--surface); }
.ai-hello { text-align: center; margin: auto 0; padding: 10px 6px; }
.ai-hello h3 { font-size: 18px; }
.ai-hello p { font-size: 13px; margin: 6px 0 16px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 560; color: var(--text); }
.chip-btn:hover { border-color: #a78bfa; background: color-mix(in srgb, #7c3aed 7%, var(--surface)); }
.ai-msg { max-width: 92%; padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; animation: pop .18s var(--ease); }
.ai-msg.user { align-self: flex-end; background: var(--brand-strong); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line-2); border-bottom-left-radius: 4px; white-space: normal; }
.ai-card { margin-top: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); white-space: normal; }
.ai-card-h { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.wa-preview { background: var(--bubble-out); color: var(--bubble-text); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; line-height: 1.45; box-shadow: 0 1px .5px rgba(0,0,0,.1); max-width: 340px; }
.wa-h { font-weight: 750; margin-bottom: 4px; }
.wa-f { font-size: 11.5px; opacity: .6; margin-top: 6px; }
.wa-btn { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px -10px -2px; padding: 8px 4px 2px; border-top: 1px solid color-mix(in srgb, var(--bubble-text) 12%, transparent); color: #1a9bd7; font-weight: 650; font-size: 13px; }
.wa-btn .ic { width: 14px; height: 14px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-inline { display: flex; align-items: center; gap: 8px; padding: 10px; margin-bottom: 16px; border-radius: 12px; border: 1px dashed #a78bfa; background: color-mix(in srgb, #7c3aed 5%, var(--surface)); }
.ai-inline .input { flex: 1; min-width: 0; }
@media (max-width: 900px) {
  .ai-btn { width: 40px; padding: 0; justify-content: center; }
  .ai-btn span { display: none; }
  .ai-sheet { width: 100vw; border-left: none; }
}
