/* ==========================================================================
   PolCam design system
   Shared tokens and components for every console page.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0A0C10;
  --bg-subtle: #0E1116;
  --surface: #12151B;
  --surface-2: #181C23;
  --surface-3: #1F242D;
  --border: #242A34;
  --border-strong: #323A48;
  --border-hover: #3E4757;

  /* Text */
  --text: #E7E9EE;
  --text-2: #A6ACB8;
  --text-3: #7D8494;

  /* Brand + semantic colours */
  --primary: #4F7FFF;
  --primary-hover: #6890FF;
  --primary-press: #406EEB;
  --primary-soft: rgba(79, 127, 255, 0.12);
  --primary-border: rgba(79, 127, 255, 0.38);
  --primary-text: #93B1FF;

  --success: #2FBF8A;
  --success-soft: rgba(47, 191, 138, 0.12);
  --success-border: rgba(47, 191, 138, 0.38);
  --success-text: #5ED6A8;

  --danger: #E5484D;
  --danger-hover: #EF5D62;
  --danger-soft: rgba(229, 72, 77, 0.12);
  --danger-border: rgba(229, 72, 77, 0.42);
  --danger-text: #FF8B8F;

  --warning: #F5A524;
  --warning-soft: rgba(245, 165, 36, 0.12);
  --warning-border: rgba(245, 165, 36, 0.42);
  --warning-text: #F7C46C;

  --info: #38BDF8;
  --info-soft: rgba(56, 189, 248, 0.12);
  --info-border: rgba(56, 189, 248, 0.38);
  --info-text: #7DD3FC;

  --violet: #A78BFA;
  --violet-soft: rgba(167, 139, 250, 0.12);
  --violet-border: rgba(167, 139, 250, 0.38);
  --violet-text: #C4B5FD;

  /* Shape + depth */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);
  --ring: 0 0 0 3px rgba(79, 127, 255, 0.35);

  /* Type */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --topbar-h: 56px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { background: var(--bg); }
body {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(79, 127, 255, 0.35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); background-clip: content-box; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Icons ---------- */
.icon {
  width: 16px; height: 16px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-xs { width: 12px; height: 12px; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: 500 13px/1 var(--font-sans);
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:active:not(:disabled) { background: var(--primary-press); }

.btn-secondary { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-hover); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-danger-soft { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.btn-danger-soft:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-success { background: var(--success); color: #03140D; }
.btn-success:hover:not(:disabled) { filter: brightness(1.08); }

.btn-warning-soft { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.btn-warning-soft:hover:not(:disabled) { background: var(--warning); border-color: var(--warning); color: #1A1102; }

.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; border-radius: var(--radius); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; gap: 5px; }
.btn-xs .icon { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-xs { width: 26px; }

.spinner {
  width: 14px; height: 14px; flex: none;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.label-row .btn-xs { margin: -4px 0; }
.hint { font-size: 12px; color: var(--text-3); }

.input, .select {
  width: 100%; height: 36px; padding: 0 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: 400 13.5px var(--font-sans);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--border-hover); }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: var(--ring); }
.input:disabled, .select:disabled { opacity: .6; cursor: not-allowed; }
.input[type="date"] { color-scheme: dark; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237D8494' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
.select option { background: var(--surface); color: var(--text); }
.input-lg { height: 42px; font-size: 14px; }
.input-sm, .select.input-sm { height: 30px; font-size: 12.5px; }
.input-mono { font-family: var(--font-mono); font-size: 13px; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 34px; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; padding: 4px 0; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); }

/* Required marker + optional tag */
.req { color: var(--danger-text); margin-left: 2px; }
.opt { color: var(--text-3); font-weight: 400; margin-left: 4px; }

/* Validation */
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus, .select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.3); }
.field-error { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--danger-text); }
.field-error .icon { width: 13px; height: 13px; }

/* Input with trailing action(s) inside the field */
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix > .input { padding-right: var(--affix-pad, 44px); }
.input-affix .affix {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 2px;
}
.affix-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 8px;
  border: 0; border-radius: 5px;
  background: transparent;
  color: var(--text-2);
  font: 500 12px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
}
.affix-btn .icon { width: 14px; height: 14px; }
.affix-btn:hover { background: var(--surface-3); color: var(--text); }
.affix-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.input-lg + .affix .affix-btn, .input-affix .input-lg ~ .affix .affix-btn { height: 32px; }

/* Form layout: sections with a heading column on wide modals */
.form { display: flex; flex-direction: column; }
.modal-body.form { gap: 0; }
.form-section { display: flex; flex-direction: column; gap: 14px; padding: 20px 0; border-top: 1px solid var(--border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section:last-child { padding-bottom: 0; }
.form-section-head { display: flex; flex-direction: column; gap: 2px; }
.form-section-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.form-section-desc { font-size: 12.5px; color: var(--text-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* Selectable option cards (radio group) */
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .choice-grid { grid-template-columns: 1fr; } }
.choice {
  position: relative;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.choice:hover { border-color: var(--border-hover); }
.choice:focus-visible { outline: none; box-shadow: var(--ring); }
.choice[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.choice-icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--surface-3); color: var(--text-2); }
.choice[aria-checked="true"] .choice-icon { background: var(--primary); color: #fff; }
.choice-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.choice-desc { font-size: 12px; color: var(--text-3); line-height: 1.4; margin-top: 2px; }

/* Segmented tabs (in-page) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 4px; margin-right: 16px;
  border: 0; background: none;
  color: var(--text-3);
  font: 500 13.5px var(--font-sans);
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); border-radius: 2px; }
.tab .count { font: 500 11.5px var(--font-mono); color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px; }
.tab:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

/* Responsive table helpers */
@media (max-width: 900px) { .hide-md { display: none !important; } }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
.show-sm { display: none !important; }
@media (max-width: 640px) { .show-sm { display: flex !important; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.card-title .icon { color: var(--text-3); }
.card-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 20px; }
.card-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ---------- Badges, tags, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font: 500 11.5px/1 var(--font-sans);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge .icon { width: 12px; height: 12px; }
.badge-primary { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); }
.badge-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.badge-danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger-text); }
.badge-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.badge-info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info-text); }
.badge-violet  { background: var(--violet-soft);  border-color: var(--violet-border);  color: var(--violet-text); }
.badge-square  { border-radius: 4px; }

.dot-live { animation: livePulse 2s ease-in-out infinite; }
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50% { box-shadow: 0 0 0 3px transparent; opacity: .55; }
}

/* Role badges (shared between dashboard + admin) */
.role-badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-2);
  font: 600 10.5px/1 var(--font-sans);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.role-super_admin, .role-admin { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); }
.role-district_commander      { background: var(--violet-soft);  border-color: var(--violet-border);  color: var(--violet-text); }
.role-dsp_commander           { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info-text); }
.role-sho_dispatcher, .role-supervisor { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }

/* Unit / code tag (monospace identifier) */
.tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font: 500 11px/1 var(--font-mono);
  white-space: nowrap;
}
.tag-primary { color: var(--primary-text); border-color: var(--primary-border); background: var(--primary-soft); }

/* Copyable ID chip */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 8px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font: 500 11.5px/1 var(--font-mono);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .12s ease, color .12s ease, background-color .12s ease;
}
.chip:hover { border-color: var(--border-hover); color: var(--text); background: var(--surface-3); }
.chip:focus-visible { outline: none; box-shadow: var(--ring); }
.chip .icon { width: 12px; height: 12px; opacity: .6; }

.kbd {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-3);
  font: 500 10.5px/1 var(--font-mono);
}

/* ---------- Alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px; line-height: 1.45;
}
.alert > .icon { margin-top: 1px; }
.alert-danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger-text); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success-text); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning-text); }
.alert-info    { background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); }

/* ---------- Top bar + navigation ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.topbar-divider { width: 1px; height: 24px; background: var(--border); flex: none; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, #5C88FF, #3F6CE8);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}
.brand-mark .icon { width: 17px; height: 17px; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand-product { font-size: 13px; font-weight: 500; color: var(--text-3); }

.nav { display: flex; align-items: center; gap: 2px; }
.nav-link {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font: 500 13px var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease;
}
.nav-link .icon { color: var(--text-3); transition: color .12s ease; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--surface-3); color: var(--text); }
.nav-link.active .icon { color: var(--primary-text); }
.nav-link:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Dropdown menu ---------- */
.menu { position: relative; }
.menu-trigger {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 8px 0 5px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background-color .12s ease, border-color .12s ease;
}
.menu-trigger:hover, .menu.open .menu-trigger { background: var(--surface-2); border-color: var(--border); }
.menu-trigger:focus-visible { outline: none; box-shadow: var(--ring); }
.menu-trigger > .icon { color: var(--text-3); transition: transform .15s ease; }
.menu.open .menu-trigger > .icon { transform: rotate(180deg); }
.menu-trigger-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.menu-trigger-name { font-size: 13px; font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-trigger-role { font-size: 11.5px; color: var(--text-3); text-transform: capitalize; }

.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 248px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  display: none;
  transform-origin: top right;
}
.menu.open .menu-panel { display: block; animation: menuIn .12s ease-out; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-header { display: flex; align-items: center; gap: 10px; padding: 8px 8px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.menu-header-name { font-size: 13.5px; font-weight: 600; }
.menu-header-meta { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 34px; padding: 0 10px;
  border: 0; border-radius: 6px;
  background: none;
  color: var(--text);
  font: 500 13px var(--font-sans);
  text-decoration: none; text-align: left;
  cursor: pointer;
}
.menu-item .icon { color: var(--text-3); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--danger-text); }
.menu-item.danger .icon { color: currentColor; }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--primary-text);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
}
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }

/* ---------- Page scaffolding ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.page-description { font-size: 13.5px; color: var(--text-3); margin-top: 4px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.section-label .icon { color: var(--text-3); }

/* ---------- Stat cards ---------- */
.stat {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.stat-icon {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--primary-soft); color: var(--primary-text);
}
.stat-icon.violet  { background: var(--violet-soft);  color: var(--violet-text); }
.stat-icon.success { background: var(--success-soft); color: var(--success-text); }
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.table th {
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .1s ease; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 2000;
  display: none; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(4, 6, 9, 0.72);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal-backdrop.active { display: flex; }
.modal {
  width: 100%; max-width: 480px;
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn .16s ease-out;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-description { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-footer .spacer { flex: 1; }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed; right: 20px; bottom: 20px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 420px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text);
  pointer-events: auto;
  animation: toastIn .18s ease-out;
}
.toast .icon { margin-top: 1px; color: var(--success-text); }
.toast.error .icon { color: var(--danger-text); }
.toast.leaving { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.empty > .icon { width: 28px; height: 28px; margin-bottom: 6px; opacity: .7; }
.empty-title { font-size: 14px; font-weight: 500; color: var(--text-2); }
.empty .btn { margin-top: 10px; }

/* ---------- Definition list (key/value rows) ---------- */
.dl { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); }
.dl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.dl-row:last-child { border-bottom: 0; }
.dl-label { font-size: 12.5px; color: var(--text-3); flex: none; }
.dl-value { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; min-width: 0; text-align: right; }
.dl-value .mono { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
