@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --gold: #e3a81f;
  --gold-deep: #a8740a;
  --gold-soft: #fff3d1;
  --ink: #1b1a17;
  --muted: #8a857a;
  --line: #ece8de;
  --bg: #f6f5f1;
  --card: #fff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 6px 20px rgba(40, 32, 10, .07);
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: #f3f2ee; color: var(--ink); }
button, input, textarea, select { color: inherit; font: inherit; }
button { appearance: none; -webkit-appearance: none; margin: 0; border: 0; background: none; -webkit-tap-highlight-color: transparent; cursor: pointer; }
button:focus { outline: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; }
.ui-icon { width: 1em; height: 1em; flex: none; vertical-align: -.15em; }

.app-frame { position: relative; display: flex; width: min(100%, 520px); min-height: 100dvh; flex-direction: column; margin: 0 auto; overflow: clip; background: var(--bg); box-shadow: 0 0 60px rgba(40, 32, 10, .12); }
.app-header { position: sticky; z-index: 5; top: calc(8px + env(safe-area-inset-top, 0px)); display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px; margin: 8px 10px 0; padding: 6px 8px 6px 6px; border-radius: 999px; background: #1a120c; color: #f4ead8; box-shadow: 0 10px 28px rgba(20, 14, 8, .38); }
.brand-mark { display: block; width: 44px; height: 44px; object-fit: contain; }
.header-copy small { display: block; color: #cbb9a4; font-size: 10px; }
.header-copy strong { display: block; overflow: hidden; color: #fff; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; gap: 6px; }
.icon-button { display: grid; min-width: 36px; min-height: 36px; place-items: center; padding: 0 10px; border-radius: 999px; background: #2b2118; color: #f4ead8; font-size: 12px; font-weight: 700; }
.icon-button.warn { background: #5a2a16; color: #ffd7c4; }

#app-main { flex: 1; padding: 12px 16px calc(28px + var(--safe-bottom)); }

.login-card { margin-top: 28px; padding: 22px 18px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.login-card h1 { margin: 12px 0 6px; font-size: 24px; }
.login-card p { color: var(--muted); font-size: 14px; }
.login-card label { display: grid; gap: 6px; margin-top: 14px; font-size: 12px; font-weight: 700; }
.login-card input { min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; font-weight: 500; }
.form-error { min-height: 18px; margin-top: 10px; color: #b42318; font-size: 13px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0 14px; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; flex: none; align-items: center; gap: 6px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-size: 12px; font-weight: 700; }
.tab.active { border-color: var(--gold); background: var(--gold); color: #1b1405; }
.tab b { min-width: 18px; padding: 1px 6px; border-radius: 99px; background: #1a120c; color: #fff; font-size: 11px; }
.tab.active b { background: #1a120c; color: var(--gold); }

.ticket { margin-bottom: 12px; padding: 14px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.ticket.is-new { outline: 2px solid var(--gold); }
.ticket-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ticket-head strong { font-size: 16px; }
.pill { padding: 4px 8px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-deep); font-size: 11px; font-weight: 800; }
.pill.pending { background: #fff1ce; }
.pill.preparing { background: #e8f7ef; color: #14804a; }
.pill.ready { background: #e7eefc; color: #1d4ed8; }
.pill.delivered { background: #f0f2f6; color: #58677e; }
.pill.refused { background: #fde8e8; color: #b42318; }
.meta { display: flex; gap: 10px; margin: 8px 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.lines { padding: 0; list-style: none; }
.lines li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.lines .qty { color: var(--gold-deep); font-weight: 800; margin-right: 6px; }
.note { display: flex; gap: 8px; margin-top: 8px; color: #8a4b12; font-size: 12px; }
.ticket-total { display: flex; justify-content: space-between; margin-top: 10px; font-weight: 800; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.btn-row.one { grid-template-columns: 1fr; }
.gold-button, .outline-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: 14px; font-size: 13px; font-weight: 800; }
.gold-button { background: var(--gold); color: #1b1405; }
.outline-button { border: 1.5px solid var(--gold); background: #fff; color: var(--gold-deep); }
.danger-button { background: #fde8e8; color: #b42318; }
.gold-button:disabled, .outline-button:disabled { opacity: .55; }

.empty-state { padding: 36px 12px; color: var(--muted); text-align: center; }
.call-card { background: #1a120c; color: #f4ead8; }
.call-card .meta, .call-card .note { color: #d8cbb8; }

.overlay { position: fixed; z-index: 10; inset: 0; display: flex; justify-content: center; background: rgba(27, 20, 5, .5); }
.sheet { position: relative; display: flex; width: min(100%, 520px); height: 100dvh; flex-direction: column; background: var(--card); }
.sheet-scroll { flex: 1; overflow-y: auto; padding: 20px 16px 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px 16px calc(16px + var(--safe-bottom)); border-top: 1px solid var(--line); }
.sheet-actions.one { grid-template-columns: 1fr; }
.draft-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.qty-control { display: flex; align-items: center; gap: 6px; }
.qty-control button { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: #f3efe4; }
.category-strip { display: flex; gap: 8px; overflow-x: auto; margin: 10px 0; scrollbar-width: none; }
.category-chip { flex: none; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 12px; font-weight: 700; }
.category-chip.active { border-color: var(--gold); background: var(--gold); }
.add-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.note-field { width: 100%; min-height: 72px; margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; resize: vertical; }
.reason-list { display: grid; gap: 8px; margin-top: 12px; }
.reason-list button { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; text-align: left; font-weight: 700; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); max-width: min(420px, calc(100% - 24px)); padding: 12px 16px; border-radius: 14px; background: #1a120c; color: #fff; font-size: 13px; font-weight: 600; }
.toast[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
