/* ============================================
   Kumuly — Design System
   ============================================ */

/* ── RESET & BASE ─────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* ── Brand ramp (refined SaaS blue) ── */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --brand-900: #1e3a8a;

  --primary: var(--brand-600);
  --primary-dark: var(--brand-700);
  --primary-light: var(--brand-50);
  --primary-rgb: 37, 99, 235;
  --accent: #06b6d4;

  /* ── Neutrals (slate) ── */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --border: #e6eaf0;
  --border-strong: #d6dce5;

  /* ── Sidebar (deep slate) ── */
  --sidebar-bg: #0b1220;
  --sidebar-bg-2: #0f172a;
  --sidebar-text: #97a3b6;
  --sidebar-active: #ffffff;

  /* ── Semantic ── */
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* ── Radius ── */
  --radius-sm: 8px;
  --radius: 11px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* ── Elevation (soft, layered) ── */
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
  --shadow: 0 1px 3px rgba(16,24,40,0.08), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-md: 0 6px 16px -4px rgba(16,24,40,0.10), 0 2px 6px -2px rgba(16,24,40,0.06);
  --shadow-lg: 0 16px 40px -12px rgba(16,24,40,0.18), 0 4px 12px -6px rgba(16,24,40,0.10);
  --shadow-brand: 0 6px 18px -6px rgba(var(--primary-rgb), 0.45);
  --ring: 0 0 0 3px rgba(var(--primary-rgb), 0.18);

  --sidebar-width: 248px;
  --topbar-height: 60px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* ── Motion ── */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 0.12s;
  --dur: 0.2s;
  --dur-slow: 0.35s;

  /* Typography scale */
  --text-xs: 0.75rem;
  --text-sm: 0.85rem;
  --text-base: 0.95rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.75rem;
}

body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv02','cv03','cv04','cv11';
}

h1, h2, h3, h4 {
  letter-spacing: -0.014em;
}

::selection {
  background: var(--brand-200);
  color: var(--brand-900);
}

/* Refined focus ring — keyboard only */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ── PUBLIC LAYOUT ────────────────────────── */
.public-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
}

.public-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.nav-brand:hover {
  text-decoration: none;
  color: var(--text);
}

.nav-brand-icon {
  font-size: 1.4rem;
}

.nav-links-public {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links-public a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links-public a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.public-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 3rem 2rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  font-weight: 700;
  color: white;
  font-size: 1rem;
}

.footer-links {
  display: flex;
  gap: 2rem;
}

.footer-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: white;
  text-decoration: none;
}

.footer-copy {
  font-size: 0.85rem;
}

/* ── AUTH LAYOUT ──────────────────────────── */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-panel-left {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1a56db 100%);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: white;
  text-decoration: none;
  margin-bottom: auto;
}

.auth-brand:hover {
  text-decoration: none;
  color: white;
}

.auth-tagline {
  margin-top: auto;
}

.auth-tagline h2 {
  font-size: 2rem;
  font-weight: 700;
  color: white;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.auth-tagline p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  line-height: 1.6;
}

.auth-features {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-features li {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.auth-features li::before {
  content: "✓";
  color: #06b6d4;
  font-weight: 700;
}

.auth-panel-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: white;
}

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

.auth-form-header {
  margin-bottom: 2rem;
}

.auth-form-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.auth-form-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 2rem;
  transition: color 0.2s;
}

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

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── APP LAYOUT ───────────────────────────── */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-brand:hover {
  text-decoration: none;
  color: white;
}

.brand-icon {
  font-size: 1.3rem;
}

.nav-links {
  list-style: none;
  padding: 0.75rem 0;
  margin: 0;
  flex: 1;
}

.nav-links li {
  padding: 0 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  text-decoration: none;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.nav-icon {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.nav-section {
  padding: 0.5rem 1.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.5rem;
}

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.5);
  padding: 1rem 1.5rem 0.375rem;
  list-style: none;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

/* Mobile menu */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1001;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.mobile-menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all 0.2s;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar-backdrop.active {
  opacity: 1;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg);
}

/* ── BUTTONS ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: var(--font);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

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

.btn-secondary:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-danger {
  background: #fef2f2;
  color: var(--error);
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
  color: var(--error);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.btn-success:hover {
  background: #dcfce7;
  color: #16a34a;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ── FORMS ────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.form-group label small {
  color: var(--text-muted);
  font-weight: 400;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.form-row .form-group {
  flex: 1;
  min-width: 160px;
  margin-bottom: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.input-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.input-disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

fieldset legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 0.375rem;
}

.form-actions {
  display: flex;
  gap: 0.625rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

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

.form-group-checkbox label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.form-group-checkbox input {
  width: auto;
}

.inline-form {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input,
.inline-form select {
  max-width: 240px;
}

/* ── PASSWORD STRENGTH ────────────────────── */
.pw-strength {
  margin-top: 0.5rem;
}

.pw-strength-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.pw-strength-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
  background: var(--error);
  width: 0%;
}

.pw-strength-fill[data-strength="1"] { background: var(--error); }
.pw-strength-fill[data-strength="2"] { background: var(--warning); }
.pw-strength-fill[data-strength="3"] { background: #3b82f6; }
.pw-strength-fill[data-strength="4"] { background: var(--success); }

.pw-reqs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.pw-reqs li {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pw-reqs li.met {
  color: var(--success);
}

.pw-reqs li::before {
  content: "○";
}

.pw-reqs li.met::before {
  content: "●";
  color: var(--success);
}

/* ── CARDS ────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.card-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-section {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.card-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.card-danger {
  border-color: #fecaca;
}

.card-danger .card-header {
  background: #fef2f2;
}

.card-danger .card-header h2 {
  color: #991b1b;
}

form {
  padding: 1.25rem;
}

.form-card form {
  padding: 1.5rem;
}

/* ── PAGE HEADER ──────────────────────────── */
.page-header {
  margin-bottom: 1.75rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.page-header p,
.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ── ALERTS ───────────────────────────────── */
.alert {
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ── BADGES ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-owner { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: var(--primary-light); color: var(--primary); }
.badge-staff { background: #f1f5f9; color: #475569; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-sent { background: #eff6ff; color: #2563eb; }
.badge-paid { background: #f0fdf4; color: #16a34a; }
.badge-overdue { background: #fef2f2; color: var(--error); }
.badge-cancelled { background: #f1f5f9; color: #9ca3af; }
.badge-accepted { background: #f0fdf4; color: #16a34a; }
.badge-rejected { background: #fef2f2; color: var(--error); }
.badge-expired { background: #fffbeb; color: #b45309; }
.badge-converted { background: #ede9fe; color: #5b21b6; }

/* ── TABLES ───────────────────────────────── */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg);
}

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

.data-table tfoot td {
  background: var(--bg);
  font-weight: 500;
}

.text-right { text-align: right !important; }
.actions-cell { white-space: nowrap; }
.row-inactive td { opacity: 0.55; }

/* ── STATS GRID ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

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

.stat-card-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* Legacy stat card support */
.stat-icon { font-size: 1.75rem; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.75rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.125rem; }
.stat-link { display: block; margin-top: 0.5rem; font-size: 0.8rem; }

/* Quick stats */
.quick-stats {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.quick-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  text-align: center;
  text-decoration: none;
  min-width: 120px;
  transition: box-shadow 0.15s;
  color: var(--text);
}

.quick-stat:hover {
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--text);
}

.qs-value { display: block; font-size: 1.5rem; font-weight: 700; }
.qs-label { display: block; font-size: 0.75rem; color: var(--text-muted); }

/* ── FILTER BAR ───────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-form {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 200px;
}

.filter-form select {
  max-width: 180px;
}

/* ── EMPTY STATE ──────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon,
.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

.empty-state h3,
.empty-state h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ── INVOICE / QUOTE VIEW ─────────────────── */
.invoice-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.doc-header,
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.doc-number {
  font-size: 1.25rem;
  font-weight: 700;
}

.doc-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meta-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.meta-group p {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0;
}

.inv-from h2 { font-size: 1.125rem; color: var(--primary); margin-bottom: 0.375rem; }
.inv-meta h2 { font-size: 1.375rem; font-weight: 700; color: var(--primary); text-align: right; margin-bottom: 0.625rem; }

.meta-table { border-collapse: collapse; }
.meta-table td { padding: 0.2rem 0.625rem; font-size: 0.825rem; }
.meta-table td:first-child { color: var(--text-muted); }

.inv-bill-to {
  padding: 1rem;
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 4px;
  margin-bottom: 1.75rem;
}

.inv-bill-to h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.inv-items { margin-bottom: 1.5rem; }
.inv-items tfoot td { border-top: 1px solid var(--border); }
.total-row-final td { font-weight: 700; font-size: 0.95rem; color: var(--primary); border-top: 2px solid var(--primary) !important; }

.inv-notes {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.inv-notes h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ── LINE ITEMS ───────────────────────────── */
.line-items-header {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 1fr 1fr 40px;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.line-item-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 1fr 1fr 40px;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.line-item-row input {
  padding: 0.5rem 0.625rem;
}

.line-total {
  text-align: right;
  font-weight: 500;
  font-size: 0.9rem;
  padding-right: 0.25rem;
  white-space: nowrap;
}

.article-quick-add {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  margin-bottom: 0.75rem;
  padding: 0.625rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.article-quick-add label { font-size: 0.825rem; white-space: nowrap; }
.article-quick-add select { max-width: 300px; }

/* ── TOTALS BOX ───────────────────────────── */
.totals-box {
  margin-left: auto;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.totals-row,
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.35rem 0;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.totals-row:last-child,
.total-row:last-child {
  border-bottom: none;
}

.totals-row.total {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  border-top: 2px solid var(--border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.total-final {
  background: var(--primary-light);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  padding: 0.5rem;
  border-radius: var(--radius);
  margin-top: 0.25rem;
}

/* ── BUSINESS CARDS ───────────────────────── */
.business-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.business-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: block;
}

.business-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
  text-decoration: none;
  color: var(--text);
}

.business-card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.business-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.business-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* Legacy business card styles */
.business-card .card-header { flex-direction: column; align-items: flex-start; gap: 4px; }
.business-card .card-header h2 a { color: var(--text); }
.business-card .card-header h2 a:hover { color: var(--primary); text-decoration: none; }

.meta-row {
  display: flex;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* Dashboard quick links */
.business-quick-links { display: flex; flex-direction: column; gap: 0.75rem; }

.quick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.quick-card-name { font-weight: 600; }
.quick-card-actions { display: flex; gap: 0.5rem; }

.section { margin-top: 2rem; }
.section h2 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 1rem; }

/* ── STOCK BADGES ─────────────────────────── */
.stock-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.stock-ok { color: #16a34a; font-weight: 500; }
.stock-low { color: #b45309; font-weight: 500; }
.stock-zero { color: var(--error); font-weight: 500; }

/* ── STATUS / DANGER ──────────────────────── */
.status-card { margin-bottom: 1.25rem; }
.status-card form { padding: 0.875rem 1.25rem; }

.danger-actions { display: flex; justify-content: flex-end; margin-top: 0.75rem; }
.danger-actions form { padding: 0; }

/* ── CRM DETAIL VIEW ─────────────────────── */
.detail-list { display: flex; flex-direction: column; gap: 0.75rem; }
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  min-width: 80px;
  flex-shrink: 0;
}
.link-primary { color: var(--primary); font-weight: 500; }
.link-primary:hover { text-decoration: underline; }

/* ── CLIENT PICKER ───────────────────────── */
.client-picker-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.client-new-btn {
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 1px; /* align with input baseline */
}
.client-manual-fields {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.quick-create-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.quick-create-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.quick-create-header strong { font-size: 0.9rem; }

/* ── MODAL ────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: modal-in 0.18s ease;
}
@keyframes modal-in {
  from { opacity:0; transform:scale(0.96) translateY(8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; margin: 0; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-body p { color: var(--text-muted); margin-bottom: 0; }
.modal-footer {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.delete-name-hint {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: #fef2f2;
  color: #991b1b;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* ── SETTINGS CARDS ───────────────────────── */
.settings-card { margin-bottom: 1.5rem; }
.card-subtitle { color: var(--text-muted); font-size: 0.875rem; margin: 0.25rem 0 0; }
.danger-card { border-color: #fecaca; }
.danger-header { background: #fef2f2; }
.danger-header h2 { color: #991b1b; }

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ── PERMISSION GROUPS ────────────────────── */
.builtin-roles { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.5rem; }
.builtin-role-row { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }

.group-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.group-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.group-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.group-perms { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.perm-chip {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 500;
}
.perm-on  { background: var(--primary-light); color: var(--primary); }
.perm-off { background: #f1f5f9; color: #94a3b8; }
.group-edit-form {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.perm-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
}
.perm-label:hover { background: var(--bg); }
.perm-label input[type=checkbox] { accent-color: var(--primary); }
.group-create-section {
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

/* ── MISC UTILITIES ───────────────────────── */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }

code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: var(--bg);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* ── BREADCRUMBS ─────────────────────────── */
.breadcrumbs {
  margin-bottom: 0.75rem;
}
.breadcrumbs ol {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 0.25rem;
  font-size: var(--text-sm);
  flex-wrap: wrap;
}
.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
}
.breadcrumbs a:hover {
  color: var(--primary);
  text-decoration: underline;
}
.breadcrumb-sep {
  color: var(--border);
  margin: 0 0.125rem;
}
.breadcrumb-current {
  color: var(--text);
  font-weight: 500;
}

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .sidebar-backdrop.active { display: block; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: 3.5rem; /* space for hamburger button */
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
  }
  .data-table {
    min-width: 600px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .line-items-header {
    display: none;
  }

  .line-item-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .auth-split {
    grid-template-columns: 1fr;
  }

  .auth-panel-left {
    display: none;
  }

  .public-header .nav-links-public {
    display: none;
  }

  .public-footer .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .doc-meta {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* ── ANALYTICS ────────────────────────────── */
.period-tabs {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.period-tab {
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  text-decoration: none;
  transition: all 0.15s;
}

.period-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

.period-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.375rem;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
}

.kpi-green  { border-left-color: #10b981; }
.kpi-yellow { border-left-color: #f59e0b; }
.kpi-red    { border-left-color: #ef4444; }
.kpi-blue   { border-left-color: #3b82f6; }
.kpi-purple { border-left-color: #8b5cf6; }
.kpi-teal   { border-left-color: #06b6d4; }

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.kpi-sub {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* Chart grid */
.chart-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chart-card {
  min-width: 0; /* prevent grid blowout */
}

/* Legend dot */
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chart-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════════
   ONBOARDING LAYOUT
════════════════════════════════════════════ */
.onboarding-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 2rem 1rem;
}

.onboarding-container {
  width: 100%;
  max-width: 520px;
}

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

.onboarding-header {
  margin-bottom: 1.5rem;
}

.onboarding-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.onboarding-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 0.5rem;
}

.progress-step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.progress-step.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.progress-step.done {
  border-color: #10b981;
  background: #10b981;
  color: white;
}

.progress-line {
  flex: 1;
  height: 2px;
  background: var(--border);
}

.progress-line.done {
  background: #10b981;
}

.onboarding-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.25rem 0 1.25rem;
}

.onboarding-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.onboarding-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.onboarding-checklist li {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.onboarding-checklist li::before {
  content: "→";
  color: var(--primary);
  font-weight: 700;
}

.onboarding-checklist li a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.onboarding-checklist li a:hover {
  color: var(--primary);
}

.onboarding-success-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.form-input-lg {
  font-size: 1.1rem;
  padding: 0.75rem 1rem;
}

.onboarding-skip-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* ════════════════════════════════════════════
   SUBSCRIPTION PAGE
════════════════════════════════════════════ */
.sub-banner {
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.sub-banner-green  { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.sub-banner-yellow { background: #fefce8; border: 1px solid #fde68a; color: #b45309; }
.sub-banner-orange { background: #fff7ed; border: 1px solid #fed7aa; color: #c2410c; }
.sub-banner-red    { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

.trial-days-big {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}

.sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.sub-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.sub-price {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0.5rem 0 1rem;
}

.sub-price-free { color: #16a34a; }

.sub-features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.sub-features li {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sub-features li::before {
  content: "✓";
  color: #10b981;
  font-weight: 700;
  flex-shrink: 0;
}

.sub-next-billing {
  font-size: 0.825rem;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.sub-beta-note {
  font-size: 0.825rem;
  color: var(--text-muted);
  padding: 0.625rem 0.75rem;
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.badge-beta {
  display: inline-block;
  background: #ede9fe;
  color: #7c3aed;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

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

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Danger button */
.btn-danger {
  padding: 0.6rem 1.25rem;
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.btn-danger:hover {
  background: #fef2f2;
}

/* Subscription modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  animation: modal-in 0.18s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 0;
}

.modal-header h3 { font-size: 1.1rem; font-weight: 700; margin: 0; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: 4px;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 1.25rem 1.5rem; }
.modal-body p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0; }

.modal-actions {
  padding: 0 1.5rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Status badges */
.badge-trialing {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.badge-active {
  display: inline-block;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.badge-expired {
  display: inline-block;
  background: #ffedd5;
  color: #c2410c;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.badge-cancelled {
  display: inline-block;
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

/* ── Responsive additions ─────────────────── */
@media (max-width: 680px) {
  .sub-grid { grid-template-columns: 1fr; }
  .pricing-grid-2 { grid-template-columns: 1fr; }
}

/* ── Line item discount compound & label ── */
.li-desc-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.disc-label-input {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  padding: 0.3rem 0.5rem !important;
  border-color: var(--border);
  background: var(--surface);
}

.disc-compound {
  display: flex;
  gap: 0.25rem;
  align-items: stretch;
}

.disc-compound input {
  flex: 1;
  min-width: 0;
}

.disc-compound select {
  width: auto;
  min-width: 44px;
  padding: 0.5rem 0.25rem;
  font-size: 0.82rem;
}

/* ── STOCK MOVEMENTS ──────────────────────── */
.badge-move-in {
  display: inline-block;
  background: #dcfce7;
  color: #15803d;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.badge-move-out {
  display: inline-block;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.badge-move-adjust {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.badge-reorder {
  display: inline-block;
  background: #ffedd5;
  color: #c2410c;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.delta-positive { color: #16a34a; font-weight: 600; }
.delta-negative { color: #ef4444; font-weight: 600; }
.delta-neutral  { color: #64748b; font-weight: 600; }

.btn-stock-in  { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.btn-stock-out { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.btn-stock-adj { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.btn-stock-in:hover  { background: #bbf7d0; }
.btn-stock-out:hover { background: #fecaca; }
.btn-stock-adj:hover { background: #bfdbfe; }

/* Import label button */
.import-file-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Report table footer */
.report-category-row td {
  border-top: 2px solid var(--border);
}

/* Flash messages */
.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ── DISCOUNT PRESETS ─────────────────────── */
.discount-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-bottom: 1rem;
  background: var(--bg);
}

.discount-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.discount-section-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 68px;
}

.disc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.disc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.disc-chip:hover {
  border-color: var(--disc-color, var(--primary));
  color: var(--disc-color, var(--primary));
  background: color-mix(in srgb, var(--disc-color, var(--primary)) 8%, white);
}

.disc-chip-active {
  border-color: var(--disc-color, var(--primary));
  color: var(--disc-color, var(--primary));
  background: color-mix(in srgb, var(--disc-color, var(--primary)) 12%, white);
  font-weight: 600;
}

.disc-chip-value {
  font-size: 0.75rem;
  opacity: 0.75;
}

.disc-chip-custom {
  border-style: dashed;
}

.discount-custom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.625rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border);
}

/* ── TOAST NOTIFICATIONS ─────────────────── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toast-in 0.3s ease forwards;
  max-width: 400px;
}

.toast--success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.toast--error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast--warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.toast--info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

.toast.toast-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

/* ── CONFIRMATION DIALOG ─────────────────── */
dialog.confirm-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  width: 90vw;
}

dialog.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.confirm-dialog__body {
  padding: 1.5rem;
}

.confirm-dialog__title {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.confirm-dialog__message {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── TRANSITIONS ─────────────────────────── */
.btn, .nav-link, .card, a {
  transition: all 0.15s ease;
}

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

/* ── SKELETON LOADERS ────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-row {
  height: 3rem;
  margin-bottom: 0.5rem;
}

.skeleton-card {
  height: 6rem;
  margin-bottom: 0.75rem;
}

.skeleton-text {
  height: 1rem;
  width: 60%;
  margin-bottom: 0.5rem;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── EMPTY STATES ────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state__description {
  font-size: var(--text-sm);
  margin-bottom: 1.5rem;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ── FORM VALIDATION FEEDBACK ────────────── */
.form-group input:invalid:not(:placeholder-shown),
.form-group input.is-invalid {
  border-color: var(--error);
}

.form-group input:valid:not(:placeholder-shown):not([type="hidden"]) {
  border-color: var(--success);
}

.field-error {
  color: var(--error);
  font-size: var(--text-xs);
  margin-top: 0.25rem;
  display: none;
}

.field-error.visible {
  display: block;
}

/* ── SPINNER OVERLAY ─────────────────────── */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.spinner-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Sort Headers ──────────────────────────────────────────────────────────── */
.sort-header { color: inherit; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 0.25rem; }
.sort-header:hover { color: var(--color-primary); }
.sort-header.active { font-weight: 600; }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination-bar { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; margin-top: 0.5rem; border-top: 1px solid #e2e8f0; }
.pagination-info { font-size: 0.85rem; color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: 0.5rem; }
.pagination-page { font-size: 0.85rem; color: var(--text-muted); }
.btn.disabled, .btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ── Advanced Filters Toggle ───────────────────────────────────────────────── */
.advanced-filters-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.5rem; }

/* ── Global Search Overlay ─────────────────────────────────────────────────── */
.search-overlay { position: fixed; inset: 0; z-index: 1100; display: flex; justify-content: center; padding-top: 20vh; }
.search-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.search-modal { position: relative; width: 100%; max-width: 560px; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; max-height: 60vh; display: flex; flex-direction: column; }
.search-modal input { width: 100%; padding: 1rem 1.25rem; border: none; border-bottom: 1px solid #e2e8f0; font-size: 1rem; outline: none; box-sizing: border-box; }
.search-results { overflow-y: auto; padding: 0.5rem; }
.search-result { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; border-radius: 8px; text-decoration: none; color: inherit; cursor: pointer; }
.search-result:hover, .search-result.selected { background: #f1f5f9; }
.search-result-info { display: flex; flex-direction: column; }
.search-result-title { font-weight: 500; font-size: 0.9rem; }
.search-result-subtitle { font-size: 0.8rem; color: var(--text-muted); }
.search-type-badge { font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.4rem; border-radius: 4px; text-transform: uppercase; flex-shrink: 0; }
.search-type-article { background: #dbeafe; color: #1d4ed8; }
.search-type-invoice { background: #dcfce7; color: #16a34a; }
.search-type-quote { background: #ffedd5; color: #ea580c; }
.search-type-client { background: #f3e8ff; color: #9333ea; }
.search-empty { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.search-kbd { font-size: 0.7rem; padding: 0.1rem 0.4rem; border: 1px solid #d1d5db; border-radius: 4px; background: #f9fafb; margin-left: auto; }

/* ── RECURRING INVOICE BADGES ─────────────── */
.badge-active { background: #f0fdf4; color: #16a34a; }
.badge-paused { background: #f1f5f9; color: #9ca3af; }
.badge-recurring { background: #ede9fe; color: #7c3aed; }

/* ── PUBLIC PAGE EDITOR ───────────────────── */
.public-page-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface, #fff);
}
.public-page-form legend {
  font-weight: 600;
  padding: 0 0.5rem;
  color: var(--text, #0f172a);
}

/* Opening-hours editor */
.hours-editor { display: flex; flex-direction: column; gap: 0.5rem; }
.hours-day {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  background: var(--surface, #fff);
}
.hours-day-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
}
.hours-day-name { font-weight: 600; text-transform: capitalize; min-width: 6rem; }
.hours-day-toggles { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.hours-chip {
  display: inline-flex; align-items: center; gap: 0.375rem;
  font-size: var(--text-sm); padding: 0.25rem 0.6rem;
  border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; white-space: nowrap; user-select: none;
}
.hours-chip input { margin: 0; }
.hours-ranges { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.75rem; }
.hours-range { display: flex; align-items: center; gap: 0.5rem; }
.hours-range input[type="time"] { max-width: 9rem; }
.hours-dash { color: var(--text-muted); }
.hours-range-remove {
  border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.25rem; line-height: 1;
  padding: 0 0.25rem; border-radius: 6px;
}
.hours-range-remove:hover { color: #ef4444; background: #fef2f2; }
.hours-add { margin-top: 0.5rem; }
/* When a day is Closed or Open-24h, hide the range editor. */
.hours-day--off .hours-ranges,
.hours-day--off .hours-add { display: none; }

/* ── PUBLIC PAGE EDITOR — polish (animations, switches, sticky bar) ── */

/* Staggered fade/slide-in of the form sections on load. */
@keyframes ppFadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .public-page-form fieldset { animation: ppFadeInUp 0.35s ease both; }
  .public-page-form fieldset:nth-of-type(2) { animation-delay: 0.05s; }
  .public-page-form fieldset:nth-of-type(3) { animation-delay: 0.10s; }
  .public-page-form fieldset:nth-of-type(4) { animation-delay: 0.15s; }
  .public-page-form fieldset:nth-of-type(5) { animation-delay: 0.20s; }
  .public-page-form fieldset:nth-of-type(6) { animation-delay: 0.25s; }
}

/* Buttons: smooth hover lift + focus ring (scoped to the editor). */
.public-page-form .btn,
.public-page-save-bar .btn {
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}
.public-page-form .btn:hover,
.public-page-save-bar .btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.10); }
.public-page-form .btn:active,
.public-page-save-bar .btn:active { transform: translateY(0); box-shadow: none; }
.public-page-form .btn:focus-visible,
.public-page-save-bar .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Tasteful native checkboxes + hover lift on day cards. */
.public-page-form input[type="checkbox"] { accent-color: var(--primary); }
.public-page-form .hours-day { transition: box-shadow 0.15s ease, border-color 0.15s ease; }
.public-page-form .hours-day:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
/* Highlight a chip when its checkbox is on (modern :has()). */
.public-page-form .hours-chip:has(input:checked) {
  background: var(--primary-light, #e8f0fe);
  border-color: var(--primary);
  color: var(--primary);
}
.public-page-form .hours-range { transition: opacity 0.15s ease; }
.public-page-form .hours-range-remove { transition: color 0.12s ease, background-color 0.12s ease; }

/* Animated switch for prominent boolean toggles. */
.switch-toggle {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: 0 0 auto;
  width: 42px; height: 24px; border-radius: 999px;
  background: var(--border); cursor: pointer;
  transition: background-color 0.2s ease; vertical-align: middle;
}
.switch-toggle::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.2s ease;
}
.switch-toggle:checked { background: var(--primary); }
.switch-toggle:checked::before { transform: translateX(18px); }
.switch-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Sticky save bar at the bottom of the editor. */
.public-page-save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; justify-content: flex-end; gap: 0.75rem;
  margin-top: 1.5rem; padding: 0.85rem 1rem;
  background: rgba(255,255,255,0.85); backdrop-filter: blur(6px);
  border-top: 1px solid var(--border); border-radius: var(--radius);
}

/* Styled native dropdowns (custom chevron, consistent focus). */
.public-page-form select {
  appearance: none; -webkit-appearance: none;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background-color: #fff;
  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='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1rem;
  cursor: pointer; transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.public-page-form select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light, #e8f0fe);
}

/* Custom checkboxes (the non-switch ones: page Enabled is a switch). */
.public-page-form input[type="checkbox"]:not(.switch-toggle) {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; flex: 0 0 auto;
  border: 1.5px solid var(--border); border-radius: 5px;
  background: #fff; cursor: pointer; position: relative; vertical-align: middle;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.public-page-form input[type="checkbox"]:not(.switch-toggle):checked {
  background: var(--primary); border-color: var(--primary);
}
.public-page-form input[type="checkbox"]:not(.switch-toggle):checked::after {
  content: ""; position: absolute; left: 5px; top: 1px;
  width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.public-page-form input[type="checkbox"]:not(.switch-toggle):focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* Quill rich-text editor theming to match the form. */
.public-page-form .ql-toolbar.ql-snow,
.public-page-form .ql-container.ql-snow { border-color: var(--border); }
.public-page-form .ql-toolbar.ql-snow {
  border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
  background: var(--bg, #f8fafc);
}
.public-page-form .ql-container.ql-snow {
  border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius);
}
.public-page-form .ql-editor { min-height: 140px; font-size: 0.95rem; }

/* ════════════════════════════════════════════════════════════════════════
   MODERN REFINEMENT LAYER (v2) — Refined-SaaS aesthetic
   Source-ordered last so it elevates the high-visibility components.
   ════════════════════════════════════════════════════════════════════════ */

/* ── Custom scrollbars ── */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* ── Lucide icon sizing ── */
.icon { width: 1.15em; height: 1.15em; stroke-width: 2; flex-shrink: 0; vertical-align: -0.18em; }
.icon-sm { width: 1em; height: 1em; }
.icon-lg { width: 1.4em; height: 1.4em; }

/* ── Buttons (refined) ── */
.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  will-change: transform;
}
.btn:active { transform: translateY(0.5px) scale(0.99); }
.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  box-shadow: var(--shadow-brand), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--brand-600), var(--brand-700)); transform: translateY(-1px); box-shadow: 0 8px 22px -6px rgba(var(--primary-rgb),0.55); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-subtle); transform: translateY(-1px); }
.btn-ghost:hover { background: var(--surface-2); transform: translateY(-1px); }

/* ── Inputs (refined) ── */
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="date"], input[type="time"], input[type="tel"], input[type="search"],
select, textarea, .form-control {
  border-radius: var(--radius-sm);
  border-color: var(--border-strong);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--text-subtle); }
input:focus, select:focus, textarea:focus, .form-control:focus { border-color: var(--primary); box-shadow: var(--ring); }
.form-group label, .form-label { font-weight: 600; letter-spacing: -0.005em; }
select:not([multiple]) {
  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='%2364748b' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1rem;
  padding-right: 2.25rem;
}

/* ── Cards (refined) ── */
.card {
  border-radius: var(--radius-lg);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { border-color: var(--border); }
.card-header h2 { letter-spacing: -0.01em; }

/* ── App shell ── */
.layout { background: var(--bg); }
.sidebar {
  background: linear-gradient(185deg, var(--sidebar-bg-2), var(--sidebar-bg));
  border-right: 1px solid rgba(255,255,255,0.04);
  padding-bottom: 0.5rem;
}
.sidebar-brand { font-size: 1.02rem; letter-spacing: -0.02em; border-bottom-color: rgba(255,255,255,0.06); padding: 1.15rem 1.35rem; }
.sidebar-brand .brand-icon, .nav-brand-icon { color: var(--brand-400); display: inline-flex; }
.nav-links li { padding: 0 0.6rem; }
.nav-link {
  border-radius: var(--radius-sm);
  font-weight: 500;
  position: relative;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link .nav-icon { color: var(--text-subtle); transition: color var(--dur-fast) var(--ease); display: inline-flex; align-items: center; }
.nav-link:hover { background: rgba(255,255,255,0.06); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(var(--primary-rgb),0.22), rgba(var(--primary-rgb),0.08));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb),0.25);
}
.nav-link.active .nav-icon { color: var(--brand-300); }
.nav-link.active::before {
  content: ""; position: absolute; left: -0.6rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 1.1rem; border-radius: 0 3px 3px 0; background: var(--brand-400);
}
.nav-group-label { color: rgba(148,163,184,0.55); }
.sidebar-footer { border-top-color: rgba(255,255,255,0.06); }

/* ── Top bar (new, optional via .app-topbar) ── */
.app-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  height: var(--topbar-height); margin: 0 -2rem 1.75rem;
  padding: 0 2rem;
  background: rgba(246,248,251,0.82);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-topbar .topbar-search {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 0.4rem 0.85rem; color: var(--text-muted);
  font-size: 0.85rem; cursor: pointer; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  min-width: 240px;
}
.app-topbar .topbar-search:hover { border-color: var(--text-subtle); box-shadow: var(--shadow-xs); }
.app-topbar .topbar-spacer { flex: 1; }
.topbar-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); cursor: pointer; text-decoration: none;
  transition: all var(--dur-fast) var(--ease);
}
.topbar-icon-btn:hover { color: var(--text); border-color: var(--text-subtle); transform: translateY(-1px); }

/* ── Page header ── */
.page-header h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
.page-subtitle, .page-header p { color: var(--text-muted); }

/* ── Tables (refined) ── */
.table-container { border-radius: var(--radius-lg); border-color: var(--border); box-shadow: var(--shadow-xs); }
.data-table th { background: var(--surface-2); font-size: 0.72rem; letter-spacing: 0.06em; border-bottom-color: var(--border); }
.data-table td { border-bottom-color: #eef1f5; }
.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.data-table tr:hover td { background: var(--brand-50); }

/* ── Badges / pills (refined) ── */
.badge {
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  padding: 0.22rem 0.55rem;
  text-transform: capitalize;
  line-height: 1.2;
}

/* ── Stat / KPI cards (refined) ── */
.stat-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-value { letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi-card { box-shadow: var(--shadow-xs); transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-value { letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ── Business cards ── */
.business-card { border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.business-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }

/* ── Empty states (refined) ── */
.empty-state { padding: 4rem 2rem; }
.empty-state .empty-state-icon, .empty-state .empty-icon {
  width: 64px; height: 64px; margin: 0 auto 1.1rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 18px; background: var(--brand-50); color: var(--brand-600);
  box-shadow: inset 0 0 0 1px var(--brand-100);
}
.empty-state .empty-state-icon .icon, .empty-state .empty-icon .icon { width: 30px; height: 30px; }

/* ── Modals (refined) ── */
.modal-box, .modal-card, .search-modal { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-backdrop, .modal-overlay { background: rgba(15,23,42,0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }

/* ── Public navbar / footer ── */
.public-header { background: rgba(255,255,255,0.78); border-bottom-color: var(--border); }
.nav-brand { letter-spacing: -0.02em; }
.nav-brand-icon { color: var(--brand-600); }

/* ── Auth ── */
.auth-panel-left { background: linear-gradient(150deg, #0b1220 0%, #16264a 55%, var(--brand-700) 120%); }

/* ── Soft section divider helper ── */
.divider { height: 1px; background: var(--border); border: 0; margin: 1.5rem 0; }

/* ── Motion: entrance + reveal ── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .main-content > * { animation: fadeInUp var(--dur-slow) var(--ease-out) both; }
  .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out); }
  .reveal.in { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ── Count-up numbers reserve space ── */
[data-countup] { font-variant-numeric: tabular-nums; }

/* ── Stagger helper for grids ── */
@media (prefers-reduced-motion: no-preference) {
  .stagger > * { animation: fadeInUp var(--dur-slow) var(--ease-out) both; }
  .stagger > *:nth-child(2) { animation-delay: 0.04s; }
  .stagger > *:nth-child(3) { animation-delay: 0.08s; }
  .stagger > *:nth-child(4) { animation-delay: 0.12s; }
  .stagger > *:nth-child(5) { animation-delay: 0.16s; }
  .stagger > *:nth-child(6) { animation-delay: 0.20s; }
}

/* ════════════════════════════════════════════════════════════════════════
   GUIDED PRODUCT TOUR (first-run spotlight)
   ════════════════════════════════════════════════════════════════════════ */
.tour-backdrop { position: fixed; inset: 0; z-index: 4000; background: rgba(11,18,32,0.55); backdrop-filter: blur(1px); }
.tour-spotlight {
  position: fixed; z-index: 4001; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(11,18,32,0.55), 0 0 0 3px var(--brand-400);
  transition: all var(--dur-slow) var(--ease-out);
}
.tour-pop {
  position: fixed; z-index: 4002; width: 300px; max-width: calc(100vw - 2rem);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 1.1rem 1.2rem; animation: fadeInUp var(--dur) var(--ease-out) both;
}
.tour-pop h4 { font-size: 1rem; margin: 0 0 0.35rem; letter-spacing: -0.01em; }
.tour-pop p { font-size: 0.875rem; color: var(--text-muted); margin: 0 0 0.9rem; line-height: 1.5; }
.tour-pop-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.tour-progress { font-size: 0.78rem; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.tour-pop-buttons { display: flex; gap: 0.5rem; }

/* ── Setup checklist (dashboard) ── */
.setup-card { border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-xs); overflow: hidden; }
.setup-progress-track { background: var(--border); border-radius: 999px; height: 7px; overflow: hidden; }
.setup-progress-fill { height: 7px; border-radius: 999px; background: linear-gradient(90deg, var(--brand-500), var(--brand-600)); transition: width var(--dur-slow) var(--ease-out); }
.setup-item {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.setup-item:hover { transform: translateY(-1px); border-color: var(--brand-300); box-shadow: var(--shadow-xs); text-decoration: none; color: var(--text); }
.setup-item .setup-tick {
  width: 22px; height: 22px; border-radius: 999px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--border-strong); color: transparent; background: var(--surface);
}
.setup-item.done .setup-tick { background: var(--success); border-color: var(--success); color: #fff; }
.setup-item.done .setup-label { color: var(--text-subtle); text-decoration: line-through; }

/* ── Language picker (segmented control) ── */
.lang-picker {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
}
.lang-option {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; padding: 0.18rem 0.5rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text-muted); text-decoration: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.lang-option:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.lang-option.active { background: var(--primary); color: #fff; }
.sidebar .lang-picker { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.10); width: 100%; justify-content: center; margin-bottom: 0.5rem; }
.sidebar .lang-option { color: var(--sidebar-text); }
.sidebar .lang-option:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar .lang-option.active { background: var(--brand-600); color: #fff; }

/* ── Responsive refinements ── */
@media (max-width: 768px) {
  .app-topbar { display: none; }
  .page-header h1 { font-size: 1.35rem; }
  .stat-card-value { font-size: 1.6rem; }
}
@media (min-width: 769px) {
  /* Tasteful inset for the sticky topbar's bleeding edges already handled by margins */
  .main-content { scroll-padding-top: var(--topbar-height); }
  /* When the topbar is present it owns the top edge: drop main-content's top
     padding so the bar sits flush at the very top (no offset at rest, and the
     sticky bar pins flush on scroll). Pages without a topbar keep their padding. */
  .main-content:has(> .app-topbar) { padding-top: 0; }
}
