/* ============================================================
   InstantData Proxy Dashboard — Design System
   common.css: tokens (dark + light), reset, typography, components
   ============================================================

   Theme is driven by <html data-theme="dark|light">, set before first
   paint by the inline script in layout.hbs (persisted in localStorage).
   Dark is the brand default; light re-maps the same orange accent onto
   neutral light surfaces. Every color in the app goes through a token
   below - components never hardcode rgba() for surfaces or text.
*/

/* ---------- Tokens: shared ---------- */
:root {
  --font-sans: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

  --primary: #FF5E00;
  --primary-hover: #FF7A2E;
  --primary-dark: #E65100;
  --primary-rgb: 255, 94, 0;
  --on-primary: #FFFFFF;

  --success: #10B981;  --success-rgb: 16, 185, 129;
  --warning: #F59E0B;  --warning-rgb: 245, 158, 11;
  --danger:  #EF4444;  --danger-rgb: 239, 68, 68;
  --info:    #3B82F6;  --info-rgb: 59, 130, 246;
  --purple:  #A855F7;  --purple-rgb: 168, 85, 247;
  --pink:    #EC4899;  --pink-rgb: 236, 72, 153;
  --teal:    #14B8A6;  --teal-rgb: 20, 184, 166;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 40px;

  --fs-xs: 0.72rem; --fs-sm: 0.8rem; --fs-base: 0.9rem; --fs-md: 1rem;
  --fs-lg: 1.15rem; --fs-xl: 1.35rem; --fs-2xl: 1.7rem; --fs-3xl: 2.1rem;

  --control-h: 40px;
  --control-h-sm: 32px;
  --control-h-lg: 48px;
  --row-pad-y: 14px;          /* table density; overridden by [data-density] */

  --ease: cubic-bezier(.2,.7,.2,1);
  --t-fast: 120ms var(--ease);
  --t: 200ms var(--ease);

  --z-dropdown: 1200;
  --z-sticky: 900;
  --z-sidebar: 1000;
  --z-drawer: 1500;
  --z-modal: 2000;
  --z-toast: 3000;

  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;
  --content-max: 1480px;
}

/* ---------- Tokens: dark (default) ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F0F10;
  --bg-glow-1: rgba(255, 94, 0, 0.06);
  --bg-glow-2: rgba(255, 94, 0, 0.035);
  --surface: #171718;
  --surface-2: #1E1E20;
  --surface-3: #262628;
  --surface-hover: rgba(255, 255, 255, 0.035);
  --surface-active: rgba(255, 255, 255, 0.06);
  --overlay: rgba(0, 0, 0, 0.7);
  --sidebar-bg: #121213;
  --topbar-bg: rgba(15, 15, 16, 0.82);

  --text: #F3F4F6;
  --text-2: #B9BCC3;
  --text-muted: #8A8F98;
  --text-dim: #5E636B;
  --text-inverse: #111111;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-primary: rgba(var(--primary-rgb), 0.35);

  --primary-text: #FF7A2E;
  --primary-soft: rgba(var(--primary-rgb), 0.12);
  --primary-soft-hover: rgba(var(--primary-rgb), 0.2);

  --input-bg: rgba(255, 255, 255, 0.04);
  --input-bg-focus: rgba(255, 255, 255, 0.06);
  --input-border: rgba(255, 255, 255, 0.12);
  --code-bg: rgba(0, 0, 0, 0.35);
  --thead-bg: rgba(var(--primary-rgb), 0.07);
  --track: rgba(255, 255, 255, 0.07);
  --skeleton: rgba(255, 255, 255, 0.06);
  --skeleton-shine: rgba(255, 255, 255, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --shadow-primary: 0 6px 18px rgba(var(--primary-rgb), 0.3);

  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-tick: #8A8F98;
  --chart-tooltip-bg: #1E1E20;
}

/* ---------- Tokens: light ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F5F7;
  --bg-glow-1: rgba(255, 94, 0, 0.05);
  --bg-glow-2: rgba(255, 94, 0, 0.03);
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EEF0F3;
  --surface-hover: rgba(17, 17, 17, 0.035);
  --surface-active: rgba(17, 17, 17, 0.06);
  --overlay: rgba(17, 17, 17, 0.45);
  --sidebar-bg: #FFFFFF;
  --topbar-bg: rgba(244, 245, 247, 0.85);

  --text: #15171A;
  --text-2: #3D4148;
  --text-muted: #6B7079;
  --text-dim: #9AA0A9;
  --text-inverse: #FFFFFF;

  --border: rgba(17, 17, 17, 0.08);
  --border-strong: rgba(17, 17, 17, 0.14);
  --border-primary: rgba(var(--primary-rgb), 0.4);

  --primary-text: #D94E00;
  --primary-soft: rgba(var(--primary-rgb), 0.1);
  --primary-soft-hover: rgba(var(--primary-rgb), 0.18);

  --input-bg: #FFFFFF;
  --input-bg-focus: #FFFFFF;
  --input-border: rgba(17, 17, 17, 0.14);
  --code-bg: #F1F2F4;
  --thead-bg: rgba(var(--primary-rgb), 0.06);
  --track: rgba(17, 17, 17, 0.08);
  --skeleton: rgba(17, 17, 17, 0.06);
  --skeleton-shine: rgba(17, 17, 17, 0.12);

  --shadow-sm: 0 1px 2px rgba(17, 17, 17, 0.06);
  --shadow: 0 6px 20px rgba(17, 17, 17, 0.08);
  --shadow-lg: 0 20px 50px rgba(17, 17, 17, 0.16);
  --shadow-primary: 0 6px 18px rgba(var(--primary-rgb), 0.25);

  --chart-grid: rgba(17, 17, 17, 0.07);
  --chart-tick: #6B7079;
  --chart-tooltip-bg: #15171A;
}

/* Table density preference (persisted client-side) */
:root[data-density="compact"] { --row-pad-y: 8px; --control-h: 36px; }
:root[data-density="comfortable"] { --row-pad-y: 18px; }

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t), color var(--t);
}
/* Ambient brand glow: a fixed pseudo-element instead of background-attachment:fixed (janky on iOS) */
body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(900px 600px at 15% 0%, var(--bg-glow-1), transparent 60%), radial-gradient(900px 700px at 100% 100%, var(--bg-glow-2), transparent 60%); }
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--primary-text); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--primary); }
::selection { background: rgba(var(--primary-rgb), 0.35); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-xs); }
[hidden] { display: none !important; }

h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
h5 { font-size: var(--fs-base); }
p { color: var(--text-2); }
small, .text-sm { font-size: var(--fs-sm); }
strong { font-weight: 600; color: var(--text); }
code, kbd, pre, .mono { font-family: var(--font-mono); }
code { font-size: 0.85em; background: var(--code-bg); border: 1px solid var(--border); padding: 2px 6px; border-radius: var(--radius-xs); color: var(--primary-text); }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; font-size: 0.82rem; line-height: 1.6; color: var(--text); }
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
kbd { font-size: 0.75em; padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--radius-xs); background: var(--surface-2); color: var(--text-2); }
hr, .divider { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: padding-box; }

/* ---------- Utilities ---------- */
.flex { display: flex; }  .inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; } .items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; } .justify-center { justify-content: center; }
.flex-1 { flex: 1 1 0%; min-width: 0; }
.grid { display: grid; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); } .gap-5 { gap: var(--space-5); } .gap-6 { gap: var(--space-6); }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); } .mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: var(--space-1); } .mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); } .mb-6 { margin-bottom: var(--space-6); }
.ml-auto { margin-left: auto; } .mr-auto { margin-right: auto; }
.w-full { width: 100%; }
.text-center { text-align: center; } .text-right { text-align: right; } .text-left { text-align: left; }
.text-muted { color: var(--text-muted); } .text-dim { color: var(--text-dim); } .text-2 { color: var(--text-2); }
.text-primary { color: var(--primary-text); } .text-success { color: var(--success); } .text-warning { color: var(--warning); } .text-danger { color: var(--danger); } .text-info { color: var(--info); }
.text-xs { font-size: var(--fs-xs); } .text-md { font-size: var(--fs-md); } .text-lg { font-size: var(--fs-lg); }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.upper { text-transform: uppercase; letter-spacing: 0.06em; }
.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.break-all { word-break: break-all; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }

/* Responsive visibility. sm < 640, md < 768, lg < 1024 */
@media (max-width: 639px) { .hide-sm { display: none !important; } }
@media (min-width: 640px) { .show-sm { display: none !important; } }
@media (max-width: 767px) { .hide-md { display: none !important; } }
@media (min-width: 768px) { .show-md { display: none !important; } }
@media (max-width: 1023px) { .hide-lg { display: none !important; } }
@media (min-width: 1024px) { .show-lg { display: none !important; } }

/* Responsive grids */
.grid-auto { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(var(--min, 260px), 1fr)); }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--space-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1199px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1023px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }
.span-2 { grid-column: span 2; }
@media (max-width: 639px) { .span-2 { grid-column: span 1; } }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-h); padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-base); font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
}
.btn i { font-size: 0.95em; }
.btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { --btn-bg: linear-gradient(135deg, var(--primary), var(--primary-dark)); --btn-fg: var(--on-primary); --btn-bd: transparent; box-shadow: var(--shadow-primary); }
.btn-primary:hover { --btn-bg: linear-gradient(135deg, var(--primary-hover), var(--primary)); color: var(--on-primary); border-color: transparent; box-shadow: 0 8px 22px rgba(var(--primary-rgb), 0.38); }
.btn-secondary, .btn-outline { --btn-bg: transparent; --btn-fg: var(--text); --btn-bd: var(--border-strong); }
.btn-secondary:hover, .btn-outline:hover { background: var(--surface-hover); border-color: var(--primary); color: var(--primary-text); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: transparent; }
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-text); --btn-bd: transparent; }
.btn-soft:hover { background: var(--primary-soft-hover); color: var(--primary-text); border-color: transparent; }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-bd: transparent; }
.btn-success:hover { background: #0EA371; color: #fff; }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger:hover { background: #DC2626; color: #fff; }
.btn-warning { --btn-bg: var(--warning); --btn-fg: #1a1a1a; --btn-bd: transparent; }
.btn-warning:hover { background: #D97706; color: #1a1a1a; }
.btn-danger-soft { --btn-bg: rgba(var(--danger-rgb), 0.12); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }
.btn-success-soft { --btn-bg: rgba(var(--success-rgb), 0.12); --btn-fg: var(--success); --btn-bd: transparent; }
.btn-success-soft:hover { background: var(--success); color: #fff; }
.btn-warning-soft { --btn-bg: rgba(var(--warning-rgb), 0.14); --btn-fg: var(--warning); --btn-bd: transparent; }
.btn-warning-soft:hover { background: var(--warning); color: #1a1a1a; }
.btn-info-soft { --btn-bg: rgba(var(--info-rgb), 0.12); --btn-fg: var(--info); --btn-bd: transparent; }
.btn-info-soft:hover { background: var(--info); color: #fff; }
.btn-link { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--primary-text); padding: 0; height: auto; }
.btn-link:hover { background: none; text-decoration: underline; }

.btn-xs { height: 28px; padding: 0 10px; font-size: var(--fs-xs); border-radius: 7px; gap: 6px; }
.btn-sm { height: var(--control-h-sm); padding: 0 12px; font-size: var(--fs-sm); border-radius: 8px; }
.btn-lg { height: var(--control-h-lg); padding: 0 24px; font-size: var(--fs-md); border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }
.btn-icon.btn-xs { width: 28px; }
.btn-pill { border-radius: var(--radius-pill); }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 10px 0 0 10px; }
.btn-group .btn:last-child { border-radius: 0 10px 10px 0; }
.btn-group .btn + .btn { margin-left: -1px; }

/* ---------- Forms ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group + .form-group { margin-top: var(--space-4); }
.form-grid .form-group + .form-group, .form-row .form-group + .form-group { margin-top: 0; }
.form-label, label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.form-label i { color: var(--primary-text); font-size: 0.85em; }
.form-label .req { color: var(--danger); }
.form-hint { font-size: var(--fs-xs); color: var(--text-muted); }
.form-error { font-size: var(--fs-xs); color: var(--danger); }
/* :where() keeps the base rule at zero specificity so .input-sm, .input-icon > input
   and page-level sizing rules win without !important */
.form-control,
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"])),
:where(select), :where(textarea) {
  width: 100%; min-width: 0; height: var(--control-h); padding: 0 14px;
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 10px;
  color: var(--text); font-size: var(--fs-base);
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
:where(textarea) { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-dim); }
input:focus, select:focus, textarea:focus, .form-control:focus {
  outline: none; border-color: var(--primary); background: var(--input-bg-focus);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(var(--danger-rgb), 0.12); }
:where(select) {
  cursor: pointer; appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238A8F98' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select[multiple] { height: auto; padding: 8px; background-image: none; }
select[multiple] option { padding: 6px 8px; border-radius: 6px; }
select option { background: var(--surface-2); color: var(--text); }
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { color-scheme: inherit; }
input[type="number"] { -moz-appearance: textfield; }
.input-sm, input.input-sm, select.input-sm { height: var(--control-h-sm); font-size: var(--fs-sm); padding: 0 10px; border-radius: 8px; }
.input-sm select, select.input-sm { padding-right: 30px; }

.input-group { display: flex; align-items: stretch; width: 100%; min-width: 0; }
.input-group > * { min-width: 0; }
.input-group > input, .input-group > select, .input-group > .form-control { flex: 1 1 auto; border-radius: 0; }
.input-group > :first-child { border-radius: 10px 0 0 10px; }
.input-group > :last-child { border-radius: 0 10px 10px 0; }
.input-group > * + * { margin-left: -1px; }
.input-group > .btn { flex-shrink: 0; }
.input-addon { display: inline-flex; align-items: center; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--input-border); color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; font-size: 0.9em; }
.input-icon > input, .input-icon > select { padding-left: 38px; }
.input-icon.icon-right > i { left: auto; right: 13px; }
.input-icon.icon-right > input { padding-left: 14px; padding-right: 38px; }
.input-icon .input-action { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.form-grid.cols-3 { --cols: 3; }
.form-grid.cols-4 { --cols: 4; }
@media (max-width: 1023px) { .form-grid.cols-4 { --cols: 2; } .form-grid.cols-3 { --cols: 2; } }
@media (max-width: 639px) { .form-grid, .form-grid.cols-3, .form-grid.cols-4 { --cols: 1; } }
.form-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-actions { display: flex; gap: var(--space-3); justify-content: flex-end; align-items: center; flex-wrap: wrap; padding-top: var(--space-4); margin-top: var(--space-5); border-top: 1px solid var(--border); }
.form-section-title { font-size: var(--fs-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: var(--space-5) 0 var(--space-3); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-section-title:first-child { margin-top: 0; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }

/* Checkbox / radio */
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-base); color: var(--text); font-weight: 400; }
.check input[type="checkbox"], .check input[type="radio"], input[type="checkbox"], input[type="radio"] {
  appearance: none; width: 18px; height: 18px; flex-shrink: 0; margin: 0;
  border: 1.5px solid var(--border-strong); border-radius: 5px; background: var(--input-bg);
  display: inline-grid; place-content: center; cursor: pointer; transition: all var(--t-fast);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before { content: ''; width: 10px; height: 10px; transform: scale(0); transition: transform var(--t-fast);
  background: #fff; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
input[type="radio"]::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: scale(0); transition: transform var(--t-fast); }
input[type="checkbox"]:checked, input[type="radio"]:checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:indeterminate::before { transform: scale(1); clip-path: none; height: 2px; width: 10px; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.check-list { display: flex; flex-direction: column; gap: 10px; }
.check-grid { display: grid; gap: 10px 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.check-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast); }
.check-card:hover { border-color: var(--border-strong); }
.check-card:has(input:checked) { border-color: var(--border-primary); background: var(--primary-soft); }
.check-card input { margin-top: 2px; }
.check-card .check-title { font-weight: 600; color: var(--text); font-size: var(--fs-base); }
.check-card .check-desc { font-size: var(--fs-xs); color: var(--text-muted); }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--text); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .switch-track { position: relative; width: 44px; height: 24px; border-radius: 24px; background: var(--track); border: 1px solid var(--border); transition: background var(--t), border-color var(--t); flex-shrink: 0; }
.switch .switch-track::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,0.4); transition: transform var(--t); }
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-color: transparent; }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; cursor: not-allowed; }
.switch.switch-sm .switch-track { width: 36px; height: 20px; }
.switch.switch-sm .switch-track::after { width: 14px; height: 14px; }
.switch.switch-sm input:checked + .switch-track::after { transform: translateX(16px); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; max-width: 100%; overflow-x: auto; }
.seg-btn { height: 30px; padding: 0 12px; border-radius: 7px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); white-space: nowrap; transition: all var(--t-fast); display: inline-flex; align-items: center; gap: 6px; }
.seg-btn:hover { color: var(--text); background: var(--surface-hover); }
.seg-btn.active { background: var(--surface); color: var(--primary-text); box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .seg-btn.active, :root:not([data-theme="light"]) .seg-btn.active { background: var(--surface-3); }
.seg.seg-primary .seg-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }

/* Pills (period selectors etc.) */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { height: 32px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; transition: all var(--t-fast); white-space: nowrap; }
.pill:hover { border-color: var(--border-primary); color: var(--text); }
.pill.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-color: transparent; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card { margin-top: var(--space-5); }
:where(.grid, .grid-2, .grid-3, .grid-4, .grid-auto, .admin-cols, .form-grid, .stats-grid) > .card + .card { margin-top: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-header .card-title { margin: 0; }
.card-title { font-size: var(--fs-lg); font-weight: 600; display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title i { color: var(--primary-text); font-size: 0.95em; }
.card-title .badge { margin-left: 4px; }
.card-subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; font-weight: 400; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.card-body { padding: 22px; }
.card-body + .card-body { border-top: 1px solid var(--border); }
.card-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.card.is-flush .card-body { padding: 0; }
.card.is-compact .card-header { padding: 14px 18px; }
.card.is-compact .card-body { padding: 18px; }
.card-accent { border-top: 3px solid var(--accent, var(--primary)); }
.card-accent-success { --accent: var(--success); } .card-accent-danger { --accent: var(--danger); } .card-accent-warning { --accent: var(--warning); } .card-accent-info { --accent: var(--info); }
.card-hover { transition: border-color var(--t), box-shadow var(--t), transform var(--t); }
.card-hover:hover { border-color: var(--border-primary); box-shadow: var(--shadow); }
.card.is-danger { border-color: rgba(var(--danger-rgb), 0.5); }
.card.is-success { border-color: rgba(var(--success-rgb), 0.5); }
.card.is-warning { border-color: rgba(var(--warning-rgb), 0.5); }
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel-title { font-size: var(--fs-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-title i { color: var(--primary-text); }
@media (max-width: 639px) {
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .card-footer { padding: 12px 16px; }
  .panel { padding: 14px; }
}

/* ---------- Stat tiles ---------- */
.stats-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: var(--space-6); }
.stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; box-shadow: var(--shadow-sm); transition: border-color var(--t), box-shadow var(--t); }
.stat::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--accent, var(--primary)); opacity: 0.9; }
.stat:hover { border-color: var(--border-primary); box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; color: var(--accent, var(--primary)); background: color-mix(in srgb, var(--accent, var(--primary)) 14%, transparent); flex-shrink: 0; }
.stat-value { font-size: var(--fs-2xl); font-weight: 700; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-value small { font-size: 0.5em; font-weight: 500; color: var(--text-muted); margin-left: 2px; }
.stat-foot { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); flex-wrap: wrap; }
.stat-delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: var(--fs-sm); }
.stat-delta.up { color: var(--success); } .stat-delta.down { color: var(--danger); } .stat-delta.flat { color: var(--text-muted); }
.stat-success { --accent: var(--success); } .stat-warning { --accent: var(--warning); } .stat-danger { --accent: var(--danger); } .stat-info { --accent: var(--info); } .stat-purple { --accent: var(--purple); } .stat-teal { --accent: var(--teal); }
.stat.is-alert { border-color: rgba(var(--danger-rgb), 0.5); background: linear-gradient(180deg, rgba(var(--danger-rgb), 0.08), transparent 60%), var(--surface); }
.stat.is-alert .stat-value { color: var(--danger); }
.stat .sparkline { position: absolute; right: 0; bottom: 0; width: 45%; height: 46px; opacity: 0.35; pointer-events: none; }
@media (min-width: 640px) and (max-width: 1023px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .stat { padding: 14px; } .stat-value { font-size: var(--fs-xl); } .stat-icon { width: 34px; height: 34px; font-size: 0.9rem; } }
@media (max-width: 379px) { .stats-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--radius-pill); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; line-height: 1; background: var(--surface-3); color: var(--text-2); border: 1px solid transparent; vertical-align: middle; }
.badge i { font-size: 0.85em; }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }
.badge-success { background: rgba(var(--success-rgb), 0.14); color: var(--success); }
.badge-warning { background: rgba(var(--warning-rgb), 0.16); color: #D97706; }
:root:not([data-theme="light"]) .badge-warning { color: var(--warning); }
.badge-danger { background: rgba(var(--danger-rgb), 0.14); color: var(--danger); }
.badge-info { background: rgba(var(--info-rgb), 0.14); color: var(--info); }
.badge-purple { background: rgba(var(--purple-rgb), 0.14); color: var(--purple); }
.badge-teal { background: rgba(var(--teal-rgb), 0.14); color: var(--teal); }
.badge-neutral { background: var(--surface-3); color: var(--text-muted); }
.badge-outline { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-lg { height: 26px; padding: 0 12px; font-size: var(--fs-sm); }
.badge.upper { text-transform: uppercase; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 500; color: var(--text-2); white-space: nowrap; }
.chip.mono { font-family: var(--font-mono); }
.chip .chip-x { color: var(--text-muted); cursor: pointer; }
.chip-xs { height: 20px; padding: 0 7px; font-size: 0.66rem; border-radius: 6px; }
.chip.is-ok { color: var(--success); border-color: rgba(var(--success-rgb), 0.35); background: rgba(var(--success-rgb), 0.08); }
.chip.is-warn { color: var(--warning); border-color: rgba(var(--warning-rgb), 0.4); background: rgba(var(--warning-rgb), 0.1); }
.chip.is-danger { color: var(--danger); border-color: rgba(var(--danger-rgb), 0.35); background: rgba(var(--danger-rgb), 0.08); }
.chip.is-primary { color: var(--primary-text); border-color: var(--border-primary); background: var(--primary-soft); }
.chip .chip-x:hover { color: var(--danger); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.status-dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(var(--success-rgb), 0.2); }
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(var(--danger-rgb), 0.2); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 0 3px rgba(var(--warning-rgb), 0.2); }
.status-dot.pulse { animation: pulse-dot 1.8s ease-in-out infinite; }

/* ---------- Avatars ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 0.8rem; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.02em; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.68rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.6rem; }
.avatar-admin { background: linear-gradient(135deg, var(--danger), #B91C1C); }
.avatar-moderator { background: linear-gradient(135deg, var(--warning), #B45309); }
.avatar-info { background: linear-gradient(135deg, var(--info), #1D4ED8); }
.avatar-neutral { background: var(--surface-3); color: var(--text-2); }
.identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.identity-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.identity-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity-sub { font-size: var(--fs-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Alerts ---------- */
.alert { --alert: var(--info); --alert-rgb: var(--info-rgb); display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); border: 1px solid rgba(var(--alert-rgb), 0.35); background: rgba(var(--alert-rgb), 0.09); color: var(--text); font-size: var(--fs-base); margin-bottom: var(--space-4); }
.alert > i:first-child { color: var(--alert); font-size: 1.05rem; margin-top: 2px; flex-shrink: 0; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: var(--text); }
.alert p, .alert-text { color: var(--text-2); font-size: var(--fs-sm); margin: 0; }
.alert .alert-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.alert-close { color: var(--text-muted); padding: 2px 4px; border-radius: 4px; }
.alert-close:hover { color: var(--text); background: var(--surface-hover); }
.alert-success { --alert: var(--success); --alert-rgb: var(--success-rgb); }
.alert-warning { --alert: var(--warning); --alert-rgb: var(--warning-rgb); }
.alert-danger, .alert-error { --alert: var(--danger); --alert-rgb: var(--danger-rgb); }
.alert-info { --alert: var(--info); --alert-rgb: var(--info-rgb); }
.alert-primary { --alert: var(--primary); --alert-rgb: var(--primary-rgb); }
.alert.is-compact { padding: 8px 12px; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.login-error { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--radius); border: 1px solid rgba(var(--danger-rgb), 0.35); background: rgba(var(--danger-rgb), 0.09); color: var(--danger); margin-bottom: var(--space-4); }

/* ---------- Tables ---------- */
.table-wrap { position: relative; width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card > .table-wrap, .card .card-body > .table-wrap:only-child { border: 0; border-radius: 0; }
.card.is-flush .table-wrap { border: 0; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: var(--table-min, 640px); font-size: var(--fs-base); }
.table th, .table td { padding: var(--row-pad-y) 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th { background: var(--thead-bg); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; position: relative; }
.table thead th:first-child { border-top-left-radius: var(--radius); }
.table thead th:last-child { border-top-right-radius: var(--radius); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover > td { background: var(--surface-hover); }
.table tbody tr.is-selected > td { background: var(--primary-soft); }
.table tbody tr.is-muted > td { opacity: 0.6; }
.table tbody tr.row-danger > td { background: rgba(var(--danger-rgb), 0.06); }
.table tbody tr.row-warning > td { background: rgba(var(--warning-rgb), 0.06); }
.table tbody tr.is-hidden { display: none; }
.table td { color: var(--text-2); }
.table td strong, .table td .identity-name { color: var(--text); }
.table .td-num, .table .th-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .td-center, .table .th-center { text-align: center; }
.table .td-shrink { width: 1%; white-space: nowrap; }
.table .td-check { width: 1%; padding-right: 4px; }
.table .td-actions { width: 1%; white-space: nowrap; }
.table .td-actions .actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.table .td-mono { font-family: var(--font-mono); font-size: 0.82rem; }
.table .td-muted { color: var(--text-muted); font-size: var(--fs-sm); }
.table .td-clamp { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; padding-right: 26px; }
.table th.sortable:hover { color: var(--text); }
.table th.sortable::after { content: '\2195'; position: absolute; right: 10px; opacity: 0.35; font-size: 0.9em; }
.table th.sortable[data-sort-dir="asc"]::after { content: '\25B2'; opacity: 1; color: var(--primary-text); font-size: 0.6em; }
.table th.sortable[data-sort-dir="desc"]::after { content: '\25BC'; opacity: 1; color: var(--primary-text); font-size: 0.6em; }
.table-sticky thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.table-sm { --table-min: 0; font-size: var(--fs-sm); }
.table-sm th, .table-sm td { padding: 8px 12px; }
.table-plain { --table-min: 0; }
.table-plain th { background: transparent; }
.table-plain, .table-plain .table-wrap { border: 0; }
.table-progress { min-width: 140px; }
.table-progress .progress { margin-top: 5px; }
.table-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.table-toolbar .search { flex: 1 1 220px; max-width: 360px; }
.table-toolbar select { width: auto; min-width: 140px; }
.table-toolbar .toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-muted); }
.card > .table-footer:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-empty td { text-align: center; padding: 48px 20px !important; color: var(--text-muted); }
.bulk-bar { display: none; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; background: var(--primary-soft); border-bottom: 1px solid var(--border-primary); font-size: var(--fs-sm); }
.bulk-bar.is-active { display: flex; }
.bulk-bar .bulk-count { font-weight: 600; color: var(--primary-text); }
.bulk-bar select, .bulk-bar input { width: auto; }
.expand-row > td { padding: 0 !important; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.expand-row .expand-body { padding: 18px 20px; }
@media (max-width: 639px) {
  .table th, .table td { padding: 10px 12px; }
  .table-toolbar { padding: 12px 14px; }
  .table-toolbar .search { max-width: none; flex-basis: 100%; }
  .table-toolbar select { flex: 1 1 auto; }
  .table-footer { padding: 12px 14px; }
}

/* Sticky trailing actions column (opt-in): keeps row actions visible while the table scrolls */
.table-sticky-actions th.td-actions, .table-sticky-actions td.td-actions { position: sticky; right: 0; background: var(--surface); box-shadow: -8px 0 12px -10px rgba(0,0,0,0.5); z-index: 1; }
.table-sticky-actions thead th.td-actions { background: var(--surface-2); }
.table-sticky-actions tbody tr:hover > td.td-actions { background: var(--surface-2); }

/* ---------- Pagination ---------- */
.pagination { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.page-btn { min-width: 34px; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: all var(--t-fast); text-decoration: none; }
.page-btn:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary-text); }
.page-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-color: transparent; }
.page-btn:disabled, .page-btn.is-disabled { opacity: 0.4; pointer-events: none; }
.page-ellipsis { padding: 0 6px; color: var(--text-dim); }
.page-size { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.page-size select { width: auto; height: 34px; padding: 0 30px 0 10px; font-size: var(--fs-sm); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--space-5); }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 42px; padding: 0 16px; font-size: var(--fs-base); font-weight: 500; color: var(--text-muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t-fast), border-color var(--t-fast); text-decoration: none; }
.tab i { font-size: 0.9em; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-text); border-bottom-color: var(--primary); font-weight: 600; }
.tab .badge { height: 18px; padding: 0 6px; }
.tabs.tabs-pills { border: 0; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 10px; }
.tabs.tabs-pills .tab { height: 34px; border: 0; border-radius: 7px; margin: 0; }
.tabs.tabs-pills .tab.active { background: var(--surface); box-shadow: var(--shadow-sm); }
:root:not([data-theme="light"]) .tabs.tabs-pills .tab.active { background: var(--surface-3); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn var(--t); }
@media (max-width: 639px) { .tab { padding: 0 12px; font-size: var(--fs-sm); } }

/* ---------- Dropdown menu ---------- */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; max-width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: var(--z-dropdown); display: none; animation: dropIn 140ms var(--ease); }
.dropdown-menu.is-open { display: block; }
.dropdown-menu.align-left { right: auto; left: 0; }
.dropdown-menu.drop-up { top: auto; bottom: calc(100% + 6px); }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; font-size: var(--fs-base); color: var(--text-2); text-align: left; white-space: nowrap; text-decoration: none; cursor: pointer; transition: background var(--t-fast), color var(--t-fast); border: 0; background: none; }
.dropdown-item i { width: 16px; text-align: center; color: var(--text-muted); font-size: 0.9em; }
.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-item:hover i { color: var(--primary-text); }
.dropdown-item.is-danger { color: var(--danger); }
.dropdown-item.is-danger i { color: var(--danger); }
.dropdown-item.is-danger:hover { background: rgba(var(--danger-rgb), 0.1); color: var(--danger); }
.dropdown-item.is-active { color: var(--primary-text); background: var(--primary-soft); }
.dropdown-item:disabled { opacity: 0.5; cursor: not-allowed; }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown-header { padding: 8px 12px 4px; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.dropdown-menu form { margin: 0; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--overlay); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.modal-backdrop.is-open { display: flex; animation: fadeIn 150ms var(--ease); }
.modal { width: 100%; max-width: var(--modal-w, 560px); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: modalIn 200ms var(--ease); margin: auto; }
.modal.modal-sm { --modal-w: 420px; } .modal.modal-lg { --modal-w: 760px; } .modal.modal-xl { --modal-w: 960px; }
.modal-header { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: var(--fs-lg); font-weight: 600; display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.modal-title i { color: var(--primary-text); }
.modal-close { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--text-muted); font-size: 1.1rem; flex-shrink: 0; }
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-shrink: 0; }
.modal-footer .left { margin-right: auto; }
.modal-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; margin: 0 auto 14px; background: rgba(var(--danger-rgb), 0.12); color: var(--danger); }
.modal-icon.is-warning { background: rgba(var(--warning-rgb), 0.14); color: var(--warning); }
.modal-icon.is-info { background: rgba(var(--info-rgb), 0.12); color: var(--info); }
.modal-icon.is-primary { background: var(--primary-soft); color: var(--primary-text); }
.modal.modal-confirm .modal-body { text-align: center; padding-top: 28px; }
.modal.modal-confirm .modal-body h3 { margin-bottom: 8px; }
body.modal-open { overflow: hidden; }
@media (max-width: 639px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; animation: sheetIn 220ms var(--ease); }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer { border-radius: 0; }
  .modal-footer .btn { flex: 1 1 auto; }
}

/* ---------- Drawer (side panel) ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: var(--z-drawer); background: var(--overlay); display: none; }
.drawer-backdrop.is-open { display: block; animation: fadeIn 150ms var(--ease); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); z-index: calc(var(--z-drawer) + 1); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 240ms var(--ease); visibility: hidden; }
.drawer.is-open { transform: translateX(0); visibility: visible; }
.drawer.drawer-lg { width: min(760px, 100vw); }
.drawer-header { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.drawer-title { font-size: var(--fs-lg); font-weight: 600; flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-footer { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; flex-shrink: 0; }
@media (max-width: 639px) { .drawer-header, .drawer-body, .drawer-footer { padding-left: 16px; padding-right: 16px; } }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 16px; right: 16px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { --alert: var(--info); --alert-rgb: var(--info-rgb); pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border-strong); border-left: 3px solid var(--alert); box-shadow: var(--shadow-lg); animation: toastIn 220ms var(--ease); position: relative; overflow: hidden; }
.toast > i:first-child { color: var(--alert); margin-top: 2px; }
.toast-body { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--text); }
.toast-title { font-weight: 600; }
.toast-close { color: var(--text-muted); padding: 0 2px; }
.toast-close:hover { color: var(--text); }
.toast.is-leaving { animation: toastOut 200ms var(--ease) forwards; }
.toast-success { --alert: var(--success); --alert-rgb: var(--success-rgb); }
.toast-error, .toast-danger { --alert: var(--danger); --alert-rgb: var(--danger-rgb); }
.toast-warning { --alert: var(--warning); --alert-rgb: var(--warning-rgb); }
.toast-info { --alert: var(--info); --alert-rgb: var(--info-rgb); }
@media (max-width: 639px) { .toast-stack { top: auto; bottom: 16px; left: 16px; right: 16px; width: auto; } }

/* ---------- Progress ---------- */
.progress { --bar: linear-gradient(90deg, var(--primary), var(--primary-dark)); position: relative; height: 8px; width: 100%; background: var(--track); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--bar); border-radius: 4px; transition: width 500ms var(--ease); }
.progress.is-warn { --bar: linear-gradient(90deg, var(--warning), #D97706); }
.progress.is-danger { --bar: linear-gradient(90deg, var(--danger), #DC2626); }
.progress.is-success { --bar: linear-gradient(90deg, var(--success), #059669); }
.progress.is-info { --bar: linear-gradient(90deg, var(--info), #2563EB); }
.progress-sm { height: 5px; } .progress-lg { height: 12px; border-radius: 6px; }
.progress-labels { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 6px; }
.progress-striped .progress-fill { background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%); background-size: 16px 16px; }
.ring { --size: 96px; --pct: 0; --ring: var(--primary); width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(var(--ring) calc(var(--pct) * 1%), var(--track) 0); flex-shrink: 0; }
.ring::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring > * { position: relative; z-index: 1; text-align: center; }
.ring .ring-value { font-size: calc(var(--size) * 0.2); font-weight: 700; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.ring .ring-label { font-size: calc(var(--size) * 0.1); color: var(--text-muted); margin-top: 2px; }
.ring.is-warn { --ring: var(--warning); } .ring.is-danger { --ring: var(--danger); } .ring.is-success { --ring: var(--success); }
.meter-list { display: flex; flex-direction: column; gap: 12px; }
.meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.meter .meter-label { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter .meter-value { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.meter .progress { grid-column: 1 / -1; }

/* ---------- Skeleton / loading ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--skeleton); border-radius: 6px; min-height: 12px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: shimmer 1.4s infinite; }
.skeleton-text { height: 12px; margin: 6px 0; }
.skeleton-title { height: 20px; width: 40%; }
.skeleton-block { height: 120px; }
.spinner { display: inline-block; width: 36px; height: 36px; border: 3px solid rgba(var(--primary-rgb), 0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.is-busy { position: relative; pointer-events: none; }
.is-busy::after { content: ''; position: absolute; inset: 0; background: var(--surface); opacity: 0.5; border-radius: inherit; }
.chart-box { position: relative; height: var(--chart-h, 260px); min-width: 0; }
.chart-box.is-loading::after { content: ''; position: absolute; inset: 0; background: var(--surface); opacity: 0.55; border-radius: var(--radius); }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-muted); font-size: var(--fs-sm); pointer-events: none; }
.chart-empty i { font-size: 1.6rem; color: var(--text-dim); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: var(--fs-sm); color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--primary)); }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 20px; color: var(--text-muted); gap: 8px; }
.empty-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 1.6rem; color: var(--primary-text); background: var(--primary-soft); margin-bottom: 6px; }
.empty h3, .empty-title { font-size: var(--fs-lg); color: var(--text); }
.empty p, .empty-text { max-width: 420px; font-size: var(--fs-base); color: var(--text-muted); }
.empty .btn { margin-top: 10px; }
.empty.is-compact { padding: 28px 16px; }
.empty.is-compact .empty-icon { width: 46px; height: 46px; font-size: 1.15rem; border-radius: 12px; }

/* ---------- Code block with header ---------- */
.code-block { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.code-block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.code-block-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.code-block pre { background: transparent; border: 0; border-radius: 0; padding: 14px 16px; margin: 0; white-space: pre; }
.code-block pre.wrap { white-space: pre-wrap; word-break: break-all; }
.code-block .code-tabs { display: flex; gap: 2px; }
.code-block .code-tab { height: 26px; padding: 0 10px; border-radius: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.code-block .code-tab.active { background: var(--surface-3); color: var(--primary-text); }
.code-block .code-tab:hover { color: var(--text); }

/* Copyable value (credentials, keys) */
.copy-field { display: flex; align-items: center; gap: 6px; min-width: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 0 6px 0 12px; height: var(--control-h); }
.copy-field .copy-value { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 0.85rem; color: var(--primary-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-field .copy-value.is-masked { letter-spacing: 0.15em; }
.copy-field .copy-btn, .copy-btn { width: 32px; height: 32px; border-radius: 7px; display: inline-grid; place-items: center; color: var(--text-muted); flex-shrink: 0; transition: all var(--t-fast); font-size: 0.85rem; }
.copy-field .copy-btn:hover, .copy-btn:hover { background: var(--surface-hover); color: var(--primary-text); }
.copy-btn.is-copied { color: var(--success); }
.field-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ---------- Key/value list ---------- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; font-size: var(--fs-base); align-items: baseline; }
.kv dt { color: var(--text-muted); font-size: var(--fs-sm); white-space: nowrap; }
.kv dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.kv.kv-stack { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.kv.kv-stack dt { margin-bottom: -8px; }
@media (max-width: 479px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 4px; } .kv dd { margin-bottom: 8px; } }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline-item { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; color: var(--primary-text); background: var(--primary-soft); flex-shrink: 0; }
.timeline-dot.is-danger { color: var(--danger); background: rgba(var(--danger-rgb), 0.14); }
.timeline-dot.is-success { color: var(--success); background: rgba(var(--success-rgb), 0.14); }
.timeline-dot.is-warning { color: var(--warning); background: rgba(var(--warning-rgb), 0.16); }
.timeline-dot.is-info { color: var(--info); background: rgba(var(--info-rgb), 0.14); }
.timeline-content { min-width: 0; font-size: var(--fs-sm); color: var(--text-2); }
.timeline-title { color: var(--text); font-weight: 500; font-size: var(--fs-base); }
.timeline-meta { color: var(--text-muted); font-size: var(--fs-xs); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Accordion / details ---------- */
.accordion { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.accordion + .accordion { margin-top: 10px; }
.accordion > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-weight: 600; color: var(--text); user-select: none; }
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary > i:first-child { color: var(--primary-text); }
.accordion > summary::after { content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 0.7rem; margin-left: auto; color: var(--text-muted); transition: transform var(--t); }
.accordion[open] > summary { border-bottom: 1px solid var(--border); }
.accordion[open] > summary::after { transform: rotate(180deg); }
.accordion-body { padding: 18px; }
.accordion.is-sub { background: var(--surface-2); }

/* ---------- Tooltip (CSS-only) ---------- */
[data-tip] { position: relative; }
[data-tip]::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px); background: var(--chart-tooltip-bg); color: #F3F4F6; font-size: var(--fs-xs); font-weight: 500; padding: 6px 10px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast); z-index: var(--z-dropdown); box-shadow: var(--shadow); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip].tip-right::after { left: auto; right: 0; transform: translateX(0) translateY(4px); }
[data-tip].tip-right:hover::after { transform: translateX(0) translateY(0); }
[data-tip].tip-left::after { left: 0; transform: translateX(0) translateY(4px); }
[data-tip].tip-left:hover::after { transform: translateX(0) translateY(0); }
[data-tip].tip-bottom::after { bottom: auto; top: calc(100% + 8px); }
.help-icon { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 0.6rem; color: var(--text-muted); border: 1px solid var(--border-strong); cursor: help; vertical-align: middle; margin-left: 4px; }

/* ---------- Misc ---------- */
.section-title { font-size: var(--fs-xl); font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-4); }
.section-title i { color: var(--primary-text); font-size: 0.9em; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: var(--space-4); }
.section-head .section-title { margin-bottom: 0; }
.eyebrow { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--primary-text); }
.icon-box { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem; color: var(--primary-text); background: var(--primary-soft); flex-shrink: 0; }
.icon-box.is-success { color: var(--success); background: rgba(var(--success-rgb), 0.14); }
.icon-box.is-danger { color: var(--danger); background: rgba(var(--danger-rgb), 0.14); }
.icon-box.is-warning { color: var(--warning); background: rgba(var(--warning-rgb), 0.16); }
.icon-box.is-info { color: var(--info); background: rgba(var(--info-rgb), 0.14); }
.icon-box.is-purple { color: var(--purple); background: rgba(var(--purple-rgb), 0.14); }
.icon-box.is-teal { color: var(--teal); background: rgba(var(--teal-rgb), 0.14); }
.list-tile { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); min-width: 0; transition: border-color var(--t-fast), background var(--t-fast); }
.list-tile:hover { border-color: var(--border-strong); }
.list-tile + .list-tile { margin-top: 8px; }
.list-tile .tile-main { flex: 1; min-width: 0; }
.list-tile .tile-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-tile .tile-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.list-tile .tile-actions { display: flex; gap: 6px; flex-shrink: 0; }
a.list-tile { color: inherit; }
.quick-action { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: inherit; transition: border-color var(--t), box-shadow var(--t), transform var(--t); min-width: 0; }
.quick-action:hover { border-color: var(--border-primary); box-shadow: var(--shadow); color: inherit; }
.quick-action .qa-title { font-weight: 600; color: var(--text); }
.quick-action .qa-desc { font-size: var(--fs-xs); color: var(--text-muted); }
.quick-action > i.arrow { margin-left: auto; color: var(--text-dim); }
.notice-strip { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--primary-soft); border: 1px solid var(--border-primary); font-size: var(--fs-sm); color: var(--text); flex-wrap: wrap; }
.notice-strip.is-danger { background: rgba(var(--danger-rgb), 0.1); border-color: rgba(var(--danger-rgb), 0.4); }
.notice-strip.is-warning { background: rgba(var(--warning-rgb), 0.1); border-color: rgba(var(--warning-rgb), 0.4); }
.notice-strip i { color: var(--primary-text); }
.notice-strip.is-danger i { color: var(--danger); }
.notice-strip.is-warning i { color: var(--warning); }

/* ---------- Icon buttons / theme toggle (shared by app shell + login) ---------- */
.topbar-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); font-size: 0.95rem; transition: all var(--t-fast); position: relative; }
.topbar-btn:hover { background: var(--surface-hover); color: var(--primary-text); }
.topbar-btn .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }
.theme-toggle .fa-sun { display: none; }
.theme-toggle .fa-moon { display: block; }
:root[data-theme="light"] .theme-toggle .fa-sun { display: block; }
:root[data-theme="light"] .theme-toggle .fa-moon { display: none; }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.animate-in { animation: fadeInUp 300ms var(--ease) both; }
