/* Balíky — warm paper and ink, one amber accent, numbers that line up. */

:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --sunk: #efece6;
  --ink: #16130f;
  --ink-2: #4a453e;
  --muted: #8b847a;
  --line: rgb(22 19 15 / 0.08);
  --line-2: rgb(22 19 15 / 0.14);
  --accent: #e08a00;
  --accent-ink: #1b1204;
  --late: #d9363e;
  --soon: #d98a00;
  --ok: #2f8f5b;
  --shadow: 0 1px 0 rgb(22 19 15 / 0.04), 0 6px 18px -10px rgb(22 19 15 / 0.18);
  --r: 16px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d0c; --surface: #191715; --sunk: #232120; --ink: #f2efea; --ink-2: #c9c3b9; --muted: #8f887e;
    --line: rgb(255 255 255 / 0.07); --line-2: rgb(255 255 255 / 0.12);
    --accent: #f2a12c; --late: #ff5a5f; --soon: #f2a12c; --ok: #4cc38a;
    --shadow: 0 0 0 1px rgb(255 255 255 / 0.04);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 15px/1.35 var(--sans); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; }

/* ---- header ----------------------------------------------------------

   iOS draws its own frosted band under the status bar in home-screen apps
   and blurs whatever rests there. So in standalone mode everything starts
   --edge below the safe area: the title block scrolls away normally, and
   only the tab bar is pinned, just below that band. */

:root { --edge: 0px; }
@media (display-mode: standalone) { :root { --edge: 34px; } }

[hidden] { display: none !important; }

header { padding: calc(env(safe-area-inset-top) + var(--edge) + 12px) 18px 0; }
.tabbar {
  position: sticky; top: calc(env(safe-area-inset-top) + var(--edge)); z-index: 5; isolation: isolate;
  padding: 8px 18px; border-bottom: 1px solid transparent; transition: border-color .2s;
}
.tabbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
}
.tabbar.scrolled { border-bottom-color: var(--line); }
.dock::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.summary .offline { color: var(--soon); font-weight: 600; }
.titlebar { display: flex; align-items: center; justify-content: space-between; max-width: 620px; margin: 0 auto; }
h1 { font: 700 30px/1.1 var(--display); letter-spacing: -0.03em; margin: 0; }
.tools { display: flex; gap: 2px; margin-right: -8px; }
.icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--ink-2); }
.icon:active { background: var(--line); }
.icon.spin svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.summary { max-width: 620px; margin: 2px auto 4px; color: var(--muted); font-size: 14px; }
.summary b { color: var(--ink); font-weight: 600; }

.seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px;
  background: var(--sunk); border-radius: 11px; max-width: 620px; margin: 0 auto;
}
.seg button { padding: 7px 0; border-radius: 9px; font-size: 13.5px; font-weight: 550; color: var(--ink-2); }
.seg button span { color: var(--muted); font-weight: 500; margin-left: 2px; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 0 0 .5px var(--line-2); }

main { padding: 6px 14px calc(110px + env(safe-area-inset-bottom)); max-width: 620px; margin: 0 auto; }
.list { display: flex; flex-direction: column; gap: 10px; }

/* ---- the ticket --------------------------------------------------------- */

.ticket {
  position: relative; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow);
  overflow: hidden; transition: transform .12s ease;
}
.ticket:active { transform: scale(.993); }
.ticket.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: var(--shadow); } }

.t-main { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; padding: 12px 16px 13px; width: 100%; text-align: left; }
.t-kicker { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); min-width: 0; }
.t-kicker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.t-kicker .shop { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-place { grid-column: 1; font: 600 16.5px/1.25 var(--display); letter-spacing: -0.015em; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.t-place.unknown { color: var(--muted); font-weight: 500; }

.t-left { grid-column: 2; grid-row: 1 / span 2; text-align: right; align-self: start; line-height: 1; }
.t-left b { font: 650 30px/1 var(--display); letter-spacing: -0.04em; }
.t-left i { font-style: normal; font-size: 14px; font-weight: 600; margin-left: 1px; color: inherit; opacity: .8; }
.t-left small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; letter-spacing: .02em; opacity: .85; }
.late { color: var(--late); } .soon { color: var(--soon); }

.t-codes { grid-column: 1 / -1; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 9px; }
.codes { display: flex; gap: 8px; min-width: 0; }
.code {
  display: inline-flex; flex-direction: column; padding: 4px 10px 5px; border-radius: 10px;
  background: var(--sunk); border: 1px dashed var(--line-2);
}
.code small { font-size: 9.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.code b { font: 600 20px/1.15 var(--mono); letter-spacing: .03em; white-space: nowrap; }
.code:active { background: color-mix(in srgb, var(--accent) 18%, var(--sunk)); }
.code.none b { font: 500 14px/1.6 var(--sans); color: var(--muted); letter-spacing: 0; }
.t-when { text-align: right; font-size: 13px; color: var(--ink-2); line-height: 1.35; white-space: nowrap; }
.t-when .open { color: var(--ok); } .t-when .closed { color: var(--late); } .t-when .unk { color: var(--muted); }

.bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.bar span { display: block; height: 100%; background: var(--fill, var(--ink-2)); opacity: .55; border-radius: 0 2px 2px 0; }

/* expanded */
.t-more { display: none; padding: 0 16px 16px; border-top: 1px solid var(--line); }
.ticket.open .t-more { display: block; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 13px 0 14px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.facts dd a { text-decoration: none; border-bottom: 1px solid var(--line-2); }
.facts .warn { color: var(--soon); display: flex; gap: 6px; }
.facts .warn svg { width: 16px; height: 16px; margin-top: 1px; }
.actions { display: flex; gap: 8px; }
.actions .primary { flex: 1; }
.actions .sq { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: var(--sunk); color: var(--ink-2); }

/* done / history rows: one line each */
.row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--surface); border-radius: 12px; text-align: left; width: 100%;
}
.row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.row .what { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.row .what b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.row .st { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.history-wrap { display: flex; flex-direction: column; gap: 6px; }
.history-wrap .ticket { border-radius: 12px; }

.empty { text-align: center; padding: 64px 20px 20px; color: var(--muted); }
.empty b { display: block; font: 600 20px/1.3 var(--display); color: var(--ink); letter-spacing: -0.02em; margin-bottom: 4px; }

/* ---- nudges and notices ---------------------------------------------- */

.nudge {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; margin-bottom: 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
}
.nudge .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); flex: none; }
.nudge .tx { flex: 1; font-size: 14px; color: var(--ink-2); }
.nudge .tx b { display: block; color: var(--ink); font-weight: 600; font-size: 15px; }
.nudge > svg:last-child { color: var(--muted); width: 18px; height: 18px; }
.notice { padding: 12px 14px; margin-bottom: 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; }
.notice b { display: block; margin-bottom: 4px; }
.notice pre { white-space: pre-wrap; word-break: break-all; font: 13px/1.4 var(--mono); margin: 0 0 8px; color: var(--ink-2); }

/* ---- dock ------------------------------------------------------------- */

.dock {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; padding: 5px; border-radius: 999px; isolation: isolate;
  color: var(--bg); box-shadow: 0 10px 30px -8px rgb(0 0 0 / .35);
}
.dock-btn { display: flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: 15px; }
.dock-btn:active { background: rgb(255 255 255 / .12); }
.dock-btn.spin svg { animation: spin .9s linear infinite; }
.dock-sep { width: 1px; height: 20px; background: currentColor; opacity: .2; }

/* ---- buttons --------------------------------------------------------- */

.primary { background: var(--accent); color: var(--accent-ink); font-weight: 650; border-radius: 12px; padding: 13px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary:active { filter: brightness(.94); }
.ghost { padding: 13px 14px; border-radius: 12px; color: var(--ink-2); font-weight: 550; }
.ghost:active { background: var(--line); }
.danger { color: var(--late); }
.link { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.link svg { width: 18px; height: 18px; }

/* ---- sheets ------------------------------------------------------------ */

dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 620px; max-height: 92dvh;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 -10px 40px -10px rgb(0 0 0 / .3);
}
dialog.sheet[open] { animation: up .28s cubic-bezier(.2, .9, .25, 1); }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
dialog::backdrop { background: rgb(10 8 6 / .45); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 22px; } }
dialog form { padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font: 700 21px/1.2 var(--display); letter-spacing: -0.02em; margin: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet-actions .primary { flex: 1; }
.sheet-actions .spacer { flex: 1; }

.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 -18px 14px; padding: 0 18px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; padding: 8px 13px; border-radius: 999px;
  background: var(--sunk); font-size: 14px; font-weight: 550; color: var(--ink-2);
}
.chips button::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--chip); }
.chips button[aria-checked="true"] { background: var(--ink); color: var(--bg); }

input, select { font: inherit; color: var(--ink); }
.code-input {
  display: block; width: 100%; border: 0; outline: 0; border-radius: 14px; background: var(--sunk);
  padding: 16px; font: 600 28px/1.1 var(--mono); letter-spacing: .06em; text-align: center;
}
.code-input::placeholder { font: 500 17px var(--sans); letter-spacing: 0; color: var(--muted); }
.field { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 0 14px; border-radius: 14px; background: var(--sunk); color: var(--muted); }
.field input { flex: 1; border: 0; outline: 0; background: none; padding: 14px 0; font-size: 16px; }
.suggest { display: flex; flex-direction: column; margin-top: 6px; max-height: 34dvh; overflow-y: auto; }
.suggest button { display: block; text-align: left; padding: 10px 12px; border-radius: 12px; }
.suggest button + button { border-top: 1px solid var(--line); border-radius: 0; }
.suggest button.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 12px; }
.suggest .n { font-weight: 600; font-size: 15px; }
.suggest .s { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest .tag { font-size: 11px; font-weight: 600; color: var(--ok); margin-left: 6px; }
.suggest .hint { padding: 8px 4px; }

details.more { margin-top: 12px; }
details.more summary { list-style: none; color: var(--muted); font-size: 14px; padding: 6px 0; cursor: pointer; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.grid2 input { width: 100%; border: 0; border-radius: 12px; background: var(--sunk); padding: 12px; font-size: 16px; min-height: 46px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

.form-rows { border-radius: 14px; background: var(--sunk); overflow: hidden; }
.form-rows label { display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: 48px; }
.form-rows label + label { border-top: 1px solid var(--line); }
.form-rows label > span:first-child { width: 84px; flex: none; color: var(--muted); font-size: 14px; }
.form-rows input, .form-rows select { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; padding: 12px 0; }
.form-rows .pair { flex: 1; display: flex; gap: 8px; }
.form-rows .pair input { width: 50%; }
label.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 15px; }
.days { display: grid; gap: 6px; }
.days label { display: flex; align-items: center; gap: 10px; }
.days span { width: 34px; color: var(--muted); font-size: 13px; }
.days input { flex: 1; border: 0; border-radius: 10px; background: var(--sunk); padding: 9px 10px; font-size: 15px; }

/* status sheet */
#status dl { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 0 0 16px; font-size: 14px; }
#status dt { color: var(--muted); }
#status dd { margin: 0; overflow-wrap: anywhere; }
#status .bad { color: var(--late); }
#status ol { margin: 0; padding-left: 18px; color: var(--ink-2); }
#status ol a { text-decoration: none; color: var(--ink); }
#status .btns { display: flex; gap: 8px; flex-wrap: wrap; }
#status .btns button { padding: 10px 14px; border-radius: 12px; background: var(--sunk); font-weight: 550; font-size: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 550;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / .4); white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}

.warnc { color: var(--soon); }
.facts small { color: var(--muted); font-size: 12.5px; }
