/* ============================================================================
   AI Doctor — Control Center design system
   Healthcare-grade: trust (teal), clarity, restraint. Light + dark.
   Dependency-free. ========================================================== */

:root {
  --brand: #0d9488;          /* teal-600 */
  --brand-600: #0f766e;
  --brand-700: #115e59;
  --brand-soft: #ccfbf1;
  --brand-glow: rgba(13, 148, 136, .16);

  --bg: #f6f8fa;
  --bg-elev: #ffffff;
  --bg-sunken: #eef1f5;
  --surface: #ffffff;
  --surface-hover: #f4f6f9;
  --border: #e3e8ee;
  --border-strong: #d3dae2;

  --text: #0f1720;
  --text-2: #495364;
  --text-3: #77839a;
  --text-inv: #ffffff;

  --danger: #e5484d;
  --danger-soft: #ffe9e9;
  --warn: #d98413;
  --warn-soft: #fdf0d5;
  --ok: #30a46c;
  --ok-soft: #e4f5ec;
  --info: #3b82f6;
  --info-soft: #e6efff;
  --violet: #7c66dc;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 4px 8px rgba(16, 24, 40, .06);
  --shadow-pop: 0 16px 48px rgba(16, 24, 40, .18);

  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sidebar-w: 250px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --brand: #2dd4bf;
  --brand-600: #14b8a6;
  --brand-700: #0d9488;
  --brand-soft: #0b3b38;
  --brand-glow: rgba(45, 212, 191, .14);

  --bg: #0a0e14;
  --bg-elev: #10151d;
  --bg-sunken: #0c1119;
  --surface: #10151d;
  --surface-hover: #161d27;
  --border: #1e2733;
  --border-strong: #2a3542;

  --text: #eaf0f7;
  --text-2: #a7b4c6;
  --text-3: #6b7a90;
  --text-inv: #06231f;

  --danger: #ff6369;
  --danger-soft: #2b1416;
  --warn: #f2c15b;
  --warn-soft: #2a2011;
  --ok: #4cc38a;
  --ok-soft: #10261c;
  --info: #6ea8fe;
  --info-soft: #101c2e;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  --shadow-pop: 0 20px 56px rgba(0,0,0,.65);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--brand-glow); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid var(--bg); }

/* ---- Boot / loading ------------------------------------------------------ */
.app-loading { display: grid; place-items: center; height: 100vh; }
.boot { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.boot-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  position: relative; box-shadow: var(--shadow-lg);
}
.boot-logo::before, .boot-logo::after {
  content: ""; position: absolute; background: #fff; border-radius: 3px;
}
.boot-logo::before { width: 26px; height: 5px; top: 23.5px; left: 13px; }
.boot-logo::after { width: 5px; height: 26px; top: 13px; left: 23.5px; }
.boot-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- App layout ---------------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  position: relative; box-shadow: 0 3px 10px var(--brand-glow);
}
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: #fff; border-radius: 2px; }
.brand-mark::before { width: 17px; height: 3.4px; top: 15.3px; left: 8.5px; }
.brand-mark::after { width: 3.4px; height: 17px; top: 8.5px; left: 15.3px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--text-3); font-weight: 500; margin-top: -2px; }

.nav { padding: 12px 12px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase;
  color: var(--text-3); padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm); color: var(--text-2);
  font-weight: 550; font-size: 13.5px; margin-bottom: 2px;
  transition: background .12s, color .12s; position: relative;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-700); font-weight: 650; }
[data-theme="dark"] .nav-item.active { color: var(--brand); }
.nav-item.active .ico { color: var(--brand-700); }
[data-theme="dark"] .nav-item.active .ico { color: var(--brand); }
.nav-item .ico { width: 18px; height: 18px; flex: none; color: var(--text-3); }
.nav-item:hover .ico { color: var(--text-2); }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px;
  font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px;
  display: grid; place-items: center; padding: 0 5px;
}
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }

/* ---- Topbar -------------------------------------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 62px; display: flex; align-items: center; gap: 16px;
  padding: 0 26px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; font-weight: 500; }
.topbar-spacer { flex: 1; }
.hamburger { display: none; }

.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center;
  transition: background .12s, border-color .12s;
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.icon-btn .ico { width: 18px; height: 18px; }

.content { padding: 26px; max-width: 1420px; width: 100%; margin: 0 auto; }

/* ---- Typography helpers -------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; font-weight: 750; letter-spacing: -.4px; }
.page-head p { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .92em; }

/* ---- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; font-weight: 680; letter-spacing: -.2px; }
.card-head .sub { font-size: 12px; color: var(--text-3); }

.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

/* ---- KPI tiles ----------------------------------------------------------- */
.kpi { padding: 18px 18px 16px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: 9px; color: var(--text-3); font-size: 12.5px; font-weight: 600; }
.kpi-top .ico { width: 16px; height: 16px; }
.kpi-val { font-size: 29px; font-weight: 760; letter-spacing: -1px; margin-top: 10px; line-height: 1; }
.kpi-foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 12px; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.trend.up { color: var(--ok); background: var(--ok-soft); }
.trend.down { color: var(--danger); background: var(--danger-soft); }
.trend.flat { color: var(--text-3); background: var(--bg-sunken); }
.kpi-spark { position: absolute; right: 0; bottom: 0; opacity: .5; pointer-events: none; }
.kpi.accent-danger .kpi-val { color: var(--danger); }
.kpi.accent-ok .kpi-val { color: var(--ok); }

/* ---- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650;
  padding: 2.5px 9px; border-radius: 20px; border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.gray { background: var(--bg-sunken); color: var(--text-2); }
.badge.teal { background: var(--brand-soft); color: var(--brand-700); }
[data-theme="dark"] .badge.teal { color: var(--brand); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.violet { background: color-mix(in srgb, var(--violet) 15%, transparent); color: var(--violet); }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px var(--brand-glow); }
.btn.primary:hover { background: var(--brand-600); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Inputs -------------------------------------------------------------- */
.input, .select {
  height: 36px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
  transition: border-color .12s, box-shadow .12s; width: 100%;
}
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.search { position: relative; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.search .input { padding-left: 34px; }
.field-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 620; color: var(--text-3); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .4px; padding: 11px 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface);
}
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-hover); }
.tbl tr.clickable { cursor: pointer; }
.cell-strong { font-weight: 620; }
.cell-sub { color: var(--text-3); font-size: 12px; }

/* ---- Charts -------------------------------------------------------------- */
.chart { width: 100%; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); font-weight: 550; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-center { text-align: center; }
.donut-center .big { font-size: 26px; font-weight: 760; letter-spacing: -.5px; }
.donut-center .lbl { font-size: 11px; color: var(--text-3); }

/* ---- Insight cards ------------------------------------------------------- */
.insight {
  display: flex; gap: 13px; padding: 15px 16px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface); align-items: flex-start;
}
.insight + .insight { margin-top: 10px; }
.insight-ic { width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; }
.insight-ic .ico { width: 18px; height: 18px; }
.insight.critical .insight-ic { background: var(--danger-soft); color: var(--danger); }
.insight.critical { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.insight.warning .insight-ic { background: var(--warn-soft); color: var(--warn); }
.insight.info .insight-ic { background: var(--info-soft); color: var(--info); }
.insight.ok .insight-ic { background: var(--ok-soft); color: var(--ok); }
.insight-body h4 { font-size: 13.5px; font-weight: 660; margin-bottom: 2px; }
.insight-body p { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }

/* ---- Feed / list items --------------------------------------------------- */
.feed-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-ic { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--bg-sunken); color: var(--text-2); }
.feed-ic .ico { width: 16px; height: 16px; }
.feed-main { min-width: 0; flex: 1; }
.feed-title { font-size: 13px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.feed-time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* ---- Bars (horizontal breakdown) ---------------------------------------- */
.hbar-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 7px 0; }
.hbar-label { font-size: 12.5px; font-weight: 550; }
.hbar-track { grid-column: 1 / -1; height: 8px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; margin-top: 2px; }
.hbar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-600)); }
.hbar-val { font-size: 12px; color: var(--text-3); font-weight: 600; }

/* ---- Login --------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-glow), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card .card { padding: 30px; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-logo .brand-mark { width: 48px; height: 48px; border-radius: 13px; }
.login-logo .brand-mark::before { width: 24px; height: 4.6px; top: 21.7px; left: 12px; }
.login-logo .brand-mark::after { width: 4.6px; height: 24px; top: 12px; left: 21.7px; }
.login-title { font-size: 18px; font-weight: 730; text-align: center; }
.login-sub { font-size: 12.5px; color: var(--text-3); text-align: center; margin-top: 3px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.login-err { color: var(--danger); font-size: 12.5px; margin-top: 10px; text-align: center; min-height: 16px; }

/* ---- Modal / drawer ------------------------------------------------------ */
.overlay { position: fixed; inset: 0; background: rgba(9, 13, 20, .5); backdrop-filter: blur(3px);
  z-index: 100; display: grid; place-items: center; padding: 24px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 560px; max-width: 94vw;
  background: var(--bg-elev); border-left: 1px solid var(--border); box-shadow: var(--shadow-pop);
  z-index: 101; display: flex; flex-direction: column; animation: slidein .2s cubic-bezier(.2,.8,.2,1); }
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-head h3 { font-size: 16px; font-weight: 700; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal { width: 100%; max-width: 440px; }
.modal .card { padding: 24px; }
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal p { font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---- Toast --------------------------------------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 550; animation: slideup .2s; min-width: 240px; }
@keyframes slideup { from { transform: translateY(12px); opacity: 0; } }
.toast .ico { width: 18px; height: 18px; flex: none; }
.toast.ok .ico { color: var(--ok); } .toast.err .ico { color: var(--danger); } .toast.info .ico { color: var(--info); }

/* ---- Detail rows (drawer) ------------------------------------------------ */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; }
.dl dt { color: var(--text-3); font-weight: 550; }
.dl dd { font-weight: 550; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-3); margin: 22px 0 10px; }
.chat-turn { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 10px; }
.chat-turn .q { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.chat-turn .a { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; line-height: 1.5; }
.chat-turn .meta { display: flex; gap: 8px; align-items: center; margin-top: 9px; flex-wrap: wrap; }

/* ---- Pagination ---------------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 0; }
.pager .info { font-size: 12.5px; color: var(--text-3); }
.pager .controls { display: flex; gap: 8px; }

/* ---- Skeleton ------------------------------------------------------------ */
.sk { background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--surface-hover) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -135% 0; } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-kpi { height: 108px; border-radius: var(--r-lg); }

/* ---- Status pills (health) ---------------------------------------------- */
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-name { display: flex; align-items: center; gap: 10px; font-weight: 560; font-size: 13.5px; }
.status-name .ico { width: 18px; height: 18px; color: var(--text-3); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 3px 10px; border-radius: 20px; }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.status-pill.ok { background: var(--ok-soft); color: var(--ok); } .status-pill.ok .dot { background: var(--ok); }
.status-pill.bad { background: var(--danger-soft); color: var(--danger); } .status-pill.bad .dot { background: var(--danger); }
.status-pill.warn { background: var(--warn-soft); color: var(--warn); } .status-pill.warn .dot { background: var(--warn); }

/* ---- Empty state --------------------------------------------------------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .ico { width: 34px; height: 34px; margin-bottom: 12px; opacity: .6; }
.empty h4 { font-size: 14px; font-weight: 620; color: var(--text-2); margin-bottom: 4px; }

/* ---- Config editor ------------------------------------------------------- */
.cfg-row { display: grid; grid-template-columns: 1fr 220px; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.cfg-row:last-child { border-bottom: none; }
.cfg-key { font-weight: 600; font-size: 13.5px; font-family: var(--mono); }
.cfg-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 20px; transition: .18s; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .18s; box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---- Segmented control --------------------------------------------------- */
.seg { display: inline-flex; background: var(--bg-sunken); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; color: var(--text-2); font-weight: 600; font-size: 12.5px; padding: 5px 12px; border-radius: 6px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, 1fr); } .span-2 { grid-column: span 2; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; transform: translateX(-100%); transition: transform .22s; width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .hamburger { display: grid; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .content { padding: 18px; }
}
@media (max-width: 560px) {
  .cols-4 { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .cfg-row { grid-template-columns: 1fr; gap: 10px; }
  .topbar { padding: 0 16px; }
}
