
  :root {
    --teal: #e0483c;
    --teal-dark: #b8362b;
    --navy: #1c3f66;
    --orange: #f2b134;
    --cream: #faf7f2;
    --card: #ffffff;
    --text: #262624;
    --muted: #6b6b66;
    --border: #e5e0d8;
    --danger: #7a1f17;
    --success: #2e8b57;
    --warning: #d9a441;
    --radius: 12px;
  }
  #canteen-root, #canteen-root * { box-sizing: border-box; }
  #canteen-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--cream); color: var(--text);
    -webkit-tap-highlight-color: transparent;
  }
  #app { display: flex; width: 100%; height: 78vh; min-height: 560px; max-height: 900px; border: 1px solid #e5e0d8; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,0.06); }

  /* Tablet: sidebar starts collapsed to icons-only by default, expandable via the toggle. */
  @media (max-width: 1024px) and (min-width: 781px) {
    #sidebar { width: 72px; }
    #sidebar.expanded { width: 220px; }
    #sidebar:not(.expanded) .nav-label,
    #sidebar:not(.expanded) .brand small,
    #sidebar:not(.expanded) .user-box { display: none; }
    #sidebar:not(.expanded) .brand { text-align: center; padding: 0 6px 16px; font-size: 0; }
    #sidebar:not(.expanded) .nav-item { justify-content: center; padding: 13px 0; }
  }

  /* Phone: sidebar stacks on top as a row of icons; tap the toggle to reveal labels. */
  @media (max-width: 780px) {
    #app { flex-direction: column; height: auto; min-height: 0; max-height: none; }
    #sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 8px; }
    #sidebar .sidebar-top-row { width: 100%; }
    #sidebar .brand { flex: 1; }
    #sidebar .user-box { display: none; }
    #main { max-height: 70vh; }
  }

  /* Manual collapse (any screen size) via the ☰ toggle — persisted per-browser. */
  #sidebar.collapsed { width: 72px; }
  #sidebar.collapsed .nav-label,
  #sidebar.collapsed .brand small,
  #sidebar.collapsed .user-box { display: none; }
  #sidebar.collapsed .brand { text-align: center; padding: 0 6px 16px; font-size: 0; }
  #sidebar.collapsed .nav-item { justify-content: center; padding: 13px 0; }

  /* ---------- Sidebar Nav ---------- */
  #sidebar {
    width: 220px; background: var(--teal-dark); color: #fff; flex-shrink: 0;
    display: flex; flex-direction: column; padding: 16px 0; overflow-y: auto; overflow-x: hidden;
    transition: width 0.15s ease;
  }
  .sidebar-top-row { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 8px 0 0; }
  .sidebar-toggle {
    background: transparent; color: #fff; opacity: 0.8; border: none; font-size: 18px;
    padding: 4px 8px; margin: 0; cursor: pointer; flex-shrink: 0;
  }
  .sidebar-toggle:hover { opacity: 1; }
  #sidebar .brand { padding: 0 20px 16px; font-size: 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.15); margin-bottom: 12px; flex: 1; min-width: 0; overflow: hidden; }
  #sidebar .brand small { display: block; font-weight: 400; opacity: 0.75; font-size: 12px; margin-top: 2px; }
  .nav-item {
    display: flex; align-items: center; gap: 10px; padding: 13px 20px; cursor: pointer;
    font-size: 15px; color: rgba(255,255,255,0.85); border-left: 3px solid transparent; white-space: nowrap;
  }
  .nav-item:hover { background: rgba(255,255,255,0.08); }
  .nav-item.active { background: rgba(255,255,255,0.14); border-left-color: var(--orange); color: #fff; font-weight: 600; }
  .nav-item .icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
  #sidebar .user-box { margin-top: auto; padding: 14px 20px; font-size: 12px; opacity: 0.8; border-top: 1px solid rgba(255,255,255,0.15); }

  /* ---------- Main ---------- */
  #main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 24px 28px 60px; }
  .view { display: none; }
  .view.active { display: block; }
  h1.page-title { font-size: 24px; margin: 0 0 18px; }
  .subtitle { color: var(--muted); font-size: 14px; margin-top: -12px; margin-bottom: 20px; }

  /* ---------- Cards / Grid ---------- */
  .card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 16px;
  }
  .grid { display: grid; gap: 16px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
  @media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
  @media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

  .stat-card { text-align: left; }
  .stat-card .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
  .stat-card .value { font-size: 26px; font-weight: 700; color: var(--navy); }
  .stat-card.warn .value { color: var(--warning); }
  .stat-card.danger .value { color: var(--danger); }
  .dashboard-summary { margin-bottom: 22px; }
  .dashboard-summary-primary { background: rgba(15, 118, 110, 0.04); border: 1px solid rgba(15, 118, 110, 0.16); border-radius: var(--radius); padding: 16px; }
  .dashboard-section-title { margin: 0 0 4px; font-size: 18px; color: var(--navy); }
  .dashboard-section-note { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
  .dashboard-stat-grid { gap: 12px; }
  .dashboard-stat-grid .stat-card { padding: 14px 16px; margin-bottom: 0; min-width: 0; }
  .dashboard-stat-grid .stat-card .value { font-size: 23px; }

  /* ---------- Buttons ---------- */
  button, .btn {
    font-family: inherit; font-size: 15px; font-weight: 600; border: none; border-radius: 10px;
    padding: 12px 20px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
    transition: transform 0.05s ease, opacity 0.15s ease;
  }
  button:active, .btn:active { transform: scale(0.97); }
  button:disabled { opacity: 0.5; cursor: not-allowed; }
  .btn-primary { background: var(--teal); color: #fff; }
  .btn-primary:hover { background: var(--teal-dark); }
  .btn-orange { background: var(--orange); color: #fff; }
  .btn-secondary { background: #eee; color: var(--text); }
  .btn-danger { background: var(--danger); color: #fff; }
  .btn-icon-small {
    background: none; border: none; padding: 2px 4px; margin: 0; font-size: 13px; cursor: pointer;
    border-radius: 4px; vertical-align: middle; opacity: 0.6;
  }
  .btn-icon-small:hover { opacity: 1; background: rgba(0,0,0,0.06); }
  .btn-small { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
  .btn-block { width: 100%; justify-content: center; }

  /* ---------- Forms ---------- */
  label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
  input, select, textarea {
    width: 100%; padding: 12px 14px; font-size: 15px; border: 1px solid var(--border);
    border-radius: 8px; font-family: inherit; background: #fff;
  }
  input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
  .field-row { display: flex; gap: 12px; }
  .field-row > div { flex: 1; }
  .checkbox-row { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
  .checkbox-row input { width: auto; }

  /* ---------- Tables ---------- */
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
  th { text-align: left; padding: 10px 12px; background: #f2efe9; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
  td { padding: 10px 12px; border-top: 1px solid var(--border); }
  tr:hover td { background: #fbfaf7; }
  .table-wrap { overflow-x: auto; }

  /* ---------- Badges ---------- */
  .badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
  .session-pill-select {
    display: inline-block; padding: 3px 22px 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
    border: none; cursor: pointer; font-family: inherit; -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3e%3cpath fill='%23666' d='M2 4l4 4 4-4'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 6px center; background-size: 9px;
  }
  .session-pill-select:hover { filter: brightness(0.96); }
  .camper-checkbox-col { display: none; }
  #camper-table.cleanup-active .camper-checkbox-col { display: table-cell; }
  .badge-green { background: #e2f4e9; color: var(--success); }
  .badge-red { background: #fbe6e3; color: var(--danger); }
  .badge-yellow { background: #fbf1dc; color: #91711f; }
  .badge-blue { background: #dce8fb; color: #1c4e91; }
  .badge-purple { background: #ece0fb; color: #5b3a91; }
  .badge-gray { background: #eee; color: var(--muted); }

  /* ---------- Product picker (purchase screen) ---------- */
  .product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .product-tile {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center;
    cursor: pointer; background: #fff; position: relative; user-select: none;
  }
  .product-tile.selected { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal) inset; background: #f0f8f7; }
  .product-tile img { width: 100%; height: 70px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; background: #f2efe9; }
  .product-tile .pname { font-weight: 600; font-size: 14px; }
  .product-tile .pprice { color: var(--teal); font-weight: 700; margin-top: 4px; }
  .product-tile .qty-badge {
    position: absolute; top: -8px; right: -8px; background: var(--orange); color: #fff;
    border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
  }
  .product-tile .remove-badge {
    position: absolute; top: -8px; left: -8px; background: var(--orange); color: #fff;
    border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  }
  .product-tile .remove-badge:hover { background: var(--teal-dark); }
  .category-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
  .category-tab {
    padding: 8px 16px; border-radius: 20px; background: #eee; font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .category-tab.active { background: var(--teal); color: #fff; }
  .category-tab-select {
    padding: 8px 16px; border-radius: 20px; background: #eee; font-size: 13px; font-weight: 600; cursor: pointer;
    border: none; color: var(--text); font-family: inherit; width: auto; flex: 0 0 auto; max-width: 160px;
  }
  .category-tab-select.active { background: var(--teal); color: #fff; }
  .category-tab-select:focus { outline: 2px solid var(--teal); }

  /* ---------- Cart / Balance strip ---------- */
  .balance-strip {
    display: flex; justify-content: space-between; align-items: center; background: var(--teal-dark);
    color: #fff; padding: 16px 20px; border-radius: var(--radius); margin-bottom: 16px;
  }
  .balance-strip .name { font-size: 18px; font-weight: 700; }
  .balance-strip .sub { font-size: 13px; opacity: 0.85; }
  .balance-strip .bal { font-size: 24px; font-weight: 700; }
  .balance-strip .bal.negative { color: #ffb4a8; }

  .cart-line { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
  .cart-line .qty-controls { display: flex; align-items: center; gap: 8px; }

  .balance-btn {
    background: none; border: none; padding: 4px 8px; margin: -4px -8px; border-radius: 6px;
    font-weight: 700; font-size: 14px; color: var(--text); cursor: pointer; font-family: inherit;
  }
  .balance-btn:hover { background: rgba(224,72,60,0.1); color: var(--teal); }
  .balance-btn.negative { color: var(--danger); }
  .balance-btn.negative:hover { background: rgba(122,31,23,0.1); }
  .balance-inline-input {
    width: 110px; padding: 4px 8px; font-weight: 700; font-size: 14px; border: 1px solid var(--teal);
    border-radius: 6px; font-family: inherit;
  }

  /* ---------- Kiosk purchase mode ---------- */
  .kiosk-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; padding-bottom: 90px; }
  .kiosk-grid .product-tile { padding: 18px 14px; }
  .kiosk-grid .product-tile img,
  .kiosk-grid .product-tile .no-image { height: 100px; }
  .kiosk-grid .product-tile .no-image { font-size: 60px !important; }
  .kiosk-grid .product-tile .pname { font-size: 16px; }
  .kiosk-grid .product-tile .pprice { font-size: 15px; }
  .kiosk-grid .category-tab { padding: 12px 22px; font-size: 15px; }

  .kiosk-cart-bar {
    position: sticky; bottom: 0; margin: 20px -28px 0; background: var(--teal-dark); color: #fff;
    display: flex; align-items: center; justify-content: space-between; padding: 16px 28px;
    box-shadow: 0 -4px 14px rgba(0,0,0,0.15); z-index: 500;
  }
  .kiosk-cart-bar .kiosk-cart-summary { display: flex; align-items: center; gap: 14px; cursor: pointer; }
  .kiosk-cart-bar .kiosk-cart-summary span { font-size: 14px; opacity: 0.85; }
  .kiosk-cart-bar .kiosk-cart-summary strong { font-size: 22px; }
  .kiosk-cart-bar button:disabled { opacity: 0.4; }
  .kiosk-checkout-search-results .cart-line:hover { background: #f7f5f0; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
  .qty-btn { width: 30px; height: 30px; border-radius: 50%; background: #eee; font-size: 16px; padding: 0; }

  /* ---------- Modal ---------- */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none;
    align-items: center; justify-content: center; z-index: 1000; padding: 20px;
  }
  .modal-overlay.active { display: flex; }
  .modal-box { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 480px; width: 100%; max-height: 85vh; overflow-y: auto; }
  .modal-box h2 { margin-top: 0; }
  .modal-actions { display: flex; gap: 10px; margin-top: 20px; }

  /* ---------- Toast ---------- */
  #toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
  .toast {
    background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2); min-width: 240px; animation: slideIn 0.2s ease;
  }
  .toast.success { background: var(--success); }
  .toast.error { background: var(--danger); }
  @keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

  /* ---------- Loading ---------- */
  .spinner {
    width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,0.4); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  #loading-overlay {
    position: fixed; inset: 0; background: rgba(250,247,242,0.75); z-index: 3000; display: none;
    align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  }
  #loading-overlay.active { display: flex; }
  #loading-overlay .spinner { width: 36px; height: 36px; border-color: rgba(31,111,107,0.25); border-top-color: var(--teal); }

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

  /* ---------- Bunk Order Forms: compact product checkbox grid ---------- */
  .bof-product-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 14px; margin: 8px 0 4px;
  }
  .bof-product-grid .checkbox-row {
    margin: 3px 0; gap: 6px; padding: 3px 4px; border-radius: 6px; align-items: flex-start;
  }
  .bof-product-grid .checkbox-row:hover { background: #f5f2ec; }
  .bof-product-grid .checkbox-row input { width: auto; margin-top: 3px; flex-shrink: 0; }
  .bof-product-grid .checkbox-row label { font-size: 13px; font-weight: 400; color: var(--text); line-height: 1.25; }
  @media (max-width: 1024px) { .bof-product-grid { grid-template-columns: repeat(2, 1fr); } }
  @media (max-width: 560px) { .bof-product-grid { grid-template-columns: 1fr; } }
  .search-bar { display: flex; gap: 10px; margin-bottom: 16px; }
  .search-bar input { flex: 1; }
  .pill-select {
    width: auto; max-width: 180px; flex: 0 0 auto; border-radius: 20px; padding: 10px 16px;
    background: #eee; border: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--text);
    cursor: pointer;
  }
  .pill-select:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
  .confidence-low { background: #fbe6e3 !important; }
  .warning-text { color: var(--danger); font-size: 12px; }

  /* ---------- PIN / Name gate ---------- */
  .canteen-pin-gate {
    display: flex; align-items: center; justify-content: center; min-height: 420px;
    background: var(--cream); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  }
  .canteen-pin-box { max-width: 340px; width: 100%; text-align: center; }
  .canteen-pin-box h2 { margin-bottom: 6px; }
  .canteen-pin-box p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
  .canteen-pin-box input {
    text-align: center; font-size: 22px; letter-spacing: 4px; margin-bottom: 14px;
  }
  .canteen-pin-error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
