/* Opscale Orderintag – köksskärm.
   Idé: ordrarna är bongar (termopapper) som hänger på en stålskena i köket.
   Status visas med klämman överst: saffran = ny, flamma = tillagas, blad = klar, larm = sen. */
:root {
  /* Opscale: svart, Apple-grått, smaragd (samma som opscale.se och mejlen) */
  --steel: #050505;          /* sida */
  --steel-2: #0f0f10;        /* toppfält */
  --steel-3: #232325;        /* knappar, linjer */
  --card: #161617;           /* kort/ytor */
  --steel-ink: #f5f5f7;
  --steel-mute: #a1a1a6;

  --paper: #f5f5f7;          /* bongpapper */
  --paper-edge: #d2d2d7;
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --chili: #c4302b;          /* tillval/ändringar på bongen */
  --marker: #fde68a;         /* överstrykningspenna för kundens notering */

  --brand: #10b981;          /* Opscale-grön */
  --brand-ink: #022c22;
  --saffron: #f5a524;        /* ny order */
  --flame: #f5f5f7;          /* tillagas (vit klämma) */
  --leaf: #10b981;           /* klar */
  --alarm: #ef4444;

  --ui: "Inter", -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="light"] {
  --steel: #f5f5f7;
  --steel-2: #ffffff;
  --steel-3: #e3e3e8;
  --card: #ffffff;
  --steel-ink: #1d1d1f;
  --steel-mute: #6e6e73;
  --paper: #ffffff;
  --brand: #059669;
  --brand-ink: #ffffff;
}
[data-theme="light"] .bar { background: rgba(255,255,255,.85); }
[data-theme="light"] .ticket-paper { box-shadow: inset 0 0 0 1px #d2d2d7; }
[data-theme="light"] .ticket.s-new .ticket-paper { box-shadow: inset 0 0 0 3px var(--saffron); }
[data-theme="light"] .ticket.is-late .ticket-paper { box-shadow: inset 0 0 0 3px var(--alarm); }
[data-theme="light"] .ticket.is-late { --clip: var(--alarm); }
[data-theme="light"] .ticket.s-confirmed { --clip: #1d1d1f; }
[data-theme="light"] .lane-confirmed h2::before { background: #1d1d1f; }
[data-theme="light"] .alert { color: #991b1b; }
[data-theme="light"] .alert.warn { color: #92400e; }
[data-theme="light"] .health .bad, [data-theme="light"] .gate-error, [data-theme="light"] .t-cancel.armed { color: #b91c1c; }
[data-theme="light"] .switch::after, [data-theme="light"] .ai-switch::after { box-shadow: 0 1px 3px #0003; }
[data-theme="light"] .sheet-backdrop { background: rgba(0,0,0,.3); }
[data-theme="light"] .zreport { box-shadow: inset 0 0 0 1px #d2d2d7; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--steel); color: var(--steel-ink); font-family: var(--ui); font-size: 16px;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; border: 0; background: none; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Tangenter (knappar) ---------- */
.key {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 12px;
  background: var(--card); color: var(--steel-ink); border: 1px solid var(--steel-3);
  font-weight: 600; font-size: 18px;
  transition: transform .06s ease, filter .12s ease;
}
.key:active { transform: scale(.97); }
.key-go, .key-done { border-color: transparent; }
.key-go { background: var(--brand); color: var(--brand-ink); }
.key-done { background: var(--brand); color: var(--brand-ink); }
.key-quiet { background: transparent; }
.key-huge { min-height: 72px; font-size: 22px; padding: 0 36px; }

/* ---------- Inloggning / start ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--steel); }
.gate-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 18px; }
.gate-card.center { align-items: center; text-align: center; }
.wordmark { font-weight: 800; font-size: 44px; letter-spacing: -0.02em; line-height: 1; display: flex; flex-direction: column; gap: 10px; }
.gate-card.center .wordmark { align-items: center; }
.wordmark small { font-weight: 500; font-size: 17px; letter-spacing: 0; color: var(--steel-mute); }
.gate label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--steel-mute); font-weight: 600; }
.gate input { font: inherit; font-size: 19px; color: var(--steel-ink); background: var(--card); border: 1px solid var(--steel-3);
  border-radius: 12px; padding: 14px 16px; }
.gate input:focus { border-color: var(--brand); outline: none; }
.gate-error { margin: 0; color: #ff8787; font-weight: 600; }
.gate-hint { margin: 0; color: var(--steel-mute); font-size: 15px; }

/* ---------- Appskal: sidomeny + toppfält (iPad) ---------- */
#app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: calc(88px + env(safe-area-inset-left)) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
#app { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#app input, #app textarea, #app select { -webkit-user-select: text; user-select: text; }
body:has(#app:not([hidden])) { padding-left: 0; }

.side { grid-row: 1 / -1; grid-column: 1; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px calc(16px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: var(--steel-2); border-right: 1px solid var(--steel-3); }
.side-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 22px; letter-spacing: -0.04em; }
.tabs { display: flex; flex-direction: column; gap: 6px; width: 100%; flex: 1; }
.tab { position: relative; width: 100%; min-height: 64px; padding: 8px 4px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font-weight: 600; font-size: 12px; color: var(--steel-mute); text-align: center; line-height: 1.1; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab:active { background: var(--steel-3); }
.tab.is-on { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.tab-badge { position: absolute; top: 6px; right: 12px; background: var(--saffron); color: #241a00; line-height: 1.35; border-radius: 99px; min-width: 22px; padding: 1px 6px; font-size: 12px; font-weight: 800; text-align: center; }
.side .theme { margin-top: auto; }

.bar { grid-column: 2; display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 10px calc(20px + env(safe-area-inset-right)) 10px 22px;
  background: var(--steel-2); border-bottom: 1px solid var(--steel-3); }
.bar-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.rest-name { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-line { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; color: var(--steel-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-line i, .health i { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--steel-mute); }
.open-line.ok { color: var(--steel-ink); }
.open-line.ok i, .health .ok i { background: var(--brand); }
.open-line.warn i, .health .warn i { background: var(--saffron); }

.bar-right { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.health { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; font-size: 13px; font-weight: 600; color: var(--steel-mute); }
.health li { display: flex; align-items: center; gap: 7px; white-space: nowrap; padding: 8px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--steel-3); }
.health .bad { color: #ff8787; border-color: color-mix(in srgb, var(--alarm) 45%, transparent); }
.health .bad i { background: var(--alarm); }
[data-theme="light"] .health .bad { color: #b91c1c; }

.ai { display: flex; align-items: center; gap: 12px; padding: 7px 14px 7px 8px; border-radius: 14px; background: var(--card); border: 1px solid var(--steel-3); text-align: left; }
.ai-switch { position: relative; width: 52px; height: 31px; border-radius: 99px; background: var(--brand); flex: 0 0 auto; transition: background .15s; }
.ai-switch::after { content: ""; position: absolute; top: 2px; left: 23px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px #0005; }
.ai-text { display: flex; flex-direction: column; line-height: 1.15; }
.ai-text b { font-size: 16px; }
.ai-text small { font-size: 13px; color: var(--steel-mute); }
.ai[aria-pressed="false"] .ai-switch { background: var(--steel-3); }
.ai[aria-pressed="false"] .ai-switch::after { left: 2px; }

.theme { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--steel-3); color: var(--steel-mute); }
.theme svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme .i-sun { display: none; }
[data-theme="light"] .theme .i-sun { display: block; }
[data-theme="light"] .theme .i-moon { display: none; }
.clock { font-weight: 700; font-size: 28px; min-width: 84px; text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.alert { grid-column: 2; display: flex; align-items: center; gap: 12px; margin: 12px 20px 0; padding: 12px 16px; border-radius: 14px;
  font-weight: 600; font-size: 16px; line-height: 1.35; background: color-mix(in srgb, var(--alarm) 14%, var(--card)); color: #fecaca;
  border: 1px solid color-mix(in srgb, var(--alarm) 45%, transparent); }
.alert::before { content: ""; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--alarm); box-shadow: 0 0 0 4px color-mix(in srgb, var(--alarm) 25%, transparent); }
.alert.warn { background: color-mix(in srgb, var(--saffron) 14%, var(--card)); color: #fde7c2; border-color: color-mix(in srgb, var(--saffron) 45%, transparent); }
.alert.warn::before { background: var(--saffron); box-shadow: 0 0 0 4px color-mix(in srgb, var(--saffron) 25%, transparent); }
.alert.info { background: var(--card); color: var(--steel-ink); border-color: var(--steel-3); }
.alert.info::before { background: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent); }

main { grid-column: 2; grid-row: 3; min-height: 0; display: flex; }
.pane { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }

/* ---------- Skenan med bongar ---------- */
.rail { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 18px 20px 0; height: 100%; }
.t-pickup.preorder { color: var(--chili); font-weight: 700; }
.lane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
/* Långa ord (länkar, nummer, skräp i anteckningar) får aldrig spränga layouten */
.ticket, .bk-row, .hrow, .dish, .tb-row, .exc, .view-body, .alert { overflow-wrap: anywhere; }
.lane h2 { margin: 0 0 12px; font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.lane h2::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--steel-mute); }
.lane-new h2::before { background: var(--saffron); }
.lane-confirmed h2::before { background: var(--flame); }
.lane-ready h2::before { background: var(--leaf); }
.lane-count { font-size: 15px; color: var(--steel-mute); font-weight: 700; }
.tickets { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 22px; padding: 8px 2px 28px; }
.lane-empty { color: var(--steel-mute); font-size: 15px; line-height: 1.5; padding: 20px; background: var(--card); border-radius: 16px; margin: 0; }

.ticket { --clip: var(--steel-mute); position: relative; flex: 0 0 auto; }
.ticket > .ticket-paper { filter: drop-shadow(0 10px 14px rgba(0,0,0,.35)); }
[data-theme="light"] .ticket > .ticket-paper { filter: drop-shadow(0 8px 14px rgba(0,0,0,.08)); }
.ticket.s-new { --clip: var(--saffron); }
.ticket.s-confirmed { --clip: var(--flame); }
.ticket.s-ready { --clip: var(--leaf); }
.ticket.is-late { --clip: var(--alarm); }

/* klämman */
.ticket::before { content: ""; position: absolute; z-index: 1; top: -4px; left: 50%; transform: translateX(-50%);
  width: 56px; height: 9px; border-radius: 99px; background: var(--clip); box-shadow: 0 2px 6px #0006; }

.ticket-paper {
  background: var(--paper); color: var(--ink); padding: 22px 20px 28px; border-radius: 6px 6px 0 0;
  box-shadow: 0 18px 30px -18px #000;
  --zz: 9px;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - var(--zz)) no-repeat,
                conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(var(--zz) * 2) var(--zz) repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - var(--zz)) no-repeat,
                conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(var(--zz) * 2) var(--zz) repeat-x;
}
.ticket.s-new .ticket-paper { box-shadow: inset 0 0 0 3px var(--saffron); }
.ticket.is-late .ticket-paper { box-shadow: inset 0 0 0 3px var(--alarm); }

.t-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.t-no { font-weight: 800; font-size: 44px; line-height: .9; letter-spacing: -0.045em; }
.t-when { text-align: right; font-family: var(--mono); font-size: 14px; line-height: 1.35; color: var(--ink-soft); }
.t-when b { display: block; color: var(--ink); font-size: 17px; font-weight: 600; }
.t-when .late { color: var(--alarm); font-weight: 600; }
.t-when .soon { color: #b45309; font-weight: 600; }
.t-who { margin-top: 12px; font-weight: 700; font-size: 18px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.t-who a { font-family: var(--mono); font-weight: 400; font-size: 15px; color: var(--ink-soft); text-decoration: underline; text-decoration-color: var(--paper-edge); text-underline-offset: 3px; }
.t-pickup { font-family: var(--mono); font-size: 14px; color: var(--ink); margin-top: 4px; }
.t-cut { border: 0; border-top: 2px dashed var(--paper-edge); margin: 14px 0; }
.t-items { list-style: none; margin: 0; padding: 0; font-family: var(--mono); display: flex; flex-direction: column; gap: 10px; }
.t-items li { display: grid; grid-template-columns: 34px 1fr; column-gap: 6px; font-size: 18px; line-height: 1.3; }
.t-items .q { font-weight: 700; }
.t-items .n { font-weight: 600; }
.t-items .mods { grid-column: 2; color: var(--chili); font-size: 15px; }
.t-note { margin: 14px 0 0; font-family: var(--mono); font-size: 15px; line-height: 1.5; }
.t-note span { background: linear-gradient(transparent 12%, var(--marker) 12% 88%, transparent 88%); padding: 0 3px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.t-foot { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }
.t-foot .total { font-size: 18px; font-weight: 600; color: var(--ink); }
.t-foot .printed-no { color: #b45309; }

.t-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.t-keys .key { min-height: 56px; padding: 0 6px; font-size: 20px; font-weight: 700; border-radius: 14px; }
.t-keys .key-wide { grid-column: 1 / -1; }
.t-keys-label { grid-column: 1 / -1; font-size: 14px; font-weight: 600; color: var(--steel-mute); }
.t-cancel { grid-column: 1 / -1; justify-self: end; font-size: 15px; font-weight: 600; color: var(--steel-mute); min-height: 44px; padding: 0 8px; }
.t-cancel.armed { color: #ff8787; }

/* en ny bong "hängs upp" – det enda rörliga momentet */
@keyframes hang { from { transform: translateY(-24px) rotate(-1.5deg); opacity: 0; } to { transform: none; opacity: 1; } }
.ticket.just-in { animation: hang .45s cubic-bezier(.2,.9,.3,1.2); }
@keyframes clip-blink { 50% { filter: brightness(1.6); } }
.ticket.s-new::before { animation: clip-blink 1.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .ticket.just-in, .ticket.s-new::before { animation: none; } }

/* ---------- Meny ---------- */
.menu-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 56px; }
.menu-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.menu-head .key { white-space: nowrap; flex: 0 0 auto; }
.page-title { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.menu-intro { margin: 6px 0 0; color: var(--steel-mute); font-size: 15px; max-width: 60ch; line-height: 1.45; }
.cat-row { display: flex; gap: 10px; overflow-x: auto; padding: 22px 0 6px; scrollbar-width: none; }
.cat-row::-webkit-scrollbar { display: none; }
.cat { flex: 0 0 auto; min-width: 116px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border-radius: 16px; background: var(--card); border: 1px solid var(--steel-3); text-align: left; }
.cat-mono { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: var(--steel-3); color: var(--steel-ink); }
.cat b { font-size: 15px; font-weight: 600; }
.cat small { font-size: 13px; color: var(--steel-mute); margin-top: -8px; }
.cat.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.cat.is-on .cat-mono { background: rgba(255,255,255,.28); color: var(--brand-ink); }
.cat.is-on small { color: var(--brand-ink); opacity: .75; }
.cat-add { justify-content: center; align-items: center; color: var(--steel-mute); border-style: dashed; font-weight: 600; }
.menu-group { margin: 26px 0 10px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 10px; }
.menu-group small { font-size: 14px; color: var(--steel-mute); font-weight: 500; }
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.dish { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--steel-3); min-height: 132px; }
.dish-top { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; row-gap: 2px; padding-right: 40px; }
.dish-no { font-family: var(--mono); font-size: 14px; color: var(--steel-mute); }
.dish-name { font-weight: 700; font-size: 17px; text-transform: uppercase; letter-spacing: 0.02em; }
.dish-price { flex-basis: 100%; font-family: var(--mono); font-size: 15px; color: var(--steel-mute); white-space: nowrap; }
.dish-desc { font-size: 14px; color: var(--steel-mute); line-height: 1.4; flex: 1; }
.dish-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.dish-state { font-size: 14px; font-weight: 600; color: var(--brand); }
.dish.off { opacity: .62; }
.dish.off .dish-name { text-decoration: line-through; text-decoration-thickness: 2px; }
.dish.off .dish-state { color: var(--alarm); }
.dish-edit { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--steel-mute); }
.dish-edit:active { background: var(--steel-3); }
.dish-edit svg { width: 20px; height: 20px; }
.switch { position: relative; width: 52px; height: 31px; border-radius: 99px; background: var(--steel-3); flex: 0 0 auto; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px #0005; }
.switch[aria-pressed="true"] { background: var(--brand); }
.switch[aria-pressed="true"]::after { left: 23px; }

/* ---------- Redigeringsark ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; }
.sheet { width: min(560px, 100%); background: var(--card); color: var(--steel-ink); border: 1px solid var(--steel-3); border-radius: 22px; padding: 24px;
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 60px -20px #000; animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--steel-mute); flex: 1; }
.sheet input, .sheet textarea { font: inherit; font-size: 17px; color: var(--steel-ink); background: var(--steel); border: 1px solid var(--steel-3); border-radius: 12px; padding: 12px 14px; resize: none; }
.sheet input:focus, .sheet textarea:focus { outline: none; border-color: var(--brand); }
.sheet-row { display: flex; gap: 12px; }
.sheet .check { flex-direction: row; align-items: center; gap: 10px; font-size: 16px; color: var(--steel-ink); }
.sheet .check input { width: 22px; height: 22px; accent-color: var(--brand); }
.sheet-keys { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.sheet-keys .spacer { flex: 1; }
.sheet .t-cancel { grid-column: auto; }

/* ---------- Öppettider ---------- */
.hours-wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px 56px; display: flex; flex-direction: column; gap: 16px; }
.hours-wrap .menu-head { margin-bottom: 4px; }
.key:disabled { opacity: .55; cursor: default; }
.week { display: flex; flex-direction: column; }
.wd { display: grid; grid-template-columns: 110px 64px 1fr; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--steel-3); }
.wd:first-child { border-top: 0; }
.wd-name { font-weight: 600; font-size: 16px; }
.wd-name.today::after { content: "idag"; margin-left: 8px; font-size: 12px; font-weight: 700; color: var(--brand); }
.wd-spans { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.wd-closed { color: var(--steel-mute); font-size: 15px; }
.span { display: inline-flex; align-items: center; gap: 6px; }
.span input[type=time] { font: inherit; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--steel-ink); background: var(--steel); border: 1px solid var(--steel-3); border-radius: 12px; padding: 10px 12px; min-height: 46px; color-scheme: dark; }
[data-theme="light"] .span input[type=time], [data-theme="light"] .exc input[type=date] { color-scheme: light; }
.span input:focus { outline: none; border-color: var(--brand); }
.span .dash { color: var(--steel-mute); }
.span .night { font-size: 12px; color: var(--steel-mute); }
.x { width: 44px; height: 44px; border-radius: 9px; color: var(--steel-mute); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.x:active { background: var(--steel-3); }
.lastorder { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 16px; }
select { font: inherit; font-size: 16px; color: var(--steel-ink); background: var(--steel); border: 1px solid var(--steel-3); border-radius: 12px; padding: 10px 12px; min-height: 46px; }
.exc-intro { margin: -6px 0 8px; display: block; }
.exc { display: grid; grid-template-columns: 170px 170px 1fr 44px; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--steel-3); }
.exc input[type=date], .exc input[type=text] { font: inherit; font-size: 16px; color: var(--steel-ink); background: var(--steel); border: 1px solid var(--steel-3); border-radius: 12px; padding: 10px 12px; min-height: 46px; color-scheme: dark; min-width: 0; }
.exc .exc-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.exc .exc-right input[type=text] { flex: 1; min-width: 120px; }
.exc.past { opacity: .5; }
.health #open-pill.ok span { color: var(--steel-ink); }

/* ---------- Översikt ---------- */
.ov { max-width: 1140px; margin: 0 auto; padding: 24px 20px 56px; display: flex; flex-direction: column; gap: 16px; }
.ov-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ov-controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--card); border: 1px solid var(--steel-3); }
.seg button { min-height: 44px; padding: 0 16px; border-radius: 9px; font-weight: 600; font-size: 15px; color: var(--steel-mute); white-space: nowrap; }
.seg button.is-on { background: var(--brand); color: var(--brand-ink); }
.ov-date { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--steel-mute); }
.ov-date input { font: inherit; font-size: 15px; color: var(--steel-ink); background: var(--card); border: 1px solid var(--steel-3); border-radius: 12px; padding: 9px 12px; color-scheme: dark; }
[data-theme="light"] .ov-date input { color-scheme: light; }
.ov-date input.is-on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.ov-period { margin: -6px 0 0; color: var(--steel-mute); font-size: 15px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--steel-3); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k { font-size: 14px; color: var(--steel-mute); font-weight: 500; }
.kpi .v { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 13px; font-weight: 600; color: var(--steel-mute); }
.kpi .d.up { color: var(--brand); }
.kpi .d.down { color: #f87171; }
[data-theme="light"] .kpi .d.down { color: #b91c1c; }

.ov-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.panel { background: var(--card); border: 1px solid var(--steel-3); border-radius: 18px; padding: 18px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.muted-n { color: var(--steel-mute); font-weight: 500; font-size: 15px; }
.link { color: var(--brand); font-weight: 600; font-size: 16px; min-height: 44px; padding: 0 6px; display: inline-flex; align-items: center; }

/* stapeldiagram (en serie, ingen legend) */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.chart .grid { stroke: var(--steel-3); stroke-width: 1; }
.chart .axis { fill: var(--steel-mute); font-size: 12px; font-family: var(--ui); }
.chart .bar { fill: var(--brand); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.is-hover { fill: color-mix(in srgb, var(--brand) 75%, #fff); }
.tip { position: absolute; pointer-events: none; transform: translate(-50%, -100%); background: var(--steel-ink); color: var(--steel); border-radius: 10px;
  padding: 7px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; box-shadow: 0 6px 16px -6px #0008; }
.tip small { display: block; font-weight: 500; opacity: .7; }
.chart-empty { color: var(--steel-mute); padding: 40px 0; text-align: center; }

.top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.top li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 15px; }
.top .nm { font-weight: 600; }
.top .q { font-family: var(--mono); color: var(--steel-mute); font-size: 14px; }
.top .meter { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--steel-3); overflow: hidden; }
.top .meter i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }

.search { font: inherit; font-size: 15px; color: var(--steel-ink); background: var(--steel); border: 1px solid var(--steel-3); border-radius: 12px; padding: 10px 14px; min-width: min(340px, 100%); }
.search:focus { outline: none; border-color: var(--brand); }
.hist { display: flex; flex-direction: column; }
.hrow { display: grid; grid-template-columns: 56px 118px minmax(0, 1fr) minmax(0, 1.4fr) 84px 92px; gap: 12px; align-items: center; text-align: left;
  padding: 12px 6px; border-top: 1px solid var(--steel-3); font-size: 15px; border-radius: 10px; }
.hrow:first-child { border-top: 0; }
.hrow:active, .hrow:hover { background: color-mix(in srgb, var(--steel-3) 45%, transparent); }
.hrow .no { font-weight: 700; font-family: var(--mono); }
.hrow .t { color: var(--steel-mute); font-family: var(--mono); font-size: 14px; }
.hrow .who b { font-weight: 600; display: block; }
.hrow .who small { color: var(--steel-mute); font-family: var(--mono); font-size: 13px; }
.hrow .it { color: var(--steel-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.hrow .sum { font-family: var(--mono); text-align: right; }
.chip { justify-self: end; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 99px; background: var(--steel-3); color: var(--steel-ink); }
.chip.done { background: color-mix(in srgb, var(--brand) 20%, transparent); color: var(--brand); }
.chip.cancelled { background: color-mix(in srgb, var(--alarm) 18%, transparent); color: #f87171; }
[data-theme="light"] .chip.cancelled { color: #b91c1c; }
.chip.new { background: color-mix(in srgb, var(--saffron) 22%, transparent); color: var(--saffron); }
.more { align-self: center; margin-top: 10px; width: 100%; }
.hist-empty { color: var(--steel-mute); padding: 18px 6px; }

.sheet-view { width: min(480px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.sheet-view .ticket { margin-top: 6px; }
.sheet-view .zreport { margin: 0; max-width: none; }

/* Dagsrapport (Z-rapport) */
.zreport { font-family: var(--mono); font-size: 16px; padding: 28px 26px 34px; }
.z-title { font-family: var(--ui); text-align: center; font-weight: 800; font-size: 26px; letter-spacing: -0.01em; }
.z-sub { text-align: center; color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.z-row { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; }
.z-row .k { white-space: nowrap; }
.z-row .dots { flex: 1; border-bottom: 2px dotted var(--paper-edge); transform: translateY(-4px); }
.z-row .v { font-weight: 600; white-space: nowrap; }
.z-row.big { font-size: 20px; }
.stats-keys { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }

/* ---------- Stående iPad (834) / iPad mini (744) ---------- */
@media (max-width: 1000px) {
  .wd { grid-template-columns: 96px 56px 1fr; }
  .exc { grid-template-columns: 1fr 1fr 44px; }
  .exc .exc-right { grid-column: 1 / -1; grid-row: 2; }
  .ov-grid { grid-template-columns: 1fr; }
  .hrow { grid-template-columns: 50px 90px minmax(0,1fr) 80px; }
  .hrow .it, .hrow .chip { display: none; }
  .health li span { display: none; }      /* bara prickar, texten syns i varningsraden */
  .health li { padding: 10px; }
  .ai-text small { display: none; }
  .clock { font-size: 24px; min-width: 70px; }
  .rail { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); height: auto; }
  .lane-new { grid-column: 1 / -1; }
  .lane-new .tickets { flex-direction: row; overflow-x: auto; overflow-y: visible; padding-top: 8px; scroll-snap-type: x mandatory; }
  .lane-new .ticket { width: min(380px, 80vw); scroll-snap-align: start; }
  .tickets { overflow: visible; }
}

/* ---------- Mobil: flikrad längst ner ---------- */
@media (max-width: 640px) {
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .side { grid-row: 4; grid-column: 1; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--steel-3); }
  .side-mark, .side .theme { display: none; }
  .tabs { flex-direction: row; }
  .tab { min-height: 54px; }
  .bar, .alert, main { grid-column: 1; }
  .bar { padding: 10px 16px; min-height: 60px; gap: 10px; }
  .rest-name { font-size: 17px; }
  .health { gap: 4px; }                    /* mobil: bara prickar för skrivare och anslutning */
  .health li { padding: 8px; }
  .health li span { display: none; }
  .health #open-pill { display: none; }
  .ai { padding: 6px; }
  .ai-text { display: none; }
  .rail { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 0; }
}

/* ---------- Bokningar ---------- */
.bk-wrap { max-width: 1000px; }
.bk-sum { margin: 0; }
.bk-row { display: grid; grid-template-columns: 70px 74px minmax(0, 1fr) 90px auto; gap: 12px; align-items: center; padding: 12px 6px; border-top: 1px solid var(--steel-3); font-size: 15px; }
.bk-row:first-child { border-top: 0; }
.bk-row .tm { font-family: var(--mono); font-weight: 700; font-size: 18px; }
.bk-row .pp { font-weight: 700; font-size: 16px; }
.bk-row .pp small { display: block; color: var(--steel-mute); font-weight: 500; font-size: 12px; }
.bk-row .who b { font-weight: 600; display: block; }
.bk-row .who a, .bk-row .who small { color: var(--steel-mute); font-family: var(--mono); font-size: 13px; text-decoration: none; }
.bk-row .who .nt { display: block; font-family: var(--ui); color: var(--saffron); font-size: 13px; margin-top: 2px; }
.bk-row .tb { color: var(--steel-mute); font-size: 14px; }
.bk-row .tb.none { color: var(--saffron); }
.bk-row .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.bk-row .acts .key { min-height: 44px; padding: 0 14px; font-size: 15px; }
.bk-row.st-cancelled, .bk-row.st-no_show, .bk-row.st-done { opacity: .5; }
.bk-row .src { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand); margin-left: 6px; vertical-align: 2px; }
.bk-req { border-color: color-mix(in srgb, var(--saffron) 55%, var(--steel-3)); }
.bk-set { display: flex; flex-direction: column; gap: 14px; }
.bk-set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px; }
.lastorder select, .tb-row input { font: inherit; font-size: 16px; color: var(--steel-ink); background: var(--steel); border: 1px solid var(--steel-3); border-radius: 12px; padding: 10px 12px; min-height: 46px; }
.tb-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 64px 44px; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--steel-3); }
.tb-row:first-child { border-top: 0; }
.tb-row input { min-width: 0; width: 100%; }
.tb-row .seats { display: flex; align-items: center; gap: 8px; color: var(--steel-mute); }
.tb-row .seats input { width: 72px; }
.bk-msg { margin: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--saffron) 16%, transparent); color: var(--steel-ink); font-size: 15px; }
.bk-alts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.bk-alts .key { min-height: 40px; padding: 0 12px; font-size: 15px; }
@media (max-width: 1000px) {
  .bk-row { grid-template-columns: 60px 56px minmax(0, 1fr) auto; }
  .bk-row .tb { grid-column: 3; grid-row: 2; font-size: 13px; }
  .bk-row .acts { grid-column: 4; grid-row: 1 / span 2; justify-content: flex-end; }
  .bk-row.st-cancelled, .bk-row.st-no_show, .bk-row.st-done { padding-top: 6px; padding-bottom: 6px; }
}
@media (max-width: 640px) {
  .tb-row { grid-template-columns: minmax(0, 1fr) 90px 52px 40px; }
  .sheet-row { flex-wrap: wrap; }
}
.start-switch { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 8px; }
