:root {
  color-scheme: dark;
  --bg: #11100e;
  --bg-raised: #171512;
  --surface: #201d18;
  --surface-hover: #29251f;
  --surface-strong: #2e2921;
  --line: #4b4130;
  --line-soft: #332d24;
  --text: #f6f1e7;
  --text-muted: #c7bcab;
  --text-faint: #998d7c;
  --gold: #d4a017;
  --gold-bright: #f2c94c;
  --gold-ink: #211805;
  --green: #65b78c;
  --green-ink: #0e2117;
  --red: #e86b59;
  --red-ink: #2c0f0a;
  --blue: #79b8d8;
  --blue-ink: #0b1d28;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(242, 201, 76, 0.42);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

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

button, select { cursor: pointer; }

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

button, input, select, textarea { touch-action: manipulation; }

img { max-width: 100%; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -64px;
  left: 16px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--gold-bright);
  color: var(--gold-ink);
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus { top: 16px; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.auth-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: var(--bg);
}

.auth-card {
  width: min(100%, 456px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--gold);
  border-radius: 50%;
  object-fit: cover;
  background: #000;
}

.brand--auth img { width: 56px; height: 56px; }

.brand span { display: grid; gap: 1px; min-width: 0; }

.brand strong { color: var(--gold-bright); font-size: 14px; line-height: 1.1; }

.brand small { color: var(--text-muted); font-size: 11px; font-weight: 700; line-height: 1.1; }

.auth-copy { margin: 32px 0 24px; }

.auth-copy h1, .view-heading h1 {
  margin: 4px 0 8px;
  color: var(--text);
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.15;
}

.auth-copy p:last-child, .view-description { max-width: 65ch; margin: 0; color: var(--text-muted); }

.eyebrow {
  margin: 0;
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

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

label { display: grid; gap: 7px; color: var(--text); font-size: 14px; font-weight: 700; }

label small { color: var(--text-muted); font-size: 12px; font-weight: 500; }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text);
}

textarea { min-height: 92px; resize: vertical; }

input::placeholder, textarea::placeholder { color: var(--text-faint); opacity: 1; }

input:hover, select:hover, textarea:hover { border-color: #766343; }

.input-with-action { position: relative; display: block; }

.input-with-action input { padding-right: 68px; }

.text-action {
  min-height: 44px;
  padding: 7px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--gold-bright);
  font-size: 14px;
  font-weight: 800;
}

.text-action:hover { background: rgba(242, 201, 76, 0.1); }

.input-with-action .text-action { position: absolute; top: 3px; right: 3px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }

.button:active:not(:disabled) { transform: translateY(0); }

.button--primary { border-color: var(--gold-bright); background: var(--gold-bright); color: var(--gold-ink); }

.button--primary:hover:not(:disabled) { background: #ffe075; border-color: #ffe075; }

.button--quiet { border-color: var(--line); background: var(--surface); color: var(--text); }

.button--quiet:hover:not(:disabled) { border-color: var(--gold); background: var(--surface-hover); }

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

.button--danger:hover:not(:disabled) { background: #f48777; border-color: #f48777; }

.button--success { border-color: var(--green); background: var(--green); color: var(--green-ink); }

.button--success:hover:not(:disabled) { background: #89d5aa; border-color: #89d5aa; }

.button--wide { width: 100%; }

.form-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 650;
}

.form-message--error { border-color: rgba(232, 107, 89, 0.66); background: rgba(232, 107, 89, 0.14); color: #ffd1ca; }

.form-message--success { border-color: rgba(101, 183, 140, 0.66); background: rgba(101, 183, 140, 0.14); color: #c2f0d5; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(20px, calc((100% - 1600px) / 2 + 24px)) 12px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(17, 16, 14, 0.97);
}

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }

.connection-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.connection-state::before {
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  content: "";
}

.connection-state.is-live { border-color: rgba(101, 183, 140, 0.7); color: #c2f0d5; }
.connection-state.is-live::before { background: var(--green); }
.connection-state.is-error { border-color: rgba(232, 107, 89, 0.7); color: #ffd1ca; }
.connection-state.is-error::before { background: var(--red); }

.profile-block { display: grid; min-width: 0; gap: 1px; text-align: right; }
.profile-block strong { max-width: 180px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.profile-block small { color: var(--text-muted); font-size: 11px; }

.app-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); max-width: 1600px; min-height: calc(100dvh - 70px); margin: 0 auto; }

.app-nav {
  position: sticky;
  top: 70px;
  align-self: start;
  display: grid;
  gap: 5px;
  max-height: calc(100dvh - 70px);
  padding: 20px 14px;
  border-right: 1px solid var(--line-soft);
}

.nav-group { display: grid; gap: 5px; }
.nav-group-label { padding: 4px 12px 2px; color: var(--text-faint); font-size: 10px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }

.nav-button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  text-align: left;
}

.nav-button:hover { border-color: var(--line); background: var(--surface); color: var(--text); }
.nav-button.is-active { border-color: rgba(212, 160, 23, 0.75); background: rgba(212, 160, 23, 0.14); color: var(--gold-bright); }

.nav-count {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  place-items: center;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--gold-bright);
  color: var(--gold-ink);
  font-size: 12px;
}

.app-main { min-width: 0; padding: 32px; }

.app-view { width: min(100%, 1360px); margin: 0 auto; }

.view-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }

.metric {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric span { display: block; color: var(--text-muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin-top: 9px; color: var(--text); font-family: var(--mono); font-size: 28px; line-height: 1; }
.metric--accent { border-color: rgba(212, 160, 23, 0.54); }
.metric--attention { border-color: rgba(232, 107, 89, 0.6); }
.metric--loading { position: relative; overflow: hidden; background: var(--surface); }
.metric--loading::after { display: block; width: 52%; height: 11px; margin-top: 31px; border-radius: 5px; background: var(--surface-strong); content: ""; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.overview-panel { min-width: 0; }
.overview-list, .overview-table-list { display: grid; gap: 8px; }
.overview-row, .overview-table-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--bg-raised); color: var(--text); text-align: left; }
.overview-row { width: 100%; cursor: pointer; }
.overview-row:hover { border-color: var(--line); background: var(--surface-hover); }
.overview-row strong, .overview-table-row b { color: var(--gold-bright); font-family: var(--mono); }
.overview-table-row small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 12px; }
.overview-table-row b.has-queue { color: #ffd1ca; }
.overview-shortcuts { margin-bottom: 14px; }
.overview-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.queue-switcher { display: grid; gap: 8px; margin-bottom: 12px; }
.queue-switcher-label { color: var(--text-muted); font-size: 12px; font-weight: 800; }
.queue-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.queue-button {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.queue-button:hover { border-color: var(--gold); background: var(--surface-hover); color: var(--text); transform: translateY(-1px); }
.queue-button:active { transform: translateY(0); }
.queue-button.is-active { border-color: rgba(212, 160, 23, 0.75); background: rgba(212, 160, 23, 0.14); color: var(--gold-bright); }

.order-mode-switcher { display: grid; gap: 8px; margin-bottom: 12px; }
.queue-buttons--mode { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 560px; }
.history-switcher { margin-bottom: 12px; }
.history-date-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 10px; }
.history-date-row .filter-field { min-width: 170px; }
.history-date-row .button { min-height: 44px; }
.history-date-row .inline-note { display: flex; flex: 1 1 220px; min-height: 44px; align-items: center; }

.filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(132px, 0.75fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.filter-field { gap: 4px; color: var(--text-muted); font-size: 12px; }
.filter-field input, .filter-field select { min-height: 44px; padding: 8px 10px; }

.loading-line { padding: 10px 0; color: var(--text-muted); font-size: 14px; font-weight: 700; }
.loading-line::after { display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 2px solid var(--line); border-top-color: var(--gold-bright); border-radius: 50%; content: ""; animation: spin 760ms linear infinite; vertical-align: -1px; }

.orders-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(292px, 1fr)); gap: 14px; align-items: start; }

.order-card {
  display: grid;
  min-height: 254px;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.15);
}

.order-card.is-new { border-color: rgba(212, 160, 23, 0.8); }
.order-card.is-payment { border-color: rgba(232, 107, 89, 0.76); }
.order-card.is-updated { animation: card-in 280ms ease-out; }

.order-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-card h2 { margin: 0; font-family: var(--mono); font-size: 22px; line-height: 1.1; }
.order-card-time { margin: 5px 0 0; color: var(--text-muted); font-size: 13px; font-weight: 650; }

.badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.badge--delivery { border-color: rgba(121, 184, 216, 0.55); color: #bde0ef; }
.badge--table { border-color: rgba(101, 183, 140, 0.55); color: #c2f0d5; }
.badge--walk-in { border-color: rgba(212, 160, 23, 0.55); color: var(--gold-bright); }
.badge--payment { border-color: rgba(232, 107, 89, 0.65); color: #ffd1ca; }
.badge--verified { border-color: rgba(101, 183, 140, 0.65); color: #c2f0d5; }
.badge--rejected, .badge--cancelled { border-color: rgba(232, 107, 89, 0.65); color: #ffd1ca; }

.order-card-summary { display: grid; gap: 7px; min-height: 62px; }
.order-card-summary p { margin: 0; overflow: hidden; color: var(--text-muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.order-card-summary strong { color: var(--text); font-size: 16px; }
.order-card-context { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.order-card-context strong { color: var(--text); }

.order-item-preview { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; color: var(--text-muted); font-size: 13px; }
.order-item-preview li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-item-preview li:last-child { color: var(--text-faint); }

.payment-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(232, 107, 89, 0.5);
  border-radius: 6px;
  background: rgba(232, 107, 89, 0.1);
  color: #ffd1ca;
  font-size: 13px;
  font-weight: 750;
}

.payment-callout--verified { border-color: rgba(101, 183, 140, 0.5); background: rgba(101, 183, 140, 0.1); color: #c2f0d5; }
.payment-callout--neutral { border-color: var(--line-soft); background: var(--bg-raised); color: var(--text-muted); }

.order-card-footer { display: flex; align-items: end; gap: 8px; margin-top: auto; }
.order-card-footer .button { flex: 1; }

.card-error { margin-top: -4px; padding: 8px 9px; border-radius: 6px; background: rgba(232, 107, 89, 0.14); color: #ffd1ca; font-size: 12px; font-weight: 700; }

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.empty-state strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 17px; }
.orders-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding-top: 18px; }
.orders-pagination .button { min-height: 44px; }

.panel { 
  padding: 20px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.account-panel { max-width: 720px; display: grid; gap: 18px; }
.account-panel .detail-grid { margin: 0; }
.account-panel .button { justify-self: start; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-heading h2, .panel > h2 { margin: 0; color: var(--text); font-size: 18px; line-height: 1.2; }
.inline-note { color: var(--text-muted); font-size: 13px; font-weight: 650; }

.pos-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, 0.8fr); gap: 18px; align-items: start; }
.pos-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pos-item { display: grid; min-height: 106px; align-content: space-between; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg-raised); color: var(--text); text-align: left; }
.pos-item:hover { border-color: var(--gold); background: var(--surface-hover); }
.pos-item strong { font-size: 14px; line-height: 1.3; }
.pos-item span { color: var(--gold-bright); font-family: var(--mono); font-size: 13px; font-weight: 800; }
.pos-ticket { position: sticky; top: 92px; }
.pos-lines { display: grid; gap: 0; border-top: 1px solid var(--line-soft); }
.pos-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.pos-line span { min-width: 0; font-size: 14px; }
.pos-line strong { color: var(--text); font-family: var(--mono); font-size: 13px; }
.pos-line-actions { display: inline-flex; align-items: center; gap: 4px; }
.quantity-button { display: inline-grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--bg-raised); color: var(--text); font-size: 18px; font-weight: 800; }
.quantity-button:hover { border-color: var(--gold); background: var(--surface-hover); }
.quantity-value { width: 24px; text-align: center; font-family: var(--mono); font-size: 13px; font-weight: 800; }
.ticket-total { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 4px; color: var(--text-muted); font-weight: 700; }
.ticket-total strong { color: var(--gold-bright); font-family: var(--mono); font-size: 20px; }

.admin-grid { display: grid; grid-template-columns: minmax(300px, 0.9fr) minmax(300px, 1.1fr); gap: 18px; align-items: start; margin-bottom: 18px; }
.category-form { align-self: start; }
.list-panel { min-width: 0; }
.list-search { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; }
.list-search input { min-width: 200px; min-height: 44px; }
.admin-list { display: grid; gap: 8px; }
.admin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--bg-raised); }
.admin-row-info { display: grid; min-width: 0; gap: 3px; }
.admin-row-info strong { overflow: hidden; color: var(--text); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.admin-row-info span { overflow-wrap: anywhere; color: var(--text-muted); font-size: 13px; }
.admin-row-info small { color: var(--text-faint); font-size: 12px; }
.admin-row-actions { display: flex; gap: 8px; }
.admin-row-photo { width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 6px; object-fit: cover; background: var(--surface-strong); }
.photo-placeholder { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-strong); color: var(--text-faint); font-size: 10px; font-weight: 700; text-align: center; }
.admin-row-with-photo { grid-template-columns: 48px minmax(0, 1fr) auto; }

fieldset { display: grid; gap: 14px; margin: 0; padding: 16px; border: 1px solid var(--line-soft); border-radius: 6px; }
legend { padding: 0 6px; color: var(--gold-bright); font-size: 13px; font-weight: 800; }
.settings-form { max-width: 720px; }
.settings-time-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check-row { display: flex; align-items: center; gap: 9px; min-height: 36px; font-size: 14px; }
.check-row input { width: 19px; min-height: 19px; accent-color: var(--gold); }

.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.table-card { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line-soft); border-radius: var(--radius); background: var(--surface); }
.table-card > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.table-card strong { color: var(--gold-bright); font-size: 20px; }
.table-card code { overflow-wrap: anywhere; color: var(--text-muted); font-family: var(--mono); font-size: 12px; }
.table-card-qr { display: block; width: min(100%, 220px); aspect-ratio: 1; margin: 0 auto; padding: 8px; border: 1px solid var(--line-soft); background: #fff; object-fit: contain; }
.table-card-qr--staff { display: grid; place-items: center; padding: 18px; color: var(--text-muted); background: var(--surface-soft); font-size: 13px; font-weight: 800; text-align: center; }
.table-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-card-actions .button { flex: 1 1 120px; }
.table-state { display: inline-flex; min-height: 26px; align-items: center; padding: 3px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--text-muted); font-size: 11px; font-weight: 800; }
.table-state--active { border-color: rgba(101, 183, 140, 0.65); color: #c2f0d5; }
.table-state--paused { border-color: rgba(232, 107, 89, 0.65); color: #ffd1ca; }

dialog {
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

dialog::backdrop { background: rgba(0, 0, 0, 0.68); }

.drawer-dialog { width: min(100%, 620px); height: 100dvh; margin: 0 0 0 auto; }
.drawer-panel { display: grid; min-height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; padding: max(20px, env(safe-area-inset-top)) 22px max(22px, env(safe-area-inset-bottom)); background: var(--surface); box-shadow: -18px 0 38px rgba(0, 0, 0, 0.32); overflow-y: auto; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.drawer-header h2 { margin: 4px 0 0; font-size: 25px; line-height: 1.15; }
.drawer-close { flex: 0 0 auto; }
.drawer-body { display: grid; gap: 20px; padding: 20px 0; }
.drawer-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-section { display: grid; gap: 10px; }
.detail-section h3 { margin: 0; color: var(--text); font-size: 15px; }
.detail-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line-soft); }
.detail-list li { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.detail-list li > div { display: grid; gap: 3px; min-width: 0; }
.detail-list strong { font-size: 14px; }
.detail-list span { color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.item-note { color: var(--gold-bright) !important; }
.detail-total { color: var(--gold-bright); font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-grid > .full { grid-column: 1 / -1; }
.detail-value { display: grid; gap: 2px; min-width: 0; padding: 11px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--bg-raised); }
.detail-value span { color: var(--text-faint); font-size: 11px; font-weight: 700; }
.detail-value strong { overflow-wrap: anywhere; color: var(--text); font-size: 14px; }
.detail-field { display: grid; gap: 6px; min-width: 0; padding: 11px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--bg-raised); color: var(--text-faint); font-size: 11px; font-weight: 700; }
.detail-field select { min-width: 0; width: 100%; }
.timeline { display: grid; gap: 0; padding: 0; margin: 0; list-style: none; border-left: 2px solid var(--line); }
.timeline li { position: relative; display: grid; gap: 2px; padding: 0 0 15px 15px; }
.timeline li::before { position: absolute; top: 4px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); content: ""; }
.timeline time { color: var(--text-faint); font-family: var(--mono); font-size: 12px; }
.timeline strong { font-size: 14px; }
.timeline span { color: var(--text-muted); font-size: 13px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.drawer-actions .button { flex: 1 1 190px; }
.payment-proof-replacement { padding: 14px; border: 1px solid rgba(232, 107, 89, 0.62); border-radius: 7px; background: rgba(232, 107, 89, 0.08); }
.payment-proof-replacement > p { margin: 0; color: #ffd1ca; font-size: 14px; line-height: 1.5; }
.payment-proof-replacement .form-stack { gap: 12px; }
.payment-proof-replacement input[type="file"] { padding: 9px; background: var(--bg-raised); }

.order-edit-form { gap: 18px; }
.order-edit-intro { gap: 9px; }
.order-edit-intro > p { margin: 0; color: var(--text-muted); font-size: 14px; }
.order-edit-draft-status { min-height: 22px; margin: 0; color: var(--text-muted); font-size: 13px; font-weight: 750; }
.order-edit-draft-status.is-attention { color: #ffd1ca; }
.order-edit-conflict { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.order-edit-conflict .text-action { flex: 0 0 auto; border: 1px solid rgba(232, 107, 89, 0.62); color: #ffd1ca; }
.order-edit-conflict .text-action:hover { background: rgba(232, 107, 89, 0.16); }
.order-edit-lines { display: grid; gap: 12px; }
.order-edit-line { min-width: 0; padding: 14px; border-color: var(--line); background: var(--bg-raised); }
.order-edit-line--unavailable { border-color: rgba(232, 107, 89, 0.72); }
.order-edit-line-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.order-edit-line-head > div { display: grid; min-width: 0; gap: 3px; }
.order-edit-line-head strong { overflow-wrap: anywhere; color: var(--text); font-size: 15px; }
.order-edit-line-head span { color: var(--text-muted); font-family: var(--mono); font-size: 13px; }
.order-edit-remove { flex: 0 0 auto; border: 1px solid rgba(232, 107, 89, 0.62); color: #ffd1ca; }
.order-edit-remove:hover { background: rgba(232, 107, 89, 0.16); }
.order-edit-quantity-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; font-weight: 750; }
.order-edit-quantity-controls { display: grid; grid-template-columns: 44px minmax(36px, auto) 44px minmax(90px, auto); align-items: center; gap: 8px; }
.order-edit-quantity-button { width: 44px; height: 44px; border-radius: 6px; }
.order-edit-quantity-controls .quantity-value { width: auto; min-width: 36px; font-size: 14px; }
.order-edit-quantity-controls .detail-total { justify-self: end; }
.order-edit-line label { gap: 6px; }
.order-edit-line textarea { min-height: 82px; }
.order-edit-line .form-message { margin: 0; }
.order-edit-empty { margin: 0; padding: 14px; border: 1px dashed var(--line); border-radius: 6px; color: var(--text-muted); font-size: 14px; }
.order-edit-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; padding: 14px; border: 1px solid var(--line-soft); border-radius: 7px; background: var(--bg-raised); }
.order-edit-add .button { min-width: 112px; }
.order-edit-total { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; align-items: end; padding: 14px; border: 1px solid rgba(212, 160, 23, 0.54); border-radius: 7px; background: rgba(212, 160, 23, 0.08); }
.order-edit-total span, .order-edit-total small { color: var(--text-muted); font-size: 13px; font-weight: 700; }
.order-edit-total small { grid-column: 1 / -1; }
.order-edit-total strong { color: var(--gold-bright); font-family: var(--mono); font-size: 21px; line-height: 1.1; }
.order-edit-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.order-edit-actions .button { width: 100%; }

.receipt-dialog { width: min(100% - 32px, 1280px); height: min(100dvh - 32px, 900px); margin: auto; }
.receipt-panel { display: grid; height: 100%; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 14px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.receipt-summary { margin: 0; color: var(--text-muted); font-size: 14px; }
.receipt-stage { display: grid; min-height: 0; place-items: center; overflow: auto; border: 1px solid var(--line-soft); border-radius: 6px; background: #090908; }
.receipt-stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.receipt-actions { display: flex; justify-content: flex-end; gap: 8px; }

.confirm-dialog { width: min(100% - 32px, 430px); margin: auto; }
.confirm-panel { display: grid; gap: 14px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.confirm-panel h2 { margin: 0; font-size: 23px; }
.confirm-panel > p:not(.eyebrow) { margin: 0; color: var(--text-muted); }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast-region { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 60; display: grid; width: min(100% - 32px, 390px); gap: 10px; }
.toast { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid rgba(212, 160, 23, 0.72); border-radius: var(--radius); background: #292015; box-shadow: var(--shadow); animation: toast-in 220ms ease-out; }
.toast--error { border-color: rgba(232, 107, 89, 0.7); background: #321713; }
.toast strong { display: block; color: var(--text); font-size: 14px; }
.toast span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 13px; }
.toast .text-action { color: var(--gold-bright); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-in { from { opacity: 0.4; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-nav { position: sticky; top: 70px; z-index: 20; display: flex; max-height: none; padding: 8px 16px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line-soft); background: var(--bg); }
  .nav-group { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; }
  .nav-group-label { display: none; }
  .nav-button { flex: 0 0 auto; }
  .pos-layout { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 840px) {
  .app-header { min-height: 64px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
  .brand img { width: 38px; height: 38px; }
  .header-actions { gap: 6px; }
  .connection-state, .profile-block { display: none; }
  .app-nav { top: 64px; padding: 8px 12px; }
  .app-main { padding: 20px 14px max(32px, env(safe-area-inset-bottom)); }
  .view-heading { gap: 14px; margin-bottom: 18px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .queue-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orders-pagination { align-items: stretch; flex-direction: column; }
  .orders-pagination .button { width: 100%; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-field--search { grid-column: 1 / -1; }
  .filter-bar .button { grid-column: 1 / -1; }
  .pos-layout, .admin-grid { grid-template-columns: 1fr; }
  .pos-ticket { position: static; }
}

@media (max-width: 560px) {
  .auth-card { padding: 24px 20px; }
  .auth-copy { margin: 26px 0 20px; }
  .app-header .brand small { display: none; }
  .app-header .brand strong { font-size: 12px; }
  .header-actions .button { min-height: 44px; padding: 8px 10px; font-size: 13px; }
  .app-nav { gap: 5px; }
  .nav-button { min-height: 44px; padding: 9px 11px; font-size: 13px; }
  .app-main { padding-right: 12px; padding-left: 12px; }
  .view-heading { align-items: stretch; flex-direction: column; }
  .view-heading > .button { width: 100%; }
  .metrics-grid { gap: 8px; }
  .metric { min-height: 86px; padding: 13px; }
  .metric strong { font-size: 23px; }
  .queue-buttons { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; padding: 10px; }
  .filter-field--search, .filter-bar .button { grid-column: auto; }
  .orders-grid { grid-template-columns: 1fr; gap: 10px; }
  .order-card { min-height: 0; padding: 14px; }
  .order-card-footer { flex-direction: column; }
  .order-card-footer .button { width: 100%; }
  .panel { padding: 15px; }
  .pos-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pos-item { min-height: 92px; padding: 11px; }
  .admin-row { grid-template-columns: 1fr; align-items: stretch; }
  .admin-row-with-photo { grid-template-columns: 42px minmax(0, 1fr); }
  .admin-row-with-photo .admin-row-actions { grid-column: 1 / -1; }
  .admin-row-actions .button { flex: 1; }
  .list-search { display: grid; width: 100%; }
  .list-search input { min-width: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .settings-time-grid { grid-template-columns: 1fr; }
  .drawer-dialog { width: 100%; }
  .drawer-panel { padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); }
  .drawer-header h2 { font-size: 22px; }
  .drawer-header { align-items: center; }
  .drawer-header .button { min-height: 44px; padding: 8px 10px; }
  .order-edit-line { padding: 12px; }
  .order-edit-quantity-row { grid-template-columns: 1fr; gap: 7px; }
  .order-edit-quantity-controls { justify-content: start; }
  .order-edit-add { grid-template-columns: 1fr; }
  .order-edit-add .button { width: 100%; }
  .receipt-dialog { width: 100%; height: 100dvh; }
  .receipt-panel { padding: max(16px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)); border: 0; border-radius: 0; }
  .receipt-actions { flex-direction: column; }
  .receipt-actions .button { width: 100%; }
  .confirm-actions { flex-direction: column-reverse; }
  .confirm-actions .button { width: 100%; }
}

@media (max-width: 390px) {
  .order-edit-line-head { align-items: stretch; flex-direction: column; }
  .order-edit-remove { align-self: start; }
  .order-edit-quantity-controls { grid-template-columns: 44px minmax(32px, auto) 44px 1fr; gap: 6px; }
  .order-edit-quantity-controls .detail-total { min-width: 0; font-size: 13px; }
  .order-edit-actions { grid-template-columns: 1fr; }
}

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