/*
 * JIT Central v2 — Bright Admin Theme
 * Clean, modern, light-themed admin UI built with vanilla CSS.
 */

/* ========================================
   Design Tokens
   ======================================== */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", monospace;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  --color-border-focus: #0666eb;

  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #ffffff;

  --color-primary: #0666eb;
  --color-primary-hover: #0552c0;
  --color-primary-light: #eff6ff;

  --color-success: #16a34a;
  --color-success-light: #f0fdf4;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-warning: #d97706;
  --color-warning-light: #fffbeb;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.03);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.06), 0 1px 2px rgb(0 0 0 / 0.04);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);

  --sidebar-width: 260px;
}

/* ========================================
   Reset & Base
   ======================================== */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  color: var(--color-primary-hover);
}

h1, h2, h3, h4 {
  letter-spacing: -0.2px;
}

/* ========================================
   Layout
   ======================================== */

.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 24px;
  font-size: 17px;
  font-weight: 750;
  color: var(--color-text);
  letter-spacing: -0.3px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

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

.nav-section-label {
  padding: 20px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--color-text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background 0.1s, color 0.1s;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 16px;
}

.user-info {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  word-break: break-all;
  margin-bottom: 8px;
}

.sidebar-footer .nav-item {
  font-size: 13px;
  color: var(--color-text-muted);
  padding: 6px 12px;
}

.sidebar-footer .nav-item:hover {
  color: var(--color-danger);
  background: var(--color-danger-light);
}

/* Main Content */

.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: 40px;
  max-width: 1200px;
}

/* ========================================
   Flash Messages
   ======================================== */

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  line-height: 1.5;
}

.flash.notice {
  background: var(--color-success-light);
  color: #15803d;
  border-color: #bbf7d0;
}

.flash.alert {
  background: var(--color-danger-light);
  color: #b91c1c;
  border-color: #fecaca;
}

/* ========================================
   Auth Pages
   ======================================== */

.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 400px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-brand-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgb(6 102 235 / 0.25);
}

.auth-brand-name {
  font-size: 22px;
  font-weight: 750;
  color: var(--color-text);
  letter-spacing: -0.3px;
}

.auth-form-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  padding: 32px;
}

.auth-form-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--color-text);
}

.auth-form-card .auth-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

.auth-form-card .field {
  margin-bottom: 20px;
}

.auth-form-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-secondary);
}

.auth-form-card input[type="email"],
.auth-form-card input[type="password"],
.auth-form-card input[type="text"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-form-card input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgb(6 102 235 / 0.1);
}

.auth-form-card input.input-error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.1);
}

.auth-form-card .field-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.auth-form-card .field.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.auth-form-card .field.checkbox label {
  margin-bottom: 0;
  font-weight: 500;
  font-size: 14px;
}

.auth-form-card .field.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.auth-form-card input[type="submit"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.auth-form-card input[type="submit"]:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 2px 8px rgb(6 102 235 / 0.3);
}

.auth-form-card input[type="submit"]:active {
  transform: translateY(0.5px);
}

.shared-links {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  text-align: center;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.shared-links a {
  font-weight: 500;
}

.shared-links a:not(:last-child)::after {
  content: "\00B7";
  margin-left: 4px;
  color: var(--color-text-muted);
  font-weight: 400;
}

/* Devise error messages */

#error_explanation {
  background: var(--color-danger-light);
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

#error_explanation h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-danger);
  margin-bottom: 8px;
}

#error_explanation ul {
  list-style: none;
  padding: 0;
}

#error_explanation li {
  font-size: 13px;
  color: #b91c1c;
  padding: 2px 0;
}

#error_explanation li::before {
  content: "\2192\00a0";
  color: var(--color-danger);
  opacity: 0.6;
}

/* ========================================
   Dashboard
   ======================================== */

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

.page-header h1 {
  font-size: 24px;
  font-weight: 750;
  color: var(--color-text);
}

.page-header p {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.card-icon.blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.card-icon.green {
  background: var(--color-success-light);
  color: var(--color-success);
}

.card-icon.amber {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.card-icon.purple {
  background: #f5f3ff;
  color: #7c3aed;
}

.card-icon.rose {
  background: #fff1f2;
  color: #e11d48;
}

.card h3 {
  font-size: 16px;
  font-weight: 650;
  color: var(--color-text);
}

.card p {
  color: var(--color-text-secondary);
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 20px;
  flex: 1;
}

.card-actions {
  display: flex;
  gap: 10px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.12s, box-shadow 0.12s;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
  text-decoration: none;
}

.btn:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
  color: var(--color-text-inverse);
  box-shadow: 0 2px 8px rgb(6 102 235 / 0.25);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.btn-danger {
  background: var(--color-danger);
}

.btn-danger:hover {
  background: #b91c1c;
  box-shadow: 0 2px 8px rgb(220 38 38 / 0.25);
}

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

.btn.disabled,
.btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  pointer-events: none;
  color: var(--color-text-inverse);
  opacity: 0.7;
  box-shadow: none;
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-border-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 16px;
  color: var(--color-text-muted);
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

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

/* ========================================
   Tables
   ======================================== */

.table-wrapper {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.table-header h3 {
  font-size: 15px;
  font-weight: 650;
}

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

th, td {
  padding: 11px 20px;
  text-align: left;
}

th {
  background: var(--color-bg);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

td {
  border-bottom: 1px solid var(--color-border-light);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--color-surface-hover);
}

/* ========================================
   Badges
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-green {
  background: var(--color-success-light);
  color: #15803d;
}

.badge-red {
  background: var(--color-danger-light);
  color: #b91c1c;
}

.badge-amber {
  background: var(--color-warning-light);
  color: #b45309;
}

.badge-blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge-gray {
  background: var(--color-surface-hover);
  color: var(--color-text-secondary);
}

/* ========================================
   Status Dot
   ======================================== */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.green {
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgb(22 163 74 / 0.15);
}

.status-dot.red {
  background: var(--color-danger);
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.15);
}

.status-dot.amber {
  background: var(--color-warning);
  box-shadow: 0 0 0 3px rgb(217 119 6 / 0.15);
}

.status-dot.gray {
  background: var(--color-text-muted);
  box-shadow: 0 0 0 3px rgb(148 163 184 / 0.15);
}

/* ========================================
   Stat Cards (for dashboard summaries)
   ======================================== */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 750;
  color: var(--color-text);
  letter-spacing: -0.5px;
}

.stat-card .stat-change {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

.stat-card .stat-change.positive {
  color: var(--color-success);
}

.stat-card .stat-change.negative {
  color: var(--color-danger);
}

/* ========================================
   Section Dividers
   ======================================== */

.section {
  margin-bottom: 32px;
}

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

.section-header h2 {
  font-size: 17px;
  font-weight: 650;
  color: var(--color-text);
}

/* ========================================
   Danger Zone
   ======================================== */

.danger-zone {
  margin-top: 32px;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid #fecaca;
  background: var(--color-danger-light);
}

.danger-zone h3 {
  font-size: 14px;
  font-weight: 650;
  color: var(--color-danger);
  margin-bottom: 6px;
}

.danger-zone p {
  font-size: 13.5px;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

/* ========================================
   Filter Bar
   ======================================== */

.filter-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}

.filter-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-row .filter-group {
  flex-direction: row;
  align-items: center;
}

.form-input, .form-select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgb(6 102 235 / 0.1);
}

/* ========================================
   Progress Bar
   ======================================== */

.progress-bar-wrapper {
  margin-bottom: 28px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--color-border-light);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.progress-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.progress-success {
  background: var(--color-success);
}

.progress-danger {
  background: var(--color-danger);
}

.progress-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* ========================================
   Client Cards
   ======================================== */

.client-card {
  margin-bottom: 16px;
}

.client-card summary {
  cursor: pointer;
  list-style: none;
}

.client-card summary::-webkit-details-marker {
  display: none;
}

.client-card summary::after {
  content: "\25BE";
  margin-left: auto;
  color: var(--color-text-muted);
  font-size: 14px;
  transition: transform 0.2s;
}

.client-card[open] summary::after {
  transform: rotate(180deg);
}

.client-metrics {
  padding-top: 12px;
}

.metric-nested h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-nested dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
}

.metric-nested dt {
  color: var(--color-text-muted);
  font-weight: 400;
}

.metric-nested dd {
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
}

/* ========================================
   Metrics Grid
   ======================================== */

.metrics-grid {
  display: grid;
  gap: 16px;
}

.metrics-grid.three-col {
  grid-template-columns: repeat(3, 1fr);
}

.metric-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-xs);
}

.metric-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--color-text);
  margin-bottom: 12px;
}

.metric-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border-light);
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-row span:first-child {
  color: var(--color-text-secondary);
}

.metric-value {
  font-weight: 650;
  font-size: 14px;
}

.text-warning {
  color: #d97706;
}

.text-success {
  color: #16a34a;
}

.stat-success {
  color: #16a34a;
}

.stat-warning {
  color: #d97706;
}

.stat-danger {
  color: #dc2626;
}

/* ========================================
   Detail Grid
   ======================================== */

.detail-grid {
  display: grid;
  gap: 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 14px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 13px;
}

.detail-value {
  color: var(--color-text);
  font-weight: 500;
  text-align: right;
}

/* Actions column in tables */

td.actions-cell {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ========================================
   Stacked Bar Charts
   ======================================== */

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-xs);
}

.chart-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--color-text);
  margin-bottom: 12px;
}

.stacked-bar {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--color-border-light);
}

.stacked-bar-sm {
  height: 10px;
}

.stacked-segment {
  height: 100%;
  min-width: 2px;
  transition: width 0.3s ease;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.client-chart {
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border-light);
}

/* ========================================
   Collapsible Sections
   ======================================== */

.section-details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.section-details .card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: 0;
}

.section-details .card:last-child {
  border-bottom: none;
}

.section-header-clickable {
  cursor: pointer;
  user-select: none;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.section-header-clickable::-webkit-details-marker {
  display: none;
}

.section-header-clickable::after {
  content: "\25BE";
  color: var(--color-text-muted);
  font-size: 14px;
  transition: transform 0.2s;
}

.section-details[open] > .section-header-clickable::after {
  transform: rotate(180deg);
}

.section-header-clickable h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 16px;
}

/* ========================================
   Text Utilities
   ======================================== */

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

/* ========================================
   Air Datepicker Theme Overrides
   ======================================== */

.air-datepicker {
  --adp-font-family: var(--font-sans);
  --adp-font-size: 13px;
  --adp-cell-size: 36px;
  --adp-accent: #0666eb;
  --adp-background: var(--color-surface);
  --adp-border: var(--color-border);
  --adp-nav-color: var(--color-text);
  --adp-day-name-color: var(--color-text-muted);
  --adp-other-month-color: var(--color-text-muted);
  --adp-cell-background-hover: var(--color-surface-hover);
  --adp-cell-background-selected: #0666eb;
  --adp-cell-color-selected: #fff;
  --adp-border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}

.air-datepicker-cell.-current- {
  color: #0666eb;
}

.air-datepicker-nav--title i {
  color: var(--color-text-secondary);
}

.air-datepicker-button {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
}

/* Make text inputs with datepicker readonly look clickable */

.datepicker {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Cline x1='16' y1='2' x2='16' y2='6'%3E%3C/line%3E%3Cline x1='8' y1='2' x2='8' y2='6'%3E%3C/line%3E%3Cline x1='3' y1='10' x2='21' y2='10'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

/* ========================================
   Responsive
   ======================================== */

/* Mobile Header (hidden on desktop) */

.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* Tablet */
@media (max-width: 1024px) {
  .metrics-grid.three-col {
    grid-template-columns: repeat(2, 1fr);
  }

  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 640px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 101;
  }

  .mobile-header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 750;
    color: var(--color-text);
  }

  .mobile-header-brand .sidebar-brand-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .mobile-menu-btn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
  }

  .mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgb(0 0 0 / 0.15);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.3);
    z-index: 199;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .sidebar-brand {
    padding: 20px 20px 16px;
  }

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

  .nav-section-label {
    padding: 16px 12px 6px;
  }

  .sidebar-footer {
    display: block;
    padding: 16px;
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px 32px;
  }

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

  .page-header h1 {
    font-size: 20px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .dashboard-cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card .stat-value {
    font-size: 22px;
  }

  .metrics-grid.three-col {
    grid-template-columns: 1fr;
  }

  .metric-card {
    padding: 16px;
  }

  /* Filter bar */
  .filter-bar {
    padding: 12px;
  }

  .filter-row {
    flex-direction: column;
    gap: 8px;
  }

  .filter-row .filter-group {
    width: 100%;
  }

  .filter-row .form-input,
  .filter-row select {
    width: 100%;
  }

  .filter-row .btn {
    width: 100%;
  }

  /* Tables */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  table {
    min-width: 580px;
  }

  th, td {
    padding: 8px 12px;
    font-size: 12.5px;
  }

  td.actions-cell {
    flex-direction: column;
    gap: 4px;
  }

  /* Progress bar */
  .progress-legend {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
  }

  /* Charts */
  .chart-card {
    padding: 14px;
  }

  .chart-legend {
    gap: 8px;
    font-size: 11px;
  }

  .client-chart {
    padding: 10px 14px;
  }

  /* Section headers */
  .section-header-clickable {
    padding: 12px 14px;
  }

  .section-header-clickable h2 {
    font-size: 14px;
    gap: 6px;
  }

  .section-header-clickable h2 .badge {
    font-size: 11px;
  }

  /* Cards */
  .card {
    padding: 16px;
  }

  .card-header {
    gap: 10px;
  }

  .card-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .card h3 {
    font-size: 14px;
  }

  .card p {
    font-size: 13px;
  }

  /* Detail grid */
  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 0;
  }

  .detail-value {
    text-align: left;
  }

  /* Auth pages */
  .auth-container {
    padding: 16px;
  }

  .auth-box {
    max-width: 100%;
  }

  .auth-form-card {
    padding: 24px;
  }

  .auth-brand {
    margin-bottom: 24px;
  }

  .auth-brand-icon {
    width: 48px;
    height: 48px;
    font-size: 18px;
    margin-bottom: 12px;
  }

  .auth-brand-name {
    font-size: 20px;
  }

  .shared-links {
    flex-direction: column;
    gap: 8px;
  }

  .shared-links a::after {
    display: none;
  }

  /* Client cards */
  .client-card summary::after {
    font-size: 16px;
  }

  .metric-nested dl {
    font-size: 12px;
  }

  /* Danger zone */
  .danger-zone {
    padding: 16px;
    margin-top: 24px;
  }

  /* Tables - user/client list */
  .table-header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Flash messages */
  .flash {
    padding: 10px 12px;
    font-size: 13px;
  }
}