/* ============================================================================
   SNELBOEK — Shared design system
   Single source of truth for tokens + components. Linked by every page.
   ----------------------------------------------------------------------------
   DESIGN TOKENS (committed)
     Font ........ Inter (Google Fonts), base 14px / line-height 1.5
     Primary ..... #2563eb   hover #1d4ed8   tint #eff6ff
     Text ........ #0f172a   secondary #475569   muted #94a3b8
     Surface ..... bg #f8fafc   card #ffffff   border #e2e8f0
     Status ...... success #16a34a   warning #f59e0b   error #dc2626
     Radius ...... sm 8px (inputs/buttons)  md 12px (cards)  lg 16px (modals)
                   pill 9999px (badges)
     Shadow ...... sm  0 1px 3px rgba(15,23,42,.04), 0 1px 2px rgba(15,23,42,.06)
                   md  0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04)
     Spacing ..... 4px base — 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64
     Motion ...... 150–200ms ease on buttons / inputs / hovers
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;        /* primary hover */
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;       /* tint background */

  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #475569;               /* secondary text (used widely as var(--muted)) */
  --light: #94a3b8;               /* muted / tertiary text */

  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;

  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #f59e0b;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fecaca;

  --radius: 8px;                  /* inputs / buttons */
  --radius-card: 12px;
  --radius-modal: 16px;

  --shadow-sm: 0 1px 3px rgba(15,23,42,0.04), 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-pop: 0 4px 24px rgba(15,23,42,0.12);

  --ease: 150ms ease;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-dark: #60a5fa;
  --primary-hover: #60a5fa;
  --primary-light: #1e3a8a;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --light: #64748b;
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --success: #4ade80;
  --success-bg: #052e16;
  --success-border: #166534;
  --error: #f87171;
  --error-bg: #450a0a;
  --error-border: #7f1d1d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-pop: 0 4px 24px rgba(0,0,0,0.5);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-osmoothing: grayscale;
}

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

/* Tabular figures for any numeric column / stat */
.tnum, .stat-num, .plan-stat-value, .pricing-amount, .payg-price,
.jobs-table td, .clients-table td, .inv-table td, .count-badge,
.usage-text, .progress-label { font-variant-numeric: tabular-nums; }

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

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-btn {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 6px 9px; cursor: pointer; font-size: 15px; color: var(--muted);
  transition: background var(--ease), border-color var(--ease); line-height: 1;
}
.theme-btn:hover { background: var(--bg); color: var(--text); }

/* ── App nav ──────────────────────────────────────────────────────────────── */
.nav {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.nav-left { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.brand-icon, .brand-mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: block;
}
.brand-icon {
  background: var(--primary); display: flex; align-items: center; justify-content: center;
}
.brand-icon svg { width: 17px; height: 17px; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
  padding: 6px 11px; border-radius: var(--radius); transition: background var(--ease), color var(--ease);
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
[data-theme="dark"] .nav-link.active { color: #bfdbfe; }
.nav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* ── Profile dropdown ─────────────────────────────────────────────────────── */
.profile-wrap { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: 8px; background: none;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px;
  cursor: pointer; font-family: inherit; font-size: 13px; color: var(--text); transition: background var(--ease);
}
.profile-btn:hover { background: var(--bg); }
.profile-avatar {
  width: 24px; height: 24px; background: var(--primary-light); color: var(--primary);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.profile-email { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: var(--light); font-size: 9px; transition: transform 0.2s; }
.profile-wrap.open .chevron { transform: rotate(180deg); }
.dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-pop);
  min-width: 210px; overflow: hidden; opacity: 0; transform: translateY(-6px);
  pointer-events: none; transition: opacity var(--ease), transform var(--ease);
}
.profile-wrap.open .dropdown { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dropdown-email {
  padding: 12px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-size: 13px;
  color: var(--text); text-decoration: none; cursor: pointer; background: none; border: none;
  width: 100%; font-family: inherit; transition: background 0.1s;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-bg); }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.container { max-width: 920px; margin: 0 auto; padding: 32px 16px 64px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); padding: 24px; margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card h2, h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.sub { font-size: 13px; color: var(--muted); margin-top: 4px; margin-bottom: 18px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn,
.btn-primary, .btn-ghost, .btn-danger, .btn-secondary {
  font-family: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent;
  border-radius: var(--radius); transition: all var(--ease); white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn { padding: 9px 18px; font-size: 13px; }
.btn-primary { padding: 9px 18px; font-size: 13px; background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; box-shadow: none; transform: none; }
[data-theme="dark"] .btn-primary:disabled { background: #1e3a8a; color: #93c5fd; }

.btn-secondary { padding: 9px 18px; font-size: 13px; background: var(--card); color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-ghost { padding: 8px 14px; font-size: 13px; background: var(--bg); color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-danger { padding: 8px 14px; font-size: 13px; background: var(--error-bg); color: var(--error); border-color: var(--error-border); }
.btn-danger:hover { background: #fee2e2; }
[data-theme="dark"] .btn-danger:hover { background: #5b1212; }

.btn-sm { padding: 5px 12px; border-radius: 7px; font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; border: 1px solid transparent; transition: all var(--ease); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.btn-outline-blue { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }
.btn-outline-blue:hover { background: #dbeafe; }
[data-theme="dark"] .btn-outline-blue { border-color: #1e3a8a; }
[data-theme="dark"] .btn-outline-blue:hover { background: #1e3a8a; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }

input[type="email"], input[type="password"], input[type="text"], input[type="search"],
select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; color: var(--text); background: var(--card);
  transition: border-color var(--ease), box-shadow var(--ease); outline: none; -webkit-appearance: none;
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
input:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--light); }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: var(--card); color: var(--text); border-color: var(--border);
}
[data-theme="dark"] input:disabled { background: #0f172a; color: var(--light); }

.field { margin-bottom: 16px; }
.hint { font-size: 12px; color: var(--light); margin-top: 5px; }
.error-msg { font-size: 12px; color: var(--error); margin-top: 4px; }

/* Inline form-level error banner */
.error-box, .form-err {
  background: var(--error-bg); color: var(--error); border: 1px solid var(--error-border);
  border-radius: var(--radius); padding: 10px 13px; font-size: 13px; margin-bottom: 16px;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table, .jobs-table, .clients-table, .inv-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th, .jobs-table th, .clients-table th, .inv-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--light);
  text-transform: uppercase; letter-spacing: 0.5px; padding: 10px; white-space: nowrap;
}
.data-table td, .jobs-table td, .clients-table td, .inv-table td {
  padding: 12px 10px; border-top: 1px solid var(--border); vertical-align: middle;
}
.clients-table tr:hover td, .data-table tbody tr:hover td { background: var(--bg); }

/* ── Status badges / pills ────────────────────────────────────────────────── */
.status-badge, .status-pill, .count-badge, .plan-badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 9999px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
}
.status-badge { padding: 3px 9px; text-transform: capitalize; }
.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.status-badge.completed, .status-pill.filled { background: var(--success-bg); color: var(--success); }
.status-badge.processing { background: #fffbeb; color: #92400e; }
.status-badge.failed { background: var(--error-bg); color: var(--error); }
.status-badge.pending, .status-pill.pending { background: var(--bg); color: var(--muted); }
[data-theme="dark"] .status-badge.processing { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .status-pill.pending { background: #1e293b; }

.status-pill { padding: 2px 8px; }
.status-pill.pending { background: #fffbeb; color: #92400e; }
[data-theme="dark"] .status-pill.pending { background: #451a03; color: #fbbf24; }

.count-badge { padding: 2px 8px; }
.count-badge.pending { background: #fffbeb; color: #92400e; }
.count-badge.zero { background: var(--bg); color: var(--muted); }
[data-theme="dark"] .count-badge.pending { background: #451a03; color: #fbbf24; }

.plan-badge {
  padding: 2px 9px; background: var(--primary-light); color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.4px;
}

/* ── Empty states ─────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--light); }

/* ── Skeleton loaders ─────────────────────────────────────────────────────── */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
  display: inline-block; border-radius: 4px; background-size: 400px 100%;
  background-image: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  animation: shimmer 1.4s infinite;
}
[data-theme="dark"] .skeleton { background-image: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%); }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column;
  gap: 8px; z-index: 2000; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px 16px;
  box-shadow: var(--shadow-pop); min-width: 260px; max-width: 380px;
  transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.16,1,0.3,1); pointer-events: auto;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.info { border-left: 3px solid var(--primary); }
.toast-msg { flex: 1; font-size: 13px; line-height: 1.4; color: var(--text); }
.toast-close { background: none; border: none; color: var(--light); cursor: pointer; font-size: 16px; padding: 0; line-height: 1; flex-shrink: 0; }
.toast-close:hover { color: var(--muted); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
@keyframes modal-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 100; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius-modal); width: 100%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(15,23,42,0.25); max-height: 90vh; display: flex; flex-direction: column;
  animation: modal-in 0.2s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--light); cursor: pointer; line-height: 1; padding: 0; transition: color var(--ease); }
.modal-close:hover { color: var(--muted); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav { padding: 0 16px; }
  .container { padding: 20px 12px 48px; }
  .card { padding: 16px; }
  .profile-email { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
}
