:root {
  --ink: #12130f;
  --paper: #f4f2ea;
  --card: #ffffff;
  --line: #d9d7cf;
  --lime: #d8ff3e;
  --green: #1b9b62;
  --amber: #ec9c22;
  --red: #e74b3c;
  --muted: #6b6d65;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.kitchen-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 4%, rgba(216, 255, 62, 0.16), transparent 20rem),
    var(--paper);
}

.topbar {
  min-height: 92px;
  padding: 16px clamp(20px, 4vw, 56px);
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 12px 30px rgba(15, 16, 12, 0.12);
}

.brand-row,
.topbar-actions,
.summary-row,
.modal-heading,
.modal-footer,
.status-footer {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--lime);
  color: var(--ink);
  font-size: 25px;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #a9aca2;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.03em;
}

.topbar-actions {
  gap: clamp(12px, 2.6vw, 34px);
}

.topbar time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.live-indicator,
.status-footer span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 650;
}

.live-indicator i,
.status-footer i {
  width: 9px;
  height: 9px;
  background: #4de58f;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(77, 229, 143, 0.12);
}

.live-indicator.offline i {
  background: #ff776c;
  box-shadow: 0 0 0 5px rgba(255, 119, 108, 0.12);
}

.live-indicator.demo i {
  background: var(--lime);
  box-shadow: 0 0 0 5px rgba(216, 255, 62, 0.12);
}

.settings-button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid #41433c;
  border-radius: 12px;
  background: #292a25;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

.settings-button:hover,
.settings-button:focus-visible {
  border-color: var(--lime);
  outline: none;
}

.dashboard {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 24px;
}

.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 13px 16px;
  border: 1px solid #efb4ae;
  border-radius: 13px;
  background: #fff0ee;
  color: #942a20;
  font-size: 13px;
}

.error-banner strong {
  flex: 0 0 auto;
}

.error-banner.info {
  border-color: #c6d68c;
  background: #f8ffe4;
  color: #485618;
}

.summary-row {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 23px;
}

.summary-row h2 {
  margin: 0;
  font-size: clamp(29px, 4vw, 46px);
  letter-spacing: -0.055em;
  line-height: 1;
}

.oldest-pill {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
}

.oldest-pill span {
  color: var(--muted);
  font-size: 13px;
}

.oldest-pill strong {
  font-size: 17px;
}

.oldest-pill.urgent {
  border-color: #efb4ae;
  background: #fff0ee;
  color: #a82c20;
}

.order-list {
  display: grid;
  gap: 14px;
}

.order-card {
  width: 100%;
  min-height: 160px;
  display: grid;
  grid-template-columns: 180px minmax(240px, 1fr) 168px;
  padding: 0;
  border: 1px solid var(--line);
  border-left: 7px solid var(--green);
  border-radius: 20px;
  overflow: hidden;
  background: var(--card);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(24, 25, 20, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 150ms ease;
}

.order-card.waiting {
  border-left-color: var(--amber);
}

.order-card.urgent {
  border-left-color: var(--red);
  background: linear-gradient(90deg, #fff8f7, #fff 28%);
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 36px rgba(24, 25, 20, 0.1);
}

.order-card:focus-visible {
  outline: 4px solid rgba(27, 155, 98, 0.24);
  outline-offset: 2px;
}

.order-card.finishing {
  opacity: 0;
  transform: translateX(28px) scale(0.99);
}

.receipt-block,
.item-list,
.order-meta {
  padding: 25px 27px;
}

.receipt-block {
  border-right: 1px solid #ecebe6;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.receipt-block small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.receipt-block strong {
  max-width: 100%;
  margin-top: 2px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(32px, 5vw, 62px);
  letter-spacing: -0.08em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-list {
  display: grid;
  align-content: center;
  gap: 13px;
}

.item-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  align-items: start;
  gap: 6px;
}

.item-row > b {
  color: var(--green);
  font-size: 22px;
  line-height: 1.2;
}

.urgent .item-row > b {
  color: var(--red);
}

.item-row > span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.item-row strong {
  overflow-wrap: anywhere;
  font-size: clamp(19px, 2vw, 24px);
  letter-spacing: -0.02em;
}

.item-row small {
  color: #8f4b19;
  font-size: 13px;
  font-weight: 650;
}

.order-meta {
  border-left: 1px solid #ecebe6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}

.payment-badge {
  margin-bottom: 13px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.payment-badge.card {
  background: #e8f1ff;
  color: #245a9c;
}

.payment-badge.cash {
  background: #e5f7ed;
  color: #16663f;
}

.order-meta > strong {
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}

.order-meta > small {
  margin-top: 2px;
  color: var(--muted);
}

.done-hint {
  margin-top: 16px;
  color: #85877f;
  font-size: 11px;
  font-weight: 650;
}

.empty-state,
.loading-state {
  min-height: 390px;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 2px dashed #d6d4cb;
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 50%;
  background: #e2f3e9;
  color: var(--green);
  font-size: 32px;
}

.empty-state h3 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 28px;
}

.empty-state p,
.loading-state p {
  margin: 0;
}

.spinner {
  width: 38px;
  height: 38px;
  margin-bottom: 16px;
  border: 4px solid #dddcd5;
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-footer {
  justify-content: space-between;
  gap: 20px;
  padding: 18px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.status-footer span:last-child {
  text-align: right;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 13, 10, 0.72);
  backdrop-filter: blur(7px);
}

.setup-modal {
  width: min(820px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
}

.modal-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.modal-heading h2 {
  max-width: 600px;
  margin: 4px 0 8px;
  font-size: clamp(29px, 4.5vw, 45px);
  letter-spacing: -0.055em;
  line-height: 1.05;
}

.modal-heading p:last-child {
  max-width: 570px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.step-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  background: #f0efe9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.product-actions {
  display: flex;
  gap: 8px;
  margin: 28px 0 13px;
}

.product-actions button {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #faf9f5;
  color: #50524b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

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

.product-option {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.product-option > span {
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid #c8c8c1;
  border-radius: 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.product-option.selected {
  border-color: #a4c722;
  background: #f9ffe2;
  box-shadow: inset 0 0 0 1px #c5ed2c;
}

.product-option.selected > span {
  border-color: var(--lime);
  background: var(--lime);
}

.no-products {
  margin: 0;
  padding: 18px;
  border: 1px solid #e1dfd7;
  border-radius: 14px;
  background: #f8f7f2;
  color: var(--muted);
  line-height: 1.55;
}

.no-products code {
  color: var(--ink);
}

.modal-footer {
  justify-content: space-between;
  gap: 20px;
  margin-top: 29px;
  padding-top: 22px;
  border-top: 1px solid #e6e4dd;
}

.modal-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.start-button {
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 13px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
}

.start-button span {
  margin-left: 11px;
  color: var(--lime);
  font-size: 18px;
}

.start-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.undo-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 15px 14px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 16px 46px rgba(0, 0, 0, 0.24);
  font-size: 13px;
  font-weight: 650;
}

.undo-toast button {
  border: 0;
  background: transparent;
  color: var(--lime);
  cursor: pointer;
  font-weight: 750;
}

.undo-toast button:disabled {
  opacity: 0.5;
}

noscript {
  display: block;
  margin: 20px;
  padding: 15px;
  background: #fff0ee;
  color: #942a20;
}

@media (max-width: 760px) {
  .topbar {
    min-height: auto;
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .live-indicator {
    display: none;
  }

  .settings-button {
    min-height: 38px;
    font-size: 12px;
  }

  .dashboard {
    width: min(100% - 24px, 1180px);
    padding-top: 28px;
  }

  .error-banner {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .order-card {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .receipt-block,
  .item-list,
  .order-meta {
    padding: 20px;
  }

  .order-meta {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
    border-top: 1px solid #ecebe6;
    border-left: 0;
  }

  .order-meta .payment-badge,
  .order-meta > strong,
  .order-meta > small,
  .order-meta .done-hint {
    margin: 0;
  }

  .done-hint {
    margin-left: auto !important;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand-mark {
    width: 43px;
    height: 43px;
    border-radius: 12px;
  }

  .brand-row h1 {
    display: none;
  }

  .topbar time {
    font-size: 14px;
  }

  .settings-button {
    width: 42px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    position: relative;
  }

  .settings-button::after {
    content: "•••";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
  }

  .summary-row {
    align-items: flex-end;
  }

  .summary-row h2 {
    font-size: 29px;
  }

  .oldest-pill {
    display: none;
  }

  .order-card {
    grid-template-columns: 92px minmax(0, 1fr);
    border-radius: 16px;
  }

  .receipt-block,
  .item-list {
    padding: 17px 14px;
  }

  .receipt-block strong {
    font-size: 30px;
  }

  .item-row {
    grid-template-columns: 38px 1fr;
  }

  .item-row > b,
  .item-row strong {
    font-size: 18px;
  }

  .order-meta {
    padding: 10px 14px;
  }

  .done-hint {
    display: none;
  }

  .status-footer {
    justify-content: center;
  }

  .status-footer span:last-child {
    display: none;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .setup-modal {
    max-height: calc(100vh - 20px);
    padding: 24px 18px;
    border-radius: 20px;
  }

  .step-badge {
    display: none;
  }

  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .start-button {
    width: 100%;
  }

  .undo-toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
