:root {
  --ink: #2a1b12;
  --sidebar: #1a110d;
  --gold: #f0b429;
  --red: #c62828;
  --cream: #f6f0e6;
  --paper: #fffdf8;
  --line: #eadcc8;
  --muted: #7d6a59;
  --good: #1f7a45;
  --shadow: 0 18px 40px rgba(42, 27, 18, 0.08);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: Georgia, "Palatino Linotype", serif; margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; }

#login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(circle at top left, rgba(240, 180, 41, 0.35), transparent 32%),
    linear-gradient(160deg, #2a120e 0%, #1a110d 55%, #3a1d12 100%);
}
.login-card {
  width: min(440px, 100%);
  background: var(--paper);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card .logo { width: 100%; height: auto; display: block; object-fit: contain; background: #000; border-radius: 18px; }
.login-card h1 { margin: 18px 0 6px; font-size: 34px; }
.lede { color: var(--muted); margin-top: 0; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; margin: 12px 0; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 11px 12px;
}
textarea { min-height: 70px; resize: vertical; }
button, .login-card button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--ink);
  color: white;
  font-weight: 700;
}
.login-card button { width: 100%; background: var(--red); margin-top: 8px; }
.demo { display: grid; gap: 4px; margin-top: 16px; padding: 12px; background: #fff6e4; border-radius: 14px; font-size: 13px; }
.demo strong { color: #8a5a10; }

#app { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
aside {
  background: var(--sidebar);
  color: #f7efe4;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand img { width: 100%; height: auto; display: block; object-fit: contain; background: #000; border-radius: 14px; }
nav { display: grid; gap: 4px; margin-top: 8px; }
nav button {
  text-align: left;
  background: transparent;
  color: #f4e7d4;
  border-radius: 12px;
}
nav button.active, nav button:hover { background: rgba(240, 180, 41, 0.16); color: var(--gold); }
#sign-out { margin-top: auto; background: transparent; color: #e7c7c0; border: 1px solid rgba(255,255,255,.12); }
#who { font-size: 13px; color: #d9c3ae; }

.workspace { padding: 22px 26px 40px; }
header { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 18px; }
.eyebrow { letter-spacing: .14em; text-transform: uppercase; font-size: 12px; color: var(--muted); margin: 0 0 4px; font-weight: 700; }
header h1 { font-size: 40px; }
#branch-slot select { min-width: 220px; background: white; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card, .panel, .ticket, .item-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 16px; }
.card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.card strong { display: block; margin-top: 8px; font-size: 28px; font-family: Georgia, serif; }
.split { display: grid; grid-template-columns: 1.2fr .8fr; gap: 14px; margin-top: 14px; }
.panel { padding: 16px; }
.panel h2 { font-size: 24px; margin-bottom: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.clickable { cursor: pointer; }
.low td { background: #fff1f0; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 8px; background: #f3eadc; font-size: 12px; font-weight: 700; }
.pill.good { background: #e5f6ec; color: var(--good); }
.pill.bad { background: #fde8e6; color: var(--red); }
.pill.wait { background: #fff3d6; color: #8a5a10; }

.toolbar, .form-grid, .lines { display: grid; gap: 10px; }
.form-grid { grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.row-actions, .inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.danger { background: var(--red); }
.gold { background: var(--gold); color: #2a1b12; }

.pos { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cats button.active { background: var(--gold); color: #2a1b12; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.item-card { text-align: left; padding: 14px; min-height: 110px; }
.item-card b { display: block; font-size: 18px; font-family: Georgia, serif; }
.item-card span { color: var(--muted); }
.ticket { padding: 16px; position: sticky; top: 16px; }
.ticket h2 { font-size: 28px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.qty button { width: 28px; height: 28px; padding: 0; border-radius: 8px; }
.shift-box { background: #fff6e4; border-radius: 14px; padding: 10px; margin: 10px 0; }

#modal { position: fixed; inset: 0; background: rgba(26, 17, 13, .55); display: grid; place-items: center; padding: 18px; z-index: 5; }
.modal-card { width: min(560px, 100%); background: var(--paper); border-radius: 22px; padding: 18px; max-height: 90vh; overflow: auto; }
.modal-card .row-actions { position: sticky; top: 0; background: var(--paper); padding-bottom: 10px; z-index: 1; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.choices button.active { background: var(--gold); color: #2a1b12; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: auto; }

.bill { width: min(360px, 100%); margin: 0 auto; }
.bill .logo { width: 100%; height: auto; display: block; margin: 0 auto 8px; background: #000; border-radius: 12px; }
.bill h2, .bill h3 { text-align: center; }
.bill .token { text-align: center; font-size: 42px; margin: 6px 0; }
.bill table td:last-child, .bill .money { text-align: right; }
.total-line { display: flex; justify-content: space-between; font-size: 20px; font-weight: 800; }

#toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  border-radius: 14px;
  max-width: 320px;
  opacity: 0;
  transform: translateY(8px);
  transition: .2s ease;
  z-index: 6;
}
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--red); }
#print-root { display: none; }

@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  aside { position: relative; height: auto; }
  .cards, .split, .pos, .form-grid { grid-template-columns: 1fr; }
  header h1 { font-size: 32px; }
  .ticket { position: static; }
}

@media print {
  body * { visibility: hidden; }
  #print-root, #print-root * { visibility: visible; }
  #print-root { display: block; position: absolute; left: 0; top: 0; width: 80mm; }
  .no-print { display: none !important; }
}
