:root {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --bg-sidebar-active: rgba(16, 185, 129, 0.16);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-sidebar: #cbd5e1;
  --text-sidebar-strong: #f8fafc;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent-emerald: #10b981;
  --accent-emerald-dark: #047857;
  --accent-rate: #047857;
  --accent-blue: #2563eb;
  --accent-amber: #d97706;
  --accent-red: #dc2626;
  --accent-purple: #7c3aed;

  --badge-ok-bg: #dcfce7;
  --badge-ok-fg: #166534;
  --badge-warn-bg: #fef3c7;
  --badge-warn-fg: #92400e;
  --badge-danger-bg: #fee2e2;
  --badge-danger-fg: #991b1b;
  --badge-info-bg: #dbeafe;
  --badge-info-fg: #1e40af;
  --badge-purple-bg: #ede9fe;
  --badge-purple-fg: #5b21b6;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 14px 36px rgba(15, 23, 42, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 256px;
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-card: #111b2e;
  --bg-subtle: #162238;
  --bg-sidebar: #070c17;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.07);
  --bg-sidebar-active: rgba(16, 185, 129, 0.2);

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-subtle: #1e2d47;
  --border-strong: #334155;
  --accent-rate: #34d399;

  --badge-ok-bg: rgba(16, 185, 129, 0.18);
  --badge-ok-fg: #6ee7b7;
  --badge-warn-bg: rgba(245, 158, 11, 0.18);
  --badge-warn-fg: #fcd34d;
  --badge-danger-bg: rgba(239, 68, 68, 0.18);
  --badge-danger-fg: #fca5a5;
  --badge-info-bg: rgba(59, 130, 246, 0.18);
  --badge-info-fg: #93c5fd;
  --badge-purple-bg: rgba(139, 92, 246, 0.18);
  --badge-purple-fg: #c4b5fd;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ==================== APP SHELL ==================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.22s ease;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-title {
  color: var(--text-sidebar-strong);
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: #34d399;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
  padding: 10px 10px 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-sidebar);
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: var(--bg-sidebar-hover);
  color: #ffffff;
}

.nav-btn.active {
  background: var(--bg-sidebar-active);
  color: #34d399;
  font-weight: 600;
}

.nav-btn svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-btn.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.source-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}
.status-dot.offline { background: #f59e0b; }

.source-meta { overflow: hidden; }
.source-name {
  color: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.source-sub { color: #94a3b8; font-size: 11px; }

.sidebar-actions {
  display: flex;
  gap: 6px;
}

.sidebar-actions .btn-mini {
  flex: 1;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-actions .btn-mini:hover { background: rgba(255, 255, 255, 0.12); }

/* ==================== MAIN AREA ==================== */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.page-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-subtle); }
.btn-primary {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #ffffff;
}
.btn-primary:hover { background: var(--accent-emerald-dark); border-color: var(--accent-emerald-dark); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ==================== FILTER BAR ==================== */
.filter-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.month-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.pill:hover { border-color: var(--accent-emerald); color: var(--text-primary); }
.pill.active {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #ffffff;
}
.pill.empty { opacity: 0.45; }

.filter-select {
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  user-select: none;
}

/* ==================== CONTENT & CARDS ==================== */
.content-wrap {
  padding: 20px 24px 36px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-accent, var(--accent-emerald));
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.grid-12-7-5 {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.grid-2 .card, .grid-12-7-5 .card { margin-bottom: 0; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-desc {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== BADGES & CALLOUTS ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-ok { background: var(--badge-ok-bg); color: var(--badge-ok-fg); }
.badge-warn { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.badge-danger { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.badge-info { background: var(--badge-info-bg); color: var(--badge-info-fg); }
.badge-purple { background: var(--badge-purple-bg); color: var(--badge-purple-fg); }

.std-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

.callout {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent-blue);
  background: var(--bg-subtle);
  margin-bottom: 14px;
  font-size: 13px;
}
.callout-warn { border-left-color: #f59e0b; }
.callout-danger { border-left-color: #ef4444; }
.callout-ok { border-left-color: #10b981; }
.callout strong { color: var(--text-primary); }

/* ==================== COST BEHAVIOR BAR ==================== */
.behavior-bar {
  display: flex;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-subtle);
  margin: 10px 0 12px;
}
.behavior-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.behavior-box {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}
.behavior-box-lbl { font-size: 11.5px; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.behavior-box-val { font-size: 15px; font-weight: 800; margin-top: 3px; }
.behavior-box-sub { font-size: 11.5px; color: var(--text-secondary); }

/* ==================== CHARTS ==================== */
.vra-svg-chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-grid { stroke: var(--border-subtle); stroke-dasharray: 3 3; stroke-width: 1; }
.chart-axis-text { fill: var(--text-muted); font-size: 10.5px; font-weight: 600; }
.chart-axis-sub { fill: var(--text-muted); font-size: 9.5px; opacity: 0.7; }
.chart-val-label { fill: var(--text-secondary); font-size: 9.5px; font-weight: 700; }
.chart-bar-empty { fill: var(--border-subtle); }
.chart-hit { cursor: pointer; }
.chart-hit:hover { fill: rgba(16, 185, 129, 0.08); }

.chart-legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.chart-legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

.donut-layout {
  display: grid;
  grid-template-columns: 158px 1fr;
  gap: 12px;
  align-items: center;
}
.donut-svg { width: 100%; max-width: 158px; display: block; margin: 0 auto; }
.donut-seg { cursor: pointer; transition: opacity 0.15s; }
.donut-seg:hover { opacity: 0.82; }
.donut-center-label { fill: var(--text-muted); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; }
.donut-center-val { fill: var(--text-primary); font-size: 14px; font-weight: 800; }

.donut-legend { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.donut-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
  padding: 3px 0;
  border-bottom: 1px dashed var(--border-subtle);
}
.donut-legend-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.mini-std { font-size: 9px; color: var(--text-muted); background: var(--bg-subtle); padding: 1px 4px; border-radius: 4px; white-space: nowrap; flex-shrink: 0; }
.donut-legend-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.donut-pct { color: var(--text-muted); font-size: 11.5px; }
.donut-amt { font-weight: 700; }

.hbar-list { display: flex; flex-direction: column; gap: 9px; }
.hbar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; margin-bottom: 4px; }
.hbar-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hbar-code { font-size: 11px; color: var(--text-muted); background: var(--bg-subtle); padding: 1px 6px; border-radius: 4px; }
.hbar-meta { font-size: 11px; color: var(--text-muted); }
.hbar-val { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hbar-share { font-size: 11px; color: var(--text-muted); width: 42px; text-align: right; }
.hbar-track { height: 8px; border-radius: 99px; background: var(--bg-subtle); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 99px; transition: width 0.3s ease; }

.chart-tooltip {
  position: fixed;
  z-index: 999;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  min-width: 210px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.tip-title { font-weight: 700; margin-bottom: 5px; color: #34d399; border-bottom: 1px solid rgba(255,255,255,0.12); padding-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; margin-top: 3px; }

/* ==================== TABLES ==================== */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.search-input {
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 240px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

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

table.data-table thead th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 9px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
table.data-table thead th.sortable { cursor: pointer; user-select: none; }
table.data-table thead th.sortable:hover { color: var(--text-primary); }
table.data-table th.num, table.data-table td.num { text-align: right; }

table.data-table tbody td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
table.data-table tbody tr:hover { background: var(--bg-subtle); }
table.data-table tbody tr.clickable { cursor: pointer; }
table.data-table tfoot td {
  background: var(--bg-subtle);
  font-weight: 800;
  padding: 9px 9px;
  border-top: 2px solid var(--border-strong);
}

table.data-table .sticky-col {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 3;
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.08);
}
table.data-table thead th.sticky-col {
  left: 0;
  top: 0;
  background: var(--bg-subtle);
  z-index: 6;
}
table.data-table tfoot td.sticky-col {
  left: 0;
  background: var(--bg-subtle);
  z-index: 5;
}

.cell-spike { background: rgba(239, 68, 68, 0.12) !important; color: var(--accent-red); font-weight: 700; }
.cell-co { background: rgba(245, 158, 11, 0.12) !important; }
.cell-anom { background: rgba(139, 92, 246, 0.14) !important; color: var(--accent-purple); font-weight: 700; }
.cell-zero { color: var(--text-muted); opacity: 0.45; }

/* ==================== SUB-TABS ==================== */
.subtabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.subtab-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.subtab-btn.active {
  background: var(--text-primary);
  color: var(--bg-card);
  border-color: var(--text-primary);
}

/* ==================== DRAWER (UNIT DETAIL) ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 60;
  display: none;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
}
.drawer-backdrop.open { display: flex; }

.drawer-panel {
  width: min(760px, 100vw);
  height: 100%;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-body {
  padding: 18px 22px 28px;
  overflow-y: auto;
  flex: 1;
}

/* ==================== MODAL & USAGE BUTTON ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  z-index: 75;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }

.modal-card {
  width: min(460px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.modal-body { padding: 16px 18px; }
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-usage-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px dashed var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.btn-usage-pill:hover {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald-dark);
  background: var(--badge-ok-bg);
}

.btn-edit-inline {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 11px;
}
.btn-edit-inline:hover {
  background: var(--bg-subtle);
  color: var(--accent-blue);
}

/* ==================== FORM & SETTINGS ==================== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; }
.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
}
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-subtle);
  transition: border-color 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent-emerald); }

.recon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.recon-card {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.recon-card.ok { border-color: rgba(16, 185, 129, 0.45); }
.recon-card.empty { opacity: 0.6; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: #0f172a;
  color: #f8fafc;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent-emerald);
  display: none;
  max-width: 420px;
}
.toast.show { display: block; }
.toast.error { border-left-color: #ef4444; }

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 35;
}

.print-header { display: none; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1080px) {
  .grid-2, .grid-12-7-5 { grid-template-columns: 1fr; }
  .donut-layout { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; }
  .main-area { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .topbar, .filter-bar, .content-wrap { padding-left: 14px; padding-right: 14px; }
  .behavior-grid { grid-template-columns: 1fr; }
}

/* ==================== PRINT STYLESHEET ==================== */
@media print {
  .sidebar, .topbar, .filter-bar, .no-print, .drawer-backdrop, .toast { display: none !important; }
  .main-area { margin-left: 0 !important; }
  body { background: #ffffff !important; color: #000000 !important; font-size: 11px; }
  .print-header { display: block !important; margin-bottom: 14px; border-bottom: 2px solid #0f172a; padding-bottom: 8px; }
  .card, .kpi-card { break-inside: avoid; box-shadow: none !important; border-color: #cbd5e1 !important; }
}


/* ==================== LOGIN GATE ==================== */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 60%, #020617 100%);
}
.login-gate.hidden {
  display: none;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 28px 26px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}
.login-company {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-blue);
}
.login-title {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.25;
}
.login-desc {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.login-pwd-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-pwd-wrap .form-input {
  padding-right: 42px;
}
.login-pwd-toggle {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  color: var(--text-muted);
  border-radius: 6px;
}
.login-pwd-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 6px 0 14px;
  cursor: pointer;
  user-select: none;
}
.login-error {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  font-weight: 600;
}
.login-submit {
  width: 100%;
  justify-content: center;
  padding: 11px 16px;
  font-size: 13.5px;
}
.login-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}
@media print {
  .login-gate { display: none !important; }
}
