:root {
  --ink: #17211b;
  --muted: #617067;
  --paper: #fbf8ef;
  --panel: #fffdf8;
  --line: #ded5c2;
  --accent: #b8442a;
  --accent-2: #1d6b5c;
  --accent-3: #d49b2a;
  --danger: #bf2f2f;
  --danger-bg: #fff0ec;
  --ok: #1d7b51;
  --soft: #f1ead9;
  --shadow: 0 18px 45px rgba(42, 35, 22, .12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(212, 155, 42, .18), transparent 28%),
    linear-gradient(135deg, #fbf8ef 0%, #f0eadc 45%, #f7f1e3 100%);
  font-family: "Aptos Display", "Trebuchet MS", "Gill Sans", sans-serif;
}

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

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

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

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

.sidebar {
  background: #1d271f;
  color: #fffaf0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: grid;
  gap: 3px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}

.brand strong {
  font-size: 1.25rem;
  letter-spacing: .02em;
}

.brand span {
  color: #d8cdb5;
  font-size: .88rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  color: #f8f0dd;
  text-align: left;
}

.nav button.active {
  background: #f7f0dd;
  color: #1d271f;
}

.nav button:hover:not(.active) {
  background: rgba(255, 255, 255, .08);
}

.user-panel {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #d9d0bf;
  font-size: .9rem;
}

.main {
  padding: 22px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar,
.section,
.login-card,
.modal-panel {
  background: rgba(255, 253, 248, .92);
  border: 1px solid rgba(222, 213, 194, .9);
  box-shadow: var(--shadow);
}

.topbar {
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.topbar h1,
.section h2,
.login-card h1 {
  margin: 0;
  line-height: 1.1;
}

.topbar h1 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.cloud-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff8e8;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.cloud-status.online {
  background: #e7f5eb;
  border-color: #a8d9b5;
  color: #1f6b39;
}

.cloud-status.saving,
.cloud-status.syncing {
  background: #edf4ff;
  border-color: #b9cdec;
  color: #28547c;
}

.cloud-status.conflict,
.cloud-status.offline {
  background: #fff0ed;
  border-color: #efb5ab;
  color: var(--danger);
}

.btn {
  padding: 9px 12px;
  background: var(--ink);
  color: #fffaf0;
}

.btn.secondary {
  background: var(--soft);
  color: var(--ink);
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.danger {
  background: var(--danger);
}

.section {
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.store-cards-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.kitchen-dashboard-grid {
  grid-template-columns: repeat(3, minmax(260px, 420px));
}

.variance-summary-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-bottom: 14px;
}

.metric {
  background: #fffaf0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  display: grid;
  gap: 7px;
}

.metric span {
  color: var(--muted);
  font-size: .86rem;
}

.metric strong {
  font-size: 1.45rem;
}

.metric small {
  color: var(--muted);
}

.metric-comparison strong {
  font-size: 1.22rem;
  line-height: 1.2;
}

.signed.positive {
  color: var(--ok);
}

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

.store-metric {
  width: 100%;
  text-align: left;
  color: var(--ink);
  align-content: start;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.store-card-title {
  color: var(--ink);
  font-size: .9rem;
  font-weight: 700;
}

.store-card-primary {
  display: grid;
  gap: 2px;
  margin-top: 2px;
  margin-bottom: 2px;
}

.store-card-primary span {
  color: var(--muted);
  font-size: .82rem;
}

.store-card-primary strong {
  color: var(--ink);
  font-size: 1.48rem;
  line-height: 1.05;
}

.store-card-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  border-top: 1px solid rgba(222, 213, 194, .72);
  padding-top: 6px;
  font-size: .86rem;
}

.store-card-line span {
  color: var(--muted);
}

.store-card-line b {
  font-size: .92rem;
  text-align: right;
}

.store-card-line.diff {
  font-weight: 700;
}

.dashboard-match-head span {
  color: var(--muted);
  font-size: .82rem;
}

.dashboard-match-list {
  display: grid;
  gap: 6px;
}

.dashboard-match-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(222, 213, 194, .72);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: .84rem;
  font-weight: 800;
}

.dashboard-match-row span {
  color: var(--ink);
}

.dashboard-match-row b {
  color: var(--ink);
}

.dashboard-match-row.matched {
  background: #e6f2eb;
  border-color: rgba(42, 126, 83, .28);
  color: var(--ok);
}

.dashboard-match-row.mismatch {
  background: var(--danger-bg);
  border-color: rgba(196, 52, 52, .28);
  color: var(--danger);
}

.dashboard-match-row.pending,
.pending-row {
  background: #fff7df;
  border-color: rgba(212, 155, 42, .35);
  color: #8a631b;
  font-weight: 800;
}

.store-metric:hover,
.store-metric.active {
  border-color: var(--accent-2);
  background: #f0f8f4;
  transform: translateY(-1px);
}

.store-metric.active {
  box-shadow: inset 0 0 0 2px rgba(29, 107, 92, .18);
}

.kitchen-dashboard-card {
  cursor: default;
}

.kitchen-dashboard-card:hover {
  transform: none;
}

.kitchen-analytics {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.kitchen-total-cards {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.kitchen-total-cards .metric {
  border-color: #d7bf8d;
  background: #fff3dc;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.week-jump {
  display: flex;
  gap: 8px;
  align-items: end;
}

.week-jump .btn {
  min-height: 40px;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 150px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: .82rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--ink);
  padding: 8px 10px;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.sales-report-section {
  display: grid;
  gap: 14px;
}

.sales-report-form {
  display: grid;
  gap: 14px;
}

.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: 10px;
}

.sales-card,
.sales-report-output {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.sales-report-output.compact {
  gap: 10px;
  padding: 12px;
}

.sales-report-output.compact .sales-meta-grid,
.sales-report-output.compact .sales-kpi-grid,
.sales-report-output.compact .sales-cash-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.sales-report-output.compact .sales-meta-grid > div,
.sales-report-output.compact .sales-cash-grid > div,
.sales-report-output.compact .metric {
  min-height: auto;
  padding: 9px;
}

.sales-report-output.compact .metric strong {
  font-size: 1.25rem;
}

.sales-report-output.compact table {
  font-size: .86rem;
}

.sales-report-output.compact th,
.sales-report-output.compact td {
  padding: 7px 8px;
}

.sales-card h3 {
  margin: 0;
  font-size: 1rem;
}

.sales-report-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.sales-report-title h2 {
  margin: 0;
}

.sales-report-title span {
  border-radius: 999px;
  background: #e4f1e9;
  color: var(--green);
  font-weight: 800;
  padding: 5px 10px;
}

.sales-meta-grid > div,
.sales-cash-grid > div {
  border: 1px solid #eadfc9;
  border-radius: var(--radius);
  background: #fbf5e7;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.sales-meta-grid span,
.sales-cash-grid span {
  color: var(--muted);
  font-size: .82rem;
}

.sales-save-tip {
  margin: 0;
  border-left: 4px solid var(--accent);
  background: #fff3dc;
  padding: 12px;
  font-weight: 900;
  color: var(--accent);
}

.sales-report-image-preview {
  max-height: min(68vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6efe0;
  padding: 8px;
}

.sales-report-image-preview img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fbf8ef;
}

.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);
  background: #fffdf8;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid #eadfc9;
  border-radius: var(--radius);
  background: #fbf5e7;
  font-weight: 800;
}

.check-option input {
  width: 16px;
  height: 16px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 820px;
}

.desktop-table table {
  min-width: 980px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #efe4cf;
  font-size: .82rem;
  color: #4c463a;
}

.forecast-date-head {
  display: grid;
  gap: 2px;
  min-width: 92px;
  text-align: center;
}

.forecast-date-head strong {
  color: var(--accent);
  font-size: .96rem;
  line-height: 1.1;
}

.forecast-date-head span {
  color: #4c463a;
  font-size: .78rem;
  line-height: 1.1;
}

.weekly-total-head div,
.weekly-total-cell {
  display: grid;
  gap: 3px;
}

.weekly-total-head strong,
.weekly-total-cell strong {
  color: var(--green);
  font-size: 1.02rem;
}

.weekly-total-head span,
.weekly-total-cell span {
  color: var(--accent);
  font-weight: 800;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fff8e8;
}

tfoot th,
tfoot td {
  position: static;
  background: #f5ead2;
  border-top: 2px solid #d7bf8d;
  color: #201b13;
  font-weight: 800;
}

tfoot td {
  text-align: center;
}

.forecast-summary-row.amount-row th,
.forecast-summary-row.amount-row td {
  background: #fff3dc;
  color: var(--accent);
}

.forecast-summary-card {
  border-color: #d7bf8d;
  background: #fff3dc;
}

.forecast-summary-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  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);
}

.forecast-product-total span {
  color: var(--muted);
}

.forecast-product-total b {
  color: var(--green);
}

.forecast-product-total strong {
  color: var(--accent);
}

.num-input {
  width: 78px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  text-align: right;
  background: #fffdf8;
}

.plan-input-wrap {
  display: inline-grid;
  gap: 4px;
  justify-items: center;
}

.plan-input-wrap.pending {
  min-width: 86px;
}

.plan-input.pending {
  border-color: var(--danger);
  background: #fff5f0;
  color: var(--danger);
  font-weight: 800;
}

.pending-plan-change {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  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(--danger);
  font-weight: 900;
}

.locked {
  background: #f0ece2;
}

.shortfall {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

.match-ok {
  background: #eef8f2;
  color: var(--ok);
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: .8rem;
}

.pill.ok {
  background: #e6f2eb;
  color: var(--ok);
}

.pill.warn {
  background: #fff0ec;
  color: var(--danger);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tabs button {
  padding: 8px 11px;
  background: #f0e5d1;
  color: var(--ink);
}

.tabs button.active {
  background: var(--accent-2);
  color: #fff;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(980px, 100%);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-columns: .9fr 1.1fr;
}

.login-hero {
  padding: 34px;
  background:
    linear-gradient(150deg, rgba(29, 39, 31, .94), rgba(35, 68, 57, .92)),
    repeating-linear-gradient(45deg, transparent 0 16px, rgba(255, 255, 255, .06) 16px 17px);
  color: #fff7e8;
  display: grid;
  align-content: space-between;
  min-height: 520px;
}

.login-hero h1 {
  font-size: clamp(2rem, 5vw, 4.5rem);
  max-width: 8ch;
}

.login-form {
  padding: 34px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.role-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.role-switch button {
  background: #f0e5d1;
  color: var(--ink);
  padding: 10px 8px;
}

.role-switch button.active {
  background: var(--accent);
  color: #fff;
}

.notice {
  border-left: 4px solid var(--accent-3);
  background: #fff7e5;
  padding: 10px 12px;
  color: #5b4420;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.kitchen-route {
  border-left-color: var(--accent);
  background: #fff0cf;
  color: #0f251b;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
}

.kitchen-store-head {
  display: grid;
  gap: 3px;
  justify-items: center;
  line-height: 1.1;
  min-width: 54px;
}

.kitchen-store-head strong {
  color: var(--accent);
  font-size: 1.08rem;
  letter-spacing: .04em;
}

.kitchen-store-head span {
  color: var(--ink);
  font-weight: 900;
  white-space: nowrap;
}

.kitchen-store-head b {
  color: #c13d27;
  font-size: 1.18rem;
}

.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-date-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  border-left-color: var(--accent);
  background: #fff2d8;
  color: #13291f;
  font-weight: 800;
}

.actual-store-name,
.actual-date-only {
  font-size: 1.15rem;
}

.actual-weekday {
  color: var(--accent);
  font-size: 1.38rem;
  line-height: 1;
}

.category-mix {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
}

.category-mix-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.category-mix-head strong {
  font-size: 1.02rem;
}

.category-mix-head span {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 14px;
  color: var(--muted);
  font-weight: 700;
}

.category-mix-head span b {
  font-weight: 800;
}

.category-stack {
  display: flex;
  width: 100%;
  height: 24px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe4cf;
}

.category-stack span {
  min-width: 2px;
}

.category-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
}

.category-legend-item {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(222, 213, 194, .72);
  border-radius: 6px;
  background: #fff8e8;
  font-size: .86rem;
}

.category-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.category-legend-item span {
  flex: 1 1 130px;
  min-width: max-content;
  white-space: normal;
}

.category-legend-item em {
  color: var(--muted);
  font-style: normal;
}

.category-legend-item b {
  white-space: nowrap;
}

.category-legend-item strong {
  color: var(--accent);
  margin-left: auto;
  font-size: .86rem;
  text-align: right;
  white-space: nowrap;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(23, 33, 27, .45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  border-radius: var(--radius);
  padding: 16px;
}

.modal-panel form {
  display: grid;
  gap: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.audit-list {
  display: grid;
  gap: 8px;
}

.audit-item {
  border: 1px solid var(--line);
  background: #fffaf0;
  border-radius: var(--radius);
  padding: 10px;
}

.mobile-cards {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: #fffaf0;
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 80;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    padding-bottom: 8px;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav button {
    justify-content: center;
    padding: 9px 6px;
    font-size: .86rem;
  }

  .user-panel {
    display: none;
  }

  .main {
    padding: 12px;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .actions {
    justify-content: start;
  }

  .grid.cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-legend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: 240px;
  }
}

@media (max-width: 640px) {
  .grid.cards,
  .two-col,
  .role-switch {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
  }

  .sales-report-title {
    display: grid;
  }

  .field {
    min-width: 100%;
  }

  .desktop-table {
    display: none;
  }

  .mobile-cards {
    display: grid;
    gap: 10px;
  }

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

  .item-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fffdf8;
    padding: 11px;
    display: grid;
    gap: 9px;
  }

  .item-card .row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
  }

  .num-input {
    width: 100%;
  }

  .login-form,
  .login-hero {
    padding: 22px;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 10mm;
  }

  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .topbar .actions,
  .toolbar,
  .tabs,
  .kitchen-route,
  .kitchen-analytics,
  .no-print,
  .toast {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .section,
  .topbar {
    box-shadow: none;
    border: 0;
  }

  table {
    min-width: 0;
    font-size: 11px;
  }

  .kitchen-table-wrap {
    border: 0;
  }

  th {
    position: static;
  }

  .kitchen-store-head strong {
    color: #000;
  }

  .kitchen-store-head b {
    color: #000;
    font-weight: 900;
  }
}
