/* ============================================================
   COSINT — Dark Terminal Theme
   Cannabis Open Source Intelligence Platform
   Brand: #E85D26 orange on #1a1a1a dark
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Surfaces */
  --bg-deepest: #0a0a0a;
  --bg-deep: #111111;
  --bg-surface: #1a1a1a;
  --bg-elevated: #222222;
  --border-primary: #333333;
  --border-subtle: #262626;

  /* Text */
  --text-primary: #ededed;
  --text-secondary: #c4c4c4;
  --text-muted: #8a8a8a;
  --text-faint: #555555;

  /* Brand — COSINT Orange */
  --accent-primary: #E85D26;
  --accent-primary-dim: rgba(232, 93, 38, 0.14);
  --accent-primary-glow: rgba(232, 93, 38, 0.07);
  --accent-primary-hover: #F06D38;

  /* Semantic accents */
  --accent-green: #3fb950;
  --accent-green-dim: rgba(63, 185, 80, 0.14);
  /* Former “info/secondary” blue → brand orange (matches logo) */
  --accent-blue: var(--accent-primary);
  --accent-blue-dim: var(--accent-primary-dim);
  --accent-amber: #d29922;
  --accent-amber-dim: rgba(210, 153, 34, 0.14);
  --accent-red: #f85149;
  --accent-red-dim: rgba(248, 81, 73, 0.14);
  --accent-purple: #bc8cff;
  --accent-purple-dim: rgba(188, 140, 255, 0.14);
  --accent-cyan: #39d2c0;
  --accent-cyan-dim: rgba(57, 210, 192, 0.14);

  /* Typography */
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* Layout */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --sidebar-width: 250px;
  --transition-fast: 0.15s ease;
  --transition-med: 0.25s ease;

  --nav-hover-bg: rgba(255, 255, 255, 0.04);
  --chart-tick: #555555;
  --chart-legend: #8a8a8a;
  --chart-grid: rgba(255, 255, 255, 0.06);
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-deep);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
}

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

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

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-deepest);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar-brand {
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
}

.sidebar-brand-link {
  display: block;
  line-height: 0;
  text-decoration: none;
}

.sidebar-brand-link:hover .sidebar-brand-logo {
  opacity: 0.92;
}

.sidebar-brand-logo {
  display: block;
  width: 100%;
  max-width: 214px;
  height: auto;
  max-height: 52px;
  object-fit: contain;
  object-position: left center;
}

.sidebar-nav {
  list-style: none;
  padding: 10px 0;
}

.sidebar-nav--main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-account {
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

.sidebar-account .sidebar-section-label {
  padding-top: 14px;
}

.sidebar-account .sidebar-nav {
  padding-top: 4px;
  padding-bottom: 6px;
}

.sidebar-section-label {
  padding: 16px 18px 6px;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.sidebar-nav li a,
.sidebar-nav li button,
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
  font-family: var(--font-sans);
}

.sidebar-nav li a:hover,
.sidebar-nav li button:hover,
.sidebar-nav-link:hover {
  color: var(--text-secondary);
  background: var(--nav-hover-bg);
}

.sidebar-nav li.active a,
.sidebar-nav li.active .sidebar-nav-link,
.sidebar-nav-link.active {
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
  border-left-color: var(--accent-primary);
}

.sidebar-nav li.sub-item a {
  padding-left: 36px;
  font-size: 12px;
}

.sidebar-nav li .badge-soon {
  font-size: 9px;
  color: var(--text-faint);
  background: var(--border-subtle);
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: auto;
  font-family: var(--font-mono);
}

.sidebar-divider {
  margin: 8px 18px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-deepest);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-username {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-userrole {
  font-size: 10px;
  color: var(--text-faint);
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav li.active .nav-icon {
  opacity: 1;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-header {
  padding: 20px 28px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.content-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.content-header .subtitle {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.content-body {
  padding: 20px 28px 32px;
  flex: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-primary);
  font-family: var(--font-sans);
  text-decoration: none;
}

.btn-default {
  background: var(--border-subtle);
  color: var(--text-secondary);
  border-color: var(--border-primary);
}
.btn-default:hover {
  background: var(--border-primary);
  color: var(--text-primary);
}

.btn-primary {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}
.btn-primary:hover {
  background: rgba(232, 93, 38, 0.25);
  color: var(--accent-primary-hover);
}

.btn-secondary {
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}
.btn-secondary:hover {
  background: rgba(232, 93, 38, 0.25);
  color: var(--accent-primary-hover);
}

.btn-danger {
  background: var(--accent-red-dim);
  color: var(--accent-red);
  border-color: rgba(248, 81, 73, 0.4);
}
.btn-danger:hover {
  background: rgba(248, 81, 73, 0.25);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-sans);
}
.btn-link:hover {
  color: var(--accent-primary);
}

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

/* ============================================================
   METRIC CARDS
   ============================================================ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.metric-label {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.metric-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
  line-height: 1.2;
}

.metric-value.brand   { color: var(--accent-primary); }
.metric-value.success  { color: var(--accent-green); }
.metric-value.warning  { color: var(--accent-amber); }
.metric-value.danger   { color: var(--accent-red); }
.metric-value.info     { color: var(--accent-blue); }

.metric-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: var(--font-mono);
}

.metric-detail.success { color: var(--accent-green); }
.metric-detail.warning { color: var(--accent-amber); }
.metric-detail.brand   { color: var(--accent-primary); }

/* ============================================================
   PANELS / CARDS
   ============================================================ */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-action {
  font-size: 12px;
  color: var(--accent-primary);
  cursor: pointer;
  text-decoration: none;
}
.panel-action:hover {
  color: var(--accent-primary-hover);
}

.panel-body {
  padding: 18px;
}

.panel-body-flush {
  padding: 0;
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  padding: 10px 18px;
  text-align: left;
  font-weight: 400;
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 18px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr.clickable-row {
  cursor: pointer;
}
.data-table tbody tr.clickable-row:hover {
  background: var(--accent-primary-glow);
}

.data-table .mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.data-table .muted {
  color: var(--text-muted);
}

.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
}
.data-table thead th.sortable:hover {
  color: var(--text-secondary);
}
.data-table thead th.sorted-asc::after {
  content: ' ▲';
  font-size: 8px;
}
.data-table thead th.sorted-desc::after {
  content: ' ▼';
  font-size: 8px;
}

/* flush table in panel */
.panel .data-table thead th:first-child,
.panel .data-table tbody td:first-child {
  padding-left: 18px;
}
.panel .data-table thead th:last-child,
.panel .data-table tbody td:last-child {
  padding-right: 18px;
}

/* ============================================================
   SEARCH & FILTER BAR
   ============================================================ */
.search-filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-deepest);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(232, 93, 38, 0.1);
}

.search-input::placeholder {
  color: var(--text-faint);
}

.filter-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-select {
  padding: 9px 32px 9px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-deepest);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8a8a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  min-width: 140px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(232, 93, 38, 0.1);
}

/* Active filter chips */
.active-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--accent-primary);
  background: var(--accent-primary-dim);
  border: 1px solid rgba(232, 93, 38, 0.3);
  border-radius: 20px;
  font-family: var(--font-mono);
}

.filter-chip .chip-remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  color: inherit;
}
.filter-chip .chip-remove:hover {
  opacity: 1;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.pagination-info {
  color: var(--text-faint);
}

.pagination-controls {
  display: flex;
  gap: 4px;
}

.pagination-controls a,
.pagination-controls span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.pagination-controls a:hover {
  background: var(--border-subtle);
  color: var(--text-secondary);
}

.pagination-controls .current {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  font-weight: 500;
}

.pagination-controls .disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.chart-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
  min-height: 300px;
}

/* Market data (and similar): cap chart height — Chart.js + flex was stretching the canvas */
.chart-container--bounded {
  min-height: unset;
}

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 260px;
  max-height: min(280px, 42vh);
}

/* Doughnut: keep box from growing too tall */
.chart-canvas-wrap--short {
  height: 220px;
  max-height: min(240px, 38vh);
}

/* Full-width trend chart */
.chart-canvas-wrap--wide {
  height: 240px;
  max-height: min(280px, 40vh);
}

.chart-container canvas {
  max-width: 100%;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  font-family: var(--font-mono);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-deepest);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.chart-tab {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  transition: all var(--transition-fast);
}

.chart-tab:hover {
  color: var(--text-secondary);
}

.chart-tab.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
}

/* ============================================================
   STATUS INDICATORS
   ============================================================ */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  white-space: nowrap;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.active   { color: var(--accent-green); }
.status-dot.active::before { background: var(--accent-green); }
.status-dot.inactive { color: var(--accent-amber); }
.status-dot.inactive::before { background: var(--accent-amber); }
.status-dot.revoked  { color: var(--accent-red); }
.status-dot.revoked::before { background: var(--accent-red); }
.status-dot.pending  { color: var(--text-faint); }
.status-dot.pending::before { background: var(--text-faint); }
.status-dot.success  { color: var(--accent-green); }
.status-dot.success::before { background: var(--accent-green); }

/* License type badges */
.license-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}

.license-type.retail       { background: var(--accent-primary-dim); color: var(--accent-primary); }
.license-type.cultivator   { background: var(--accent-green-dim); color: var(--accent-green); }
.license-type.manufacturer { background: var(--accent-purple-dim); color: var(--accent-purple); }
.license-type.distributor  { background: var(--accent-blue-dim); color: var(--accent-blue); }
.license-type.testing      { background: var(--accent-cyan-dim); color: var(--accent-cyan); }
.license-type.other        { background: var(--border-subtle); color: var(--text-faint); }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.progress-row:last-child { margin-bottom: 0; }

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--border-subtle);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-med);
}

.progress-fill.orange { background: var(--accent-primary); }
.progress-fill.green  { background: var(--accent-green); }
.progress-fill.blue   { background: var(--accent-blue); }
.progress-fill.purple { background: var(--accent-purple); }
.progress-fill.amber  { background: var(--accent-amber); }
.progress-fill.cyan   { background: var(--accent-cyan); }

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 120px;
  font-family: var(--font-mono);
}

.progress-value {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 48px;
  text-align: right;
  font-family: var(--font-mono);
}

/* ============================================================
   STATUS ROWS
   ============================================================ */
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}
.status-row:first-child { padding-top: 0; }
.status-row:last-child  { padding-bottom: 0; }

.status-row-label {
  font-size: 13px;
  color: var(--text-muted);
}

.status-row-value {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.status-row-value .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-row-value .dot.green  { background: var(--accent-green); }
.status-row-value .dot.amber  { background: var(--accent-amber); }
.status-row-value .dot.red    { background: var(--accent-red); }
.status-row-value .dot.orange { background: var(--accent-primary); }

.status-row-value.green  { color: var(--accent-green); }
.status-row-value.amber  { color: var(--accent-amber); }
.status-row-value.red    { color: var(--accent-red); }

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-deepest);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(232, 93, 38, 0.1);
}

.form-control::placeholder {
  color: var(--text-faint);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8a8a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ============================================================
   AUTH PAGES (Login, Register, Password Reset)
   ============================================================ */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-deep);
  padding: 24px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo img {
  height: 48px;
  width: auto;
}

.auth-logo-text {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--accent-primary);
  letter-spacing: 3px;
}

.auth-logo-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 24px;
}

.auth-card .form-control {
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 4px;
}

.auth-card .btn {
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
  font-size: 14px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-faint);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-error {
  background: var(--accent-red-dim);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--accent-red);
  font-size: 13px;
  margin-bottom: 16px;
}

/* SSO buttons */
.btn-google {
  background: var(--bg-deepest);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 10px 16px;
  width: 100%;
  justify-content: center;
  font-size: 14px;
}
.btn-google:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.btn-google svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-microsoft {
  background: var(--bg-deepest);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 10px 16px;
  width: 100%;
  justify-content: center;
  font-size: 14px;
  margin-top: 8px;
}
.btn-microsoft:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ============================================================
   PROFILE
   ============================================================ */
.profile-section-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.profile-table {
  width: 100%;
  font-size: 13px;
}

.profile-table td {
  padding: 8px 0;
  vertical-align: top;
}

.profile-table td:first-child {
  color: var(--text-muted);
  width: 180px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.profile-table td:last-child {
  color: var(--text-secondary);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}

.badge-success { background: var(--accent-green-dim); color: var(--accent-green); }
.badge-warning { background: var(--accent-amber-dim); color: var(--accent-amber); }
.badge-danger  { background: var(--accent-red-dim); color: var(--accent-red); }
.badge-info    { background: var(--accent-blue-dim); color: var(--accent-blue); }
.badge-brand   { background: var(--accent-primary-dim); color: var(--accent-primary); }
.badge-muted   { background: var(--border-subtle); color: var(--text-faint); }

/* ============================================================
   DETAIL / LOG VIEW
   ============================================================ */
.log-output {
  background: var(--bg-deepest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 16px;
  font-size: 13px;
}

.detail-key {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
}

.detail-value {
  color: var(--text-secondary);
}

/* ============================================================
   EMPTY STATES & ALERTS
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-faint);
}

.empty-state-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 14px;
  margin-bottom: 16px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success {
  background: var(--accent-green-dim);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--accent-green);
}

.alert-error {
  background: var(--accent-red-dim);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--accent-red);
}

.alert-info {
  background: var(--accent-blue-dim);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: var(--accent-blue);
}

/* ============================================================
   TAB NAV
   ============================================================ */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.tab-nav a,
.tab-nav button {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  margin-bottom: -1px;
}

.tab-nav a:hover,
.tab-nav button:hover {
  color: var(--text-secondary);
}

.tab-nav a.active,
.tab-nav button.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* ============================================================
   EXPORT OPTIONS
   ============================================================ */
.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-deepest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.export-option:hover {
  border-color: var(--border-primary);
}

.export-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.export-option-name {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.export-option-desc {
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ============================================================
   DATA FRESHNESS INDICATOR
   ============================================================ */
.data-freshness {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.data-freshness .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ============================================================
   MISC
   ============================================================ */
/* Logout must match Profile / Settings link padding — do not strip .sidebar-nav-link styles */
#logout-form {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-med);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content-body { padding: 16px; }
  .mobile-menu-toggle { display: flex; }
  .search-filter-bar { flex-direction: column; align-items: stretch; }
  .search-input-wrap { min-width: 100%; }
  .filter-group { width: 100%; }
  .filter-select { flex: 1; min-width: 0; }
}

@media (min-width: 769px) {
  .mobile-menu-toggle { display: none; }
}

.mobile-menu-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-primary); }

/* ============================================================
   SETTINGS — left subnav & theme toggle
   ============================================================ */
.settings-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  max-width: 56rem;
}

.settings-subnav {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 168px;
  padding-right: 20px;
  border-right: 1px solid var(--border-subtle);
}

.settings-subnav button {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-md);
  border-left: 2px solid transparent;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
  font-family: var(--font-sans);
}

.settings-subnav button:hover {
  color: var(--text-secondary);
  background: var(--nav-hover-bg);
}

.settings-subnav button.active {
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
  border-left-color: var(--accent-primary);
}

.settings-panels {
  flex: 1;
  min-width: 0;
}

@media (max-width: 640px) {
  .settings-layout {
    flex-direction: column;
    gap: 16px;
  }
  .settings-subnav {
    flex-direction: row;
    flex-wrap: wrap;
    min-width: 0;
    width: 100%;
    padding-right: 0;
    padding-bottom: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .settings-subnav button {
    border-left: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    border-radius: 0;
    padding: 10px 14px;
  }
  .settings-subnav button.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent-primary);
    background: transparent;
  }
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 40rem;
}

.settings-row-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 14px;
}

.settings-row-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 28rem;
}

.theme-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.theme-toggle-label {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-primary);
  border-radius: 24px;
  transition: background var(--transition-fast);
  border: 1px solid var(--border-subtle);
}

.theme-switch-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition-med);
}

.theme-switch input:checked + .theme-switch-slider {
  background: var(--accent-primary-dim);
  border-color: var(--accent-primary);
}

.theme-switch input:checked + .theme-switch-slider::before {
  transform: translateX(20px);
  background: var(--accent-primary);
}

.theme-switch input:focus-visible + .theme-switch-slider {
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

/* ============================================================
   LIGHT THEME
   ============================================================ */
html[data-theme="light"] {
  --bg-deepest: #e4e7ec;
  --bg-deep: #eef1f6;
  --bg-surface: #ffffff;
  --bg-elevated: #f7f9fc;
  --border-primary: #c8ced9;
  --border-subtle: #dde2ea;
  --text-primary: #12141a;
  --text-secondary: #3a3f4d;
  --text-muted: #5c6370;
  --text-faint: #7a8290;
  --accent-primary-glow: rgba(232, 93, 38, 0.12);
  --accent-primary-dim: rgba(232, 93, 38, 0.16);
  --nav-hover-bg: rgba(0, 0, 0, 0.05);
  --chart-tick: #5c6370;
  --chart-legend: #6b7280;
  --chart-grid: rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .data-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="light"] .data-table tbody tr.clickable-row:hover {
  background: var(--accent-primary-glow);
}

html[data-theme="light"] .mobile-menu-toggle {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html[data-theme="light"] .auth-card {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
