:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eef5f3;
  --text: #15201d;
  --muted: #64716d;
  --line: #dbe5e1;
  --primary: #0f766e;
  --primary-strong: #0b5d57;
  --blue: #1d64d8;
  --danger: #b42318;
  --warning: #a15c00;
  --ok-bg: #e6f6ef;
  --wait-bg: #fff7db;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
}

button:disabled {
  opacity: .55;
}

.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #efc8c3;
}

.app-shell {
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(82px + env(safe-area-inset-bottom));
}

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

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.input-block,
.list-section,
.empty-state,
.form-stack,
.usage-list,
.usage-grid,
.summary-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.input-block {
  padding: 12px;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

#orderText {
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  line-height: 1.42;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

.switch input {
  width: 22px;
  height: 22px;
  accent-color: var(--primary);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
  overflow: hidden;
}

.summary-strip div,
.usage-grid div {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.summary-strip div:last-child,
.usage-grid div:last-child {
  border-right: 0;
}

.summary-strip strong,
.usage-grid strong {
  display: block;
  font-size: 23px;
  line-height: 1;
}

.summary-strip span,
.usage-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.list-section {
  margin-top: 12px;
  padding: 12px;
}

.list-section h2 {
  margin: 0 0 10px;
  font-size: 18px;
  letter-spacing: 0;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.item-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.item-name {
  font-weight: 800;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.aisle-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  white-space: nowrap;
  background: var(--ok-bg);
  color: var(--primary-strong);
}

.aisle-pill.wait {
  background: var(--wait-bg);
  color: var(--warning);
}

.meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.save-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}

.save-row input {
  min-height: 44px;
  padding: 0 12px;
}

.empty-state {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 22px 12px;
  text-align: center;
}

.empty-state strong {
  font-size: 19px;
}

.empty-state span {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.form-stack label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.form-stack input,
.form-stack textarea {
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  font-weight: 500;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.usage-list {
  display: grid;
  gap: 1px;
  margin-top: 12px;
  overflow: hidden;
}

.usage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  background: #fff;
}

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

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  background: rgba(244, 247, 246, .92);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 0;
  min-height: 48px;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--line);
}

dialog {
  border: 0;
  padding: 0;
  border-radius: 12px;
  width: min(360px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(13, 24, 21, .42);
}

.login-card {
  padding: 16px;
  background: var(--surface);
}

.login-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.login-card input {
  min-height: 48px;
  padding: 0 12px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  max-width: min(460px, calc(100vw - 28px));
  padding: 10px 12px;
  border-radius: 999px;
  background: #17201d;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  font-weight: 650;
  text-align: center;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 22px;
  }
}
