/* ============================================================
   KN B2B CRM — premium UI system
   Mobile-first. Sidebar layout from 1024px.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@500;600;700&display=swap');

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "cv11", "ss01", "cv02";
  scroll-behavior: smooth;
}
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; font-size: 16px; } /* 16px to prevent iOS zoom */
@media (min-width: 700px) { input, select, textarea { font-size: var(--text-sm); } }
a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-2); }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { font-size: .9em; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; font-weight: 600; }
h1 { font-size: var(--text-3xl); letter-spacing: -0.025em; }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

/* ============================================================
   Design tokens
   ============================================================ */
:root {
  /* Spacing — strict 4px scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Type scale */
  --text-2xs: 11px;
  --text-xs:  12px;
  --text-sm:  13px;
  --text-md:  14px;
  --text-lg:  16px;
  --text-xl:  18px;
  --text-2xl: 22px;
  --text-3xl: 28px;
  --text-4xl: 36px;
  --text-5xl: 48px;

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Refined neutrals — slightly warmer for premium feel */
  --bg:           #fafafa;
  --surface:      #ffffff;
  --surface-2:    #f4f4f5;
  --surface-3:    #e9e9ec;
  --text:         #09090b;
  --text-soft:    #27272a;
  --muted:        #71717a;
  --subtle:       #a1a1aa;
  --border:       #e8e8eb;
  --border-strong:#d4d4d8;

  /* Brand & status */
  --primary:        #65beec;
  --primary-2:      #2e9fc9;
  --primary-soft:   #e6f4fc;
  --primary-on:     #ffffff;
  --primary-glow:   rgba(101, 190, 236, .28);

  --success:        #16a34a;
  --success-soft:   #ecfdf5;
  --warning:        #ea580c;
  --warning-soft:   #fff7ed;
  --danger:         #dc2626;
  --danger-soft:    #fef2f2;
  --info:           #0284c7;
  --info-soft:      #f0f9ff;

  /* Layered shadows — slight blue tint, multi-layer for depth */
  --shadow-xs:   0 1px 2px rgba(11, 18, 32, .04);
  --shadow-sm:   0 1px 2px rgba(11, 18, 32, .04), 0 1px 3px rgba(11, 18, 32, .04);
  --shadow-md:   0 4px 12px -2px rgba(11, 18, 32, .06), 0 2px 4px -2px rgba(11, 18, 32, .04);
  --shadow-lg:   0 16px 32px -8px rgba(11, 18, 32, .12), 0 4px 8px -4px rgba(11, 18, 32, .06);
  --shadow-xl:   0 24px 48px -12px rgba(11, 18, 32, .2), 0 8px 16px -8px rgba(11, 18, 32, .08);
  --shadow-ring: 0 0 0 3px var(--primary-glow);

  /* Layout */
  --topbar-h:    56px;
  --bottomnav-h: 68px;
  --sidebar-w:   256px;
  --container:   1320px;

  --ease:        cubic-bezier(.4, 0, .2, 1);
  --ease-out:    cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

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

/* Sidebar als slide-in drawer op mobile (< 1024px). */
.sidebar {
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(86vw, 320px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform .22s var(--ease-out);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.app-shell.menu-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.18); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,20,.42);
  z-index: 199; opacity: 0; pointer-events: none;
  transition: opacity .18s var(--ease-out);
}
.app-shell.menu-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

.main {
  flex: 1; min-width: 0;
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--space-4));
  display: flex; flex-direction: column;
}
.page {
  flex: 1; width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-4);
  animation: pageFadeIn .25s var(--ease-out);
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (min-width: 1024px) {
  .sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: sticky; top: 0;
    transform: none !important;
    flex-shrink: 0;
    z-index: auto;
    box-shadow: none;
  }
  .sidebar-backdrop { display: none !important; }
  .topbar    { display: none; }
  .bottomnav { display: none; }
  .main      { padding-bottom: 0; }
  .page      { padding: var(--space-8) var(--space-10); }
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-3);
  font-weight: 600; font-size: var(--text-md);
  letter-spacing: -0.015em;
  color: var(--text);
}
.sidebar__brand-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary) 0%, #2e9fc9 100%);
  border-radius: 9px;
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, .4),
              inset 0 1px 0 rgba(255, 255, 255, .2);
}
.sidebar__brand-logo svg { width: 22px; height: 22px; }
.sidebar__nav {
  flex: 1;
  padding: var(--space-1) var(--space-3);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px;
  scrollbar-width: thin;
}
.sidebar__section {
  padding: var(--space-4) var(--space-2) var(--space-1);
  font-size: var(--text-2xs); font-weight: 600;
  color: var(--subtle);
  text-transform: uppercase; letter-spacing: .08em;
}
.sidebar__link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  color: var(--text-soft);
  font-weight: 500;
  font-size: var(--text-sm);
  position: relative;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.sidebar__link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar__link svg {
  width: 18px; height: 18px; flex-shrink: 0;
  color: var(--muted);
  transition: color .12s var(--ease);
  stroke-width: 1.75;
}
.sidebar__link:hover svg { color: var(--text-soft); }
.sidebar__link.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}
.sidebar__link.active svg { color: var(--primary); }
.sidebar__link.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.sidebar__user {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-2);
  margin: 0;
}
.sidebar__user:hover { background: var(--surface-2); }
.sidebar__user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fce7f3 100%);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: var(--text-2xs);
  color: var(--primary);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .1);
}
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name { font-weight: 600; font-size: var(--text-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-role { font-size: var(--text-xs); color: var(--muted); }
.sidebar__logout-btn {
  background: transparent; border: 0; color: var(--muted);
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--radius-xs);
  transition: background .12s var(--ease), color .12s var(--ease);
}
.sidebar__logout-btn:hover { background: var(--surface-3); color: var(--text); }
.sidebar__logout-btn svg { width: 15px; height: 15px; }

/* ============================================================
   Mobile topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--space-3);
  max-width: var(--container);
  margin: 0 auto;
}
.topbar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 600; font-size: var(--text-md);
  color: var(--text);
  letter-spacing: -0.015em;
}
.topbar__brand-logo {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), #2e9fc9);
  border-radius: 8px;
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 2px 6px -1px rgba(79, 70, 229, .35),
              inset 0 1px 0 rgba(255, 255, 255, .15);
}
.topbar__brand-logo svg { width: 19px; height: 19px; }
.topbar__spacer { flex: 1; }
.topbar__btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent; border: 0;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  transition: background .12s var(--ease);
}
.topbar__btn:hover, .topbar__btn:focus-visible { background: var(--surface-2); }
.topbar__btn:active { background: var(--surface-3); }
.topbar__btn svg { width: 20px; height: 20px; }

/* ============================================================
   Bottom nav
   ============================================================ */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
}
.bottomnav__link {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: var(--text-2xs); font-weight: 500;
  text-decoration: none;
  padding: var(--space-2) var(--space-1);
  position: relative;
  transition: color .12s var(--ease);
  min-height: 44px;
}
.bottomnav__link svg { width: 22px; height: 22px; transition: transform .15s var(--ease-spring); }
.bottomnav__link:active svg { transform: scale(.92); }
.bottomnav__link.active { color: var(--primary); }
.bottomnav__link.active svg { transform: translateY(-1px); }
.bottomnav__link.active::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}

/* ============================================================
   Page heads
   ============================================================ */
.page-head { margin-bottom: var(--space-6); }
.page-head h1 { font-size: var(--text-3xl); letter-spacing: -0.025em; }
.page-head p { color: var(--muted); margin: var(--space-1) 0 0; font-size: var(--text-sm); }
.page-head--row { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: var(--space-3); }
.action-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.link { color: var(--primary); font-weight: 500; font-size: var(--text-sm); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--space-3); margin-bottom: var(--space-4);
}
.card--flush .card__head { padding: var(--space-4) var(--space-5) 0; margin-bottom: var(--space-3); }
.card__head h2 { margin: 0; }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

@media (min-width: 1024px) { .card { padding: var(--space-6); } }

/* ============================================================
   KPI grid
   ============================================================ */
.kpi-grid {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: var(--space-6);
}
@media (min-width: 720px)  { .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: var(--space-4); } }
@media (min-width: 1100px) { .kpi-grid { grid-template-columns: repeat(5, 1fr); } }
.kpi {
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  text-decoration: none;
  color: var(--text);
  position: relative;
  transition: transform .15s var(--ease-out), box-shadow .15s var(--ease-out), border-color .15s var(--ease-out);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.kpi::after {
  /* subtle radial glow that's only visible on hover */
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at top right, var(--primary-soft) 0%, transparent 60%);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease-out);
}
.kpi:hover {
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.kpi:hover::after { opacity: .5; }
.kpi > * { position: relative; }
.kpi__icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: var(--space-1);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .08);
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__icon--success { background: var(--success-soft); color: var(--success); box-shadow: inset 0 0 0 1px rgba(22, 163, 74, .12); }
.kpi__icon--warning { background: var(--warning-soft); color: var(--warning); box-shadow: inset 0 0 0 1px rgba(234, 88, 12, .12); }
.kpi__icon--danger  { background: var(--danger-soft);  color: var(--danger);  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .12); }
.kpi__icon--info    { background: var(--info-soft);    color: var(--info);    box-shadow: inset 0 0 0 1px rgba(2, 132, 199, .12); }
.kpi__label {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
  letter-spacing: -0.005em;
}
.kpi__value {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kpi__sub { font-size: var(--text-xs); color: var(--muted); }

/* ============================================================
   Tables
   ============================================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.table th, .table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-weight: 600;
  color: var(--muted);
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--surface-2);
}
.table tbody tr { transition: background .1s var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table--compact th, .table--compact td { padding: var(--space-2) var(--space-3); }

/* Mobile tables → cards */
@media (max-width: 760px) {
  .table--responsive { background: transparent; border: 0; }
  .table--responsive thead { display: none; }
  /* Whole-card tap target: stretch the first link to cover the entire row. */
  .table--responsive tr { position: relative; }
  .table--responsive td:first-child > a:first-of-type::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
  }
  /* Interactive elements inside the row stay above the overlay. */
  .table--responsive tr form,
  .table--responsive tr button,
  .table--responsive tr .editable-badge,
  .table--responsive tr a:not(:first-of-type) {
    position: relative;
    z-index: 2;
  }
  .table--responsive tbody {
    display: flex; flex-direction: column; gap: var(--space-2);
    padding: var(--space-3);
  }
  .card--flush .table--responsive tbody { padding: var(--space-3); }
  .table--responsive tr {
    display: flex; flex-direction: column; gap: var(--space-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    transition: border-color .15s var(--ease), transform .15s var(--ease);
  }
  .table--responsive tr:active { transform: scale(.99); }
  .table--responsive tr:hover { background: var(--surface); border-color: var(--border-strong); }
  .table--responsive td {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-3);
    border: 0; padding: 0;
  }
  .table--responsive td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: var(--text-2xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
  }
  .table--responsive td:first-child {
    flex-direction: column; align-items: flex-start;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-1);
  }
  .table--responsive td:first-child::before { display: none; }
  .table--responsive td:first-child a { font-weight: 600; font-size: var(--text-md); color: var(--text); }
}

/* ============================================================
   Lists
   ============================================================ */
.list { list-style: none; padding: 0; margin: 0; }
.list__item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}
.list__item:last-child { border-bottom: 0; padding-bottom: 0; }
.list__item:first-child { padding-top: 0; }
.list__title { display: block; font-weight: 500; color: var(--text); font-size: var(--text-md); }
.list__meta { display: flex; flex-wrap: wrap; gap: var(--space-2); font-size: var(--text-xs); color: var(--muted); align-items: center; margin-top: var(--space-1); }
.timeline { list-style: none; padding: 0; margin: var(--space-4) 0 0; display: grid; gap: var(--space-2); }
.timeline > li {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--primary);
}
.timeline__meta { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--muted); margin-bottom: var(--space-1); }
.timeline__body { white-space: pre-wrap; font-size: var(--text-md); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-2xs); font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  letter-spacing: .005em;
  white-space: nowrap;
  line-height: 1.4;
}
.badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge--new        { background: #eff6ff; color: #1d4ed8; }
.badge--contacted  { background: #f5f3ff; color: #6d28d9; }
.badge--interested { background: #fefce8; color: #a16207; }
.badge--quoted     { background: #fff7ed; color: #c2410c; }
.badge--won        { background: var(--success-soft); color: #15803d; }
.badge--lost       { background: var(--danger-soft);  color: #b91c1c; }
.badge--draft      { background: #f4f4f5; color: #52525b; }
.badge--sent       { background: var(--info-soft); color: #0369a1; }
.badge--paid       { background: var(--success-soft); color: #15803d; }
.badge--overdue    { background: var(--danger-soft);  color: #b91c1c; }
.badge--cancelled  { background: #f4f4f5; color: #71717a; }
.badge--open       { background: var(--info-soft); color: #0369a1; }
.badge--done       { background: var(--success-soft); color: #15803d; }

/* Stock badges (numeric, no dot) */
.stock {
  display: inline-block;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 9px; border-radius: var(--radius-xs);
  font-size: var(--text-sm);
}
.stock--ok        { background: var(--success-soft); color: #15803d; }
.stock--low       { background: var(--warning-soft); color: #c2410c; }
.stock--out       { background: var(--danger-soft);  color: #b91c1c; }
.stock--untracked { background: var(--surface-2);    color: var(--muted); }

/* ============================================================
   Chips — compact status pills
   ============================================================ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--text-xs); font-weight: 500;
  color: var(--text);
  text-decoration: none;
  line-height: 1.5;
  transition: filter .12s var(--ease), border-color .12s var(--ease);
}
.chip::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--subtle);
  flex-shrink: 0;
}
.chip:hover { text-decoration: none; filter: brightness(.97); }
.chip__count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* Status variants — baked in, no nested .badge needed */
.chip--new        { background: #eff6ff; border-color: #dbeafe; color: #1d4ed8; }
.chip--new::before        { background: #1d4ed8; }
.chip--new .chip__count   { color: #1d4ed8; }
.chip--contacted  { background: #f5f3ff; border-color: #ede9fe; color: #6d28d9; }
.chip--contacted::before  { background: #6d28d9; }
.chip--contacted .chip__count { color: #6d28d9; }
.chip--interested { background: #fefce8; border-color: #fef9c3; color: #a16207; }
.chip--interested::before { background: #a16207; }
.chip--interested .chip__count { color: #a16207; }
.chip--quoted     { background: #fff7ed; border-color: #ffedd5; color: #c2410c; }
.chip--quoted::before     { background: #c2410c; }
.chip--quoted .chip__count { color: #c2410c; }
.chip--won        { background: var(--success-soft); border-color: #bbf7d0; color: #15803d; }
.chip--won::before        { background: #15803d; }
.chip--won .chip__count   { color: #15803d; }
.chip--lost       { background: var(--danger-soft); border-color: #fecaca; color: #b91c1c; }
.chip--lost::before       { background: #b91c1c; }
.chip--lost .chip__count  { color: #b91c1c; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background .12s var(--ease), border-color .12s var(--ease), transform .08s var(--ease), box-shadow .12s var(--ease);
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
  min-height: 36px;
  box-shadow: var(--shadow-xs);
}
.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
  border-color: var(--border-strong);
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn svg { width: 15px; height: 15px; stroke-width: 2; }

/* Standaard fallback voor inline SVG-iconen (uit icon()-helper) buiten
   knoppen/sidebar: 1em zodat ze de regelhoogte volgen i.p.v. naar de
   intrinsic viewBox-grootte uit te zetten. */
svg[aria-hidden="true"]:not(.logo-mark) {
  width: 1em; height: 1em; vertical-align: -0.15em;
}
/* Specifiekere selectors hieronder overschrijven dit (bv. .btn svg,
   .sidebar__link svg, .hero__avatar svg) door later in de cascade te
   staan en/of een hogere specificiteit te hebben. */

.btn--primary {
  background: linear-gradient(180deg, #88d2f3 0%, var(--primary) 100%);
  color: var(--primary-on);
  border-color: var(--primary-2);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .14);
}
.btn--primary:hover {
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-2) 100%);
  border-color: var(--primary-2);
}
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-soft); box-shadow: none; }
.btn--ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
.btn--sm { padding: 5px 10px; font-size: var(--text-xs); min-height: 30px; }
.btn--sm svg { width: 13px; height: 13px; }
.btn--block { display: flex; width: 100%; min-height: 40px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.inline { display: inline-block; }
.inline-form { display: inline-flex; gap: var(--space-1); align-items: center; }
.inline-form input {
  padding: 8px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  min-width: 200px;
  background: var(--surface);
}

/* ============================================================
   Forms
   ============================================================ */
.form { display: flex; flex-direction: column; gap: var(--space-3); }
.form--grid { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
@media (min-width: 800px) { .form--grid { grid-template-columns: 1fr 1fr; gap: var(--space-4); } .fieldset--wide { grid-column: 1 / -1; } }
.fieldset {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(2, 1fr);
  box-shadow: var(--shadow-xs);
}
@media (max-width: 600px) { .fieldset { grid-template-columns: 1fr; padding: var(--space-4); } }
.fieldset > legend {
  font-weight: 600; font-size: var(--text-2xs);
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  padding: 0 6px;
}
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field--wide { grid-column: 1 / -1; }
.field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-soft);
}
.field input[type=text],
.field input[type=email],
.field input[type=password],
.field input[type=number],
.field input[type=search],
.field input[type=date],
.field input[type=datetime-local],
.field select,
.field textarea,
.form input,
.form select,
.form textarea {
  width: 100%;
  padding: 9px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
  font-size: var(--text-md);
}
@media (min-width: 700px) {
  .field input, .field select, .field textarea, .form input, .form select, .form textarea {
    font-size: var(--text-sm);
  }
}
.field textarea { min-height: 80px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: var(--shadow-ring);
}
.form input:disabled, .form input[readonly] { background: var(--surface-2); color: var(--muted); }
.form__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; grid-column: 1 / -1; }
.switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); }
.switch input { width: auto !important; }

/* ============================================================
   Filter bar
   ============================================================ */
.filterbar {
  display: grid; gap: var(--space-2);
  margin-bottom: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .filterbar { grid-template-columns: 2fr repeat(2, 1fr) auto; } }
.filterbar input, .filterbar select {
  padding: 9px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.filterbar input:focus, .filterbar select:focus {
  outline: 0; border-color: var(--primary);
  box-shadow: var(--shadow-ring);
}

/* ============================================================
   Definition list
   ============================================================ */
.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); }

/* ============================================================
   Auth
   ============================================================ */
.auth-page {
  background:
    radial-gradient(circle at 0% 0%,   rgba(79, 70, 229, .18) 0%, transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(124, 58, 237, .18) 0%, transparent 55%),
    var(--bg);
  min-height: 100vh; padding: 0;
}
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-xl);
  padding: var(--space-8) var(--space-6);
  animation: authIn .35s var(--ease-out);
}
@keyframes authIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.auth-card__brand { text-align: center; margin-bottom: var(--space-6); }
.auth-card__brand .auth-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), #2e9fc9);
  border-radius: 16px;
  display: grid; place-items: center;
  margin: 0 auto var(--space-3);
  color: #fff;
  box-shadow: 0 10px 24px -8px rgba(79, 70, 229, .4),
              inset 0 1px 0 rgba(255, 255, 255, .25);
}
.auth-card__brand .auth-logo svg { width: 38px; height: 38px; }
.auth-card__brand h1 { font-size: var(--text-2xl); }
.auth-card__brand p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }

/* Welcome chooser — twee gestapelde keuzes binnen de auth-card. Werkt
   fluid op telefoon (volledige breedte) en op desktop blijft de
   400px-card-breedte gerespecteerd. */
.auth-chooser { display: flex; flex-direction: column; gap: var(--space-3); }
.auth-choice {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .12s var(--ease), background .12s var(--ease), transform .12s var(--ease);
  min-height: 64px;
}
.auth-choice:hover,
.auth-choice:focus-visible {
  border-color: var(--primary);
  background: var(--surface-2);
  outline: 0;
}
.auth-choice:active { transform: scale(.99); }
.auth-choice__icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: #fff;
}
.auth-choice__icon svg { width: 22px; height: 22px; }
.auth-choice__icon--customer { background: linear-gradient(135deg, #22c55e, #16a34a); }
.auth-choice__icon--staff    { background: linear-gradient(135deg, var(--primary), #2e9fc9); }
.auth-choice__icon--register { background: linear-gradient(135deg, #f97316, #ea580c); }

/* Twee-koloms grid in het register-formulier op desktop, stack op
   smal scherm. Een 3-koloms variant voor postcode/plaats/land. */
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.auth-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 520px) {
  .auth-grid, .auth-grid--3 { grid-template-columns: 1fr; }
}
.auth-register { max-width: 100%; }
.auth-note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.4;
}
.auth-choice__body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.auth-choice__body strong { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.01em; }
.auth-choice__body span   { color: var(--muted); font-size: var(--text-sm); line-height: 1.35; }
.auth-choice__arrow {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .12s var(--ease), color .12s var(--ease);
}
.auth-choice__arrow svg { width: 18px; height: 18px; }
.auth-choice:hover .auth-choice__arrow,
.auth-choice:focus-visible .auth-choice__arrow { color: var(--primary); transform: translate(2px, -2px); }

.auth-foot {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  text-align: center;
  line-height: 1.4;
}

/* Telefoonbreedte: kleinere icon-vakjes + minder padding zodat de
   keuze-cards niet onnodig veel verticale ruimte opslokken. */
@media (max-width: 420px) {
  .auth-choice { gap: var(--space-3); padding: var(--space-3); min-height: 56px; }
  .auth-choice__icon { width: 38px; height: 38px; border-radius: 10px; }
  .auth-choice__icon svg { width: 18px; height: 18px; }
}

/* ============================================================
   Flash / toasts (legacy classes for backward compat)
   ============================================================ */
.flash-stack { display: grid; gap: var(--space-2); margin-bottom: var(--space-4); }

/* ============================================================
   Empty states
   ============================================================ */
.empty { padding: var(--space-12) var(--space-5); text-align: center; color: var(--muted); }
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-16) var(--space-5);
  text-align: center;
}
.empty-state__icon {
  width: 64px; height: 64px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  color: var(--muted);
  display: grid; place-items: center;
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border);
}
.empty-state__icon svg { width: 30px; height: 30px; }
.empty-state h3 { color: var(--text); font-size: var(--text-lg); letter-spacing: -0.015em; text-transform: none; font-weight: 600; }
.empty-state p { color: var(--muted); margin: 0 0 var(--space-3); max-width: 380px; font-size: var(--text-sm); }

.pager { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-top: var(--space-3); }

.repeater { display: grid; gap: var(--space-2); grid-column: 1 / -1; }
.repeater__row { display: grid; gap: var(--space-2); grid-template-columns: 1fr 1fr; }

/* ============================================================
   Invoice items table (form)
   ============================================================ */
.table--items input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
}
.table--items input:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-ring); }
.table--items td { padding: 6px; }
@media (max-width: 760px) {
  .table--items thead { display: none; }
  .table--items tbody { display: flex; flex-direction: column; gap: var(--space-3); }
  .table--items tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
  }
  .table--items td { padding: 0; }
  .table--items td:nth-child(1), .table--items td:nth-child(2) { grid-column: 1 / -1; }
}

/* ============================================================
   Errors
   ============================================================ */
.error-page { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: var(--space-10);
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.error-card h1 { font-size: var(--text-5xl); margin: 0; color: var(--primary); letter-spacing: -0.04em; }
.error-card p { color: var(--muted); margin: var(--space-2) 0 var(--space-5); }

/* ============================================================
   Utilities
   ============================================================ */
.text-right { text-align: right; }
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }

kbd {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, monospace;
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-soft);
  line-height: 1.4;
}

/* ============================================================
   Modal (HTML5 dialog)
   ============================================================ */
dialog.modal {
  border: 0;
  padding: 0;
  background: var(--surface);
  border-radius: 18px;
  max-width: 520px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  overflow: hidden;
  color: var(--text);
  box-shadow: var(--shadow-xl);
  margin: auto;
  position: fixed;
  inset: 0;
}
dialog.modal::backdrop {
  background: rgba(11, 18, 32, .55);
  /* No backdrop-filter — iOS Safari can leave a blurred "screenshot"
     residue on the page after the dialog closes, looking like a stuck
     grey overlay. Plain darken-overlay is reliable everywhere. */
}
dialog.modal[open] { animation: modalIn .2s var(--ease-out); }
dialog.modal[open]::backdrop { animation: backdropIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal__inner { display: flex; flex-direction: column; max-height: calc(100vh - 64px); }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-5) var(--space-3);
  gap: var(--space-3);
}
.modal__head h2 { font-size: var(--text-lg); font-weight: 600; }
.modal__close {
  background: transparent; border: 0; color: var(--muted);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  transition: background .12s var(--ease);
}
.modal__close:hover { background: var(--surface-2); color: var(--text); }
.modal__close svg { width: 18px; height: 18px; }
.modal__body {
  padding: var(--space-1) var(--space-5) var(--space-4);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-3);
}
.modal__foot {
  padding: var(--space-3) var(--space-5);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--space-2); justify-content: flex-end;
  flex-wrap: wrap;
}
.modal__foot .btn { min-width: 100px; }

@media (max-width: 600px) {
  dialog.modal {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    margin: auto auto 0;
    bottom: 0; top: auto;
    max-height: 90vh;
  }
  dialog.modal[open] { animation: sheetIn .3s var(--ease-out); }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal__inner { max-height: 90vh; }
  .modal__head::before {
    content: '';
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px; border-radius: 999px;
    background: var(--border-strong);
  }
  .modal__head { position: relative; padding-top: var(--space-5); }
}

.modal__body .form--grid { grid-template-columns: 1fr; gap: var(--space-3); }
.modal__body .fieldset { border: 0; padding: 0; box-shadow: none; }
.modal__body .fieldset > legend { display: none; }

/* ============================================================
   Toasts
   ============================================================ */
.toast-container {
  position: fixed; z-index: 80;
  top: var(--space-4); right: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
@media (max-width: 600px) {
  .toast-container { top: auto; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--space-4)); left: var(--space-4); right: var(--space-4); }
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-sm); font-weight: 500;
  color: var(--text);
  display: flex; align-items: center; gap: var(--space-2);
  min-width: 260px; max-width: 380px;
  animation: toastIn .25s var(--ease-out);
}
.toast.is-dismissing { animation: toastOut .2s ease forwards; }
.toast--success { border-left-color: var(--success); }
.toast--error   { border-left-color: var(--danger); }
.toast--info    { border-left-color: var(--info); }
.toast__icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%;
}
.toast--success .toast__icon { background: var(--success-soft); color: var(--success); }
.toast--error   .toast__icon { background: var(--danger-soft);  color: var(--danger); }
.toast--info    .toast__icon { background: var(--info-soft);    color: var(--info); }
.toast__icon svg { width: 14px; height: 14px; stroke-width: 2.5; }
.toast__msg { flex: 1; min-width: 0; }
.toast__close {
  background: transparent; border: 0; color: var(--muted);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 4px;
  flex-shrink: 0;
}
.toast__close:hover { background: var(--surface-2); color: var(--text); }
.toast__close svg { width: 14px; height: 14px; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
@media (max-width: 600px) {
  @keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
}

/* ============================================================
   FAB / sidebar quick-add
   ============================================================ */
.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--space-4));
  z-index: 35;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border: 0;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px -6px rgba(79, 70, 229, .5),
              inset 0 1px 0 rgba(255, 255, 255, .15);
  cursor: pointer;
  transition: transform .15s var(--ease-spring), box-shadow .15s var(--ease);
}
.fab:hover { transform: scale(1.05); box-shadow: 0 16px 32px -6px rgba(79, 70, 229, .6); }
.fab:active { transform: scale(.94); }
.fab svg { width: 24px; height: 24px; stroke-width: 2.5; }
@media (min-width: 1024px) { .fab { display: none; } }

.sidebar__quick-add {
  margin: 0 var(--space-3) var(--space-2);
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #88d2f3 0%, var(--primary) 100%);
  color: #fff;
  font-weight: 600;
  font-size: var(--text-sm);
  border: 0;
  cursor: pointer;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: filter .12s var(--ease), transform .08s var(--ease);
}
.sidebar__quick-add:hover { filter: brightness(1.08); }
.sidebar__quick-add:active { transform: scale(.98); }
.sidebar__quick-add svg { width: 16px; height: 16px; }

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.quick-action {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: border-color .12s var(--ease), transform .15s var(--ease), box-shadow .12s var(--ease);
}
.quick-action:hover { text-decoration: none; border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.quick-action__icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}
.quick-action__icon svg { width: 20px; height: 20px; }
.quick-action__title { font-size: var(--text-md); font-weight: 600; }
.quick-action__desc  { font-size: var(--text-xs); color: var(--muted); font-weight: 400; }

/* ============================================================
   Loading state on submit buttons
   ============================================================ */
.btn.is-loading {
  position: relative;
  pointer-events: none;
  color: transparent !important;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  top: 50%; left: 50%;
  margin: -7px 0 0 -7px;
  animation: spin .6s linear infinite;
  color: var(--text-soft);
}
.btn--primary.is-loading::after { color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Sticky form actions on mobile
   ============================================================ */
@media (max-width: 760px) {
  .form__actions--sticky {
    position: sticky;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    background: var(--surface);
    margin: 0 calc(-1 * var(--space-4)) calc(-1 * var(--space-4));
    padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px -8px rgba(11, 18, 32, .15);
    z-index: 10;
  }
  .form__actions--sticky .btn { flex: 1; justify-content: center; }
}

time.relative {
  cursor: default;
  border-bottom: 1px dotted transparent;
}
time.relative:hover { border-bottom-color: var(--border-strong); }

/* ============================================================
   Hero (detail-page header)
   ============================================================ */
.hero {
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding: var(--space-5) 0 var(--space-6);
  margin-bottom: var(--space-2);
}
.hero__avatar {
  width: 60px; height: 60px;
  border-radius: var(--radius-lg);
  display: grid; place-items: center;
  font-weight: 700; font-size: var(--text-xl);
  background: linear-gradient(135deg, var(--primary-soft) 0%, #fce7f3 100%);
  color: var(--primary);
  flex-shrink: 0;
  letter-spacing: -0.025em;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .12),
              inset 0 1px 0 rgba(255, 255, 255, .6);
  font-family: 'Inter Tight', 'Inter', sans-serif;
}
.hero__avatar svg { width: 26px; height: 26px; vertical-align: 0; }
.hero__body { flex: 1; min-width: 0; }
.hero__title {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.15;
  margin: 0 0 var(--space-1);
  color: var(--text);
}
.hero__meta {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  align-items: center; font-size: var(--text-sm); color: var(--muted);
}
.hero__meta > * { display: inline-flex; align-items: center; gap: 4px; }
.hero__actions {
  display: flex; gap: var(--space-2); flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}
@media (max-width: 760px) {
  .hero { flex-direction: column; padding-top: var(--space-3); }
  .hero__actions { margin-left: 0; width: 100%; }
  .hero__actions > * { flex: 1 1 auto; }
  .hero__actions .inline-form { width: 100%; }
  .hero__actions .inline-form input { flex: 1; min-width: 0; }
}

/* ============================================================
   Popover
   ============================================================ */
.popover {
  position: absolute; z-index: 70;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  min-width: 200px;
  animation: popIn .14s var(--ease-out);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.popover button {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; padding: 7px 9px;
  background: transparent; border: 0;
  border-radius: var(--radius-xs);
  text-align: left;
  color: var(--text);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background .12s var(--ease);
}
.popover button:hover { background: var(--surface-2); }
.popover button[aria-pressed="true"]::after { content: '✓'; margin-left: auto; color: var(--primary); font-weight: 700; }

/* Click-to-edit badge */
.editable-badge {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.editable-badge .badge {
  cursor: pointer;
  padding-right: 22px;
  position: relative;
  transition: filter .12s var(--ease);
}
.editable-badge .badge::after {
  content: '';
  position: absolute; right: 8px; top: 50%;
  width: 7px; height: 7px;
  margin-top: -4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: .55;
}
.editable-badge:hover .badge { filter: brightness(.96); }

/* ============================================================
   Command palette
   ============================================================ */
dialog.cmdk {
  border: 0;
  padding: 0;
  background: var(--surface);
  border-radius: 18px;
  width: calc(100% - 32px);
  max-width: 640px;
  margin: 12vh auto auto;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
dialog.cmdk::backdrop {
  background: rgba(11, 18, 32, .5);
  /* See note on dialog.modal::backdrop — no backdrop-filter on iOS. */
}
dialog.cmdk[open] { animation: cmdkIn .18s var(--ease-out); }
@keyframes cmdkIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.cmdk__inputbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}
.cmdk__inputbar svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.cmdk__input {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: var(--text-lg);
  font-family: inherit;
  color: var(--text);
  outline: none;
  padding: 0;
}
.cmdk__input::placeholder { color: var(--subtle); }
.cmdk__hint { font-size: var(--text-2xs); color: var(--muted); display: flex; gap: 4px; align-items: center; }
.cmdk__results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
}
.cmdk__group { padding: 6px 0; }
.cmdk__group-label {
  font-size: var(--text-2xs); font-weight: 600;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 12px 4px;
}
.cmdk__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.cmdk__item:hover, .cmdk__item.is-active {
  background: var(--surface-2);
  text-decoration: none;
}
.cmdk__item-icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  flex-shrink: 0;
}
.cmdk__item-icon svg { width: 16px; height: 16px; }
.cmdk__item.is-active .cmdk__item-icon { background: var(--primary-soft); color: var(--primary); }
.cmdk__item-body { flex: 1; min-width: 0; }
.cmdk__item-title { font-size: var(--text-md); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk__item-sub { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk__item-meta { flex-shrink: 0; font-size: var(--text-2xs); }
.cmdk__empty {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}
.cmdk__foot {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--text-2xs);
  color: var(--muted);
}
.cmdk__foot kbd { font-size: 10px; }
@media (max-width: 600px) {
  dialog.cmdk { margin: 0; max-width: 100%; height: 100vh; border-radius: 0; }
  .cmdk__results { max-height: calc(100vh - 130px); }
}

/* Search trigger in sidebar/topbar */
.search-trigger {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  padding: 8px var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: text;
  font-size: var(--text-sm);
  transition: border-color .12s var(--ease), background .12s var(--ease);
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface-2); }
.search-trigger svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-trigger__placeholder { flex: 1; text-align: left; }
.search-trigger kbd { margin-left: auto; }
.sidebar > .search-trigger { margin: 0 var(--space-3) var(--space-2); }

/* ============================================================
   Kebab menu
   ============================================================ */
.kebab { position: relative; display: inline-block; }
.kebab__btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
  box-shadow: var(--shadow-xs);
}
.kebab__btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.kebab__btn:active { transform: scale(.96); }
.kebab__btn svg { width: 16px; height: 16px; }
.kebab__menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  display: none;
  z-index: 50;
  animation: popIn .14s var(--ease-out);
}
.kebab.is-open .kebab__menu { display: block; }
.kebab__menu a, .kebab__menu button {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: transparent; border: 0;
  color: var(--text);
  text-decoration: none;
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
  transition: background .12s var(--ease);
}
.kebab__menu a:hover, .kebab__menu button:hover { background: var(--surface-2); text-decoration: none; }
.kebab__menu .danger { color: var(--danger); }
.kebab__menu .danger:hover { background: var(--danger-soft); }
.kebab__menu svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--muted); }
.kebab__menu .danger svg { color: var(--danger); }
.kebab__menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.kebab__menu form { margin: 0; }

/* ============================================================
   Chart card (dashboard)
   ============================================================ */
.chart-card { padding: var(--space-6); }
.chart-card h2 { margin-bottom: 2px; }
.chart-card__sub { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-4); }
.chart-card__total {
  display: flex; align-items: baseline; gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.chart-card__amount {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}
.chart-card__trend {
  font-size: var(--text-xs);
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.chart-card__trend--up   { background: var(--success-soft); color: #15803d; }
.chart-card__trend--down { background: var(--danger-soft);  color: #b91c1c; }
.chart-card__trend--flat { background: var(--surface-2);    color: var(--muted); }
.chart-wrap { position: relative; height: 200px; }
.chart-wrap svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-wrap .chart-fill { fill: url(#chart-gradient); }
.chart-wrap .chart-line {
  fill: none; stroke: var(--primary); stroke-width: 2.5;
  stroke-linejoin: round; stroke-linecap: round;
}
.chart-wrap .chart-dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }
.chart-wrap .chart-grid { stroke: var(--border); stroke-dasharray: 2 6; stroke-width: 1; }
.chart-wrap .chart-label { fill: var(--muted); font-size: var(--text-2xs); }

/* Animate chart on load */
.chart-wrap .chart-line { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: chartDraw 1.2s var(--ease-out) forwards; }
.chart-wrap .chart-fill { opacity: 0; animation: chartFade .8s var(--ease-out) .3s forwards; }
.chart-wrap .chart-dot { opacity: 0; animation: chartDotFade .3s var(--ease-out) forwards; }
.chart-wrap .chart-dot:nth-of-type(1) { animation-delay: .8s; }
.chart-wrap .chart-dot:nth-of-type(2) { animation-delay: .9s; }
.chart-wrap .chart-dot:nth-of-type(3) { animation-delay: 1.0s; }
.chart-wrap .chart-dot:nth-of-type(4) { animation-delay: 1.1s; }
.chart-wrap .chart-dot:nth-of-type(5) { animation-delay: 1.2s; }
.chart-wrap .chart-dot:nth-of-type(6) { animation-delay: 1.3s; }
@keyframes chartDraw { to { stroke-dashoffset: 0; } }
@keyframes chartFade { to { opacity: 1; } }
@keyframes chartDotFade { to { opacity: 1; } }

/* ============================================================
   Document layout (invoice show)
   ============================================================ */
.doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: var(--space-4);
}
.doc__head {
  padding: var(--space-8);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-4); flex-wrap: wrap;
}
.doc__head h1 {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-3xl); font-weight: 700;
  letter-spacing: -0.028em;
  margin: 0 0 var(--space-1);
}
.doc__head-meta { color: var(--muted); font-size: var(--text-sm); display: flex; gap: var(--space-2); flex-wrap: wrap; }
.doc__addresses {
  display: grid; grid-template-columns: 1fr 1fr;
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 600px) { .doc__addresses { grid-template-columns: 1fr; gap: var(--space-5); padding: var(--space-5); } }
.doc__address-label {
  font-size: var(--text-2xs); font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 6px;
}
.doc__address-body { font-size: var(--text-md); line-height: 1.55; }
.doc__address-body strong { font-weight: 600; }
.doc__items-wrap { padding: var(--space-2) 0; }
.doc__items { width: 100%; border-collapse: collapse; }
.doc__items th, .doc__items td { padding: var(--space-3) var(--space-8); text-align: left; font-size: var(--text-md); }
.doc__items th { font-weight: 600; color: var(--muted); font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: .06em; padding-top: var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.doc__items td { border-bottom: 1px solid var(--border); }
.doc__items tbody tr:last-child td { border-bottom: 0; }
.doc__items .num { text-align: right; font-variant-numeric: tabular-nums; }
.doc__totals {
  display: flex; justify-content: flex-end;
  padding: var(--space-4) var(--space-8) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.doc__totals-table { min-width: 300px; font-size: var(--text-md); }
.doc__totals-table .row { display: flex; justify-content: space-between; padding: 4px 0; }
.doc__totals-table .row--total {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-xl); font-weight: 700;
  margin-top: 6px; padding-top: var(--space-2);
  border-top: 1px solid var(--border-strong);
  letter-spacing: -0.02em;
}
.doc__totals-table .num { font-variant-numeric: tabular-nums; }
.doc__notes { padding: var(--space-4) var(--space-8) var(--space-6); color: var(--muted); font-size: var(--text-sm); }
@media (max-width: 600px) {
  .doc__head, .doc__items th, .doc__items td, .doc__totals, .doc__notes { padding-left: var(--space-5); padding-right: var(--space-5); }
}
@media (max-width: 600px) {
  .doc__items thead { display: none; }
  .doc__items, .doc__items tbody, .doc__items tr, .doc__items td { display: block; }
  .doc__items tr { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
  .doc__items td { padding: 2px var(--space-5); }
  .doc__items td.num { text-align: right; }
  .doc__items td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 80px; color: var(--muted); font-size: var(--text-xs); }
}

/* ============================================================
   Hover-row actions in tables
   ============================================================ */
.table tbody tr .row-actions {
  visibility: hidden;
  opacity: 0;
  transition: opacity .12s var(--ease);
}
.table tbody tr:hover .row-actions { visibility: visible; opacity: 1; }
.row-actions { display: inline-flex; gap: 4px; }
.row-actions .btn { padding: 4px 8px; min-height: auto; }
.row-actions .btn svg { width: 14px; height: 14px; }
@media (max-width: 760px) { .table tbody tr .row-actions { visibility: visible; opacity: 1; } }

/* ============================================================
   Line items (invoice form) — compact card layout
   ============================================================ */
.line-items {
  display: flex; flex-direction: column;
  gap: var(--space-2);
  grid-column: 1 / -1;
}
.line-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: grid; gap: 8px;
  box-shadow: var(--shadow-xs);
  position: relative;
  transition: border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.line-item:hover, .line-item:focus-within { border-color: var(--border-strong); }

.line-item__head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: .06em;
}
.line-item__num {
  background: var(--surface-2);
  padding: 1px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.line-item__remove {
  background: transparent; border: 0; color: var(--muted);
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.line-item__remove:hover { background: var(--danger-soft); color: var(--danger); }
.line-item__remove svg { width: 14px; height: 14px; }

/* Product picker — top, visually subordinate (it's optional) */
.line-item__product {
  width: 100%;
  padding: 7px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.line-item__product:not([data-empty="true"]) { color: var(--text); border-style: solid; border-color: var(--border); background: var(--surface-2); }
.line-item__product:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-ring); color: var(--text); }

/* Description — the primary field, larger and bold-ish */
.line-item__desc {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px; /* no iOS zoom */
  font-weight: 500;
  color: var(--text);
}
.line-item__desc:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-ring); }
.line-item__desc::placeholder { color: var(--subtle); font-weight: 400; }

/* 4-up numeric grid with mini caps-labels above each input */
.line-item__nums {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.line-item__nums label {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.line-item__nums label > span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.line-item__nums input {
  width: 100%;
  padding: 8px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 16px; /* no iOS zoom */
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 0;
}
.line-item__nums input:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-ring); }

.line-item__total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
}
.line-item__total strong {
  color: var(--text);
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.line-item__add {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px;
  color: var(--text-soft);
  font-weight: 500; font-size: 13px;
  cursor: pointer;
  width: 100%;
  transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.line-item__add:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.line-item__add svg { width: 14px; height: 14px; }

/* Invoice totals card */
.invoice-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-1) var(--space-6);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 2px solid var(--border);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}
.invoice-totals dt { color: var(--muted); }
.invoice-totals dd { margin: 0; color: var(--text); text-align: right; }
.invoice-totals .total-row {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ============================================================
   Wizard (multi-step form)
   ============================================================ */
.wizard__stepper {
  display: flex; align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: var(--space-3) 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.wizard__stepper::-webkit-scrollbar { display: none; }
.wizard__dot {
  display: flex; align-items: center; gap: var(--space-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .12s var(--ease);
  opacity: .5;
}
.wizard__dot.is-active, .wizard__dot.is-completed { opacity: 1; }
.wizard__dot:not(.is-completed):not(.is-active) { cursor: not-allowed; }
.wizard__dot-num {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 50%;
  font-weight: 600;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  transition: all .15s var(--ease);
}
.wizard__dot.is-active .wizard__dot-num {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.wizard__dot.is-completed .wizard__dot-num {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.wizard__dot.is-completed .wizard__dot-num::after {
  content: '✓';
}
.wizard__dot.is-completed .wizard__dot-num span,
.wizard__dot.is-completed .wizard__dot-num { color: transparent; }
.wizard__dot.is-completed .wizard__dot-num::after {
  position: absolute; color: #fff;
  font-size: 14px; font-weight: 700;
}
.wizard__dot-num { position: relative; }
.wizard__dot-label {
  font-size: var(--text-sm);
  color: var(--text-soft);
  font-weight: 500;
  white-space: nowrap;
}
.wizard__dot.is-active .wizard__dot-label { color: var(--text); font-weight: 600; }
.wizard__dot-sep {
  flex: 1;
  height: 1px;
  background: var(--border);
  min-width: 20px;
}

.wizard__step { display: none; }
.wizard__step.is-active {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  animation: wizardStep .25s var(--ease-out);
}
@media (min-width: 800px) {
  .wizard__step.is-active.fieldset {
    grid-template-columns: repeat(2, 1fr);
  }
  .wizard__step.is-active .field--wide { grid-column: 1 / -1; }
}
@keyframes wizardStep {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wizard__nav {
  display: flex !important; align-items: center;
  gap: var(--space-3) !important;
  grid-column: 1 / -1;
}
.wizard__nav .wizard__progress-text {
  flex: 1; text-align: center;
  font-size: var(--text-sm);
  color: var(--muted);
}
.wizard__nav .wizard__progress-text strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.wizard__prev:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 600px) {
  .wizard__stepper { padding-bottom: 0; }
  .wizard__dot-label { display: none; }
  .wizard__dot.is-active .wizard__dot-label { display: inline; }
}

/* ============================================================
   Print page navigation (PWA-safe back button)
   ============================================================ */
.print-nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.print-nav__title { font-weight: 600; font-size: var(--text-sm); margin-left: var(--space-2); }
.print-nav__spacer { flex: 1; }
@media print { .print-nav { display: none !important; } }

/* ============================================================
   Turbo progress bar (top-of-viewport, primary color)
   ============================================================ */
.turbo-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), #2e9fc9);
  z-index: 999;
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  pointer-events: none;
}
.turbo-progress.is-loading {
  opacity: 1;
  transform: scaleX(.75);
  transition: transform 1.4s cubic-bezier(.16, 1, .3, 1), opacity .15s ease;
}
.turbo-progress.is-done {
  opacity: 1;
  transform: scaleX(1);
  transition: transform .2s ease, opacity .35s ease .15s;
  opacity: 0;
}

/* ============================================================
   Reverse-charge notice (BE/DE customers)
   ============================================================ */
.notice {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  border: 1px solid #bae6fd;
  color: #075985;
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
  grid-column: 1 / -1;
}
.notice strong { color: #0c4a6e; }
.notice svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Universal [hidden] enforcement.
   Class-level display rules (.notice, .btn, .wizard__step, ...) have
   higher specificity than the browser default [hidden]{display:none},
   so without this rule a JS `el.hidden = true` toggle has no visual
   effect on these elements. This bit them in multiple places: the
   wizard "Volgende" button stayed visible on the last step and the
   "BTW verlegd" notice stayed visible for NL customers. */
[hidden] { display: none !important; }

/* ============================================================
   View transitions (browsers that support it)
   ============================================================ */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .18s;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

/* ============================================================
   iOS-zoom kill — all form fields are 16px on small screens
   so Mobile Safari does not zoom on focus. Above 700px we go
   back to the compact 13px design font-size.
   ============================================================ */
@media (max-width: 699px) {
  input, select, textarea,
  .field input, .field select, .field textarea,
  .form input, .form select, .form textarea,
  .filterbar input, .filterbar select,
  .line-item input, .line-item select,
  .table--items input,
  .inline-form input,
  .cmdk__input {
    font-size: 16px !important;
  }
}

/* ============================================================
   Wizard stepper — never wrap onto multiple lines
   ============================================================ */
.wizard__stepper {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--space-4));
  padding: var(--space-3) var(--space-4);
}
.wizard__stepper::-webkit-scrollbar { display: none; }
.wizard__dot {
  flex-shrink: 0;
  scroll-snap-align: center;
  white-space: nowrap;
}
.wizard__dot-label { white-space: nowrap; }
.wizard__dot-sep {
  flex: 0 0 24px !important;
  min-width: 24px;
}
/* On very narrow screens only show the label of the active step */
@media (max-width: 480px) {
  .wizard__dot:not(.is-active) .wizard__dot-label { display: none; }
  .wizard__dot-sep { flex-basis: 16px !important; min-width: 16px; }
}

/* Wizard nav (Vorige / Stap X van Y / Volgende) — keep on one line */
.wizard__nav { flex-wrap: nowrap !important; }
.wizard__nav .wizard__progress-text {
  flex: 1; text-align: center;
  font-size: var(--text-xs);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wizard__nav .btn { flex-shrink: 0; min-width: 0; }
/* .btn sets display: inline-flex, which overrides the browser default
   [hidden]{display:none}. Re-assert it explicitly. */
.wizard__nav [hidden] { display: none !important; }
@media (max-width: 380px) {
  .wizard__nav .wizard__progress-text { display: none; }
}

/* ============================================================
   Confirmation dialog — center on mobile, not bottom-sheet
   ============================================================ */
dialog.modal.modal--center {
  margin: auto !important;
  bottom: auto !important;
  top: auto !important;
  border-radius: 18px !important;
  max-width: 420px !important;
  width: calc(100% - 32px) !important;
  max-height: calc(100vh - 64px) !important;
  position: fixed;
  inset: 0;
}
dialog.modal.modal--center[open] {
  animation: modalIn .2s var(--ease-out) !important;
}
dialog.modal.modal--center .modal__head::before { display: none; }

/* ============================================================
   Print modal — iframe-in-dialog so the user stays in the app
   ============================================================ */
dialog.modal.modal--lg {
  max-width: 880px;
  width: calc(100% - 32px);
}
dialog.modal.modal--lg .modal__body--flush {
  padding: 0;
  background: var(--surface-2);
}
.print-iframe {
  display: block;
  width: 100%;
  height: 68vh;
  min-height: 480px;
  border: 0;
  background: #fff;
}
@media (max-width: 600px) {
  dialog.modal.modal--lg {
    max-width: 100%; width: 100%;
    border-radius: 20px 20px 0 0 !important;
    margin: auto auto 0 !important;
    bottom: 0 !important; top: auto !important;
    max-height: 92vh !important;
  }
  .print-iframe { height: calc(92vh - 140px); }
}

/* ============================================================
   Command palette — mobile polish
   ============================================================ */
@media (max-width: 600px) {
  dialog.cmdk {
    margin: 0 !important;
    max-width: 100%;
    height: 100dvh;            /* dynamic viewport so iOS toolbar doesn't cover */
    max-height: 100dvh;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .cmdk__inputbar {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }
  .cmdk__inputbar .cmdk__hint { display: none; }
  .cmdk__inputbar::after {
    /* Mobile close button */
    content: '✕';
    color: var(--muted);
    font-size: 18px;
    padding: 6px 4px 6px 8px;
    cursor: pointer;
  }
  .cmdk__results {
    max-height: calc(100dvh - 130px);
    padding: var(--space-2);
  }
  .cmdk__item { padding: var(--space-3); }
  .cmdk__foot { display: none; }   /* keyboard hints not useful on touch */
}

/* ============================================================
   Personal hub: activity bar-chart
   ============================================================ */
.activity-summary {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: var(--text-sm);
}
.activity-summary strong {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.activity-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  align-items: end;
  height: 140px;
}
.activity-chart__col {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  height: 100%;
  cursor: default;
}
.activity-chart__bar-wrap {
  flex: 1;
  width: 100%;
  display: flex; align-items: flex-end; justify-content: center;
  min-height: 0;
}
.activity-chart__bar {
  width: 70%; max-width: 36px;
  height: var(--h, 0%);
  min-height: 4px;
  background: linear-gradient(180deg, var(--primary) 0%, #2e9fc9 100%);
  border-radius: 6px 6px 4px 4px;
  position: relative;
  transition: transform .15s var(--ease);
  animation: barRise .5s var(--ease-out) backwards;
}
.activity-chart__col:nth-child(1) .activity-chart__bar { animation-delay: 0.00s; }
.activity-chart__col:nth-child(2) .activity-chart__bar { animation-delay: 0.05s; }
.activity-chart__col:nth-child(3) .activity-chart__bar { animation-delay: 0.10s; }
.activity-chart__col:nth-child(4) .activity-chart__bar { animation-delay: 0.15s; }
.activity-chart__col:nth-child(5) .activity-chart__bar { animation-delay: 0.20s; }
.activity-chart__col:nth-child(6) .activity-chart__bar { animation-delay: 0.25s; }
.activity-chart__col:nth-child(7) .activity-chart__bar { animation-delay: 0.30s; }
@keyframes barRise { from { height: 0; opacity: 0; } to { height: var(--h, 4px); opacity: 1; } }
.activity-chart__col:hover .activity-chart__bar { transform: scaleY(1.04); transform-origin: bottom; }
.activity-chart__count {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  font-size: var(--text-xs); font-weight: 600;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity .15s var(--ease);
}
.activity-chart__col:hover .activity-chart__count { opacity: 1; }
.activity-chart__label {
  font-size: var(--text-2xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}

/* ============================================================
   Personal hub: stats grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4) var(--space-6);
  margin: 0;
}
.stats-grid > div { display: flex; flex-direction: column; gap: 2px; }
.stats-grid dt {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
}
.stats-grid dd {
  font-family: 'Inter Tight', 'Inter', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin: 0;
}

/* ============================================================
   Personal hub: todo list
   ============================================================ */
.todo-add {
  display: flex; gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.todo-add input {
  flex: 1;
  padding: 9px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.todo-add input:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-ring); }
.todo-add button {
  width: 38px; min-height: 38px; padding: 0;
  display: grid; place-items: center;
}
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  animation: todoIn .2s var(--ease-out);
}
@keyframes todoIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.todo-item:last-child { border-bottom: 0; }
.todo-toggle, .todo-delete { display: inline-flex; margin: 0; }
.todo-check {
  width: 22px; height: 22px;
  background: transparent; border: 0; padding: 0;
  display: grid; place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.todo-check__box {
  width: 18px; height: 18px;
  border: 1.75px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  display: grid; place-items: center;
  transition: all .12s var(--ease);
  color: #fff;
}
.todo-check:hover .todo-check__box { border-color: var(--primary); }
.todo-check.is-checked .todo-check__box {
  background: var(--primary);
  border-color: var(--primary);
}
.todo-check.is-checked .todo-check__box svg { width: 12px; height: 12px; stroke-width: 3; }
.todo-text {
  flex: 1; min-width: 0;
  font-size: var(--text-md);
  color: var(--text);
  word-break: break-word;
  transition: color .15s var(--ease);
}
.todo-item.is-done .todo-text {
  color: var(--muted);
  text-decoration: line-through;
}
.todo-due {
  font-size: var(--text-2xs);
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}
.todo-delete-btn {
  background: transparent; border: 0; color: var(--muted);
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: var(--radius-xs);
  cursor: pointer;
  opacity: 0; visibility: hidden;
  transition: opacity .12s var(--ease), background .12s var(--ease);
}
.todo-item:hover .todo-delete-btn,
.todo-delete-btn:focus-visible { opacity: 1; visibility: visible; }
@media (max-width: 700px) {
  .todo-delete-btn { opacity: .6; visibility: visible; }
}
.todo-delete-btn:hover { background: var(--danger-soft); color: var(--danger); }
.todo-delete-btn svg { width: 13px; height: 13px; }
.todo-section {
  padding: var(--space-3) 0 var(--space-1);
  font-size: var(--text-2xs); font-weight: 600;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 0 !important;
}
.todo-empty {
  padding: var(--space-5) var(--space-2);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  border-bottom: 0 !important;
}

/* ============================================================
   Mobile UX hardening
   ============================================================ */

/* Prevent unwanted horizontal scroll on small screens. */
html, body { overflow-x: clip; }

/* Tap targets — Apple HIG minimum is 44px for primary action buttons. */
@media (max-width: 760px) {
  .btn { min-height: 44px; padding: 11px 14px; }
  .btn--sm { min-height: 36px; padding: 8px 12px; }
  .btn--ghost.btn--danger,
  .row-actions .btn,
  .todo-delete-btn,
  .modal__close,
  .topbar__btn,
  .sidebar__logout-btn {
    min-width: 40px; min-height: 40px;
  }
  .bottomnav__link { min-height: 56px; }
  .field input[type="number"] { -moz-appearance: textfield; }
  .field input[type="number"]::-webkit-outer-spin-button,
  .field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
}

/* Long page heads should never push the action bar off-screen */
@media (max-width: 600px) {
  .page-head--row { flex-direction: column; align-items: stretch; }
  .page-head--row .action-row { width: 100%; }
  .page-head--row .action-row .btn { flex: 1 1 auto; justify-content: center; }
  .hero__title { word-break: break-word; }
}

/* Modal/cmdk: ensure tap targets feel right and content scrolls cleanly. */
@media (max-width: 600px) {
  .modal__body { padding-bottom: env(safe-area-inset-bottom, 0); }
  .modal__foot { padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0)); }
  .modal__foot .btn { min-height: 44px; }
}

/* ============================================================
   Saved views (filter presets)
   ============================================================ */
.saved-views {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-3);
  align-items: center;
}
.saved-views .chip { background: var(--surface-2); border-color: var(--border); }
.saved-views__save { margin-left: auto; }
.saved-views__save input[type="text"] { min-width: 180px; }

/* ============================================================
   Kanban pipeline
   ============================================================ */
.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(240px, 1fr));
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-4);
  scroll-snap-type: x proximity;
}
@media (max-width: 1100px) {
  .kanban {
    grid-template-columns: repeat(6, 280px);
  }
}
.kanban__col {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  display: flex; flex-direction: column;
  gap: var(--space-2);
  scroll-snap-align: start;
  min-width: 0;
}
.kanban__head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: var(--space-2);
}
.kanban__count {
  font-size: var(--text-2xs); font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.kanban__cards {
  display: flex; flex-direction: column;
  gap: var(--space-2);
  min-height: 100px;
}
.kanban__cards.is-drop-target {
  outline: 2px dashed var(--primary);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}
.kanban__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  cursor: grab;
  box-shadow: var(--shadow-xs);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease);
}
.kanban__card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.kanban__card.is-dragging { opacity: .5; cursor: grabbing; }
.kanban__title { font-weight: 600; font-size: var(--text-sm); color: var(--text); }
.kanban__sub   { font-size: var(--text-xs); color: var(--text-soft); margin-top: 2px; }
.kanban__meta  { font-size: var(--text-2xs); color: var(--muted); margin-top: var(--space-2); display: flex; gap: 4px; }

/* ============================================================
   Tags
   ============================================================ */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: var(--text-2xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  letter-spacing: .02em;
}
.tag--gray   { background: #f4f4f5; color: #52525b; }
.tag--red    { background: #fee2e2; color: #991b1b; }
.tag--orange { background: #ffedd5; color: #9a3412; }
.tag--yellow { background: #fef9c3; color: #854d0e; }
.tag--green  { background: #d1fae5; color: #166534; }
.tag--blue   { background: #dbeafe; color: #1d4ed8; }
.tag--purple { background: #ede9fe; color: #6d28d9; }
.tag--pink   { background: #fce7f3; color: #9d174d; }

.tags-edit__current { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-2); }
.tags-edit__panel > summary {
  font-size: var(--text-xs); color: var(--muted);
  cursor: pointer; padding: 4px 0;
  list-style: none;
}
.tags-edit__panel > summary::-webkit-details-marker { display: none; }
.tags-edit__panel > summary::before { content: '＋'; margin-right: 4px; color: var(--primary); }
.tags-edit__panel[open] > summary::before { content: '−'; }
.tags-edit__body { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; margin-top: var(--space-2); }
.tags-edit__body input { flex: 1; min-width: 200px; }

.card--tags { padding-top: var(--space-4); padding-bottom: var(--space-4); }

/* ============================================================
   Notifications bell + popover
   ============================================================ */
.notif-bell { position: relative; }
.notif-bell__badge {
  position: absolute;
  top: 6px; right: 6px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--danger);
}
.notif-popover {
  position: fixed;
  top: calc(var(--topbar-h) + 6px);
  right: var(--space-3);
  width: min(360px, calc(100vw - 24px));
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 70;
  display: flex; flex-direction: column;
  animation: popIn .14s var(--ease-out);
}
@media (min-width: 1024px) { .notif-popover { top: 12px; left: calc(var(--sidebar-w) + 6px); right: auto; } }
.notif-popover__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.notif-popover__head h3 { font-size: var(--text-md); font-weight: 600; text-transform: none; color: var(--text); letter-spacing: -.01em; }
.notif-popover__list { flex: 1; overflow-y: auto; padding: 4px 0; }
.notif-popover__item {
  display: block;
  padding: var(--space-2) var(--space-4);
  text-decoration: none; color: var(--text);
  border-left: 3px solid transparent;
}
.notif-popover__item:hover { background: var(--surface-2); text-decoration: none; }
.notif-popover__item.is-unread { border-left-color: var(--primary); background: var(--primary-soft); }
.notif-popover__title { font-weight: 500; font-size: var(--text-sm); }
.notif-popover__body { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.notif-popover__time { font-size: 11px; color: var(--subtle); margin-top: 2px; }
.notif-popover__empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); font-size: var(--text-sm); }

/* ============================================================
   Notice variants
   ============================================================ */
.notice--warning {
  background: var(--warning-soft);
  border-color: #fed7aa;
  color: #9a3412;
}
.notice--warning strong { color: #7c2d12; }
.notice--success {
  background: var(--success-soft);
  border-color: #bbf7d0;
  color: #14532d;
}
.notice--success strong { color: #166534; }
.notice--danger {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #7f1d1d;
}
.notice--danger strong { color: #991b1b; }

/* ============================================================
   Reports: funnel + rep bars
   ============================================================ */
.funnel { display: grid; gap: var(--space-2); }
.funnel__row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: var(--space-3);
  align-items: center;
}
.funnel__label { font-size: var(--text-xs); }
.funnel__bar-wrap { background: var(--surface-2); border-radius: 999px; height: 14px; overflow: hidden; }
.funnel__bar {
  height: 100%;
  width: var(--w, 0%);
  background: var(--primary);
  border-radius: 999px;
  transition: width .8s var(--ease-out);
}
.funnel__bar--new        { background: #3b82f6; }
.funnel__bar--contacted  { background: #8b5cf6; }
.funnel__bar--interested { background: #f59e0b; }
.funnel__bar--quoted     { background: #f97316; }
.funnel__bar--won        { background: #22c55e; }
.funnel__bar--lost       { background: #ef4444; }
.funnel__count { font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--text-sm); }
@media (max-width: 600px) {
  .funnel__row { grid-template-columns: 1fr auto; }
  .funnel__row .funnel__bar-wrap { grid-column: 1 / -1; }
}

.rep-bars { display: grid; gap: var(--space-3); }
.rep-bars__row {
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-2);
  align-items: center;
}
.rep-bars__name { font-size: var(--text-sm); font-weight: 500; }
.rep-bars__amount { font-size: var(--text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.rep-bars__bar-wrap {
  grid-column: 1 / -1;
  background: var(--surface-2);
  border-radius: 999px; height: 8px;
  overflow: hidden;
}
.rep-bars__bar {
  height: 100%; width: var(--w, 0%);
  background: linear-gradient(90deg, var(--primary), #2e9fc9);
  border-radius: 999px;
}

/* ============================================================
   Native-feel polish
   ============================================================ */
body { overscroll-behavior-y: contain; }
dialog.modal, .cmdk__results { overscroll-behavior: contain; }

/* Subtle custom scrollbar (desktop only) */
@media (min-width: 1024px) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--subtle); background-clip: padding-box; }
}

/* ============================================================
   Bedrijfsprofiel — compacte groepen i.p.v. zware fieldsets
   ============================================================ */
.page-head--tight { margin-bottom: var(--space-4); }
.page-head--tight h1 { font-size: var(--text-2xl); }
.page-head--tight p { font-size: var(--text-xs); }

.profile-form { gap: var(--space-2); margin-bottom: var(--space-3); }
.profile-form .form__actions { justify-content: flex-end; margin-top: var(--space-1); }

.profile-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-xs);
}
.profile-group__title {
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 var(--space-2);
}
.profile-group__hint { font-size: var(--text-xs); margin: -2px 0 var(--space-3); }
.profile-group__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-3);
}
.profile-group__grid .field--wide { grid-column: 1 / -1; }
.profile-group .field { gap: 2px; }
.profile-group .field label { font-size: var(--text-xs); color: var(--muted); }
.profile-group .field input,
.profile-group .field textarea {
  padding: 7px 10px;
  font-size: 14px;
  line-height: 1.4;
}
.profile-group .field textarea { min-height: 60px; }

@media (max-width: 640px) {
  .profile-group { padding: var(--space-3); }
  .profile-group__grid { grid-template-columns: 1fr; gap: var(--space-2); }
}

/* Sticky save-bar zodat je hem altijd ziet zonder helemaal te scrollen */
.form__actions--sticky {
  position: sticky; bottom: 0;
  background: linear-gradient(to top, var(--bg, #fafafa) 70%, rgba(0,0,0,0));
  padding: var(--space-3) 0;
  display: flex; justify-content: flex-end;
  z-index: 10;
}
@media (max-width: 1023px) {
  .form__actions--sticky { bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .form__actions--sticky .btn { width: 100%; }
}

/* Logo-rij: preview links, upload + delete naast elkaar */
.logo-row {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: wrap;
}
.logo-preview {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.logo-preview img { max-height: 34px; max-width: 120px; display: block; }
.logo-form { display: flex; align-items: center; gap: var(--space-2); flex: 1 1 280px; min-width: 0; }
.logo-form input[type=file] {
  flex: 1; min-width: 0;
  font-size: 12px;
  padding: 6px;
  /* Geen dashed border — dat suggereert ten onrechte een dropzone. */
  border: 0;
  background: transparent;
}

/* ============================================================
   Globale compactheid-tweaks
   ============================================================ */

/* Kleine inline icons in legends / kleine knoppen */
.fieldset > legend svg,
.profile-group__title svg,
.card__head h2 svg { width: 14px; height: 14px; vertical-align: -2px; opacity: .7; }

/* Hero op mobile: kleiner, minder ruimte verspild */
@media (max-width: 640px) {
  .hero { padding: var(--space-3) var(--space-4); gap: var(--space-3); }
  .hero__avatar { width: 40px; height: 40px; font-size: 14px; }
  .hero__title { font-size: var(--text-lg); }
  .hero__meta { font-size: 12px; gap: 6px; }
  .hero__actions { gap: 6px; }
  .hero__actions .btn { padding: 8px 10px; font-size: 13px; }
}

/* Card padding zuiniger op mobile */
@media (max-width: 640px) {
  .card { padding: var(--space-3) var(--space-4); }
  .card__head h2 { font-size: var(--text-md); }
  .card__head { margin-bottom: var(--space-2); }
}

/* ============================================================
   Klantportaal — gebruikt CRM design tokens
   ============================================================ */
.portal-page { background: var(--bg); min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
.portal-shell { max-width: 1080px; margin: 0 auto; padding: 0 var(--space-4) var(--space-8); }
@media (min-width: 720px) { .portal-shell { padding: 0 var(--space-6) var(--space-10); } }

.portal-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  min-height: 64px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.portal-topbar__brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 700;
  min-width: 0;
}
.portal-topbar__logo {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px;
  color: var(--primary);
  flex-shrink: 0;
}
.portal-topbar__logo svg { width: 28px; height: 28px; }
.portal-topbar__logo--img {
  /* Maximale grootte voor het bedrijfslogo zodat het netjes binnen de
     topbar past, ongeacht of het breed of vierkant is. */
  height: 40px;
  max-width: 180px;
}
.portal-topbar__logo--img img {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
/* Als er een echt bedrijfslogo is, vervangt dat de tekst-titel.
   De tekst zou daarnaast overbodig + wedijverend zijn. */
.portal-topbar__brand--has-logo .portal-topbar__name { display: none; }
.portal-topbar__name { font-family: 'Inter Tight', 'Inter', sans-serif; letter-spacing: -0.01em; }
.portal-topbar__user {
  display: flex; align-items: center; gap: var(--space-3);
  font-size: var(--text-sm);
}
.portal-topbar__company { color: var(--muted); display: none; }
@media (min-width: 720px) { .portal-topbar__company { display: inline; } }
.portal-topbar__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; flex-shrink: 0;
}
.portal-topbar__avatar--img { background: #fff; padding: 2px; border: 1px solid var(--border); }
.portal-topbar__avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

.portal-nav {
  display: flex; gap: 2px; flex-wrap: nowrap;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  scrollbar-width: thin;
}
.portal-nav__link {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-soft); text-decoration: none;
  font-size: var(--text-sm); font-weight: 500;
  white-space: nowrap;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.portal-nav__link svg { width: 16px; height: 16px; opacity: .7; }
.portal-nav__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.portal-nav__link.is-active {
  background: var(--primary);
  color: var(--primary-on);
}
.portal-nav__link.is-active svg { opacity: 1; }

.portal-main { animation: pageFadeIn .25s var(--ease-out); }

.portal-foot {
  margin-top: var(--space-10);
  padding: var(--space-6) 0 var(--space-3);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* KPI grid op portal: 2 kolommen tot tablet, dan 4 — net als CRM */
.kpi-grid--portal { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .kpi-grid--portal { grid-template-columns: repeat(2, 1fr); max-width: 640px; } }

/* Auth-card (login + setup) */
.portal-auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-5) var(--space-5) var(--space-5);
  max-width: 380px;
  margin: var(--space-6) auto 0;
}
.portal-auth-card .form { gap: var(--space-2); }
.portal-auth-card .field label { font-size: var(--text-xs); margin-bottom: 2px; }
.portal-auth-card .field input {
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.3;
}
.portal-auth-card .btn--block { margin-top: var(--space-2); padding: 10px 14px; }

.portal-auth-card__brand { text-align: center; margin-bottom: var(--space-4); }
.portal-auth-card__logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  margin-bottom: var(--space-2);
}
.portal-auth-card__logo svg { width: 26px; height: 26px; }
.portal-auth-card__logo--img {
  background: #fff;
  border: 1px solid var(--border);
  padding: 6px;
  width: 64px; height: 64px;
}
.portal-auth-card__logo--img img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.portal-auth-card__brand h1 { font-size: var(--text-lg); margin: 0 0 2px; letter-spacing: -0.02em; }
.portal-auth-card__brand p { font-size: var(--text-xs); margin: 0; }

/* ============================================================
   Portal order-builder (groepering + categorieën + sticky cart-bar)
   ============================================================ */
.order-builder { padding-bottom: 96px; } /* ruimte voor de sticky cart-bar */

.order-toolbar {
  position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: var(--space-3) 0;
  z-index: 12;
  display: flex; flex-direction: column; gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.order-toolbar__search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
}

.cat-pills {
  display: flex; gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.cat-pills::-webkit-scrollbar { display: none; }
.cat-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease), border-color .12s var(--ease);
}
.cat-pill:hover { background: var(--surface-2); color: var(--text); }
.cat-pill.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-on);
}
.cat-pill__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; padding: 0 4px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  background: rgba(0,0,0,.08); color: inherit;
}
.cat-pill.is-active .cat-pill__count { background: rgba(255,255,255,.22); }

.prod-groups { display: flex; flex-direction: column; gap: var(--space-3); }
.prod-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.prod-group__head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.prod-group__head .prod-thumb { width: 36px; height: 36px; flex-shrink: 0; }
.prod-group__meta { min-width: 0; flex: 1; }
.prod-group__title {
  display: block; font-size: 14px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prod-group__sub { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

.prod-info-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
  flex-shrink: 0;
}
.prod-info-btn:hover { background: var(--surface); color: var(--primary); }
.prod-info-btn svg { width: 18px; height: 18px; }

.prod-info-modal { display: flex; gap: 14px; align-items: flex-start; }
.prod-info-modal__media {
  flex: 0 0 96px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  height: 96px;
  display: flex; align-items: center; justify-content: center;
}
.prod-info-modal__media img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.prod-info-modal__text { flex: 1; min-width: 0; }
@media (max-width: 480px) {
  .prod-info-modal { flex-direction: column; }
  .prod-info-modal__media { width: 100%; }
}

.prod-group__variants { display: flex; flex-direction: column; }
.prod-variant {
  display: grid;
  grid-template-columns: 1fr auto auto 90px;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  border-top: 1px solid var(--border);
  cursor: text;
}
.prod-group__variants .prod-variant:first-child { border-top: 0; }
.prod-variant__name { font-size: 14px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod-variant__sku { font-size: 11px; color: var(--muted); padding: 2px 6px; background: var(--surface-2); border-radius: 4px; }
.prod-variant__price { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.prod-variant__qty {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: right;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.prod-variant__qty:focus { outline: 0; border-color: var(--primary); box-shadow: var(--shadow-ring); }

@media (max-width: 640px) {
  .prod-variant {
    grid-template-columns: 1fr 80px;
    gap: 8px;
    row-gap: 4px;
    padding: 10px var(--space-3);
  }
  .prod-variant__sku { grid-column: 1; font-size: 10px; padding: 1px 5px; justify-self: start; }
  .prod-variant__price { grid-column: 1; }
  .prod-variant__qty { grid-row: 1 / span 3; grid-column: 2; align-self: stretch; }
}

.order-cart-bar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: 12px;
  z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 720px; margin: 0 auto;
  animation: bulkBarIn .2s var(--ease-out);
}
.order-cart-bar__summary { font-size: 13px; line-height: 1.3; }
.order-cart-bar__summary strong { color: #fff; }
.order-cart-bar__actions { display: flex; gap: 8px; align-items: center; }
.order-cart-bar .btn--ghost {
  background: transparent;
  border-color: rgba(255,255,255,.25);
  color: rgba(255,255,255,.85);
}
.order-cart-bar .btn--primary {
  background: var(--primary);
  border-color: var(--primary);
}

@media (max-width: 640px) {
  .order-cart-bar {
    left: 8px; right: 8px;
    bottom: calc(var(--bottomnav-h, 0px) + env(safe-area-inset-bottom) + 8px);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  .order-cart-bar__actions { justify-content: stretch; }
  .order-cart-bar__actions .btn { flex: 1; }
}

/* Mobile breakpoint kleinere portal-topbar */
@media (max-width: 540px) {
  .portal-topbar { padding-top: var(--space-3); }
  .portal-topbar__name { font-size: var(--text-md); }
  .portal-nav { gap: 0; }
  .portal-nav__link { padding: 8px 10px; font-size: 13px; }
  .portal-nav__link span { display: none; }
}

/* Tabellen — responsive label kleiner, padding compacter op mobile */
@media (max-width: 640px) {
  .table--responsive tbody tr { padding: var(--space-2); }
  .table--responsive tbody td { font-size: 13px; padding: 4px 0; }
  .table--responsive tbody td[data-label]::before { font-size: 10.5px; }
}

/* Page-head op mobile: minder vertical waste */
@media (max-width: 640px) {
  .page-head { margin-bottom: var(--space-3); }
  .page-head h1 { font-size: var(--text-xl); }
  .page-head p { font-size: var(--text-xs); }
}

/* Buttons mobiel — touch-friendly (≥ 40px hoogte volgens Apple HIG) */
@media (max-width: 640px) {
  .btn { font-size: 14px; padding: 11px 14px; min-height: 40px; }
  .btn--sm { font-size: 13px; padding: 8px 12px; min-height: 34px; }
}

/* KPI tiles op mobile — kleiner zodat de hele dashboard zichtbaar past */
@media (max-width: 640px) {
  .kpi-grid { gap: var(--space-2); margin-bottom: var(--space-4); }
  .kpi { padding: var(--space-3); gap: 4px; }
  .kpi__icon { width: 28px; height: 28px; }
  .kpi__icon svg { width: 14px; height: 14px; }
  .kpi__value { font-size: var(--text-xl); }
  .kpi__label { font-size: 11px; }
  .kpi__sub { font-size: 11px; }
}

/* Definition list (klant show) op mobile compacter */
@media (max-width: 640px) {
  .dl { font-size: 13px; row-gap: 4px; }
  .dl dt { font-size: 11px; color: var(--muted); }
}

/* Kebab-menu items — geen overlap met dropdowns op mobile */
@media (max-width: 640px) {
  .kebab__menu { min-width: 180px; right: 0; }
  .kebab__menu a, .kebab__menu button { font-size: 13px; padding: 8px 10px; }
}

/* Section headings */
@media (max-width: 640px) {
  h2 { font-size: var(--text-lg); }
  h3 { font-size: var(--text-md); }
}

/* ============================================================
   Touch / a11y / mobile polish — UX sweep
   ============================================================ */

/* Topbar-knoppen: groot genoeg om met de duim te raken. */
.topbar__btn {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* Bottomnav tap-targets: hele tab klikbaar. */
.bottomnav__link { min-height: 56px; }

/* Filterbar: blijft sticky onder de topbar zodat je niet hoeft te scrollen
   om te herfilteren bij lange lijsten. */
@media (max-width: 1023px) {
  .filterbar {
    position: sticky;
    top: var(--topbar-h, 56px);
    z-index: 25;
    background: var(--bg);
    padding: var(--space-2) 0;
    margin-bottom: var(--space-3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
  }
}

/* Inputs: voorkom iOS zoom + zorg dat de focus-ring duidelijk is voor
   keyboard-users. */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Bestandsinput: tap-friendly, geen border (anders lijkt het een dropzone). */
input[type=file] {
  font-size: 13px;
  padding: 6px 0;
  max-width: 100%;
}

/* Tabel die te breed wordt: voorkom horizontaal scrollen op desktop, val
   terug op responsive stack op mobile (.table--responsive). */
.table:not(.table--responsive) { display: block; overflow-x: auto; }
@media (min-width: 1024px) {
  .table:not(.table--responsive) { display: table; overflow: visible; }
}

/* Lange URLs/SKUs in cellen niet laten doorlopen */
.table td code, .table td a { word-break: break-word; overflow-wrap: anywhere; }

/* Skip-link voor keyboard: spring direct naar main */
.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--primary); color: #fff;
  padding: 8px 12px; border-radius: 6px;
  z-index: 1000; font-weight: 600;
}
.skip-link:focus { left: 8px; }

/* PWA standalone tweaks — minder ruimte aan de bovenkant innemen */
@media (display-mode: standalone) {
  .topbar { padding-top: max(env(safe-area-inset-top), 8px); }
}

/* Disabled state duidelijker (zonder pointer) */
button:disabled, .btn:disabled, .btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed;
}

/* Form__actions volle breedte op mobile zodat de save-knop makkelijk te raken is */
@media (max-width: 640px) {
  .form__actions:not(.form__actions--sticky) .btn { width: 100%; }
  .form__actions { flex-direction: column; gap: 8px; }
}

/* ============================================================
   Bulk actions — sticky bar, checkbox column
   ============================================================ */
.bulk-check { width: 32px; }
.bulk-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

.bulk-bar {
  position: sticky; bottom: 12px;
  z-index: 30;
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-shadow: var(--shadow-lg);
  margin: var(--space-3) auto 0;
  max-width: min(720px, calc(100vw - 24px));
  flex-wrap: wrap;
  animation: bulkBarIn .18s var(--ease-out);
}
@keyframes bulkBarIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.bulk-bar__count { font-size: 13px; font-weight: 500; }
.bulk-bar__actions { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.bulk-bar__actions .btn {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .15);
  color: #fff;
}
.bulk-bar__actions .btn:hover { background: rgba(255, 255, 255, .22); }
.bulk-bar__actions .btn.danger { background: rgba(220, 38, 38, .25); border-color: rgba(220, 38, 38, .35); }
.bulk-bar__actions .btn.danger:hover { background: rgba(220, 38, 38, .45); }
.bulk-bar__actions .btn--ghost { background: transparent; border: 0; padding: 4px 8px; }

/* Tablet + mobile: bottomnav is zichtbaar tot 1024px, dus de
   sticky bulk-bar moet daarboven blijven hangen ipv onder de nav
   wegduiken. Eerder gold dit alleen tot 640px → tussen 641 en 1023
   verdween de bar (iPad portrait, smal browser-venster). */
@media (max-width: 1023.98px) {
  .bulk-bar {
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 6px);
  }
}
@media (max-width: 640px) {
  .bulk-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px;
  }
  .bulk-bar__actions { margin-left: 0; gap: 6px; }
  .bulk-bar__actions .btn { flex: 1; }
}

.empty--filter { padding: var(--space-5); text-align: center; color: var(--muted); font-size: 13px; }

/* ============================================================
   Sorteerbare tabel-headers
   ============================================================ */
.table th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 18px;
  transition: color .12s var(--ease);
}
.table th.sortable:hover { color: var(--text); }
.table th.sortable::after {
  content: '';
  position: absolute;
  right: 6px; top: 50%;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--border-strong);
  opacity: .35;
  transform: translateY(-50%);
  transition: opacity .12s var(--ease), border-color .12s var(--ease);
}
.table th.sortable[aria-sort="ascending"]::after  { border-top: 0; border-bottom: 4px solid var(--primary); opacity: 1; }
.table th.sortable[aria-sort="descending"]::after { border-top: 4px solid var(--primary); opacity: 1; }
.table th.sortable:hover::after { opacity: .7; }
@media (max-width: 640px) {
  /* Sort-headers verbergen we op mobile — daar staat de tabel toch als
     compacte card-rijen waar kolommen niet visueel meer bestaan. */
  .table--products th.sortable::after { display: none; }
}

/* ============================================================
   Thumbnails + inline avatars
   ============================================================ */
.thumb-col { width: 56px; padding-right: 0 !important; }
.prod-thumb {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  flex-shrink: 0;
}
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod-thumb--empty { color: var(--muted); }
.prod-thumb--empty svg { width: 18px; height: 18px; opacity: .5; }

.cell-with-avatar {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.cell-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.cell-avatar--img { background: #fff; padding: 2px; border: 1px solid var(--border); }
.cell-avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

@media (max-width: 640px) {
  .prod-thumb { width: 40px; height: 40px; }
  .cell-avatar { width: 28px; height: 28px; font-size: 10px; }
}

/* ============================================================
   Compacte producten-lijst op mobile
   ============================================================ */
@media (max-width: 640px) {
  .table--products thead { display: none; }
  .table--products tbody { display: flex; flex-direction: column; padding: 0; }
  .table--products tbody tr {
    display: grid;
    grid-template-columns: 26px 44px 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 10px;
    row-gap: 2px;
    padding: 12px 14px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
  }
  .table--products tbody tr:last-child { border-bottom: 0; }
  .table--products tbody td {
    display: block;
    padding: 0;
    border: 0;
    font-size: 13px;
    line-height: 1.3;
  }
  .table--products tbody td::before { display: none !important; content: none !important; }

  /* Kolom 1 = checkbox over alle rijen, kolom 2 = thumbnail over rijen,
     kolom 3 = naam + sku/prijs/voorraad */
  .table--products tbody td.bulk-check {
    grid-column: 1; grid-row: 1 / span 3; align-self: center;
  }
  .table--products tbody td.thumb-col {
    grid-column: 2; grid-row: 1 / span 3; align-self: center;
  }
  .table--products tbody td[data-label="Naam"] {
    grid-column: 3; grid-row: 1; font-size: 14px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .table--products tbody td[data-label="SKU"] {
    grid-column: 3; grid-row: 2; font-size: 11px; color: var(--muted);
  }
  .table--products tbody td[data-label="SKU"] code {
    background: transparent; padding: 0; font-size: 11px;
  }
  .table--products tbody td[data-label="B2B"] {
    grid-column: 3; grid-row: 3;
    font-size: 13px; font-weight: 700; color: var(--text);
    display: inline-flex; align-items: center;
  }
  .table--products tbody td[data-label="B2B"]::after {
    content: '· B2B';
    margin-left: 4px; font-size: 10px; color: var(--muted); font-weight: 500;
  }
  .table--products tbody td[data-label="Voorraad"] {
    grid-column: 3; grid-row: 3; justify-self: end;
    font-size: 11px; color: var(--muted);
  }
  .table--products tbody td[data-label="Status"] {
    grid-column: 3; grid-row: 2; justify-self: end;
  }
  /* Verberg minder relevante kolommen op mobile */
  .table--products tbody td[data-label="Advies"],
  .table--products tbody td[data-label="BTW"] { display: none; }

  /* Checkbox iets groter op mobile voor goede tap-target */
  .table--products tbody td.bulk-check input { width: 22px; height: 22px; }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
  .sidebar, .topbar, .bottomnav, .action-row, .form__actions, .fab, .toast-container, .print-nav { display: none !important; }
  body { background: #fff; }
  .card, .doc { border: 0; box-shadow: none; }
}
