/* =========================================================================
   PAWA BAKERY · Production & Sales Management System
   UI stylesheet — refined, data-first, fully responsive (desktop + mobile)
   ========================================================================= */

:root {
  /* Brand palette — warm bakery identity, cleaned up */
  --ink: #1c2620;
  --ink-soft: #3a463e;
  --muted: #6c7a70;
  --muted-2: #8c9890;

  --paper: #f7f3ea;
  --panel: #ffffff;
  --panel-2: #fbf7ee;
  --line: #e6ddcc;
  --line-soft: #efe8da;

  --accent: #c0492c;      /* terracotta */
  --accent-ink: #8f331d;
  --accent-soft: #fbeee8;
  --green: #1d7a55;       /* primary positive / kitchen-forest */
  --green-soft: #e7f3ec;
  --gold: #cf9a2c;
  --gold-soft: #fbf2dc;
  --blue: #3f6fb0;

  --ok: #1d7a55;
  --danger: #c4322f;
  --danger-bg: #fdeceb;
  --warn: #a9781a;
  --warn-bg: #fbf2da;

  /* Surfaces & elevation */
  --shell: #1e2a22;       /* sidebar / dark surface */
  --shell-ink: #f3ecdb;
  --shadow-sm: 0 1px 2px rgba(28, 38, 32, .06), 0 1px 3px rgba(28, 38, 32, .05);
  --shadow: 0 6px 18px rgba(28, 38, 32, .08), 0 1px 3px rgba(28, 38, 32, .05);
  --shadow-lg: 0 24px 60px rgba(28, 38, 32, .18);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 30px;

  --font: "Segoe UI", "Helvetica Neue", "PingFang SC", "Microsoft YaHei",
          "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  --num: "Segoe UI", "SF Mono", ui-monospace, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 12% -8%, rgba(207, 154, 44, .10), transparent 60%),
    radial-gradient(900px 520px at 98% 0%, rgba(192, 73, 44, .07), transparent 55%),
    linear-gradient(170deg, #f8f4ec 0%, #f1ebdd 100%);
  background-attachment: fixed;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

button {
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 42px;
}

button:disabled, input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed;
  opacity: .5;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* numbers read better tabular almost everywhere */
strong, b, td, th, .metric, input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   App shell
   ========================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background:
    linear-gradient(180deg, #243228 0%, #1b2620 100%);
  color: var(--shell-ink);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  display: grid;
  gap: 2px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.brand strong {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.brand span {
  color: #cdbf9f;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.nav { display: grid; gap: 4px; }
.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: transparent;
  color: #e7dfcb;
  text-align: left;
  font-size: .95rem;
  font-weight: 600;
  border-radius: 10px;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav button:hover:not(.active) { background: rgba(255, 255, 255, .08); }
.nav button.active {
  background: rgba(247, 240, 221, .96);
  color: #1c2620;
  font-weight: 700;
}
.nav button.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 8px; bottom: 8px;
  width: 4px; border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.user-panel {
  margin-top: auto;
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  font-size: .85rem;
}
.user-panel > span:first-child {
  color: #b8ac8e;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.user-panel strong { font-size: .95rem; color: #fff; }
.user-panel > span:last-child { color: #c9bd9f; }

.main {
  padding: 20px 22px 40px;
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

/* =========================================================================
   Topbar
   ========================================================================= */
.topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.topbar h1 {
  margin: 0;
  font-size: clamp(1.25rem, 1.6vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.topbar .meta { margin-top: 2px; }

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.topbar .actions select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: 6px 10px;
}

/* hamburger — hidden on desktop */
.menu-toggle { display: none; }

/* sync status chip */
.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.sync-chip .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}
.sync-chip.ok { color: var(--green); border-color: rgba(29,122,85,.3); background: var(--green-soft); }
.sync-chip.ok .dot { background: var(--green); }
.sync-chip.saving { color: var(--gold); border-color: rgba(207,154,44,.35); background: var(--gold-soft); }
.sync-chip.saving .dot { background: var(--gold); animation: pulse 1s infinite; }
.sync-chip.offline { color: var(--accent); border-color: rgba(192,73,44,.3); background: var(--accent-soft); }
.sync-chip.offline .dot { background: var(--accent); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
  padding: 10px 16px;
  background: var(--ink);
  color: #fdfaf3;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.secondary { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.secondary:hover:not(:disabled) { background: #f3ecdd; filter: none; }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); filter: none; }
.btn.danger { background: var(--accent); }

/* =========================================================================
   Sections & layout primitives
   ========================================================================= */
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  padding: 18px;
}
.section + .section { margin-top: 0; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 { margin: 0; font-size: 1.12rem; font-weight: 800; letter-spacing: -.01em; }
.section h2 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.store-cards-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.kitchen-dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.variance-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }

/* =========================================================================
   Metric cards
   ========================================================================= */
.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  align-content: start;
}
.metric > span { color: var(--muted); font-size: .82rem; font-weight: 600; }
.metric strong { font-size: 1.5rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.metric small { color: var(--muted-2); font-size: .76rem; }

.signed.positive { color: var(--green); }
.signed.negative { color: var(--danger); }

/* clickable cards */
.store-metric {
  width: 100%;
  text-align: left;
  color: var(--ink);
  min-height: 0;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
.store-metric:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--green); }
.store-metric.active {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 2px rgba(29, 122, 85, .25);
}

.store-card-title { font-size: .9rem; font-weight: 700; color: var(--ink); }
.store-card-primary { display: grid; gap: 1px; margin: 4px 0 2px; }
.store-card-primary span { color: var(--muted); font-size: .78rem; }
.store-card-primary strong { font-size: 1.55rem; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }

.store-card-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  border-top: 1px solid var(--line-soft);
  padding-top: 7px;
  margin-top: 5px;
  font-size: .84rem;
}
.store-card-line span { color: var(--muted); }
.store-card-line b { font-weight: 700; text-align: right; }
.store-card-line.diff b { font-size: .95rem; }

/* kitchen hero card */
.kitchen-dashboard-card {
  cursor: default;
  background: linear-gradient(160deg, #fdf4e2, #fbf7ee);
  border-color: #e8d4a6;
}
.kitchen-dashboard-card:hover { transform: none; box-shadow: none; border-color: #e8d4a6; }
.kitchen-dashboard-card .store-card-primary strong { color: var(--accent-ink); }

.dashboard-kitchen-flow-card,
.dashboard-sales-production-card { cursor: pointer; }

/* sales-vs-production mini list inside card */
.dashboard-match-head span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.dashboard-match-list { display: grid; gap: 5px; margin-top: 4px; }
.dashboard-match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: .82rem;
  font-weight: 700;
}
.dashboard-match-row span { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-match-row.matched { background: var(--green-soft); border-color: rgba(29,122,85,.25); color: var(--green); }
.dashboard-match-row.mismatch { background: var(--danger-bg); border-color: rgba(196,52,52,.25); color: var(--danger); }
.dashboard-match-row.pending,
.pending-row { background: var(--warn-bg); border-color: rgba(169,120,26,.32); color: var(--warn); }

/* =========================================================================
   Kitchen analytics block
   ========================================================================= */
.kitchen-analytics { display: grid; gap: 12px; margin: 14px 0; }
.kitchen-total-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kitchen-total-cards .metric { border-color: #e8d4a6; background: var(--gold-soft); }
.kitchen-total-cards .metric strong { color: var(--accent-ink); }

/* =========================================================================
   Toolbar & form fields
   ========================================================================= */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.week-jump { display: flex; gap: 8px; align-items: flex-end; }
.week-jump .btn { white-space: nowrap; }

.field { display: grid; gap: 5px; min-width: 150px; }
.field-wide { grid-column: 1 / -1; }
.field > span, .field > label { color: var(--muted); font-size: .78rem; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 9px 11px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(29, 122, 85, .12);
  outline: none;
}
.field textarea { min-height: 84px; resize: vertical; }

/* =========================================================================
   Sales report
   ========================================================================= */
.sales-report-section { display: grid; gap: 16px; }
.sales-report-form { display: grid; gap: 16px; }
.sales-field-grid,
.sales-category-grid,
.sales-kpi-grid,
.sales-cash-grid,
.sales-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.sales-card, .sales-report-output {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 16px;
  display: grid;
  gap: 14px;
}
.sales-card h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.sales-report-title {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  border-bottom: 1px solid var(--line); padding-bottom: 12px;
}
.sales-report-title h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.sales-report-title span {
  border-radius: 999px; background: var(--green-soft); color: var(--green);
  font-weight: 700; padding: 5px 12px; font-size: .82rem;
}
.sales-kpi-grid .metric { background: var(--panel); }
.sales-meta-grid > div, .sales-cash-grid > div {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--panel); padding: 11px 12px; display: grid; gap: 3px;
}
.sales-meta-grid span, .sales-cash-grid span { color: var(--muted); font-size: .78rem; }
.sales-meta-grid strong, .sales-cash-grid strong { font-size: 1.02rem; font-weight: 700; }
.sales-save-tip {
  margin: 0; border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: 12px 14px; font-weight: 700; color: var(--accent-ink); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* checkbox grid (staff stores) */
.check-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--panel);
}
.check-option {
  display: flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 7px 11px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--panel-2); font-weight: 600; cursor: pointer;
}
.check-option:has(input:checked) { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.check-option input { width: 17px; height: 17px; accent-color: var(--green); }

/* =========================================================================
   Tables
   ========================================================================= */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; min-width: 760px; }
.desktop-table table { min-width: 960px; }

th, td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}
th {
  position: sticky; top: 0; z-index: 1;
  background: #f1e9d8;
  font-size: .76rem; font-weight: 700;
  color: #5a5346; text-transform: uppercase; letter-spacing: .03em;
  white-space: nowrap;
}
tbody tr { transition: background .1s ease; }
tbody tr:nth-child(even) { background: rgba(247, 243, 234, .5); }
tbody tr:hover { background: var(--gold-soft); }

tfoot th, tfoot td {
  position: static;
  background: #f3ead4;
  border-top: 2px solid #e3cf9f;
  color: var(--ink);
  font-weight: 800;
}
tfoot td { text-align: center; }
.forecast-summary-row.amount-row th,
.forecast-summary-row.amount-row td { background: var(--gold-soft); color: var(--accent-ink); }

/* forecast date head */
.forecast-date-head { display: grid; gap: 1px; min-width: 86px; text-align: center; }
.forecast-date-head strong { color: var(--accent); font-size: .92rem; line-height: 1.1; text-transform: none; }
.forecast-date-head span { color: #5a5346; font-size: .74rem; font-weight: 600; }

.weekly-total-head div, .weekly-total-cell { display: grid; gap: 2px; }
.weekly-total-head strong, .weekly-total-cell strong { color: var(--green); font-size: 1rem; }
.weekly-total-head span, .weekly-total-cell span { color: var(--accent); font-weight: 700; white-space: nowrap; font-size: .82rem; }

/* numeric inputs in tables */
.num-input {
  width: 76px; min-height: 38px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 8px; text-align: right; background: var(--panel);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.num-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,122,85,.12); outline: none; }

.plan-input-wrap { display: inline-grid; gap: 4px; justify-items: center; }
.plan-input-wrap.pending { min-width: 86px; }
.plan-input.pending { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pending-plan-change { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; line-height: 1; white-space: nowrap; }
.pending-plan-change span { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.pending-plan-change strong { color: var(--accent); font-weight: 800; }

.locked { background: #f0ece2 !important; }
tr.shortfall, .shortfall { background: var(--danger-bg) !important; color: var(--danger); font-weight: 600; }
tr.match-ok, .match-ok { background: var(--green-soft) !important; color: var(--green); font-weight: 600; }

/* =========================================================================
   Pills, tabs, notices
   ========================================================================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; background: var(--panel-2);
  color: var(--ink-soft); font-size: .78rem; font-weight: 700; border: 1px solid var(--line-soft);
}
.pill.ok { background: var(--green-soft); color: var(--green); border-color: rgba(29,122,85,.22); }
.pill.warn { background: var(--danger-bg); color: var(--danger); border-color: rgba(196,52,52,.22); }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs button {
  padding: 9px 16px; background: var(--panel-2); color: var(--ink-soft);
  border: 1px solid var(--line); font-weight: 600; border-radius: 999px;
}
.tabs button.active { background: var(--green); color: #fff; border-color: var(--green); }

.notice {
  border-left: 4px solid var(--gold);
  background: var(--gold-soft);
  padding: 11px 14px; color: #6b521c;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .9rem;
}
.kitchen-route {
  border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink);
  font-size: 1.1rem; font-weight: 800; line-height: 1.3;
}

/* =========================================================================
   Kitchen table heads & alignment
   ========================================================================= */
.kitchen-store-head { display: grid; gap: 2px; justify-items: center; line-height: 1.1; min-width: 52px; }
.kitchen-store-head strong { color: var(--accent); font-size: 1rem; letter-spacing: .03em; text-transform: none; }
.kitchen-store-head span { color: var(--ink); font-weight: 800; white-space: nowrap; }
.kitchen-store-head b { color: var(--accent); font-size: 1.1rem; }
.kitchen-table th:nth-child(n+3), .kitchen-table td:nth-child(n+3) { text-align: center; }
.kitchen-table th:last-child, .kitchen-table td:last-child { text-align: right; }
.kitchen-table th:nth-last-child(2), .kitchen-table td:nth-last-child(2) { text-align: center; }

/* actual production banner */
.actual-date-banner {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px;
  border-left-color: var(--accent); background: var(--accent-soft); color: var(--ink);
  font-weight: 700;
}
.actual-store-name, .actual-date-only { font-size: 1.1rem; }
.actual-weekday { color: var(--accent); font-size: 1.3rem; line-height: 1; }

/* =========================================================================
   Category mix "chart"
   ========================================================================= */
.category-mix {
  display: grid; gap: 12px; margin: 14px 0; padding: 16px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2);
}
.category-mix-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.category-mix-head strong { font-size: 1rem; font-weight: 700; }
.category-mix-head span { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 16px; color: var(--muted); font-weight: 600; font-size: .85rem; }
.category-mix-head span b { font-weight: 800; color: var(--ink); }

.category-stack {
  display: flex; width: 100%; height: 30px; overflow: hidden;
  border-radius: 999px; background: #ece3d0;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.category-stack span { min-width: 3px; transition: width .3s ease; position: relative; }
.category-stack span + span { box-shadow: inset 1px 0 0 rgba(255,255,255,.5); }

.category-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.category-legend-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto;
  column-gap: 8px; row-gap: 1px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--panel); font-size: .85rem;
}
.category-legend-item i { width: 11px; height: 11px; border-radius: 3px; grid-row: 1 / 3; }
.category-legend-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.category-legend-item b { grid-column: 2; color: var(--ink-soft); font-weight: 700; }
.category-legend-item strong { grid-column: 2; color: var(--accent); font-size: .8rem; font-weight: 700; }

/* =========================================================================
   Modal, audit, misc
   ========================================================================= */
.modal {
  position: fixed; inset: 0; background: rgba(23, 33, 27, .5);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 16px; z-index: 60;
}
.modal-panel {
  width: min(680px, 100%); max-height: min(760px, 92vh); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg); padding: 22px;
}
.modal-panel h2 { margin: 0 0 14px; }
.modal-panel form { display: grid; gap: 14px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.modal-panel .actions { justify-content: flex-end; }

.audit-list { display: grid; gap: 8px; }
.audit-item {
  border: 1px solid var(--line-soft); background: var(--panel-2);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.audit-item strong { font-size: .92rem; }
.audit-item .meta { margin: 2px 0 4px; font-size: .8rem; }

.mobile-cards { display: none; }
.item-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 13px; display: grid; gap: 10px; }
.item-card .row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.forecast-summary-card { border-color: #e8d4a6; background: var(--gold-soft); }
.forecast-summary-card-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.forecast-summary-card-row b { color: var(--accent); }
.forecast-product-total { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.forecast-product-total span { color: var(--muted); }
.forecast-product-total b { color: var(--green); }
.forecast-product-total strong { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fdfaf3; padding: 12px 20px;
  border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 90;
  font-weight: 600; font-size: .9rem; max-width: 90vw;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* =========================================================================
   Login
   ========================================================================= */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(960px, 100%); border-radius: var(--radius-lg); overflow: hidden;
  display: grid; grid-template-columns: .85fr 1.15fr;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.login-hero {
  padding: 40px;
  background:
    linear-gradient(155deg, rgba(30, 42, 34, .96), rgba(36, 70, 58, .94)),
    repeating-linear-gradient(45deg, transparent 0 18px, rgba(255,255,255,.05) 18px 19px);
  color: #fdf6e7; display: grid; align-content: space-between; min-height: 480px;
}
.login-hero h1 { font-size: clamp(2.2rem, 5vw, 4rem); margin: 0; max-width: 9ch; font-weight: 800; letter-spacing: -.01em; }
.login-hero p { color: #d6cbb0; line-height: 1.6; }
.login-form { padding: 38px; display: grid; align-content: center; gap: 16px; }
.login-form h1 { margin: 0; font-size: 1.5rem; }
.role-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-switch button { background: var(--panel-2); color: var(--ink-soft); border: 1px solid var(--line); padding: 11px 8px; font-weight: 700; border-radius: var(--radius-sm); }
.role-switch button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.login-form .toolbar { background: transparent; border: 0; padding: 0; margin: 0; align-items: center; gap: 12px; }

/* =========================================================================
   Mobile drawer backdrop
   ========================================================================= */
.scrim {
  position: fixed; inset: 0; background: rgba(20, 28, 23, .5);
  z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s ease;
}

/* =========================================================================
   Responsive — tablet
   ========================================================================= */
@media (max-width: 1080px) {
  .grid.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kitchen-dashboard-grid { grid-template-columns: 1fr; }
  .category-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================================
   Responsive — mobile (off-canvas sidebar)
   ========================================================================= */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 80vw; max-width: 300px; height: 100vh;
    transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .app-shell.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .user-panel { margin-top: 20px; }

  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; min-height: 44px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--panel-2); flex: none;
  }
  .menu-toggle span,
  .menu-toggle span::before,
  .menu-toggle span::after {
    content: ""; display: block; width: 18px; height: 2px;
    background: var(--ink); border-radius: 2px; position: relative;
  }
  .menu-toggle span::before { position: absolute; top: -6px; }
  .menu-toggle span::after { position: absolute; top: 6px; }

  .main { padding: 14px; gap: 14px; }
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 1.2rem; }
  .topbar .meta { display: none; }
  .topbar > div:first-child { display: flex; align-items: center; gap: 12px; }

  .section { padding: 14px; }
  .toolbar { padding: 12px; }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .grid.cards, .two-col, .role-switch { grid-template-columns: 1fr; }
  .store-cards-grid { grid-template-columns: 1fr 1fr; }
  .kitchen-total-cards { grid-template-columns: 1fr 1fr; }
  .toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  .week-jump { grid-column: 1 / -1; }
  .toolbar .btn, .toolbar > .field:has(#search-filter) { grid-column: 1 / -1; }
  .field { min-width: 0; }
  .sales-report-title { display: grid; }

  .category-legend { grid-template-columns: 1fr; }

  /* swap tables for stacked cards */
  .desktop-table { display: none; }
  .mobile-cards { display: grid; gap: 10px; }
  .num-input { width: 100%; }

  .login-card { grid-template-columns: 1fr; }
  .login-hero { min-height: 180px; padding: 26px; }
  .login-form { padding: 26px; }

  .actions { justify-content: stretch; }
  .actions .btn { flex: 1; }
}

@media (max-width: 380px) {
  .store-cards-grid, .kitchen-total-cards { grid-template-columns: 1fr; }
}

/* =========================================================================
   Print
   ========================================================================= */
@media print {
  @page { size: landscape; margin: 10mm; }
  body { background: #fff; }
  .sidebar, .topbar, .toolbar, .tabs, .kitchen-route, .kitchen-analytics,
  .no-print, .toast, .scrim, .menu-toggle { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .section { box-shadow: none; border: 0; padding: 0; }
  table { min-width: 0; font-size: 11px; }
  th { position: static; }
  tbody tr:nth-child(even) { background: #fff; }
}
