:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4f0;
  --ink: #17201b;
  --muted: #647069;
  --line: #dce5df;
  --green: #1f8a4c;
  --green-dark: #116634;
  --red: #cf3b2e;
  --red-dark: #a52b21;
  --amber: #b46810;
  --amber-bg: #fff3d7;
  --blue: #2563eb;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

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

.auth-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px 14px;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 22px 18px 18px;
  width: 100%;
}

.auth-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.auth-title {
  font-size: 28px;
  line-height: 1.05;
  margin: 0;
}

.auth-status {
  color: var(--muted);
  font-size: 14px;
  margin: 10px 0 0;
}

.auth-status.is-error {
  color: var(--red-dark);
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.auth-button {
  margin-top: 4px;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  margin: 0 auto;
  max-width: 720px;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 16px 14px 104px;
}

.topbar {
  align-items: center;
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 14px;
}

.topbar > div,
.topbar-actions {
  min-width: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  max-width: 100%;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.session-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  max-width: 128px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-dot {
  border-radius: 50%;
  display: inline-block;
  height: 12px;
  width: 12px;
}

.connection-dot.is-ok {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.connection-dot.is-error {
  background: #ef4444;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.14);
}

.connection-dot.is-idle {
  background: #9ca3af;
}

.icon-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.banner {
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #7f1d1d;
  font-size: 14px;
  margin: 0 0 12px;
  padding: 10px 12px;
}

.is-hidden {
  display: none !important;
}

.tabs {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  min-height: 38px;
  padding: 8px 6px;
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.08);
}

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

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

.order-row {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  max-width: 100%;
  min-height: 78px;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.order-row.is-pending {
  border-color: #9bd8b4;
  box-shadow: inset 4px 0 0 var(--green);
}

.order-row.is-missed,
.order-row.is-overdue {
  border-color: #f4bf76;
  box-shadow: inset 4px 0 0 var(--amber);
}

.context-icon {
  align-items: center;
  background: var(--surface-soft);
  border-radius: 8px;
  display: flex;
  font-size: 21px;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.order-main {
  min-width: 0;
}

.order-number-badge {
  align-items: center;
  background: #fff3d7;
  border-radius: 999px;
  color: var(--amber);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 4px;
  padding: 4px 8px;
  width: fit-content;
}

.order-title {
  font-size: 16px;
  font-weight: 800;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.order-side {
  display: grid;
  gap: 6px;
  justify-items: end;
  min-width: 0;
}

.amount {
  font-weight: 800;
}

.timer {
  border-radius: 999px;
  background: #e8f7ee;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  min-width: 58px;
  padding: 4px 7px;
  text-align: center;
}

.timer.is-overdue,
.status-chip.is-missed {
  background: var(--amber-bg);
  color: var(--amber);
}

.detail-view {
  background: var(--bg);
  inset: 0;
  max-width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: fixed;
  z-index: 20;
}

.detail-inner {
  margin: 0 auto;
  max-width: 720px;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 14px 14px 172px;
}

.detail-header {
  align-items: center;
  display: flex;
  min-width: 0;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-header > div {
  min-width: 0;
}

.detail-header .muted {
  overflow-wrap: anywhere;
  white-space: normal;
}

.back-button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 42px;
  width: 42px;
}

.detail-total {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  margin: 12px 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
  max-width: 100%;
}

.chip,
.status-chip {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  text-transform: uppercase;
}

.chip {
  background: var(--surface-soft);
  color: var(--ink);
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.status-banner {
  border-radius: 8px;
  font-weight: 800;
  margin: 12px 0;
  padding: 12px;
}

.status-banner.pending,
.status-banner.accepted,
.status-banner.ready {
  background: #e8f7ee;
  color: var(--green-dark);
}

.status-banner.rejected,
.status-banner.cancelled {
  background: #fee2e2;
  color: var(--red-dark);
}

.status-banner.completed {
  background: #e0edff;
  color: #1d4ed8;
}

.status-banner.missed {
  background: var(--amber-bg);
  color: var(--amber);
}

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
  max-width: 100%;
  overflow-x: hidden;
  padding: 14px;
}

.section h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

.kv {
  display: grid;
  gap: 8px;
  max-width: 100%;
}

.kv-row,
.total-row,
.item-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-width: 0;
}

.kv-row,
.total-row {
  align-items: start;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.kv-row span:first-child,
.total-row span:first-child {
  color: var(--muted);
}

.kv-row strong,
.total-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: right;
}

.item-row {
  align-items: flex-start;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  max-width: 100%;
  padding: 14px 0;
}

.item-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.item-qty {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
  padding-top: 1px;
}

.item-body {
  min-width: 0;
}

.item-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.item-options {
  display: grid;
  gap: 5px;
  margin-top: 7px;
}

.item-option-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.item-customer-note {
  background: #fff7e5;
  border-left: 3px solid var(--amber);
  color: #6c4b0a;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 8px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  padding: 8px 10px;
}

.item-amount {
  font-size: 15px;
  padding-top: 1px;
  white-space: nowrap;
}

.order-note {
  background: #fff7e5;
  border: 1px solid #f0d7a1;
  border-radius: 8px;
  margin-top: 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  padding: 10px 12px;
}

.order-note-label {
  color: var(--amber);
  display: block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.order-note-text {
  color: #6c4b0a;
  font-size: 14px;
  line-height: 1.45;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.order-note.is-order-note {
  background: #fff4db;
  border-color: #e8bf70;
  margin-top: 14px;
}

.totals-section .kv {
  gap: 10px;
}

.total-row {
  align-items: center;
  line-height: 1.4;
}

.total-row.is-discount strong {
  color: var(--green-dark);
}

.total-row.is-total {
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 10px;
}

.total-row.is-total span,
.total-row.is-total strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.print-section .kv {
  gap: 14px;
}

.print-status-list {
  display: grid;
  gap: 10px;
  max-width: 100%;
}

.print-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  max-width: 100%;
  padding: 12px;
}

.print-row-main {
  min-width: 0;
}

.print-row-title {
  font-size: 14px;
  font-weight: 800;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.print-row-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.print-status-badge {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
  white-space: nowrap;
}

.print-status-badge.is-pending {
  background: var(--amber-bg);
  color: var(--amber);
}

.print-status-badge.is-sent {
  background: #e0edff;
  color: #1d4ed8;
}

.print-status-badge.is-printed {
  background: #e8f7ee;
  color: var(--green-dark);
}

.print-status-badge.is-failed {
  background: #fee2e2;
  color: var(--red-dark);
}

.print-status-badge.is-empty {
  background: var(--surface-soft);
  color: var(--muted);
}

.print-actions {
  display: grid;
  gap: 10px;
}

.print-actions-split {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.secondary-button.is-small {
  min-height: 44px;
  padding: 10px 8px;
}

.action-bar {
  background: rgba(245, 247, 244, 0.92);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  left: 0;
  margin: 0 auto;
  max-width: 720px;
  overflow-x: hidden;
  padding: 12px 14px 18px;
  position: fixed;
  right: 0;
  z-index: 21;
}

.primary-button,
.danger-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  min-height: 50px;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  padding: 12px;
}

.primary-button {
  background: var(--green);
}

.danger-button {
  background: var(--red);
}

.secondary-button {
  background: #374151;
}

.sheet-backdrop {
  background: rgba(15, 23, 42, 0.38);
  inset: 0;
  position: fixed;
  z-index: 30;
}

.bottom-sheet {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  bottom: 0;
  box-shadow: var(--shadow);
  left: 0;
  margin: 0 auto;
  max-height: 86vh;
  max-width: 720px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 16px 24px;
  position: fixed;
  right: 0;
  z-index: 31;
}

.sheet-title {
  font-size: 19px;
  font-weight: 900;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  margin: 0 0 12px;
}

.radio-option {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  margin: 8px 0;
  min-width: 0;
  padding: 12px;
}

.field {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  min-width: 0;
}

.field label,
.field > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.field input,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 10px 12px;
  width: 100%;
}

.time-picker {
  align-items: center;
  display: grid;
  gap: 8px;
  justify-items: center;
  margin: 16px 0;
}

.step-button {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 18px;
  font-weight: 900;
  min-height: 44px;
  width: 120px;
}

.time-display {
  background: #111827;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  min-height: 64px;
  padding: 12px 18px;
}

@media (max-width: 720px) {
  .auth-shell {
    align-items: flex-start;
    padding-top: 48px;
  }

  .app-shell {
    overflow-x: hidden;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .topbar-actions {
    justify-content: flex-end;
    width: 100%;
  }

  .session-label {
    max-width: none;
  }

  .order-row {
    align-items: start;
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 0;
  }

  .order-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    white-space: normal;
  }

  .order-side {
    align-items: center;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-items: start;
    margin-top: 2px;
  }

  .amount {
    justify-self: start;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .detail-inner {
    padding-bottom: 208px;
  }

  .kv-row,
  .total-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .kv-row strong,
  .total-row strong {
    text-align: left;
  }

  .action-bar {
    grid-template-columns: 1fr;
    padding-bottom: 20px;
  }

  .print-row {
    align-items: flex-start;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .print-status-badge {
    justify-self: start;
  }
}

@media (min-width: 760px) {
  .app-shell,
  .detail-inner {
    padding-left: 0;
    padding-right: 0;
  }

  .order-title {
    display: block;
    white-space: nowrap;
  }
}
