*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg:       #eef2f8;
    --surface:  #ffffff;
    --surface2: #dde5f0;
    --border:   #c8d4e8;
    --text:     #1e3a6e;
    --muted:    #6b8cbf;
    --gold:     #4a6fa5;
    --gold-dim: #d0ddef;
    --red:      #b83232;
    --green:    #2e7d52;
    --navy:     #1e3a6e;
    --mid-blue: #4a6fa5;
    --sans: 'Outfit', sans-serif;
    --mono: 'DM Mono', monospace;
  }

  body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 2rem;
    font-size: 13px;
  }

  /* HEADER */
  header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
  }

  .logo { display: flex; align-items: center; }
  .logo-wide   { height: 52px; width: auto; display: block; }
  .logo-square { height: 52px; width: auto; display: none; }
  @media (max-width: 600px) {
    .logo-wide   { display: none; }
    .logo-square { display: block; }
  }

  .header-right { text-align: right; }

  .live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--green);
    margin-bottom: 0.3rem;
  }

  .live-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
  }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }

  .header-date { color: var(--muted); font-size: 0.7rem; }

  /* STATUS BAR */
  .status-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.6rem 1rem;
    margin-bottom: 2rem;
    font-size: 0.7rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .status-bar.loading { color: var(--gold); }
  .status-bar.error { color: var(--red); border-color: var(--red); }
  .status-bar.success { color: var(--green); border-color: #1e3d2a; }

  /* CONFIG */
  .config-panel {
    background: var(--surface);
    border: 1px solid var(--gold-dim);
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: none;
  }

  .config-panel.visible { display: block; }

  .config-title {
    font-family: var(--sans);
    font-size: 0.9rem;
    color: var(--gold);
    margin-bottom: 1rem;
  }

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

  .config-field label {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
  }

  .config-field input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--sans);
    font-size: 0.72rem;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: border-color 0.15s;
  }

  .config-field input:focus { border-color: var(--gold); }

  .config-actions { display: flex; gap: 0.5rem; }

  .btn {
    font-family: var(--sans);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
  }

  .btn-primary {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg);
  }

  .btn:hover { opacity: 0.8; }
  .github-btn { display:inline-flex;align-items:center;padding:0.4rem 0.6rem; }

  /* TOP TOOLBAR */
  .toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
  }

  .section-label {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .toolbar-actions { display: flex; gap: 0.5rem; }

  /* KPI GRID */
  .kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    margin-bottom: 1px;
  }

  .kpi {
    background: var(--surface);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: background 0.2s;
  }

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

  .kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.6s cubic-bezier(0.4,0,0.2,1);
  }

  .kpi.loaded::before { transform: scaleX(1); }

  .kpi-label {
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
  }

  .kpi-value {
    font-family: var(--sans);
    font-size: 2.4rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1;
    margin-bottom: 0.5rem;
  }

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

  .kpi-sub .up { color: var(--green); }
  .kpi-sub .down { color: var(--red); }

  /* MAIN LAYOUT */
  .main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    margin-bottom: 1px;
  }

  .card {
    background: var(--surface);
    padding: 1.5rem;
  }

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
  }

  .card-title {
    font-family: var(--sans);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text);
  }

  .card-meta { font-size: 0.65rem; color: var(--muted); }

  .list-search {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    background: var(--surface2, var(--surface));
    color: var(--text);
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: inherit;
  }
  .list-search::placeholder { color: var(--muted); }

  /* SHOW CARDS */
  .show-list { display: flex; flex-direction: column; gap: 1rem; }

  .show-item {
    border: 1px solid var(--border);
    padding: 1rem;
    transition: border-color 0.2s;
    cursor: default;
  }

  .show-item:hover { border-color: var(--gold); }

  .show-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
  }

  .show-name {
    font-family: var(--sans);
    font-size: 0.95rem;
    font-style: italic;
    color: var(--text);
  }

  .show-date { font-size: 0.65rem; color: var(--muted); }

  .show-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
  }

  .show-stat-label { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
  .show-stat-val { font-size: 1rem; font-family: var(--sans); color: var(--text); }

  .seat-track {
    height: 3px;
    background: var(--gold-dim);
    position: relative;
    overflow: hidden;
  }

  .seat-fill {
    height: 100%;
    background: var(--gold);
    transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
  }

  .seat-fill.almost { background: var(--red); }
  .seat-fill.good { background: var(--green); }

  .seat-pct {
    font-size: 0.65rem;
    color: var(--muted);
    margin-top: 0.35rem;
    display: flex;
    justify-content: space-between;
  }

  /* REVENUE CHART */
  svg.rev-chart { width: 100%; height: 160px; }

  /* ORDERS TABLE */
  .table-wrap {
    background: var(--surface);
    padding: 1.5rem;
    border-top: 1px solid var(--border);
  }

  table { width: 100%; border-collapse: collapse; }

  thead th {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-weight: 400;
  }

  /* Sortable / filterable table headers — see makeTableController() */
  thead th.sortable-th {
    border-bottom: none;
    padding-bottom: 0.4rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  thead th.sortable-th:hover { color: var(--text); }
  thead th.sortable-th .sort-arrow { color: var(--gold); margin-left: 0.2em; }
  thead th.filter-th { border-bottom: 1px solid var(--border); padding: 0 0.3rem 0.6rem 0; }
  thead th.filter-th input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    background: var(--surface2, var(--surface));
    color: var(--text);
    border-radius: 3px;
    font-size: 0.68rem;
    font-family: inherit;
    text-transform: none;
    letter-spacing: normal;
  }
  thead th.filter-th input::placeholder { color: var(--muted); }

  tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
  }

  tbody tr:last-child { border-bottom: none; }
  tbody tr:hover { background: var(--surface2); }

  tbody td {
    padding: 0.65rem 0;
    font-size: 0.75rem;
    vertical-align: middle;
  }

  .status-pill {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 1px;
  }

  .pill-succeeded { background: #d4edde; color: var(--green); }
  .pill-created { background: var(--gold-dim); color: var(--gold); }
  .pill-failed { background: #fad7d7; color: var(--red); }
  .pill-pending { background: var(--surface2); color: var(--muted); }

  .empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
    font-size: 0.8rem;
  }

  .skeleton {
    background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 2px;
    height: 1em;
    display: inline-block;
  }

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

  .divider {
    height: 1px;
    background: var(--border);
    margin: 0;
  }

  @media (max-width: 800px) {
    body { padding: 1rem; }

    header { flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-bottom: 1.5rem; }
    .logo { font-size: 1.4rem; }

    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 1px; }
    .kpi { padding: 1rem; }
    .kpi-value { font-size: 1.6rem; }

    .main-grid { grid-template-columns: 1fr; }
    .config-grid { grid-template-columns: 1fr; }

    .toolbar { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .toolbar-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

    .show-stats { flex-wrap: wrap; gap: 0.75rem; }

    table { font-size: 0.7rem; }
    thead th, tbody td { padding: 0.5rem 0.25rem; }
    /* Hide less important columns on mobile */
    th:nth-child(3), td:nth-child(3),
    th:nth-child(6), td:nth-child(6) { display: none; }

    .card { padding: 1rem; }
    .table-wrap { padding: 1rem; }

    #weekChart { height: 140px; }
  }

  @media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .kpi-value { font-size: 1.3rem; }
    th:nth-child(4), td:nth-child(4),
    th:nth-child(5), td:nth-child(5) { display: none; }
  }


  /* ── LOGIN OVERLAY ─────────────────────────────────────── */
  #loginOverlay {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
  }

  .login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 400px;
  }

  .login-logo {
    font-size: 1.1rem; font-weight: 600; color: var(--text);
    margin-bottom: 0.25rem;
  }

  .login-sub {
    font-size: 0.72rem; color: var(--muted);
    margin-bottom: 2rem;
  }

  .login-tab-row {
    display: flex; gap: 0; margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
  }

  .login-tab {
    padding: 0.4rem 1rem; font-size: 0.75rem; cursor: pointer;
    color: var(--muted); background: none; border: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
  }

  .login-tab.active { color: var(--text); border-bottom-color: var(--gold); font-weight: 500; }

  .login-field { margin-bottom: 1rem; }
  .login-field label { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 0.3rem; }
  .login-field input {
    width: 100%; padding: 0.5rem 0.6rem;
    border: 1px solid var(--border); background: var(--surface2);
    font-family: inherit; font-size: 0.82rem; color: var(--text);
  }
  .login-field input:focus { outline: none; border-color: var(--gold); }

  .login-error { color: var(--red); font-size: 0.7rem; margin-bottom: 0.75rem; min-height: 1rem; }
  .login-success { color: var(--green); font-size: 0.7rem; margin-bottom: 0.75rem; min-height: 1rem; }

  .login-btn {
    width: 100%; padding: 0.6rem; background: var(--navy); color: #fff;
    border: none; font-family: inherit; font-size: 0.82rem;
    font-weight: 500; cursor: pointer;
  }
  .login-btn:hover { opacity: 0.9; }

  /* ── USER MANAGEMENT (admin panel) ─────────────────────── */
  .user-mgmt { margin-top: 1.5rem; }
  .user-mgmt-title { font-size: 0.75rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text); }
  .user-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0; border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
  }
  .user-row:last-child { border-bottom: none; }
  .user-info { flex: 1; }
  .user-name { font-weight: 500; color: var(--text); }
  .user-email { color: var(--muted); }
  .user-status-pill {
    font-size: 0.6rem; font-weight: 600; padding: 0.1rem 0.4rem;
    border-radius: 2px; white-space: nowrap;
  }
  .pill-pending { background: #f5e9c0; color: #8b6914; }
  .pill-active  { background: #d4edde; color: #2e7d52; }
  .user-actions { display: flex; gap: 0.3rem; }
  .user-btn {
    padding: 0.2rem 0.5rem; font-size: 0.65rem; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface2);
    font-family: inherit; color: var(--text);
  }
  .user-btn:hover { background: var(--border); }
  .user-btn.danger { color: var(--red); border-color: var(--red); }
  .user-btn.danger:hover { background: #fad7d7; }
  .approve-pw { width: 100px; }

  .empty-users { font-size: 0.72rem; color: var(--muted); padding: 0.5rem 0; }

  footer {
    margin-top: 1px;
    padding: 1.5rem 2rem;
    background: var(--surface2);
    border-top: 1px solid var(--border);
    font-size: 0.68rem;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    line-height: 1.6;
  }

  footer a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
  footer a:hover { color: var(--text); }

  .footer-row { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
  .footer-dot { color: var(--border); }

  @media (max-width: 800px) {
  
  /* ── LOGIN OVERLAY ─────────────────────────────────────── */
  #loginOverlay {
    position: fixed; inset: 0; z-index: 1000;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
  }

  .login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 400px;
  }

  .login-logo {
    font-size: 1.1rem; font-weight: 600; color: var(--text);
    margin-bottom: 0.25rem;
  }

  .login-sub {
    font-size: 0.72rem; color: var(--muted);
    margin-bottom: 2rem;
  }

  .login-tab-row {
    display: flex; gap: 0; margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
  }

  .login-tab {
    padding: 0.4rem 1rem; font-size: 0.75rem; cursor: pointer;
    color: var(--muted); background: none; border: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
  }

  .login-tab.active { color: var(--text); border-bottom-color: var(--gold); font-weight: 500; }

  .login-field { margin-bottom: 1rem; }
  .login-field label { display: block; font-size: 0.7rem; color: var(--muted); margin-bottom: 0.3rem; }
  .login-field input {
    width: 100%; padding: 0.5rem 0.6rem;
    border: 1px solid var(--border); background: var(--surface2);
    font-family: inherit; font-size: 0.82rem; color: var(--text);
  }
  .login-field input:focus { outline: none; border-color: var(--gold); }

  .login-error { color: var(--red); font-size: 0.7rem; margin-bottom: 0.75rem; min-height: 1rem; }
  .login-success { color: var(--green); font-size: 0.7rem; margin-bottom: 0.75rem; min-height: 1rem; }

  .login-btn {
    width: 100%; padding: 0.6rem; background: var(--navy); color: #fff;
    border: none; font-family: inherit; font-size: 0.82rem;
    font-weight: 500; cursor: pointer;
  }
  .login-btn:hover { opacity: 0.9; }

  /* ── USER MANAGEMENT (admin panel) ─────────────────────── */
  .user-mgmt { margin-top: 1.5rem; }
  .user-mgmt-title { font-size: 0.75rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--text); }
  .user-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0; border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
  }
  .user-row:last-child { border-bottom: none; }
  .user-info { flex: 1; }
  .user-name { font-weight: 500; color: var(--text); }
  .user-email { color: var(--muted); }
  .user-status-pill {
    font-size: 0.6rem; font-weight: 600; padding: 0.1rem 0.4rem;
    border-radius: 2px; white-space: nowrap;
  }
  .pill-pending { background: #f5e9c0; color: #8b6914; }
  .pill-active  { background: #d4edde; color: #2e7d52; }
  .user-actions { display: flex; gap: 0.3rem; }
  .user-btn {
    padding: 0.2rem 0.5rem; font-size: 0.65rem; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface2);
    font-family: inherit; color: var(--text);
  }
  .user-btn:hover { background: var(--border); }
  .user-btn.danger { color: var(--red); border-color: var(--red); }
  .user-btn.danger:hover { background: #fad7d7; }
  .approve-pw { width: 100px; }

  .empty-users { font-size: 0.72rem; color: var(--muted); padding: 0.5rem 0; }

  footer { padding: 1.25rem 1rem; }
  }

/* ── Webshop tabs ─────────────────────────────────────── */
.webshop-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.ws-tab {
  padding: 0.6rem 1.2rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.ws-tab:hover {
  color: var(--navy);
}

.ws-tab.active {
  color: var(--navy);
  border-bottom: 2px solid var(--navy);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

/* ── Webshop rows in config panel ─────────────────────── */
.webshop-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.webshop-row input[type="text"] {
  flex: 1;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 4px;
  font-size: 0.8rem;
}

.webshop-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
}

.btn-small {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
}
