/* ═══════════════════════════════════════════════════════════════
   Ardthon Billing — Design System v2 (dark-first)
   Warm terracotta accent. Icon rail + main sidebar. Cmd+K.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 150ms;

  /* Layout */
  --rail-w: 60px;
  --sidebar-w: 220px;
  --topbar-h: 56px;

  /* ─── LIGHT THEME (default) ─── */
  --bg: #faf8f5;
  --bg-subtle: #f4f1ec;
  --surface: #ffffff;
  --surface-hover: #faf8f5;
  --surface-raised: #ffffff;
  --border: #ebe6de;
  --border-strong: #d9d2c6;

  --text: #1a1815;
  --text-muted: #6b6559;
  --text-subtle: #9a9384;

  --accent: #c2542a;
  --accent-hover: #a84a24;
  --accent-subtle: #fdf1ea;
  --accent-ring: rgba(194, 84, 42, 0.15);
  --accent-text: #ffffff;

  --ink: #2b4230;
  --ink-subtle: #eaf0eb;

  --success: #4d7c4a;
  --success-bg: #eaf3ea;
  --warn: #b8761f;
  --warn-bg: #fdf4e6;
  --danger: #b23a34;
  --danger-bg: #fbedec;
  --info: #3b6ea8;
  --info-bg: #ecf2fa;

  --rail-bg: #1a1815;
  --rail-text: #a39c8f;
  --rail-text-active: #ffffff;
  --rail-hover: #2a2520;

  --sidebar-bg: #ffffff;
  --sidebar-text: #1a1815;
  --sidebar-text-muted: #6b6559;
  --sidebar-border: #ebe6de;

  --shadow-sm: 0 1px 2px rgba(26, 24, 21, 0.04);
  --shadow: 0 2px 8px rgba(26, 24, 21, 0.06);
  --shadow-lg: 0 8px 24px rgba(26, 24, 21, 0.08);
  --shadow-xl: 0 16px 48px rgba(26, 24, 21, 0.12);
}

/* ─── DARK THEME ─── */
[data-theme="dark"] {
  --bg: #0f0e0c;
  --bg-subtle: #16140f;
  --surface: #1a1815;
  --surface-hover: #221e17;
  --surface-raised: #221e17;
  --border: #2a2520;
  --border-strong: #3d362c;

  --text: #f5f2ec;
  --text-muted: #a39c8f;
  --text-subtle: #6b6559;

  --accent: #e27048;
  --accent-hover: #ea8259;
  --accent-subtle: #2a1f18;
  --accent-ring: rgba(226, 112, 72, 0.25);
  --accent-text: #ffffff;

  --ink: #7ba882;
  --ink-subtle: #1e2620;

  --success: #7ba882;
  --success-bg: #1e2620;
  --warn: #dba449;
  --warn-bg: #2a2418;
  --danger: #e07068;
  --danger-bg: #2a1c1b;
  --info: #7aa3d6;
  --info-bg: #1a2029;

  --rail-bg: #0a0908;
  --rail-text: #6b6559;
  --rail-text-active: #e27048;
  --rail-hover: #1a1815;

  --sidebar-bg: #16140f;
  --sidebar-text: #f5f2ec;
  --sidebar-text-muted: #a39c8f;
  --sidebar-border: #2a2520;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
}

/* ─── Reset ─── */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  overscroll-behavior-y: none;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
h3 { font-size: 17px; font-weight: 600; }
h4 { font-size: 15px; font-weight: 600; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   APP SHELL — icon rail + sidebar + content
   ═══════════════════════════════════════════════════════════════ */

.abs-app {
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: calc(var(--rail-w) + var(--sidebar-w));
  transition: margin-left var(--duration) var(--ease);
}

.app-main {
  flex: 1;
  padding: 24px 32px;
  max-width: 1400px;
  width: 100%;
}

/* ═══════════════════════════════════════════════════════════════
   ICON RAIL (left edge, narrow)
   ═══════════════════════════════════════════════════════════════ */

.abs-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-w);
  background: var(--rail-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  z-index: 250;
  gap: 4px;
}

.rail-brand {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
  text-decoration: none;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.rail-brand:hover { color: #fff; filter: brightness(1.1); }

.rail-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0 8px;
  overflow-y: auto;
  scrollbar-width: none;
}

.rail-nav::-webkit-scrollbar { display: none; }

.rail-item {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--rail-text);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
  position: relative;
  flex-shrink: 0;
}

.rail-item:hover {
  background: var(--rail-hover);
  color: var(--rail-text-active);
}

.rail-item.active {
  background: var(--rail-hover);
  color: var(--rail-text-active);
}

.rail-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.rail-item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-item .rail-tooltip {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--rail-bg);
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
  z-index: 300;
}

.rail-item:hover .rail-tooltip { opacity: 1; }

.rail-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--rail-hover);
  width: 40px;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR (second column — labels)
   ═══════════════════════════════════════════════════════════════ */

.abs-sidebar {
  position: fixed;
  top: 0;
  left: var(--rail-w);
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 200;
}

.sidebar-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-head-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text-muted);
}

.sidebar-head-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-text);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  scrollbar-width: thin;
}

.nav-section {
  margin-bottom: 20px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text-muted);
  padding: 0 12px 6px;
  margin: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--sidebar-text);
}

.nav-link.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.user-info { min-width: 0; flex: 1; }

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  text-transform: capitalize;
}

/* ═══════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════ */

.abs-topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
}

.topbar-breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.topbar-breadcrumb a:hover { color: var(--text); }

.topbar-breadcrumb .crumb-sep {
  color: var(--text-subtle);
  font-size: 11px;
}

.topbar-breadcrumb .crumb-active {
  color: var(--text);
  font-weight: 600;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  min-width: 220px;
  max-width: 360px;
  flex: 1;
}

.topbar-search:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.topbar-search svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  flex-shrink: 0;
}

.topbar-search .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-subtle);
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
  text-decoration: none;
}

.topbar-icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.topbar-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Theme toggle (sun/moon/system) ─── */
.theme-toggle-group {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}

.theme-btn {
  width: 28px;
  height: 26px;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration) var(--ease);
}

.theme-btn:hover {
  color: var(--text);
}

.theme-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.theme-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════════════ */

.page-header {
  margin-bottom: 24px;
}

.page-header.with-action {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.page-header .eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 6px;
}

.page-header h2 .accent {
  color: var(--accent);
}

.text-muted {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  min-height: 36px;
  line-height: 1;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  min-height: 46px;
}

.btn-block { width: 100%; }

.btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS + STATS
   ═══════════════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all var(--duration) var(--ease);
}

.stat-card:hover {
  border-color: var(--border-strong);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 10px;
  display: block;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-feature-settings: 'tnum';
}

.stat-value .accent { color: var(--accent); }

.stat-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card.stat-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #a84a24 100%);
  border-color: transparent;
  color: #fff;
}

.stat-card.stat-accent .stat-label,
.stat-card.stat-accent .stat-hint { color: rgba(255,255,255,0.8); }
.stat-card.stat-accent .stat-value { color: #fff; }

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted   { background: var(--bg-subtle); color: var(--text-muted); }
.badge-warn    { background: var(--warn-bg); color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-accent  { background: var(--accent-subtle); color: var(--accent); }
.badge-role    { background: var(--bg-subtle); color: var(--text-muted); text-transform: capitalize; }

/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead {
  background: var(--bg-subtle);
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr { transition: background var(--duration) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-hover); }

.actions-col {
  text-align: right;
  white-space: nowrap;
}

/* ─── Avatar initials in tables ─── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
}

.avatar-lg { width: 40px; height: 40px; font-size: 13px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

.avatar-blue   { background: #3b6ea8; }
.avatar-green  { background: #4d7c4a; }
.avatar-purple { background: #7a5aa8; }
.avatar-pink   { background: #b23a7a; }
.avatar-orange { background: var(--accent); }
.avatar-teal   { background: #3a8a8a; }

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 800px;
}

.form-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin: 32px 0 16px;
}

.form-section:first-child { margin-top: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.form-group .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all var(--duration) var(--ease);
  min-height: 38px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-group input[readonly] {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.form-group input[type="color"] {
  height: 40px;
  padding: 3px;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
  font-size: 13.5px;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   FLASH + EMPTY
   ═══════════════════════════════════════════════════════════════ */

.flash-container {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border-left: 3px solid;
}

.flash-success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }
.flash-error   { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.flash-info    { background: var(--info-bg); color: var(--info); border-left-color: var(--info); }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text);
  margin: 0 0 6px;
}

.empty-state p {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 13.5px;
}

/* ═══════════════════════════════════════════════════════════════
   COMMAND PALETTE (Cmd+K)
   ═══════════════════════════════════════════════════════════════ */

.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  backdrop-filter: blur(4px);
}

.cmdk-backdrop.open { display: flex; }


/* ═══════════════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════════════ */

.page-header {
  margin-bottom: 24px;
}

.page-header.with-action {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.page-header .eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 6px;
}

.page-header h2 .accent {
  color: var(--accent);
}

.text-muted {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  min-height: 36px;
  line-height: 1;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 30px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  min-height: 46px;
}

.btn-block { width: 100%; }

.btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS + STATS
   ═══════════════════════════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all var(--duration) var(--ease);
}

.stat-card:hover {
  border-color: var(--border-strong);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin-bottom: 10px;
  display: block;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-feature-settings: 'tnum';
}

.stat-value .accent { color: var(--accent); }

.stat-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-card.stat-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #a84a24 100%);
  border-color: transparent;
  color: #fff;
}

.stat-card.stat-accent .stat-label,
.stat-card.stat-accent .stat-hint { color: rgba(255,255,255,0.8); }
.stat-card.stat-accent .stat-value { color: #fff; }

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted   { background: var(--bg-subtle); color: var(--text-muted); }
.badge-warn    { background: var(--warn-bg); color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-accent  { background: var(--accent-subtle); color: var(--accent); }
.badge-role    { background: var(--bg-subtle); color: var(--text-muted); text-transform: capitalize; }

/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead {
  background: var(--bg-subtle);
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr { transition: background var(--duration) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-hover); }

.actions-col {
  text-align: right;
  white-space: nowrap;
}

/* ─── Avatar initials in tables ─── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
}

.avatar-lg { width: 40px; height: 40px; font-size: 13px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10px; }

.avatar-blue   { background: #3b6ea8; }
.avatar-green  { background: #4d7c4a; }
.avatar-purple { background: #7a5aa8; }
.avatar-pink   { background: #b23a7a; }
.avatar-orange { background: var(--accent); }
.avatar-teal   { background: #3a8a8a; }

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 800px;
}

.form-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin: 32px 0 16px;
}

.form-section:first-child { margin-top: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 5px;
}

.form-group .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all var(--duration) var(--ease);
  min-height: 38px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-group input[readonly] {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.form-group input[type="color"] {
  height: 40px;
  padding: 3px;
  cursor: pointer;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 400;
  font-size: 13.5px;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   FLASH + EMPTY
   ═══════════════════════════════════════════════════════════════ */

.flash-container {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border-left: 3px solid;
}

.flash-success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }
.flash-error   { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.flash-info    { background: var(--info-bg); color: var(--info); border-left-color: var(--info); }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 20px;
  text-align: center;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text);
  margin: 0 0 6px;
}

.empty-state p {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 13.5px;
}

/* ═══════════════════════════════════════════════════════════════
   COMMAND PALETTE (Cmd+K)
   ═══════════════════════════════════════════════════════════════ */

.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  backdrop-filter: blur(4px);
}

.cmdk-backdrop.open { display: flex; }

.cmdk-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  margin: 0 16px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.cmdk-input-wrap svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.cmdk-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}

.cmdk-input::placeholder { color: var(--text-subtle); }

.cmdk-kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-subtle);
}

.cmdk-results {
  overflow-y: auto;
  padding: 6px;
  flex: 1;
}

.cmdk-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 10px 12px 4px;
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background var(--duration) var(--ease);
}

.cmdk-item:hover,
.cmdk-item.selected {
  background: var(--accent-subtle);
  color: var(--accent);
}

.cmdk-item-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cmdk-item-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cmdk-item-body { flex: 1; min-width: 0; }

.cmdk-item-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmdk-item-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmdk-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════
   MINI CHART (sparkline)
   ═══════════════════════════════════════════════════════════════ */

.sparkline {
  display: block;
  width: 100%;
  height: 40px;
  overflow: visible;
}

.sparkline path.line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline path.fill {
  fill: var(--accent);
  opacity: 0.1;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAV
   ═══════════════════════════════════════════════════════════════ */

.mobile-bottom-nav { display: none; }

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0; top: auto;
    height: 64px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 190;
    padding-bottom: env(safe-area-inset-bottom, 0);
    align-items: stretch;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    padding: 6px 2px;
    min-width: 0;
  }

  .mobile-nav-item.active { color: var(--accent); }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 1.75;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  /* Hide label sidebar on tablet, keep rail */
  .abs-sidebar { display: none; }
  .app-content { margin-left: var(--rail-w); }
}

@media (max-width: 768px) {
  /* Hide rail + sidebar; use drawer */
  .abs-rail {
    transform: translateX(-100%);
    transition: transform 200ms var(--ease);
  }

  body.nav-open .abs-rail { transform: translateX(0); }


  body.nav-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
  }

  .app-content { margin-left: 0; }

  .abs-topbar { padding: 0 12px; gap: 10px; }

  .topbar-breadcrumb { display: none; }
  .topbar-search { min-width: 0; flex: 1; }

  .app-main { padding: 16px 12px 88px; }

  .page-header.with-action { flex-direction: column; align-items: stretch; }
  .page-header.with-action .btn { width: 100%; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 22px; }
  .stat-card { padding: 14px; }

  .form-row { grid-template-columns: 1fr; gap: 0; }

  .form-actions { flex-direction: column-reverse; gap: 8px; }
  .form-actions .btn, .form-actions button { width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .theme-toggle-group .theme-btn { width: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Table action buttons — horizontal, compact */
.actions-col .btn {
  margin-left: 4px;
}

.actions-col .inline-form {
  display: inline-block;
  margin: 0;
}

.actions-col .inline-form .btn {
  margin-left: 4px;
}

/* Tighten action column */
.data-table td.actions-col {
  padding: 8px 12px;
}

@media (max-width: 1024px) {
  .data-table td.actions-col {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* Sidebar head — slightly larger title */
.sidebar-head-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-head-sub {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ═══════════════════════════════════════════════════════════════
   LARGE DESKTOP (1440px+)
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 1440px) {
  .app-main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 32px 40px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET PORTRAIT (768px – 1024px) — keep sidebar visible but compact
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */

@media print {
  .abs-rail,
  .abs-sidebar,
  .abs-topbar,
  .mobile-bottom-nav,
  .pwa-install-banner,
  .flash-container,
  .btn {
    display: none !important;
  }

  .app-content {
    margin-left: 0 !important;
  }

  body {
    background: white;
    color: black;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FLYOUT NAVIGATION (Design 1)
   Icon rail + hover-activated flyout panel
   ═══════════════════════════════════════════════════════════════ */

/* App content no longer offset by sidebar — only by rail */
.app-content {
  margin-left: var(--rail-w);
}

/* Hide the always-visible sidebar entirely */
.abs-sidebar {
  position: fixed;
  top: 0;
  left: var(--rail-w);
  bottom: 0;
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 210;
  transform: translateX(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms var(--ease), opacity 180ms var(--ease);
  box-shadow: var(--shadow-lg);
}

body.flyout-open .abs-sidebar {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar head adjustments (used in flyout) */
.sidebar-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-head-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
}

.sidebar-head-sub {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 2px;
}

/* Rail — larger visual hit area for hover detection */
.abs-rail {
  z-index: 250;
}

.rail-item {
  position: relative;
}

/* Sidebar footer (user area) now lives in the rail flyout */
.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: var(--radius-sm);
}

/* ─── On hover of a rail item, expand the sidebar to show that section ─── */

/* Desktop: content has more room now */
@media (min-width: 769px) {
  .app-main {
    max-width: 1400px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — full-screen drawer
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .abs-rail {
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    width: var(--rail-w);
  }

  body.nav-open .abs-rail {
    transform: translateX(0);
  }


  body.nav-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
  }

  .app-content {
    margin-left: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   TABLET PORTRAIT (768–1024) — sidebar as overlay
   ═══════════════════════════════════════════════════════════════ */

@media (min-width: 769px) and (max-width: 1024px) {
  .app-content {
    margin-left: var(--rail-w);
  }
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR USER at bottom of flyout
   ═══════════════════════════════════════════════════════════════ */

.sidebar-foot .user-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.sidebar-foot .user-name {
  font-size: 13px;
}

.sidebar-foot .user-role {
  font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════════
   NAV SECTION SPACING (tighter in flyout)
   ═══════════════════════════════════════════════════════════════ */

.abs-sidebar .sidebar-nav {
  padding: 10px 8px;
}

.abs-sidebar .nav-section {
  margin-bottom: 16px;
}

.abs-sidebar .nav-link {
  padding: 7px 10px;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION-SPECIFIC SIDEBARS (client-side toggle)
   ═══════════════════════════════════════════════════════════════ */

.abs-sidebar {
  display: none;
}

body.flyout-open .abs-sidebar {
  display: flex;
}

/* Only show the sidebar matching the open section */
.abs-sidebar[data-section]:not([data-section=""]) {
  display: none;
}

body.flyout-open .abs-sidebar[data-section="dashboard"],
body.flyout-open .abs-sidebar[data-section="network"],
body.flyout-open .abs-sidebar[data-section="subscribers"],
body.flyout-open .abs-sidebar[data-section="plans"],
body.flyout-open .abs-sidebar[data-section="routers"],
body.flyout-open .abs-sidebar[data-section="payments"],
body.flyout-open .abs-sidebar[data-section="reports"],
body.flyout-open .abs-sidebar[data-section="tickets"],
body.flyout-open .abs-sidebar[data-section="leads"],
body.flyout-open .abs-sidebar[data-section="tenants"],
body.flyout-open .abs-sidebar[data-section="users"],
body.flyout-open .abs-sidebar[data-section="settings"] {
  /* These are the ones that CAN be shown */
}

/* ═══════════════════════════════════════════════════════════════
   SECTION-SPECIFIC SIDEBAR PANELS
   Only one visible at a time, controlled by JS
   ═══════════════════════════════════════════════════════════════ */

.abs-sidebar .sidebar-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.abs-sidebar .sidebar-panel.active {
  display: flex;
}

/* Wrap the existing sidebar-nav + sidebar-foot inside panels */
.sidebar-panel .sidebar-nav {
  flex: 1;
  overflow-y: auto;
}

.sidebar-panel .sidebar-foot {
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR PANEL SWITCHING — force one visible at a time
   ═══════════════════════════════════════════════════════════════ */

/* All panels hidden by default */
.abs-sidebar .sidebar-panel {
  display: none !important;
}

/* Only the active panel shows */
.abs-sidebar .sidebar-panel.active {
  display: flex !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Sidebar nav scrolls within panel */
.sidebar-panel .sidebar-nav {
  flex: 1;
  overflow-y: auto;
}

/* Sidebar footer pinned to bottom of the sidebar */
.abs-sidebar .sidebar-foot {
  flex-shrink: 0;
}

/* Sidebar head pinned to top */
.abs-sidebar .sidebar-head {
  flex-shrink: 0;
}

/* ─── Final definitive rule: hide any panel without .active ─── */
.abs-sidebar .sidebar-panel:not(.active) {
  display: none !important;
}
.abs-sidebar .sidebar-panel.active {
  display: flex !important;
}

/* ═══════════════════════════════════════════════════════════════
   HOVER FLYOUT — sidebar hidden by default, appears on hover
   ═══════════════════════════════════════════════════════════════ */

/* Base state: hidden with slide + fade */
.abs-sidebar {
  display: flex;
  transform: translateX(-12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}

body.flyout-open .abs-sidebar {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar head takes the full width nicely */
.abs-sidebar .sidebar-head {
  padding: 16px 18px;
}

/* Nav links tighter in flyout */
.abs-sidebar .sidebar-nav {
  padding: 10px 10px;
}

.abs-sidebar .nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin: 1px 0;
}

.abs-sidebar .nav-link:hover {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ─── Mobile: sidebar becomes a slide-in drawer ─── */
@media (max-width: 768px) {
  .abs-sidebar {
    display: flex;
    transform: translateX(-100%);
    opacity: 1;
    pointer-events: auto;
    width: calc(100vw - var(--rail-w));
    max-width: 320px;
    left: var(--rail-w);
  }

  body.nav-open .abs-sidebar {
    transform: translateX(0);
  }

  body.nav-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
  }
}

/* ═══════════════════════════════════════════════════════════════
   RAIL HEALTH BADGE
   ═══════════════════════════════════════════════════════════════ */

.rail-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 2px var(--rail-bg, #1a1a1a);
  pointer-events: none;
  transition: background 200ms ease, box-shadow 200ms ease;
}

.rail-badge[data-health="unknown"] { background: var(--text-muted, #666); }
.rail-badge[data-health="ok"]      { background: #22c55e; }
.rail-badge[data-health="warn"]    { background: #f59e0b; }
.rail-badge[data-health="down"]    { background: #ef4444; animation: rail-pulse 1.6s ease-in-out infinite; }

@keyframes rail-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* Rail badge inside the mobile bottom nav */
.mobile-nav-item { position: relative; }
.mobile-nav-item .rail-badge {
  top: 8px;
  right: calc(50% - 18px);
}

/* ─── Mobile sliver fix: reset sidebar left to 0 so translateX(-100%) fully hides it ─── */
@media (max-width: 768px) {
  html body .abs-sidebar {
    left: 0 !important;
  }
  html body.nav-open .abs-sidebar {
    left: 0 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ACTIVITY TIMELINE
   ═══════════════════════════════════════════════════════════════ */
.activity-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.activity-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.activity-item {
  display: flex;
  gap: 14px;
  padding: 12px 16px;
  position: relative;
}
.activity-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.activity-icon svg { width: 16px; height: 16px; stroke: var(--text-muted); }
.activity-item.activity-payment .activity-icon { border-color: #22c55e; }
.activity-item.activity-payment .activity-icon svg { stroke: #22c55e; }
.activity-item.activity-ticket .activity-icon { border-color: #f59e0b; }
.activity-item.activity-ticket .activity-icon svg { stroke: #f59e0b; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 14px; font-weight: 500; color: var(--text); }
.activity-title a { color: inherit; text-decoration: none; }
.activity-title a:hover { color: var(--accent); text-decoration: underline; }
.activity-meta { font-size: 12.5px; margin-top: 2px; }
.activity-time { font-size: 11.5px; margin-top: 2px; opacity: 0.7; }

/* ═══════════════════════════════════════════════════════════════
   ACTIVITY TIMELINE
   ═══════════════════════════════════════════════════════════════ */
.activity-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.activity-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}
.activity-item {
  display: flex;
  gap: 14px;
  padding: 12px 16px;
  position: relative;
}
.activity-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.activity-icon svg { width: 16px; height: 16px; stroke: var(--text-muted); }
.activity-item.activity-payment .activity-icon { border-color: #22c55e; }
.activity-item.activity-payment .activity-icon svg { stroke: #22c55e; }
.activity-item.activity-ticket .activity-icon { border-color: #f59e0b; }
.activity-item.activity-ticket .activity-icon svg { stroke: #f59e0b; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-size: 14px; font-weight: 500; color: var(--text); }
.activity-title a { color: inherit; text-decoration: none; }
.activity-title a:hover { color: var(--accent); text-decoration: underline; }
.activity-meta { font-size: 12.5px; margin-top: 2px; }
.activity-time { font-size: 11.5px; margin-top: 2px; opacity: 0.7; }

/* ─── Mobile drawer: paint above the rail; fill full width ─── */
@media (max-width: 768px) {
  html body .abs-sidebar {
    z-index: 300 !important;
  }
  html body.nav-open .abs-sidebar {
    left: 0 !important;
    transform: translateX(0) !important;
  }
  body.nav-open .abs-rail {
    /* rail sits behind the drawer */
    z-index: 100;
  }
}

/* ─── Sidebar close button (mobile drawer only) ─── */
.sidebar-close-btn { display: none; }

@media (max-width: 768px) {
  .sidebar-head { position: relative; }
  .sidebar-close-btn {
    display: flex;
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    padding: 0;
  }
  .sidebar-close-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
  }
}

/* ─── Mobile: rail + sidebar as two-column drawer ─── */
@media (max-width: 768px) {
  /* rail slides in when drawer open, above the sidebar */
  html body.nav-open .abs-rail {
    transform: translateX(0) !important;
    z-index: 300 !important;
  }
  /* sidebar starts after the rail */
  html body.nav-open .abs-sidebar {
    left: var(--rail-w) !important;
    width: calc(100vw - var(--rail-w)) !important;
  }
  /* closed states: both hidden */
  html body:not(.nav-open) .abs-rail {
    transform: translateX(-100%) !important;
  }
  html body:not(.nav-open) .abs-sidebar {
    left: 0 !important;
    transform: translateX(-100%) !important;
  }
}
