:root {
  --bg: #faf6f1;
  --surface: #ffffff;
  --primary: #c45c26;
  --primary-dark: #a34a1c;
  --primary-light: #f8e8df;
  --accent: #d4a017;
  --text: #2c2118;
  --text-muted: #7a6a5a;
  --border: #e8ddd0;
  --success: #2e7d32;
  --warning: #f9a825;
  --danger: #c62828;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(44, 33, 24, 0.08);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* ---- v2.2 theme tokens (light values = the previous hard-coded colours) ---- */
  color-scheme: light;
  --primary-text: #a34a1c;      /* primary used AS TEXT. v2.2.1: darkened from #c45c26 for contrast (4.28 → 6.1:1 on white) */
  --on-primary: #ffffff;        /* text on solid primary/danger/success fills */
  --danger-text: #c62828;
  --success-text: #2e7d32;
  --surface-2: #f9f5f0;         /* table header */
  --surface-hover: #fdfaf7;     /* table row hover */
  --input-bg: #ffffff;
  --input-fg: #000000;          /* = the browser default field text in v2.1, so light is unchanged */
  --placeholder: #757575;
  --focus-ring: rgba(196, 92, 38, 0.15);
  --overlay: rgba(44, 33, 24, 0.45);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.2);
  --toast-bg: #2c2118;
  --toast-fg: #ffffff;
  --grad-a: #c45c26;            /* calculator result gradient */
  --grad-b: #d4a017;
  --pill-pending-bg: #fff3e0;     --pill-pending-fg: #e65100;
  --pill-confirmed-bg: #e3f2fd;   --pill-confirmed-fg: #1565c0;
  --pill-progress-bg: #f3e5f5;    --pill-progress-fg: #7b1fa2;
  --pill-ready-bg: #e8f5e9;       --pill-ready-fg: #2e7d32;
  --pill-delivered-bg: #e0f2f1;   --pill-delivered-fg: #00695c;
  --pill-cancelled-bg: #ffebee;   --pill-cancelled-fg: #c62828;
  --err-bg: #ffebee;   --err-fg: #8e1a1a;   --err-border: #f3b6b6;
  --warn-bg: #fff8e1;  --warn-fg: #6b4e00;  --warn-border: #f1dd9a;
  --info-bg: #e8f0fe;  --info-fg: #1b3a73;  --info-border: #bcd0f7;
  --note-bg: #fff3e0;  --note-fg: #7a3d00;  --note-border: #f5cf9b;
  --ok-bg: #e8f5e9;    --ok-fg: #1b5e20;
  --est-bg: #fff3e0;   --est-fg: #b45309;   --est-border: #e0a84f;
  --neutral-bg: #eceff1; --neutral-fg: #455a64;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
#sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.brand .logo {
  font-size: 32px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-text);
}

.brand .tagline {
  font-size: 12px;
  color: var(--text-muted);
}

#main-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary-text);
}

.nav-item.active {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.nav-item .icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.version {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ========== MAIN CONTENT ========== */
#content {
  flex: 1;
  min-width: 0;
  margin-left: 260px;
  padding: 28px 32px 80px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 26px;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ========== CARDS & GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--primary);
}

.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.accent::before { background: var(--accent); }

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ========== TABLES ========== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--surface-2);
}

tr:hover td {
  background: var(--surface-hover);
}

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status.pending { background: var(--pill-pending-bg); color: var(--pill-pending-fg); }
.status.confirmed { background: var(--pill-confirmed-bg); color: var(--pill-confirmed-fg); }
.status.in-progress { background: var(--pill-progress-bg); color: var(--pill-progress-fg); }
.status.ready { background: var(--pill-ready-bg); color: var(--pill-ready-fg); }
.status.delivered { background: var(--pill-delivered-bg); color: var(--pill-delivered-fg); }
.status.cancelled { background: var(--pill-cancelled-bg); color: var(--pill-cancelled-fg); }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-text);
}

.btn-success { background: var(--success); color: var(--on-primary); }
.btn-danger { background: var(--danger); color: var(--on-primary); }
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-icon:hover { background: var(--primary-light); color: var(--primary-text); }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ========== FORMS ========== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--input-fg);
  transition: border-color 0.2s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

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

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ========== MODAL ========== */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

#modal-overlay.hidden { display: none; }

#modal {
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

#modal.modal-wide {
  max-width: 740px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 18px;
}

#modal-body {
  padding: 24px;
}

/* ========== TOAST ========== */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--toast-bg);
  color: var(--toast-fg);
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  transition: opacity 0.3s;
}

#toast.hidden { display: none; opacity: 0; }

/* ========== CALCULATOR SPECIFIC ========== */
.calc-result {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: var(--on-primary);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-top: 20px;
}

.calc-result .big {
  font-size: 36px;
  font-weight: 700;
  margin: 8px 0;
}

.calc-result .label {
  opacity: 0.9;
  font-size: 14px;
}

.cost-table {
  width: 100%;
  margin: 16px 0;
}

.cost-table td {
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.cost-table td:last-child {
  text-align: right;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ========== MOBILE ========== */
@media (max-width: 860px) {
  #sidebar {
    transform: none;
    width: 0;
    border-right: 0;
  }
  #content {
    margin-left: 0;
    padding: 20px 16px 100px;
  }

  #main-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 4px;
    z-index: 200;
    overflow-x: auto;
    gap: 0;
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 8px 4px;
    font-size: 11px;
    min-width: 64px;
  }
  .nav-item .icon { font-size: 20px; }
  .nav-item .label { font-size: 10px; }

  .brand, .sidebar-footer { display: none; }
  #sidebar { height: auto; bottom: auto; }
}

/* Utility */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 12px; }
.mb-2 { margin-bottom: 12px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.badge {
  background: var(--primary-light);
  color: var(--primary-text);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.low-stock { color: var(--danger-text); font-weight: 600; }

/* ========== v2.1 ADDITIONS ========== */
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-1 { margin-top: 6px; }

.form-error {
  background: var(--err-bg); color: var(--err-fg); border: 1px solid var(--err-border); border-left: 4px solid var(--danger);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}
.form-error ul, .form-warn ul { margin: 6px 0 0 18px; }
.form-warn {
  background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); border-left: 4px solid var(--warning);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}
.check-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; font-weight: 600; cursor: pointer; }
.check-row input { width: auto; margin-top: 3px; }
.pay-hint { font-size: 13px; color: var(--text-muted); margin: 4px 0 12px; min-height: 18px; }
.form-section { margin: 18px 0 10px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 15px; }
.readonly-box { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.readonly-box small { display: block; color: var(--text-muted); margin-top: 2px; }
.form-group small.text-muted { display: block; margin-top: 4px; font-size: 12px; }

.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 14px;
}
.banner-demo { background: var(--info-bg); border: 1px solid var(--info-border); color: var(--info-fg); }
.banner-backup { background: var(--note-bg); border: 1px solid var(--note-border); color: var(--note-fg); }

.demo-badge {
  display: inline-block; background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--info-border);
  font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 1px 6px; border-radius: 6px; vertical-align: middle;
}
.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 1px 6px; border-radius: 6px; vertical-align: middle; }
.tag-actual { background: var(--ok-bg); color: var(--ok-fg); }
.tag-est { background: var(--est-bg); color: var(--est-fg); border: 1px dashed var(--est-border); }
.tag-unknown { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge-warn { background: var(--est-bg); color: var(--est-fg); }
.text-due { color: var(--danger-text); font-weight: 600; }
.text-credit { color: var(--est-fg); font-weight: 600; }
.text-ok { color: var(--success-text); font-weight: 600; }

.data-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.data-section:last-child { border-bottom: 0; }
.data-section h4 { margin-bottom: 6px; }
.data-section p { font-size: 14px; margin-bottom: 8px; }
.data-section code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ========== v2.2 DARK THEME ==========
   Auto  : follows the device (no data-theme attribute) – works even before/without JavaScript.
   Manual: <html data-theme="light|dark"> (set by js/theme.js) always wins over the device.
   KEEP THE TWO DARK BLOCKS IDENTICAL (checked by tests/theme.test.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1511;  --surface: #241e18;  --surface-2: #2d2620;  --surface-hover: #2b241d;
    --text: #f1e8dd;  --text-muted: #b8a999;  --border: #3f362c;
    --primary: #b4501e;  --primary-dark: #963f12;  --primary-light: #3b2a20;  --primary-text: #f0976a;
    --accent: #d4a017;  --success: #2e7d32;  --warning: #f9a825;  --danger: #c62828;
    --success-text: #86d68b;  --danger-text: #ff8f86;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
    --input-bg: #1d1813;  --input-fg: #f1e8dd;  --placeholder: #a39482;  --focus-ring: rgba(240, 151, 106, 0.4);
    --overlay: rgba(0, 0, 0, 0.62);
    --toast-bg: #f1e8dd;  --toast-fg: #1a1511;
    --grad-a: #8f3f15;  --grad-b: #7d5d08;
    --pill-pending-bg: #4a3118;    --pill-pending-fg: #ffb86b;
    --pill-confirmed-bg: #1c3250;  --pill-confirmed-fg: #8ec5ff;
    --pill-progress-bg: #392447;   --pill-progress-fg: #dcaaf2;
    --pill-ready-bg: #1f3a24;      --pill-ready-fg: #8fdc95;
    --pill-delivered-bg: #16393a;  --pill-delivered-fg: #7fdcd0;
    --pill-cancelled-bg: #4a1f22;  --pill-cancelled-fg: #ff9d9d;
    --err-bg: #3d1d1d;   --err-fg: #ffb4ab;   --err-border: #6b3030;
    --warn-bg: #3b3015;  --warn-fg: #f3d77c;  --warn-border: #6b5a22;
    --info-bg: #1d2b45;  --info-fg: #b5d0ff;  --info-border: #34507f;
    --note-bg: #3d2a15;  --note-fg: #ffc58a;  --note-border: #6e4a22;
    --ok-bg: #1f3a24;    --ok-fg: #9be3a0;
    --est-bg: #3d2a15;   --est-fg: #ffc58a;   --est-border: #a87a3a;
    --neutral-bg: #2f3a40; --neutral-fg: #bccad2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1511;  --surface: #241e18;  --surface-2: #2d2620;  --surface-hover: #2b241d;
  --text: #f1e8dd;  --text-muted: #b8a999;  --border: #3f362c;
  --primary: #b4501e;  --primary-dark: #963f12;  --primary-light: #3b2a20;  --primary-text: #f0976a;
  --accent: #d4a017;  --success: #2e7d32;  --warning: #f9a825;  --danger: #c62828;
  --success-text: #86d68b;  --danger-text: #ff8f86;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.6);
  --input-bg: #1d1813;  --input-fg: #f1e8dd;  --placeholder: #a39482;  --focus-ring: rgba(240, 151, 106, 0.4);
  --overlay: rgba(0, 0, 0, 0.62);
  --toast-bg: #f1e8dd;  --toast-fg: #1a1511;
  --grad-a: #8f3f15;  --grad-b: #7d5d08;
  --pill-pending-bg: #4a3118;    --pill-pending-fg: #ffb86b;
  --pill-confirmed-bg: #1c3250;  --pill-confirmed-fg: #8ec5ff;
  --pill-progress-bg: #392447;   --pill-progress-fg: #dcaaf2;
  --pill-ready-bg: #1f3a24;      --pill-ready-fg: #8fdc95;
  --pill-delivered-bg: #16393a;  --pill-delivered-fg: #7fdcd0;
  --pill-cancelled-bg: #4a1f22;  --pill-cancelled-fg: #ff9d9d;
  --err-bg: #3d1d1d;   --err-fg: #ffb4ab;   --err-border: #6b3030;
  --warn-bg: #3b3015;  --warn-fg: #f3d77c;  --warn-border: #6b5a22;
  --info-bg: #1d2b45;  --info-fg: #b5d0ff;  --info-border: #34507f;
  --note-bg: #3d2a15;  --note-fg: #ffc58a;  --note-border: #6e4a22;
  --ok-bg: #1f3a24;    --ok-fg: #9be3a0;
  --est-bg: #3d2a15;   --est-fg: #ffc58a;   --est-border: #a87a3a;
  --neutral-bg: #2f3a40; --neutral-fg: #bccad2;
}

/* ---- theme switch (Auto / Light / Dark) ---- */
.theme-bar { display: flex; justify-content: flex-end; margin: -8px 0 10px; }
.theme-switch {
  display: inline-flex; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface);
}
.theme-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-muted); background: transparent; border: 0; cursor: pointer;
}
.theme-opt + .theme-opt { border-left: 1px solid var(--border); }
.theme-opt:hover { background: var(--primary-light); color: var(--primary-text); }
.theme-opt.active { background: var(--primary); color: var(--on-primary); }
.theme-opt:focus-visible { outline: 2px solid var(--primary-text); outline-offset: -2px; }
@media (max-width: 560px) { .theme-opt { padding: 6px 12px; } .theme-opt .theme-label { display: none; } }

/* ========== AUTH OVERLAY ========== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
}
.auth-overlay.hidden { display: none; }

.auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.12);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
}

.auth-card h2 {
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--primary-text);
}
.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}
.auth-card .warning-box {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--warn-fg);
  margin-bottom: 18px;
  line-height: 1.45;
}
.auth-card .recovery-box {
  background: var(--ok-bg);
  border: 1px solid var(--ok-fg);
  color: var(--ok-fg);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  margin: 16px 0;
}
.auth-card .recovery-code {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  font-family: monospace;
  margin: 8px 0;
  color: var(--ok-fg);
}
.user-badge {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.user-badge strong { color: var(--text); }

/* ========== v2.2.1 ANDROID / TOUCH USABILITY ========== */
@media (max-width: 860px), (pointer: coarse) {
  .btn, .btn-sm, .settings-tab { min-height: 44px; justify-content: center; }
  .btn-sm { padding: 10px 14px; min-width: 44px; }
  .btn-icon { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .form-group input:not([type="checkbox"]):not([type="radio"]),
  .form-group select,
  .form-group textarea { min-height: 44px; }
  .check-row { min-height: 44px; align-items: center; }
  .check-row input, input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .theme-opt { min-height: 44px; min-width: 44px; justify-content: center; }
}
@media (max-width: 860px) {
  #main-nav { scrollbar-width: none; }
  #main-nav::-webkit-scrollbar { display: none; }
  .nav-item { min-width: 0; min-height: 48px; padding: 6px 1px; justify-content: center; }
  #main-nav { padding-left: 2px; padding-right: 2px; }
  .nav-item .label { font-size: 9.5px; letter-spacing: -0.35px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 340px) { .nav-item .label { font-size: 8.5px; } }
@media (max-width: 860px), (pointer: coarse) {
  input[type="file"] { min-height: 44px; padding: 10px 0; }
}

/* ========== v2.2.1 OPENING SCREEN & ACCOUNT BAR ========== */
.auth-brand { font-size: 22px; color: var(--primary-text); text-align: center; }
.auth-card .subtitle, #auth-card .subtitle { text-align: center; }
.auth-tabs { display: flex; gap: 6px; margin: 14px 0 16px; padding: 4px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.auth-tab { flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--text-muted); font: inherit; font-weight: 700; cursor: pointer; }
.auth-tab.active { background: var(--primary); color: var(--on-primary); }
.auth-tab:focus-visible { outline: 2px solid var(--primary-text); outline-offset: 2px; }
#auth-panel h3 { margin-bottom: 8px; }
#auth-panel p { font-size: 14px; margin-bottom: 10px; }
.auth-diag { margin-top: 16px; font-size: 11px; color: var(--text-muted); text-align: center; word-break: break-all; }
.theme-bar { gap: 8px; flex-wrap: wrap; align-items: center; }
.account-name { display: inline-block; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

#auth-overlay { overflow-y: auto; align-items: flex-start; -webkit-overflow-scrolling: touch; }
#auth-card { margin: auto; }

/* ========== v2.2.2 DISPLAY PREFERENCES, SETTINGS & SUPPORT CENTRE (tokens only) ========== */
:root[data-font-size="small"] body { font-size: 14px; }
:root[data-font-size="large"] body { font-size: 17px; }
:root[data-font-size="large"] .stat-value { font-size: 32px; }
:root[data-dash-layout="compact"] .stats-grid { gap: 10px; margin-bottom: 16px; }
:root[data-dash-layout="compact"] .stat-card { padding: 14px; }
:root[data-dash-layout="compact"] .card { padding: 14px; margin-bottom: 12px; }
:root[data-compact-tables="1"] th, :root[data-compact-tables="1"] td { padding: 8px 10px; }

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.settings-tab:hover { background: var(--primary-light); color: var(--primary-text); }
.settings-tab.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.settings-panel h3 { font-size: 17px; margin-bottom: 10px; }
.settings-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.biz-logo-preview {
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.faq-item { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq-item:last-child { border-bottom: 0; }
.faq-item summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.faq-item p { margin-top: 6px; font-size: 14px; color: var(--text-muted); }