:root {
  --ink: #17231d;
  --muted: #65736b;
  --bg: #f6f4ee;
  --paper: #fffdf7;
  --line: #ded8ca;
  --leaf: #173f2e;
  --moss: #7f926b;
  --clay: #b96845;
  --rose: #b77a83;
  --gold: #c9a553;
  --danger: #9d3f3f;
  --shadow: 0 18px 55px rgba(36, 43, 35, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.locked .app-shell {
  display: none;
}
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255,253,247,.92), rgba(223,229,214,.88)),
    #f6f4ee;
}
.auth-screen[hidden] {
  display: none;
}
.auth-card {
  width: min(430px, 100%);
  display: grid;
  gap: 12px;
  padding: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.auth-card img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
}
.auth-card h1 {
  margin: 0;
  font-size: 1.8rem;
}
.auth-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}
.auth-note {
  font-size: .86rem;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #123325;
  color: #f8f4e9;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  background: #d7d2c6;
}
.brand strong { display: block; font-size: 1.35rem; letter-spacing: 0; }
.brand span { display: block; color: #d7dfd6; font-size: .86rem; line-height: 1.45; }

.nav {
  display: grid;
  gap: 8px;
}
.nav-btn {
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 8px;
  text-align: start;
}
.nav-badge {
  min-width: 26px;
  height: 26px;
  margin-inline-start: auto;
  padding: 0 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #d76b45;
  color: #fffdf7;
  font-style: normal;
  font-size: .82rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255,253,247,.14);
}
.nav-badge[hidden] {
  display: none;
}
.nav-btn span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, .08);
}
.nav-btn.active, .nav-btn:hover {
  background: rgba(255, 253, 247, .12);
  border-color: rgba(255, 253, 247, .18);
}

.main {
  padding: 24px clamp(16px, 3vw, 42px) 48px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.topbar h1 { margin: 3px 0 0; font-size: clamp(1.65rem, 3vw, 2.4rem); }
.eyebrow {
  margin: 0;
  color: var(--clay);
  font-weight: 800;
  font-size: .8rem;
}
.top-actions, .modal-actions, .settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.view { display: none; }
.view.active { display: block; }

.hero {
  min-height: 260px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 220px;
  gap: 24px;
  align-items: center;
  padding: clamp(22px, 4vw, 46px);
  background: linear-gradient(135deg, #fffdf7 0%, #e8e2d4 55%, #c7d0bc 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero h2 {
  font-size: clamp(2rem, 5vw, 4.5rem);
  max-width: 780px;
  line-height: 1.05;
  margin: 8px 0 14px;
}
.hero p:last-child {
  margin: 0;
  max-width: 650px;
  color: #425246;
  font-size: 1.08rem;
  line-height: 1.8;
}
.hero img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  opacity: .92;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.metric, .panel, .brand-story {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.metric {
  padding: 18px;
  min-height: 112px;
}
.metric span { color: var(--muted); font-weight: 700; font-size: .85rem; }
.metric strong { display: block; margin-top: 12px; font-size: 1.8rem; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 16px;
}
.panel { padding: 18px; min-width: 0; }
.panel-head, .section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}
.section-head h2, .panel h2, .panel h3, .brand-story h3 { margin: 0; }
.section-head { margin: 0 0 16px; }

.brand-story {
  padding: 22px;
  margin-bottom: 16px;
}
.brand-story p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 14px;
}
.category-section {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}
.category-section h3 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--leaf);
}
.product-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.product-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.product-card .image {
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 190px;
  max-height: 230px;
  background: #f7f5ed;
  display: grid;
  place-items: center;
  color: var(--leaf);
  font-size: 2rem;
  font-weight: 900;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.product-card .image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.product-card .content {
  padding: 14px;
  display: grid;
  gap: 8px;
  flex: 1;
  background: var(--paper);
  position: relative;
  z-index: 1;
}
.product-card h3 { margin: 0; font-size: 1.05rem; }
.product-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: #405144;
  font-size: .82rem;
  background: #faf7ef;
}
.card-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}
.card-actions .mini-btn {
  width: 42px;
}

.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}
.cart-panel {
  position: sticky;
  top: 24px;
  align-self: start;
}
.cart-items {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}
.cart-item, .list-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #faf8f1;
}
.cart-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.totals {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.totals p, .totals label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.totals input { max-width: 120px; }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
}
th { color: var(--muted); font-size: .84rem; }
.list { display: grid; gap: 8px; }
.orders-list {
  display: grid;
  gap: 12px;
}
.order-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.order-card.edited {
  border-color: #4078c0;
  box-shadow: 0 0 0 3px rgba(64, 120, 192, .12), var(--shadow);
}
.order-head, .order-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.order-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.order-meta p {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #faf8f1;
}
.order-meta span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}
.status-badge {
  border-radius: 999px;
  padding: 5px 10px;
  background: #edf1e7;
  color: var(--leaf);
  font-weight: 900;
  font-size: .84rem;
}
.edited-badge {
  background: #e8f0fb;
  color: #225d9c;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fffefa;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(127,146,107,.18); }

.file-upload {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}
.file-upload input {
  background: #faf8f1;
}

.primary-btn, .ghost-btn, .danger-btn, .icon-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 800;
}
.primary-btn { background: var(--leaf); color: white; }
.ghost-btn, .icon-btn { background: var(--paper); color: var(--leaf); border-color: var(--line); }
.danger-btn { background: #fff2ee; color: var(--danger); border-color: #efc8c0; }
.full { width: 100%; margin-top: 8px; }
.mini-btn {
  min-width: 34px;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--leaf);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
}
.mini-btn.wide {
  width: auto;
  min-width: 78px;
  padding: 0 12px;
  font-size: .88rem;
}
.danger-mini {
  color: #9a2f2f;
  border-color: #e3c4bd;
  background: #fff6f3;
}
.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 240px;
}
.row-actions.compact-actions {
  min-width: 78px;
  justify-content: flex-end;
}

.expense-item {
  align-items: center;
}
.expense-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.stock-alert-row small {
  color: var(--clay);
  font-weight: 800;
}
.recipe-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.recipe-editor h4 {
  margin: 0;
}
.recipe-rows {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.recipe-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(110px, .8fr) 38px;
  gap: 8px;
  align-items: center;
}

.accounting-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.accounting-filter {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}
.accounting-filter label {
  display: grid;
  gap: 5px;
  min-width: 150px;
  color: var(--muted);
  font-weight: 800;
  font-size: .84rem;
}
.accounting-filter select,
.accounting-filter input {
  min-height: 42px;
  width: 170px;
}
.accounting-filter select {
  width: 150px;
}
.accounting-range {
  margin: -6px 0 12px;
  color: var(--muted);
  font-weight: 800;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(680px, calc(100vw - 24px));
  box-shadow: 0 30px 80px rgba(0,0,0,.24);
}
dialog::backdrop { background: rgba(20, 28, 22, .45); }
.modal-form {
  display: grid;
  gap: 12px;
  padding: 22px;
  background: var(--paper);
}
.modal-form h3 { margin: 0 0 4px; }
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.details-modal {
  max-height: min(82vh, 780px);
  overflow: auto;
}
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.details-grid p,
.details-totals p {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #faf8f1;
}
.details-grid .wide { grid-column: 1 / -1; }
.details-grid span,
.details-totals span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 4px;
}
.details-table table { min-width: 620px; }
.details-totals {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.edited-text strong { color: #2563a8; }
.sale-edit-items {
  display: grid;
  gap: 8px;
}
.sale-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #faf8f1;
}
.sale-edit-row span {
  font-weight: 800;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.form-row.two {
  grid-template-columns: repeat(2, 1fr);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
}
.settings-grid p { margin: 8px 0 0; color: var(--muted); line-height: 1.75; }
.contact-card { margin-top: 16px; }
.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.contact-grid p {
  margin: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf8f1;
}
.contact-grid span {
  color: var(--muted);
  font-weight: 800;
  font-size: .84rem;
}
.contact-grid strong {
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  inset-inline: 24px auto;
  bottom: 24px;
  max-width: 360px;
  background: #10281d;
  color: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

[dir="ltr"] .toast { inset-inline: auto 24px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
    gap: 12px;
  }
  .brand img {
    width: 46px;
    height: 46px;
  }
  .brand strong {
    font-size: 1.12rem;
  }
  .brand span {
    display: none;
  }
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .nav-btn {
    justify-content: flex-start;
    min-height: 44px;
    padding: 9px 10px;
    background: rgba(255, 253, 247, .06);
  }
  .nav-btn b {
    display: inline;
    font-size: .9rem;
    line-height: 1.25;
  }
  .nav-btn span {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
  }
  .hero, .split, .pos-layout, .settings-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .order-meta { grid-template-columns: 1fr 1fr; }
  .details-grid, .details-totals { grid-template-columns: 1fr; }
  .sale-edit-row { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cart-panel { position: static; }
}

@media (max-width: 620px) {
  .main { padding: 14px 12px 32px; }
  .topbar, .panel-head, .section-head { align-items: stretch; flex-direction: column; }
  .accounting-actions,
  .accounting-filter {
    align-items: stretch;
    flex-direction: column;
  }
  .accounting-filter select,
  .accounting-filter input,
  .accounting-filter label {
    width: 100%;
  }
  .row-actions {
    min-width: 260px;
  }
  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }
  .topbar .eyebrow {
    display: none;
  }
  .topbar h1 {
    font-size: 1.8rem;
  }
  .top-actions {
    display: grid;
    grid-template-columns: .7fr 1fr 1fr;
    gap: 8px;
  }
  .top-actions .ghost-btn,
  .top-actions .icon-btn {
    width: 100%;
    padding-inline: 10px;
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: 1fr; }
  .order-meta { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.two { grid-template-columns: 1fr; }
  .recipe-row { grid-template-columns: 1fr; }
  .recipe-row .mini-btn { width: 100%; }
}

/* Admin workspace: keep this side operational, not marketing-like. */
#dashboard .hero,
#catalog .brand-story {
  display: none !important;
}

#dashboard .metrics {
  margin-top: 0;
}

@media (max-width: 620px) {
  .metric {
    min-height: auto;
    padding: 14px;
  }
  .metric strong {
    font-size: 1.45rem;
    margin-top: 7px;
  }
  .panel {
    padding: 14px;
  }
  .section-head {
    gap: 10px;
  }
}
