:root {
  --bg: #15171a;
  --panel: #1f2226;
  --card: #2a2e33;
  --card-hi: #343940;
  --line: #3a3f46;
  --ink: #f4f5f6;
  --muted: #a3a9b1;
  --new: #ff5a3c;
  --accepted: #3d9bff;
  --preparing: #ffb020;
  --ready: #2fc46b;
  --done: #7b828b;
  --scheduled: #b07cff;
  --danger: #e5484d;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 17px;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
#app { min-height: 100%; display: flex; flex-direction: column; }

/* Knappar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 22px; border-radius: 14px;
  background: var(--card-hi); color: var(--ink); font-weight: 700; font-size: 18px;
  transition: transform .06s, filter .1s;
}
.btn:active { transform: scale(.97); filter: brightness(1.15); }
.btn:disabled { opacity: .45; }
.btn.block { width: 100%; }
.btn.xl { min-height: 76px; font-size: 24px; border-radius: 18px; }
.btn.green { background: var(--ready); color: #04210f; }
.btn.blue { background: var(--accepted); color: #04182e; }
.btn.orange { background: var(--preparing); color: #2b1a00; }
.btn.red { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.small { min-height: 44px; font-size: 16px; padding: 0 14px; }

/* Inloggning */
.login { flex: 1; display: grid; place-items: center; padding: 24px; }
.login-box { width: min(440px, 100%); background: var(--panel); border-radius: 24px; padding: 32px; }
.login-box h1 { margin: 0 0 6px; font-size: 28px; }
.login-box p { color: var(--muted); margin: 0 0 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--muted); font-size: 15px; }
.input {
  width: 100%; min-height: 56px; padding: 0 16px; border-radius: 12px;
  background: var(--bg); border: 2px solid var(--line); font-size: 20px;
}
.input:focus { outline: none; border-color: var(--accepted); }
.error { color: #ff8b7a; font-weight: 600; margin: 0 0 12px; }

.start-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 11, 13, .96);
  display: grid; place-items: center; text-align: center; padding: 24px;
}
.start-overlay h2 { font-size: 34px; margin: 0 0 10px; }
.start-overlay p { color: var(--muted); margin: 0 0 28px; font-size: 19px; }

/* Topplist */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 20px; margin-right: 4px; }
.conn { width: 12px; height: 12px; border-radius: 50%; background: var(--ready); box-shadow: 0 0 0 4px rgba(47,196,107,.18); }
.conn.off { background: var(--danger); box-shadow: 0 0 0 4px rgba(229,72,77,.2); animation: blink 1s infinite; }
.tabs { display: flex; gap: 6px; margin-left: auto; }
.tab { min-height: 48px; padding: 0 18px; border-radius: 12px; background: transparent; color: var(--muted); font-weight: 700; position: relative; }
.tab.active { background: var(--card-hi); color: var(--ink); }
.tab .n { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--new); color: #fff; font-size: 14px; margin-left: 6px; }
.pause-toggle { min-height: 48px; padding: 0 16px; border-radius: 12px; font-weight: 800; background: rgba(47,196,107,.15); color: var(--ready); border: 2px solid rgba(47,196,107,.4); }
.pause-toggle.paused { background: rgba(229,72,77,.18); color: #ff8b8e; border-color: rgba(229,72,77,.55); animation: pulse-border 1.6s infinite; }
.wait-ctl { display: flex; align-items: center; gap: 4px; background: var(--card); border-radius: 12px; padding: 4px; }
.wait-ctl button { width: 44px; height: 40px; border-radius: 9px; background: var(--card-hi); font-size: 22px; font-weight: 700; }
.wait-ctl span { padding: 0 8px; font-weight: 700; white-space: nowrap; }
.clock { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }

.banner { padding: 12px 16px; font-weight: 700; text-align: center; }
.banner.paused { background: var(--danger); color: #fff; }
.banner.offline { background: #6b4b00; color: #ffe2a3; }

/* Orderkolumner */
.board { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 12px; align-items: start; }
@media (max-width: 900px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.col { background: var(--panel); border-radius: var(--radius); min-height: 60vh; display: flex; flex-direction: column; }
.col-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px; font-weight: 800; font-size: 18px; }
.col-head .count { background: var(--card-hi); border-radius: 999px; padding: 2px 12px; font-size: 16px; }
.col-head::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 8px; }
.col-head .t { flex: 1; }
.col-body { padding: 0 10px 10px; display: grid; gap: 10px; }
.col-empty { color: var(--muted); text-align: center; padding: 24px 8px; font-size: 15px; }
.sub-head { color: var(--scheduled); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; padding: 8px 4px 0; }

.ocard {
  background: var(--card); border-radius: 14px; padding: 12px; text-align: left; width: 100%;
  border-left: 6px solid var(--c); display: grid; gap: 6px;
}
.ocard:active { background: var(--card-hi); }
.ocard.late { box-shadow: inset 0 0 0 2px var(--danger); }
.ocard .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ocard .num { font-size: 28px; font-weight: 900; letter-spacing: -.02em; }
.ocard .time { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ocard .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocard .meta { color: var(--muted); font-size: 14px; }
.ocard .summary { font-size: 14px; color: #d4d8dd; line-height: 1.35; }
.ocard .btn { margin-top: 4px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 13px; font-weight: 800; }
.tag.sched { background: rgba(176,124,255,.2); color: var(--scheduled); }
.tag.paid { background: rgba(47,196,107,.18); color: var(--ready); }
.tag.unpaid { background: rgba(255,176,32,.18); color: var(--preparing); }
.tag.refund { background: rgba(229,72,77,.2); color: #ff8b8e; }
.tag.late { background: var(--danger); color: #fff; }

/* Modal */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.72); display: grid; place-items: center; padding: 16px; }
.modal {
  width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border-radius: 24px; padding: 22px;
}
.modal.new-order { border: 4px solid var(--new); animation: pulse-shadow 1.2s infinite; }
.modal.new-order.sched { border-color: var(--scheduled); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 34px; letter-spacing: -.02em; }
.modal-head .kicker { color: var(--new); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; font-size: 15px; }
.close { width: 52px; height: 52px; border-radius: 50%; background: var(--card-hi); font-size: 26px; flex: none; }
.sched-banner { background: var(--scheduled); color: #1b0a33; font-weight: 900; font-size: 22px; padding: 14px 16px; border-radius: 14px; margin-bottom: 14px; text-align: center; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.info { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.info .k { color: var(--muted); font-size: 13px; }
.info .v { font-weight: 800; font-size: 19px; word-break: break-word; }
.info a { color: var(--accepted); text-decoration: none; }
.items { background: var(--card); border-radius: 14px; padding: 4px 14px; margin-bottom: 14px; }
.item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .q { font-size: 24px; font-weight: 900; min-width: 44px; }
.item .n { flex: 1; font-size: 20px; font-weight: 700; }
.item .n small { color: var(--muted); font-weight: 600; }
.item .a { color: var(--muted); font-variant-numeric: tabular-nums; }
.mod { font-size: 17px; font-weight: 700; margin-top: 2px; }
.mod-remove { color: #ff8b7a; }
.mod-extra { color: #7fd6a2; }
.mod-note { color: var(--preparing); }
.comment-box { background: rgba(255,176,32,.14); color: #ffd48a; border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 19px; margin-bottom: 14px; }
.total-row { display: flex; justify-content: space-between; font-size: 22px; font-weight: 900; padding: 4px 2px 14px; }
.actions { display: grid; gap: 10px; }
.wait-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.label { color: var(--muted); font-weight: 700; font-size: 15px; margin: 4px 0 -2px; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; }
.action-row .btn { flex: 1; }
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Sidor: meny, försäljning, inställningar */
.page { padding: 16px; max-width: 1100px; width: 100%; margin: 0 auto; }
.page h2 { margin: 8px 0 14px; font-size: 26px; }
.page h3 { margin: 22px 0 10px; font-size: 19px; color: var(--muted); }
.list { background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 68px; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; }
.list-row .sub { color: var(--muted); font-size: 14px; }
.list-row.off .grow { opacity: .55; }
.switch { position: relative; width: 170px; min-height: 52px; border-radius: 12px; font-weight: 800; background: rgba(47,196,107,.16); color: var(--ready); }
.switch.off { background: rgba(229,72,77,.2); color: #ff8b8e; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.stat .k { color: var(--muted); font-weight: 600; }
.stat .v { font-size: 34px; font-weight: 900; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.set { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.set .k { font-weight: 800; margin-bottom: 4px; }
.set .d { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 64px; height: 56px; border-radius: 12px; background: var(--card-hi); font-size: 28px; font-weight: 800; }
.stepper .val { min-width: 110px; text-align: center; font-size: 26px; font-weight: 900; }
.hours-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.hours-row:last-child { border-bottom: 0; }
.hours-row input[type=time] { min-height: 48px; background: var(--bg); border: 2px solid var(--line); border-radius: 10px; padding: 0 10px; color-scheme: dark; }
.hours-row .times { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); }
.check input { width: 24px; height: 24px; accent-color: var(--accepted); }
.history-row { display: grid; grid-template-columns: 80px 90px 1fr auto auto; gap: 12px; align-items: center; }

#toasts { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; width: min(92vw, 520px); }
.toast { background: #f4f5f6; color: #15171a; padding: 14px 18px; border-radius: 14px; font-weight: 700; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast-error { background: var(--danger); color: #fff; }

@keyframes blink { 50% { opacity: .3; } }
@keyframes pulse-shadow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,90,60,.55); } 50% { box-shadow: 0 0 0 18px rgba(255,90,60,0); } }
@keyframes pulse-border { 50% { border-color: rgba(229,72,77,.15); } }

/* Kökskvitto (80 mm termo- eller AirPrint-skrivare) */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body { background: #fff; color: #000; }
  #app, #toasts, .modal-back { display: none !important; }
  #print-area { display: block; font-family: "Courier New", monospace; font-size: 12pt; color: #000; width: 72mm; }
  #print-area .c { text-align: center; }
  #print-area .big { font-size: 26pt; font-weight: 900; }
  #print-area .mid { font-size: 15pt; font-weight: 700; }
  #print-area hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
  #print-area .it { font-size: 13pt; font-weight: 700; margin-top: 4px; }
  #print-area .md { padding-left: 14px; }
  #print-area .inv { background: #000; color: #fff; padding: 2px 4px; font-weight: 900; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
