@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600&family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ─── TOKENS ─────────────────────────────────────────── */
:root {
  --ecru:        #F4F3EE;
  --ecru-dark:   #ECEAE2;
  --ecru-mid:    #E2E0D6;
  --navy:        #162052;
  --navy-mid:    #1E2F6B;
  --navy-light:  #2A3F8F;
  --navy-mist:   rgba(22, 32, 82, 0.06);
  --navy-border: rgba(22, 32, 82, 0.12);

  --ok:          #2D6A4F;
  --ok-bg:       #D8F3DC;
  --warn:        #B5451B;
  --warn-bg:     #FFE8DF;
  --flag:        #9C6B00;
  --flag-bg:     #FFF3CD;
  --info:        #1A6091;
  --info-bg:     #D6EAF8;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  --radius-sm:  4px;
  --radius:     8px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 3px rgba(22,32,82,0.08);
  --shadow:     0 4px 16px rgba(22,32,82,0.10);
  --shadow-lg:  0 12px 40px rgba(22,32,82,0.14);

  --sidebar-w:  260px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:   64px;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--ecru);
  color: var(--navy);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
img { display: block; max-width: 100%; }

/* ─── SCROLLBAR ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--ecru-dark); }
::-webkit-scrollbar-thumb { background: var(--navy-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(22,32,82,0.25); }

/* ─── LAYOUT ─────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  transition: grid-template-columns 0.2s ease;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

.sidebar {
  grid-row: 1 / -1;
  background: var(--navy);
  color: var(--ecru);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  width: var(--sidebar-w);
  transition: width 0.2s ease;
  overflow-x: hidden;
}

.topbar {
  background: var(--ecru);
  border-bottom: 1px solid var(--navy-border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.main-content {
  padding: 36px 40px;
  overflow-y: auto;
  max-width: 1600px;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar-logo {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(244,243,238,0.1);
}
.sidebar-logo .logo-mark {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.sidebar-logo .logo-sub-top {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.65;
  margin-top: 2px;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  font-weight: 300;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.4;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.35;
  padding: 16px 24px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(244,243,238,0.75);
  transition: all var(--transition);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  color: var(--ecru);
  background: rgba(244,243,238,0.06);
}
.nav-item.active {
  color: var(--ecru);
  background: rgba(244,243,238,0.1);
  border-left-color: var(--ecru);
  font-weight: 500;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }

/* ─── SIDEBAR COLLAPSED ──────────────────────────────── */
.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
  overflow: visible;
}
.app-layout.sidebar-collapsed {
  grid-template-columns: var(--sidebar-w-collapsed) 1fr;
}
.sidebar.collapsed .sidebar-logo {
  padding: 12px 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.sidebar.collapsed .sidebar-logo > div .logo-sub-top,
.sidebar.collapsed .sidebar-logo > div .logo-sub { display: none; }
.sidebar.collapsed .sidebar-logo > div .logo-mark { font-size: 12px; letter-spacing: 1px; }
#sidebar-collapse-btn { flex-shrink: 0; }
.sidebar.collapsed .sidebar-section-label { display: none; }
.sidebar.collapsed .nav-item {
  padding: 10px 0;
  justify-content: center;
  font-size: 0;  /* verbergt plain text nodes */
}
.sidebar.collapsed .nav-item .nav-icon {
  opacity: 0.7;
  margin: 0;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.sidebar.collapsed .nav-item span:not(.nav-badge) { display: none; }
.sidebar.collapsed .nav-item .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  font-size: 9px !important;  /* herstel van font-size: 0 op parent */
  padding: 0 3px;
  line-height: 14px;
}
.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 12px 0; }

/* ─── LOGOUT KNOP ─────────────────────────────────────────── */
.logout-btn {
  background: #c0392b;
  border: none;
  cursor: pointer;
  color: #ffffff;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.logout-btn svg { stroke: #ffffff !important; }
.logout-btn:hover { background: #e74c3c; }
.sidebar.collapsed .user-avatar { margin: 0; }
.sidebar.collapsed #sidebar-collapse-btn svg { transform: rotate(180deg); }

/* Tooltip bij collapsed — via JS afgehandeld */
.sidebar.collapsed .nav-item { position: relative; }

#sidebar-tooltip {
  position: fixed;
  background: var(--navy);
  color: var(--ecru);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 99999;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  display: none;
}

/* Toggle knop */
#sidebar-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ecru);
  opacity: 0.5;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
}
#sidebar-collapse-btn:hover { opacity: 1; }
.sidebar.collapsed #sidebar-collapse-btn svg { transform: rotate(180deg); }

.nav-badge {
  margin-left: auto;
  background: #C0392B;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(244,243,238,0.1);
  font-size: 13px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(244,243,238,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ecru);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  opacity: 0.45;
  text-transform: capitalize;
}


/* ─── TOPBAR ─────────────────────────────────────────── */
.topbar-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ─── PAGE HEADER ────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.page-header-left {}
.page-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--navy);
  opacity: 0.4;
  margin-bottom: 4px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.5px;
}
.page-subtitle {
  font-size: 14px;
  opacity: 0.55;
  margin-top: 4px;
}
.page-header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ─── CARDS ──────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card-flat {
  background: var(--ecru-dark);
  border: 1px solid var(--ecru-mid);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-navy {
  background: var(--navy);
  color: var(--ecru);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* ─── STAT CARDS ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: white;
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--navy);
  opacity: 0.12;
  pointer-events: none;
}
.stat-card.accent::before { opacity: 1; }
.stat-card.warn::before { background: var(--warn); opacity: 1; }
.stat-card.ok::before { background: var(--ok); opacity: 1; }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.45;
  margin-bottom: 10px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -1px;
}
.stat-sub {
  font-size: 12px;
  opacity: 0.45;
  margin-top: 4px;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--navy);
  color: var(--ecru);
}
.btn-primary:hover { background: var(--navy-mid); box-shadow: var(--shadow); }
.btn-secondary {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--navy-border);
}
.btn-secondary:hover { background: var(--navy-mist); border-color: var(--navy); }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  opacity: 0.6;
}
.btn-ghost:hover { opacity: 1; background: var(--navy-mist); }
.btn-danger {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1.5px solid rgba(181,69,27,0.2);
}
.btn-danger:hover { background: #FFDDD2; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-icon { padding: 9px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ─── INPUTS ─────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  opacity: 0.55;
}
.input {
  background: white;
  border: 1.5px solid var(--navy-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(22,32,82,0.08);
}
.input::placeholder { opacity: 0.35; }
.input-search {
  background: var(--ecru-dark);
  border-color: transparent;
  padding-left: 40px;
}
.input-search:focus { background: white; border-color: var(--navy); }
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.35;
  pointer-events: none;
}

/* ─── TABLES ─────────────────────────────────────────── */
.table-wrap {
  background: white;
  border: 1px solid var(--navy-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.45;
  padding: 14px 20px;
  text-align: left;
  background: var(--ecru);
  border-bottom: 1px solid var(--navy-border);
}
tbody tr {
  border-bottom: 1px solid var(--ecru-dark);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--navy-mist); }
tbody td {
  padding: 14px 20px;
  font-size: 14px;
}
.td-mono { font-family: var(--font-mono); font-size: 12px; }

/* ─── BADGES ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-navy  { background: rgba(22,32,82,0.1); color: var(--navy); }
.badge-ok    { background: var(--ok-bg); color: var(--ok); }
.badge-warn  { background: var(--warn-bg); color: var(--warn); }
.badge-flag  { background: var(--flag-bg); color: var(--flag); }
.badge-info  { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--ecru-mid); color: var(--navy); opacity: 0.6; }

/* ─── MATRIX TABLE (pakbon) ──────────────────────────── */
.matrix-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--navy-border);
}
.matrix-table { width: 100%; border-collapse: collapse; min-width: 400px; }
.matrix-table th {
  background: var(--navy);
  color: var(--ecru);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: center;
}
.matrix-table th:first-child { text-align: left; }
.matrix-table td {
  padding: 10px 14px;
  text-align: center;
  font-size: 13px;
  border-bottom: 1px solid var(--ecru-dark);
}
.matrix-table td:first-child { text-align: left; font-weight: 500; }
.matrix-table tfoot td {
  background: var(--ecru-dark);
  font-weight: 600;
  border-top: 2px solid var(--navy-border);
}
.matrix-table tr:hover td { background: var(--navy-mist); }
.matrix-zero { color: var(--navy); opacity: 0.2; }

/* ─── MODAL ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(22,32,82,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 150ms ease;
}
.modal {
  background: var(--ecru);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-lg { max-width: 760px; }
.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 6px;
}
.modal-subtitle { font-size: 14px; opacity: 0.55; margin-bottom: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--navy-border);
}

/* ─── ALERTS ─────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
}
.alert-warn { background: var(--flag-bg); color: var(--flag); border: 1px solid rgba(156,107,0,0.2); }
.alert-danger { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(181,69,27,0.2); }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid rgba(45,106,79,0.2); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(26,96,145,0.2); }

/* ─── SCAN FEEDBACK ──────────────────────────────────── */
.scan-result {
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: slideUp 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.scan-result.match { background: var(--ok-bg); border: 1px solid rgba(45,106,79,0.2); }
.scan-result.stock { background: var(--info-bg); border: 1px solid rgba(26,96,145,0.2); }
.scan-result.flag  { background: var(--warn-bg); border: 1px solid rgba(181,69,27,0.2); }
.scan-icon { font-size: 28px; flex-shrink: 0; }
.scan-info-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.scan-info-sub { font-size: 13px; opacity: 0.7; }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  opacity: 0.5;
}
.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-family: var(--font-display); font-size: 18px; margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* ─── LOADING ────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--navy-border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ─── DIVIDER ────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--navy-border);
  margin: 20px 0;
}

/* ─── LOCK INDICATOR ─────────────────────────────────── */
.lock-banner {
  background: var(--flag-bg);
  border: 1px solid rgba(156,107,0,0.25);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--flag);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── WIZARD STEPS ───────────────────────────────────── */
.wizard-steps {
  display: flex;
  gap: 0;
  margin-bottom: 32px;
}
.wizard-step {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--navy);
  opacity: 0.35;
  position: relative;
  letter-spacing: 0.5px;
}
.wizard-step::after {
  content: '';
  position: absolute;
  bottom: 0; left: 10%; right: 10%;
  height: 2px;
  background: var(--navy-border);
}
.wizard-step.active {
  opacity: 1;
}
.wizard-step.active::after { background: var(--navy); }
.wizard-step.done { opacity: 0.6; }
.wizard-step.done::after { background: var(--ok); }

/* ─── ANIMATIONS ─────────────────────────────────────── */
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes pulse    { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-in { animation: slideUp 300ms cubic-bezier(0.34, 1.2, 0.64, 1) both; }
.fade-in    { animation: fadeIn 250ms ease both; }

/* ─── UTILITIES ──────────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { opacity: 0.45; }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
