:root {
  --bg: #f5f5f7; --card: #fff; --fg: #1f2329; --muted: #6b7280; --line: #e3e5ea;
  --accent: #2f6fed; --accent-fg: #fff; --ok: #1a7f4b; --warn: #b45309; --bad: #c0362c; --chip: #eef2fd;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1b1f; --card: #26262b; --fg: #ececf0; --muted: #9a9aa5; --line: #3a3a42;
    --accent: #6c9bff; --accent-fg: #101216; --ok: #5cc88c; --warn: #f0a85a; --bad: #ff8a80; --chip: #2f3748;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1b1f; --card: #26262b; --fg: #ececf0; --muted: #9a9aa5; --line: #3a3a42;
  --accent: #6c9bff; --accent-fg: #101216; --ok: #5cc88c; --warn: #f0a85a; --bad: #ff8a80; --chip: #2f3748;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 -apple-system, "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 650; color: var(--fg); text-decoration: none; font-size: 17px; }
.grow { flex: 1; }
main { max-width: 860px; margin: 0 auto; padding: 16px; }
h1 { font-size: 21px; margin: 4px 0 4px; }
h2 { font-size: 16px; margin: 22px 0 8px; }
.sub { color: var(--muted); margin: 0 0 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
button, .btn { font: inherit; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 8px 14px; cursor: pointer; min-height: 38px; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; max-width: 100%; }
textarea { width: 100%; min-height: 160px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
.day { display: block; text-decoration: none; color: inherit; }
.day:hover { border-color: var(--accent); }
.day .t { font-weight: 600; font-size: 16px; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--chip); color: var(--accent); white-space: nowrap; }
.badge.closed { background: var(--line); color: var(--muted); }
.badge.paid { background: transparent; color: var(--ok); border: 1px solid var(--ok); }
.muted { color: var(--muted); }
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.line { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.pick { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; }
.pick button { display: flex; width: 100%; text-align: left; gap: 10px; justify-content: space-between; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 40px; }
.pick button:hover, .pick button:focus-visible { background: var(--chip); }
.chosen { display: flex; gap: 10px; justify-content: space-between; align-items: center; background: var(--chip); border-radius: 8px; padding: 8px 12px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px 14px; margin-top: 10px; }
.opts label { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; margin: 0; cursor: pointer; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 650; border-bottom: 0; }
.total { font-size: 17px; font-weight: 650; }
.me td { background: var(--chip); }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; z-index: 10; }
#toast.show { opacity: 1; }
#toast.err { background: var(--bad); color: #fff; }
.tabs { display: flex; gap: 4px; margin: 14px 0 0; }
.tabs button { border-radius: 8px 8px 0 0; border-bottom: 0; }
.tabs button.on { background: var(--card); font-weight: 600; color: var(--accent); }
@media (max-width: 560px) {
  main { padding: 12px; }
  td, th { padding: 6px 4px; }
  .hide-s { display: none; }
}
.nowrap { flex-wrap: nowrap; }
.end { justify-content: flex-end; }
.w80 { width: 80px; }
textarea.short { min-height: 90px; }
.pad { padding: 0 12px; }
.chosen { flex-wrap: wrap; }
.chosen > span:first-child { flex: 1 1 140px; }
.qr { background: #fff; padding: 6px; border-radius: 8px; line-height: 0; }
.qr svg { width: 150px; height: 150px; }
a.btn { display: inline-block; text-decoration: none; line-height: 22px; }
a.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
