/* ============================================================
   Ervian — Main Stylesheet v3
   Theme: Light, clean, Tailwind-inspired
   Primary: #166534 (logo dark forest green)
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --bg:           #F7F9F8;
  --surface:      #FFFFFF;
  --surface2:     #F1F5F2;
  --surface3:     #E4EBE6;
  --border:       #E2EAE5;
  --border-dark:  #C8D6CC;

  --primary:      #166534;
  --primary-mid:  #15803D;
  --primary-dark: #14532D;
  --primary-xd:   #052E16;
  --primary-light:#BBF7D0;
  --primary-soft: #F0FDF4;

  --blue:         #2563EB;
  --blue-dark:    #1D4ED8;
  --blue-light:   #EFF6FF;

  --amber:        #D97706;
  --amber-light:  #FEF3C7;

  --red:          #DC2626;
  --red-dark:     #B91C1C;
  --red-light:    #FEF2F2;

  --green:        #166534;
  --green-light:  #DCFCE7;

  --purple:       #7C3AED;
  --purple-light: #EDE9FE;

  --text:         #0F172A;
  --text-muted:   #64748B;
  --text-light:   #94A3B8;
  --text-xlight:  #CBD5E1;

  --white:        #FFFFFF;
  --cream:        #FAFAF9;

  --sidebar-w:    248px;
  --topbar-h:     56px;

  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full:9999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.03);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 8px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 20px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 30px rgba(0,0,0,0.09), 0 10px 12px rgba(0,0,0,0.04);
  --shadow-xl: 0 32px 48px rgba(0,0,0,0.10), 0 16px 20px rgba(0,0,0,0.05);
  --shadow-green: 0 4px 14px rgba(22,101,52,0.20);
  --shadow-blue:  0 4px 14px rgba(37,99,235,0.18);

  --transition: 0.16s ease;

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", Consolas, monospace;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── App Shell: Sidebar + Main ───────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 900; font-size: 14px;
  letter-spacing: -1px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.sidebar-logo-tagline {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

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

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

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  position: relative;
}

.sidebar-link:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

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

.sidebar-link.active .sidebar-icon { opacity: 1; }

.sidebar-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  line-height: 16px;
}

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

/* Trial chip in sidebar */
.sidebar-trial-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border: 1px solid rgba(22,101,52,0.18);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.sidebar-trial-urgent {
  color: #92400E;
  background: var(--amber-light);
  border-color: rgba(217,119,6,0.25);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--surface2); }

.sidebar-avatar {
  width: 30px; height: 30px;
  background: var(--primary-light);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-email {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-plan {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* ── Main area ───────────────────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

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

.topbar-alert-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.topbar-alert-btn:hover {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.topbar-alert-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

.trial-chip {
  background: var(--amber-light);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(217,119,6,0.2);
}

/* ── Page content ────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
}

.page-content.page-wide { max-width: 1200px; }
.page-content.page-narrow { max-width: 680px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.page-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 3px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}

.card-sm { padding: 14px 16px; }
.card-lg { padding: 28px; }

/* Interactive card — lift on hover */
.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-dark);
}

/* Card with green left accent */
.card-accent-green {
  border-left: 3px solid var(--primary);
}

/* Card with blue left accent */
.card-accent-blue {
  border-left: 3px solid var(--blue);
}

/* Card with amber left accent */
.card-accent-amber {
  border-left: 3px solid var(--amber);
}

/* Card with red left accent */
.card-accent-red {
  border-left: 3px solid var(--red);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: var(--font);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(22,163,74,0.3);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-blue {
  background: var(--blue);
  color: white;
  box-shadow: 0 1px 2px rgba(37,99,235,0.3);
}
.btn-blue:hover { background: var(--blue-dark); }

.btn-danger {
  background: var(--red);
  color: white;
}
.btn-danger:hover { background: var(--red-dark); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-dark);
}
.btn-outline:hover {
  border-color: var(--text-light);
  color: var(--text);
  background: var(--surface2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { display: flex; width: 100%; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

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

.form-label-optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.12);
}

.form-input::placeholder { color: var(--text-light); }

.form-input-error { border-color: var(--red); }
.form-input-error:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,38,38,0.1);
}

.form-error {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--red);
  font-size: 12px;
  margin-top: 5px;
}

.form-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.5;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-textarea { resize: vertical; min-height: 80px; }

/* ── Date / Time inputs ──────────────────────────────────── */
.form-input[type="date"],
.form-input[type="time"],
.form-input[type="month"] {
  color-scheme: light;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23166534' viewBox='0 0 24 24'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-input[type="date"]::-webkit-calendar-picker-indicator,
.form-input[type="time"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  right: 0;
  width: 40px;
  height: 100%;
  cursor: pointer;
}

.form-input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  color: var(--text);
}

.form-input[type="date"]::-webkit-datetime-edit-text {
  color: var(--text-muted);
  padding: 0 2px;
}

.form-input[type="date"]::-webkit-datetime-edit-year-field,
.form-input[type="date"]::-webkit-datetime-edit-month-field,
.form-input[type="date"]::-webkit-datetime-edit-day-field {
  padding: 1px 3px;
  border-radius: 3px;
  transition: background 0.1s;
}

.form-input[type="date"]::-webkit-datetime-edit-year-field:focus,
.form-input[type="date"]::-webkit-datetime-edit-month-field:focus,
.form-input[type="date"]::-webkit-datetime-edit-day-field:focus {
  background: var(--primary-light);
  color: var(--primary-xd);
  outline: none;
}

/* Checkbox */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
}

.checkbox-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
}

.checkbox-row label {
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.5;
}

/* Fieldset */
.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
}

.form-fieldset legend {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 8px;
}

/* ── Flash messages ──────────────────────────────────────── */
.flash-container {
  padding: 0 28px;
  margin-top: 12px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 8px;
}

.flash-success { background: var(--green-light); color: var(--primary-xd); border: 1px solid rgba(22,163,74,0.3); }
.flash-error   { background: var(--red-light);   color: var(--red-dark);   border: 1px solid rgba(220,38,38,0.3); }
.flash-warning { background: var(--amber-light);  color: #92400E;          border: 1px solid rgba(217,119,6,0.3); }
.flash-info    { background: var(--blue-light);   color: var(--blue-dark);  border: 1px solid rgba(37,99,235,0.3); }

/* ── Auth pages ──────────────────────────────────────────── */
body.auth-page {
  background: var(--cream);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: 48px 20px;
}

.auth-shell {
  width: 100%;
  max-width: 420px;
}

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

.auth-logo-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.auth-logo-box:hover { text-decoration: none; }

.auth-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 900; font-size: 15px;
  letter-spacing: -1px;
}

.auth-logo-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

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

.auth-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 24px;
  line-height: 1.6;
}

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

/* Password strength meter */
.pw-strength { margin-top: 10px; }

.pw-bar-track {
  height: 4px;
  background: var(--surface3);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.pw-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s, background 0.3s;
  width: 0;
}

.pw-requirements {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pw-req {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
  transition: color var(--transition);
}

.pw-req.met { color: var(--primary); }

.pw-req-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-xlight);
  flex-shrink: 0;
  transition: background var(--transition);
}

.pw-req.met .pw-req-dot { background: var(--primary); }

/* ── Onboarding ──────────────────────────────────────────── */
body.onboarding-page {
  background: var(--cream);
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}

.onboarding-shell {
  width: 100%;
  max-width: 580px;
}

.onboarding-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.onboarding-title { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.onboarding-sub   { color: var(--text-muted); font-size: 13.5px; line-height: 1.7; margin-bottom: 24px; }

.onboarding-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

/* Progress steps */
.progress-wrap { margin-bottom: 28px; }

.progress-steps {
  display: flex;
  align-items: center;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.progress-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--transition);
}

.progress-step.active .progress-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.2);
}

.progress-step.done .progress-dot {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.progress-label {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.progress-step.active .progress-label,
.progress-step.done .progress-label { color: var(--primary); }

.progress-line {
  flex: 1;
  height: 1.5px;
  background: var(--border);
  margin: 0 4px 14px;
  transition: background var(--transition);
}

.progress-line.done { background: var(--primary); }

/* ── Score card ──────────────────────────────────────────── */
.score-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  text-align: center;
  min-width: 140px;
  box-shadow: var(--shadow-sm);
}

.score-number { font-size: 40px; font-weight: 900; line-height: 1; letter-spacing: -2px; }
.score-label  { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.score-summary { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }

.score-great .score-number,
.score-great .score-label  { color: var(--primary); }
.score-great { border-color: rgba(22,163,74,0.3); }

.score-good .score-number,
.score-good .score-label   { color: #0891B2; }
.score-good  { border-color: rgba(8,145,178,0.3); }

.score-fair .score-number,
.score-fair .score-label   { color: var(--amber); }
.score-fair  { border-color: rgba(217,119,6,0.3); }

.score-risk .score-number,
.score-risk .score-label   { color: #EA580C; }
.score-risk  { border-color: rgba(234,88,12,0.3); }

.score-critical .score-number,
.score-critical .score-label { color: var(--red); }
.score-critical { border-color: rgba(220,38,38,0.3); background: var(--red-light); }

/* ── Dashboard header ────────────────────────────────────── */
.dash-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-title { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.dash-sub   { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }

/* ── Toolbar (sort + filter) ─────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-filters { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-chip {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all var(--transition);
  text-decoration: none;
}

.filter-chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.filter-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.sort-select {
  padding: 5px 32px 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2364748B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color var(--transition);
}

.sort-select:focus { outline: none; border-color: var(--primary); }

/* ── Sections ────────────────────────────────────────────── */
.section { margin-bottom: 28px; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

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

.section-title-overdue { color: var(--red); }
.section-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  background: var(--surface2);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

/* ── Obligation rows ─────────────────────────────────────── */
.obligation-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 6px;
  transition: box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.obligation-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}

.urgency-overdue::before  { background: var(--red); }
.urgency-critical::before { background: var(--amber); }
.urgency-upcoming::before { background: var(--primary); }
.urgency-future::before   { background: var(--border-dark); }

.obligation-row:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-dark);
}

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

.obligation-title {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: color var(--transition);
}

.obligation-title:hover { color: var(--primary); text-decoration: none; }

.obligation-badges { display: flex; gap: 5px; flex-wrap: wrap; flex-shrink: 0; }

.obligation-short {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
  line-height: 1.55;
}

.trigger-context {
  background: var(--primary-soft);
  border: 1px solid rgba(22,163,74,0.2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 10px;
}

.trigger-label {
  color: var(--primary);
  font-weight: 700;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 3px;
}

.obligation-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-federal_tax        { background: var(--primary-light); color: var(--primary-xd); }
.badge-sales_tax          { background: var(--amber-light);   color: #92400E; }
.badge-annual_report      { background: var(--purple-light);  color: var(--purple); }
.badge-canadian           { background: var(--blue-light);    color: var(--blue-dark); }
.badge-consumer_protection { background: #FFF7ED; color: #C2410C; }

.badge-overdue   { background: var(--red-light);   color: var(--red-dark); }
.badge-critical  { background: var(--amber-light);  color: #92400E; }
.badge-upcoming  { background: var(--primary-light); color: var(--primary-xd); }
.badge-future    { background: var(--surface2);     color: var(--text-muted); }
.badge-date      { background: var(--surface2);     color: var(--text-muted); }

.badge-green  { background: var(--primary-light); color: var(--primary-dark); }
.badge-blue   { background: var(--blue-light);   color: var(--blue-dark); }
.badge-gray   { background: var(--surface2);     color: var(--text-muted); }
.badge-red    { background: var(--red-light);    color: var(--red-dark); }
.badge-amber  { background: var(--amber-light);  color: #92400E; }

.tag {
  display: inline-block;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
  margin-bottom: 2px;
}

/* ── Obligation detail page ──────────────────────────────── */
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
  text-decoration: none;
  transition: color var(--transition);
}

.detail-back:hover { color: var(--text); text-decoration: none; }

.detail-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
  letter-spacing: -0.5px;
}

.detail-due {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.detail-context {
  background: var(--primary-soft);
  border: 1px solid rgba(22,163,74,0.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.context-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.context-body { font-size: 13.5px; color: var(--text); line-height: 1.7; }

.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  font-weight: 700; color: var(--text-muted); margin-bottom: 8px;
}
.detail-description { font-size: 14px; color: var(--text); line-height: 1.75; }
.detail-steps { font-size: 13.5px; color: var(--text); line-height: 1.85; white-space: pre-line; }

.detail-penalty {
  background: var(--red-light);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.penalty-label { color: var(--red); font-weight: 600; margin-right: 4px; }

.detail-disclaimer {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 16px;
}

/* ── Alert banners / items ───────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
}

.alert-approaching, .alert-new_discovered {
  background: var(--primary-soft);
  border: 1px solid rgba(22,163,74,0.25);
  color: var(--primary-xd);
}

.alert-due, .alert-overdue {
  background: var(--amber-light);
  border: 1px solid rgba(217,119,6,0.25);
  color: #92400E;
}

.alert-threshold_warning {
  background: var(--amber-light);
  border: 1px solid rgba(217,119,6,0.25);
  color: #92400E;
}

.alerts-list { display: flex; flex-direction: column; gap: 4px; }

.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: box-shadow var(--transition);
}

.alert-item:hover { box-shadow: var(--shadow-sm); }
.alert-item.alert-unread { border-left: 3px solid var(--primary); }

.alert-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.alert-dot-approaching, .alert-dot-new_discovered { background: var(--primary); }
.alert-dot-due, .alert-dot-overdue, .alert-dot-threshold_warning { background: var(--amber); }

.alert-content { flex: 1; }
.alert-preview { color: var(--text); font-size: 13.5px; }
.alert-meta { display: flex; gap: 10px; margin-top: 2px; }
.alert-type-label { color: var(--text-light); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.alert-time { color: var(--text-light); font-size: 11px; }

/* ── Nexus widget ────────────────────────────────────────── */
.nexus-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }

.nexus-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}

.nexus-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}

.nexus-triggered::before  { background: var(--red); }
.nexus-approaching::before { background: var(--amber); }
.nexus-monitoring::before  { background: var(--primary); }

.nexus-card:hover { box-shadow: var(--shadow); }

.nexus-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.nexus-state  { font-size: 16px; font-weight: 800; color: var(--text); }

.nexus-status-badge { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 7px; border-radius: var(--radius-full); }
.nexus-badge-triggered   { background: var(--red-light);   color: var(--red-dark); }
.nexus-badge-approaching  { background: var(--amber-light);  color: #92400E; }
.nexus-badge-monitoring   { background: var(--primary-light); color: var(--primary-xd); }

.nexus-amounts { margin-bottom: 8px; }
.nexus-sales   { color: var(--text); font-size: 15px; font-weight: 700; }
.nexus-threshold { color: var(--text-muted); font-size: 12px; margin-left: 4px; }

.nexus-bar-track { background: var(--surface2); border-radius: var(--radius-full); height: 5px; overflow: hidden; margin-bottom: 4px; }
.nexus-bar-fill  { height: 100%; border-radius: var(--radius-full); transition: width 0.4s; }
.nexus-bar-triggered   { background: var(--red); }
.nexus-bar-approaching  { background: var(--amber); }
.nexus-bar-monitoring   { background: var(--primary); }

.nexus-pct { color: var(--text-muted); font-size: 11px; text-align: right; }

/* ── Data table ──────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

/* ── Profile / Review rows ───────────────────────────────── */
.info-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); min-width: 160px; flex-shrink: 0; }
.info-value { color: var(--text); font-weight: 500; }

/* ── State sales list ────────────────────────────────────── */
.state-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.state-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.state-row:last-child { border-bottom: none; }
.state-info { display: flex; gap: 14px; align-items: center; }
.state-code  { font-weight: 700; color: var(--text); min-width: 28px; }
.state-sales { color: var(--primary); }
.state-txns  { color: var(--text-muted); }

.add-state-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.add-state-row .form-select,
.add-state-row .form-input { flex: 1; min-width: 100px; padding: 7px 10px; font-size: 13px; }

/* ── Confirm modal ───────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s;
}

.modal-backdrop.open .modal { transform: scale(1) translateY(0); }

.modal-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.modal-icon-danger { background: var(--red-light); }
.modal-icon-warning { background: var(--amber-light); }
.modal-icon-info    { background: var(--blue-light); }

.modal-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.modal-body  { font-size: 13.5px; color: var(--text-muted); line-height: 1.65; margin-bottom: 20px; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Shopify connect ─────────────────────────────────────── */
.connect-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.connect-status-connected {
  border-color: rgba(22,163,74,0.35);
  border-left: 3px solid var(--primary);
}

/* ── Empty states ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state-sub   { font-size: 13.5px; line-height: 1.65; }

/* ── Footer ──────────────────────────────────────────────── */
.page-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

.footer-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand { color: var(--primary); font-weight: 700; font-size: 13px; white-space: nowrap; }
.footer-disclaimer { color: var(--text-muted); font-size: 11.5px; line-height: 1.7; flex: 1; }
.footer-links { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--primary); }

/* ── Utility ──────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-light    { color: var(--text-light); }
.text-primary  { color: var(--primary); }
.text-red      { color: var(--red); }
.text-amber    { color: var(--amber); }
.text-sm       { font-size: 12.5px; }
.text-xs       { font-size: 11.5px; }
.font-bold     { font-weight: 700; }
.font-semibold { font-weight: 600; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.flex-1       { flex: 1; }
.flex-wrap    { flex-wrap: wrap; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

.w-full { width: 100%; }

/* ── Admin panel ─────────────────────────────────────────── */
.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}

.admin-stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-stat-value { font-size: 28px; font-weight: 800; color: var(--text); margin-top: 4px; letter-spacing: -1px; }
.admin-stat-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Error pages ─────────────────────────────────────────── */
.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; text-align: center; }
.error-code { font-size: 72px; font-weight: 900; color: var(--primary); letter-spacing: -4px; }
.error-msg  { font-size: 20px; font-weight: 700; color: var(--text); margin-top: 8px; }
.error-sub  { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-248px);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    width: 248px;
    box-shadow: var(--shadow-lg);
  }

  .main-area { margin-left: 0; }

  .topbar { padding: 0 16px; }

  .page-content { padding: 16px; }

  .dash-header { flex-direction: column; }

  .score-card { min-width: 100%; }
}
