/* ==========================================================================
   SenderWolf admin panel — design system
   Direction: Swiss/minimal dark (flat surfaces, hairline borders, one accent),
   purple-tinted neutrals shared with the desktop app. Semantic tokens only —
   components never hard-code colors. System fonts (no third-party requests).
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces (elevation: bg < panel < surface-2 < surface-3) */
  --bg: #0b0a10;
  --panel: #131218;
  --surface-2: #181620;
  --surface-3: #201d2a;
  --border: #25222e;
  --border-strong: #38334a;
  --control-border: #6b6480;   /* form-control boundary: 3.3:1 on panel (WCAG 1.4.11 needs 3:1) */

  /* Text — all ≥ 4.5:1 on --panel */
  --text: #f3eef8;
  --text-2: #cfc6dd;
  --muted: #9a92a8;

  /* Brand */
  --accent: #c58ad8;          /* text/icons/links on dark */
  --accent-strong: #7b1fa2;   /* solid fills (white text = 8.6:1) */
  --accent-dark: #6a1b9a;
  --accent-hover: #8e24aa;
  --accent-soft: rgba(197, 138, 216, 0.14);
  --ring: #e1b5ef;

  /* Status */
  --green: #4cd693;
  --orange: #ffb454;
  --red: #ff7b7b;
  --green-soft: rgba(76, 214, 147, 0.14);
  --orange-soft: rgba(255, 180, 84, 0.14);
  --red-soft: rgba(255, 123, 123, 0.14);

  /* Shape & spacing (4/8 rhythm) */
  --radius: 12px;
  --radius-sm: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --sidebar-w: 248px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);

  /* Type */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --t-fast: 140ms;
  --t-med: 200ms;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  scrollbar-color: var(--border-strong) transparent;
}
::selection { background: rgba(197, 138, 216, 0.35); }
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.015em; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 8px; }
a { color: var(--accent); text-decoration: none; }
a:visited { color: var(--accent); }
a:hover { color: #edd0f6; text-decoration: underline; text-underline-offset: 3px; }
code {
  font-family: var(--mono); font-size: 12px; color: var(--text-2);
  background: rgba(255, 255, 255, 0.05); padding: 2px 6px; border-radius: 6px;
}
svg.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }

/* Numbers align in columns and never shift as they change */
.kpi-value, .hero-stat-value, .data-table td, .pagination, .quota-bar-label, .chart-stat, .stat-row { font-variant-numeric: tabular-nums; }

/* Keyboard focus — always visible, never removed */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--accent-strong); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { top: 12px; color: #fff; text-decoration: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: 600 13px/1 var(--font); text-decoration: none;
  cursor: pointer; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--accent); color: #fff; }
.btn-danger { background: var(--red-soft); color: #ffa9a9; border-color: rgba(255, 123, 123, 0.38); }
.btn-danger:hover { background: #c62828; border-color: #c62828; color: #fff; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn[disabled], .btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { pointer-events: none; opacity: 0.75; }
.btn.is-loading::after {
  content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn, .actions a {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.icon-btn:hover, .actions a:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); border-color: rgba(255, 123, 123, 0.4); }
.actions { white-space: nowrap; }
.actions > * + * { margin-left: 4px; }
.actions form { display: inline-flex; vertical-align: middle; }

/* ==========================================================================
   Form controls (dark, consistent, 38px)
   ========================================================================== */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="range"]),
select, textarea {
  width: 100%; min-height: 38px; padding: 8px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--control-border); border-radius: var(--radius-sm);
  font: 400 14px/1.4 var(--font);
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #7d7590; }
input:hover, select:hover, textarea:hover { border-color: #8a83a0; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--accent); background: #1b1825;
}
select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a92a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: #a64bc4; flex-shrink: 0; }
input[type="date"] { color-scheme: dark; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.5; cursor: not-allowed; }
input[data-invalid="1"], select[data-invalid="1"] { border-color: var(--red); }

label { font-size: 13px; }
.form-card label, .card form > label {
  display: block; margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-2); letter-spacing: 0.01em;
}
.form-card label:first-of-type, .card form > label:first-of-type { margin-top: 0; }
label.checkbox-label, .card form label.checkbox-label, .form-card label.checkbox-label {
  display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; font-weight: 400; color: var(--text-2); cursor: pointer;
}
.field-error { display: flex; align-items: center; gap: 6px; color: var(--red); font-size: 12px; margin-top: 6px; }
.error, .notice { font-size: 13px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid; margin: 0 0 var(--space-3); }
.error { color: #ffb3b3; background: var(--red-soft); border-color: rgba(255, 123, 123, 0.35); }
.notice { color: #9df0c6; background: var(--green-soft); border-color: rgba(76, 214, 147, 0.35); }
.hint { color: var(--muted); font-size: 13px; }

.form-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); max-width: 560px; }
.domain-checklist { max-height: 220px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--control-border); border-radius: var(--radius-sm); padding: 6px 12px; margin-top: 6px; }
.inline-form { display: flex; gap: 10px; margin-bottom: var(--space-4); }
.inline-form input { flex: 1; }
.license-box {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--space-4);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 16px; color: var(--muted); font-size: 13px;
}
.license-box code { font-size: 14px; color: var(--text); background: transparent; padding: 0; letter-spacing: 0.04em; }

/* ==========================================================================
   Auth pages
   ========================================================================== */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px;
  background:
    radial-gradient(700px 360px at 50% -10%, rgba(123, 31, 162, 0.28), transparent 70%),
    var(--bg);
}
.auth-box {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.auth-brand h1 { font-size: 20px; }
.auth-brand p { color: var(--muted); font-size: 13px; margin: 0; }
.auth-box label { display: block; margin: 16px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.auth-box .btn { width: 100%; margin-top: 22px; min-height: 42px; font-size: 14px; }
.pw-field { position: relative; }
.pw-field input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px;
  display: grid; place-items: center; background: transparent; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.pw-toggle .ic-off { display: none; }
.pw-toggle.is-shown .ic-on { display: none; }
.pw-toggle.is-shown .ic-off { display: block; }

/* ==========================================================================
   App shell: sidebar + main column
   ========================================================================== */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #0e0d13; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; font-size: 16px; font-weight: 650; color: var(--text); letter-spacing: -0.01em; }
.sidebar-nav { flex: 1; padding: 4px 10px 12px; overflow-y: auto; }
.nav-group-label { padding: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: #7f7891; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px; margin: 2px 0;
  color: var(--text-2); font-size: 13.5px; font-weight: 500; text-decoration: none; border-radius: var(--radius-sm);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sidebar-link svg { color: var(--muted); transition: color var(--t-fast) var(--ease); }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.05); color: #fff; text-decoration: none; }
.sidebar-link:hover svg { color: var(--text-2); }
.sidebar-link.active { background: var(--accent-soft); color: #fff; font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-link.active svg { color: var(--accent); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, #8e24aa, #4a148c); color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase;
}
.sidebar-foot .who { min-width: 0; flex: 1; line-height: 1.25; }
.sidebar-foot .who strong { display: block; font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { font-size: 11px; color: var(--muted); }
.sidebar-foot form { margin: 0; }

.topbar {
  display: none; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px 8px 16px; background: rgba(14, 13, 19, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); }
.topbar .icon-btn { width: 44px; height: 44px; border-color: var(--border-strong); color: var(--text); }

.main-col { flex: 1; min-width: 0; }
.container { padding: var(--space-5) var(--space-5) 64px; max-width: 1240px; margin: 0 auto; }

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); visibility: hidden;
    transition: transform var(--t-med) var(--ease), visibility 0s linear var(--t-med); box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); visibility: visible; transition: transform var(--t-med) var(--ease); }
  .topbar { display: flex; }
  .container { padding: var(--space-3) var(--space-3) 48px; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.6); }
  .sidebar-backdrop.open { display: block; }
}

/* ==========================================================================
   Page header, toolbar
   ========================================================================== */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.page-head .subtitle { color: var(--muted); font-size: 13.5px; margin: 0; }

.toolbar { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); flex-wrap: wrap; }
.toolbar input:not([type="checkbox"]), .toolbar select { width: auto; min-width: 150px; }
.toolbar .search-field { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search-field input { width: 100%; padding-left: 36px; }
.toolbar .search-field svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar .spacer { flex: 1; }

/* ==========================================================================
   Cards, KPIs
   ========================================================================== */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card + .card { margin-top: var(--space-3); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 2px; }
.card-title svg { color: var(--accent); }
.card-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 var(--space-3); }
.card-hint strong { color: var(--text-2); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--space-3); align-items: start; }
.grid-2 > * { min-width: 0; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-3); }
.kpi-card {
  position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0;
  transition: border-color var(--t-fast) var(--ease);
}
.kpi-card:hover { border-color: var(--border-strong); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.kpi-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.kpi-value { color: var(--text); font-size: 28px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; margin-top: 10px; }
.kpi-caption { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Headline stats (dashboard) */
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-3); }
.hero-stat-card {
  display: flex; align-items: center; gap: 18px; padding: 22px 24px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(123, 31, 162, 0.32), rgba(197, 138, 216, 0.05) 65%), var(--panel);
  border: 1px solid rgba(197, 138, 216, 0.28);
}
.hero-stat-icon { width: 52px; height: 52px; display: grid; place-items: center; flex-shrink: 0; border-radius: 14px; background: rgba(197, 138, 216, 0.16); color: #e6c3f2; }
.hero-stat-icon svg { width: 26px; height: 26px; }
.hero-stat-value { font-size: 34px; font-weight: 700; color: #fff; letter-spacing: -0.02em; line-height: 1.1; }
.hero-stat-label { font-size: 12.5px; color: var(--text-2); margin-top: 4px; font-weight: 500; }
@media (max-width: 640px) { .hero-stat-value { font-size: 28px; } .hero-stat-card { padding: 18px; } }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }

@media (max-width: 640px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi-card { padding: 14px; }
  .kpi-icon { display: none; }
  .kpi-value { font-size: 24px; margin-top: 8px; }
  .kpi-label { letter-spacing: 0.05em; }
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.table-wrap:focus-visible { outline-offset: 0; }
.data-table { width: 100%; border-collapse: collapse; }
.table-wrap .data-table { min-width: 640px; }
.data-table th, .data-table td { padding: 11px 16px; font-size: 13px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data-table th {
  position: sticky; top: 0; background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.data-table td { color: var(--text-2); }
.data-table td a { font-weight: 500; }
.data-table code { white-space: nowrap; }
.data-table .empty { text-align: center; color: var(--muted); padding: 30px; }
.sortable-th a { color: inherit; display: inline-flex; gap: 4px; align-items: center; text-decoration: none; }
.sortable-th a:hover { color: var(--text); text-decoration: none; }
th[aria-sort] { color: var(--text); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 4px; }
.pagination a, .pagination span.current {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: var(--radius-sm); border: 1px solid transparent; color: var(--text-2); text-decoration: none; font-weight: 500;
}
.pagination a:hover { background: var(--surface-3); border-color: var(--border-strong); color: #fff; }
.pagination span.current { background: var(--accent-strong); color: #fff; }

/* ==========================================================================
   Badges, chips, quota bars
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: 0.04em; white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-trial { background: var(--orange-soft); color: var(--orange); }
.badge-pro { background: var(--green-soft); color: var(--green); }
.badge-expired { background: var(--red-soft); color: var(--red); }
.badge-suspended { background: rgba(154, 146, 168, 0.16); color: #b9b1c6; }
.badge-revoked { background: rgba(255, 123, 123, 0.26); color: #ffb0b0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2); text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--accent); color: #fff; text-decoration: none; }
.chip.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

.quota-bar-track { background: var(--surface-3); border-radius: 999px; height: 8px; overflow: hidden; }
.quota-bar-fill { height: 100%; background: var(--green); border-radius: 999px; }
.quota-bar-fill.warn { background: var(--orange); }
.quota-bar-fill.crit { background: var(--red); }
.quota-bar-label { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ==========================================================================
   Charts (hand-rolled SVG + text alternatives)
   ========================================================================== */
.sparkline-wrap svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-baseline { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-block + .chart-block { margin-top: var(--space-3); }
.chart-caption { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; flex-wrap: wrap; }
.legend { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 600; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-stat { color: var(--muted); }
.chart-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; color: var(--muted); }
details.chart-data { margin-top: 12px; }
details.chart-data summary { cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 500; width: fit-content; border-radius: 6px; padding: 2px 0; }
details.chart-data[open] summary { margin-bottom: 10px; }
details.chart-data .table-wrap { max-height: 260px; overflow: auto; }

/* ==========================================================================
   Empty / error states
   ========================================================================== */
.state-box { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 44px 20px; color: var(--muted); }
.state-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
.state-icon svg { width: 24px; height: 24px; }
.state-box h3 { margin: 0 0 6px; }
.state-box p { margin: 0 0 16px; font-size: 13.5px; max-width: 46ch; }
.card.state-box { padding: 48px 20px; }

/* ==========================================================================
   Dialog (replaces native confirm()) and toasts
   ========================================================================== */
dialog.confirm-dialog {
  border: 1px solid var(--border-strong); border-radius: 14px; background: var(--panel); color: var(--text);
  padding: 24px; width: min(420px, 92vw); box-shadow: var(--shadow);
}
dialog.confirm-dialog::backdrop { background: rgba(4, 3, 8, 0.7); backdrop-filter: blur(3px); }
dialog.confirm-dialog h3 { font-size: 16px; margin: 0 0 8px; }
dialog.confirm-dialog p { margin: 0 0 24px; font-size: 13.5px; color: var(--text-2); }
dialog.confirm-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

#toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 40px); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; min-width: 240px; max-width: 380px; padding: 12px 14px; font-size: 13px; line-height: 1.4;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow);
  animation: toast-in var(--t-med) var(--ease);
}
.toast svg { margin-top: 1px; color: var(--accent); }
.toast.toast-success svg { color: var(--green); }
.toast.toast-error svg { color: var(--red); }
.toast.toast-error { border-color: rgba(255, 123, 123, 0.45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Touch devices: 44px targets
   ========================================================================== */
@media (pointer: coarse), (max-width: 640px) {
  .btn, .chip, input:not([type="checkbox"]):not([type="radio"]), select { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .icon-btn, .actions a { width: 44px; height: 44px; }
  .sidebar-link { min-height: 44px; }
  .pagination a, .pagination span.current { min-width: 40px; height: 40px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; } /* no iOS zoom-on-focus */
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
