/* Shared styles. Tokens match the order-flow page Mia approved. Mobile first. */
:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --fg: #1c2133;
  --muted: #5b6275;
  --line: #dde0ea;
  --accent: #2f4a8a;
  --on-accent: #ffffff;
  --accent-soft: #e6ebf6;
  --ok: #1f7a4d; --ok-bg: #e3f3ea;
  --wait: #a4471d; --wait-bg: #fbe9df;
  --out: #6b6f7c; --out-bg: #eceef2;
  --err: #b42318; --err-bg: #fdecea;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --tabbar-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151e; --surface: #1a1f2b; --fg: #e6e9f2; --muted: #9aa1b4; --line: #2c3343;
    --accent: #93acec; --on-accent: #12151e; --accent-soft: #232c45;
    --ok: #6fd3a0; --ok-bg: #173527; --wait: #f2a27c; --wait-bg: #3a2318; --out: #a7acb9; --out-bg: #262b37;
    --err: #fda29b; --err-bg: #3a1d1b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151e; --surface: #1a1f2b; --fg: #e6e9f2; --muted: #9aa1b4; --line: #2c3343;
  --accent: #93acec; --on-accent: #12151e; --accent-soft: #232c45;
  --ok: #6fd3a0; --ok-bg: #173527; --wait: #f2a27c; --wait-bg: #3a2318; --out: #a7acb9; --out-bg: #262b37;
  --err: #fda29b; --err-bg: #3a1d1b;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 16px; line-height: 1.55; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
p { margin: 0; }
a { color: var(--accent); }
code, .code { font-family: var(--font-mono); font-size: 13px; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }

.page { max-width: 520px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left)) 32px max(16px, env(safe-area-inset-right)); display: grid; gap: 16px; }
.page.with-tabbar { padding-bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
.top { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.top strong { font-family: var(--font-display); font-size: 22px; }
.top span, .sub { font-size: 13px; color: var(--muted); }
.head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.head h1 { font-size: 22px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.card.flush { padding: 0; gap: 0; overflow: hidden; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.kv.muted { color: var(--muted); font-size: 13px; }
.kv b { font-size: 15px; }

.field { display: grid; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; }
.field small { font-size: 12px; color: var(--muted); }
input, textarea, select { font: inherit; font-size: 16px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; width: 100%; min-width: 0; min-height: 44px; }
textarea { resize: vertical; min-height: 64px; }
input:disabled, select:disabled, textarea:disabled { background: transparent; border-style: dashed; color: var(--muted); }
input[type="file"] { padding: 8px; font-size: 14px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 10px; }
.row.half { grid-template-columns: 1fr 1fr; }
.row.price { grid-template-columns: minmax(0, 1fr) 120px; }
.item-box { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 10px; min-width: 0; }
.item-box legend { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); font-weight: 600; padding: 0 4px; }
.item-box .remove { justify-self: end; }

button, .btn { font: inherit; font-size: 15px; font-weight: 600; border-radius: 8px; padding: 11px 14px; min-height: 44px; cursor: pointer; border: 0; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.primary { background: var(--accent); color: var(--on-accent); width: 100%; }
.ghost { background: transparent; color: var(--accent); border: 1px dashed var(--accent); }
.quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.danger { background: transparent; color: var(--err); border: 1px solid var(--err); }
.sm { font-size: 13px; padding: 6px 10px; min-height: 36px; }
.link { background: transparent; border: 0; color: var(--accent); padding: 0; min-height: 0; font-size: 14px; font-weight: 600; }
button:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > * { flex: 1 1 150px; }

.chip { align-self: center; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.wait { background: var(--wait-bg); color: var(--wait); }
.chip.out { background: var(--out-bg); color: var(--out); }

.msg { font-size: 14px; padding: 10px 12px; border-radius: 8px; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.warn { background: var(--wait-bg); color: var(--wait); }
.msg.err { background: var(--err-bg); color: var(--err); }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 28px 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { font: inherit; font-size: 13px; padding: 6px 11px; min-height: 34px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 500; }
.filter[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 700; }

.rows { display: grid; }
.row-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); background: transparent; color: var(--fg); text-align: left; text-decoration: none; width: 100%; border-radius: 0; font-weight: 400; min-height: 56px; }
.row-link:first-child { border-top: 0; }
.li-text { display: grid; gap: 2px; min-width: 0; }
.li-text b { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.li-text span { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

.thumb { width: 48px; height: 48px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 11px; display: grid; place-items: center; font-family: var(--font-mono); object-fit: cover; flex: none; padding: 0; min-height: 0; border: 0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.empty { background: transparent; border: 1px dashed var(--line); }
.line-item { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; }

.store { padding: 12px 14px 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.item { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.store + .item { border-top: 0; }
.item .act { grid-column: 2 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .act .err-line { font-size: 12px; color: var(--err); flex-basis: 100%; }

.progress { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
.progress li { display: flex; gap: 10px; align-items: center; }
.progress li::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.progress .done::before { background: var(--ok); border-color: var(--ok); }
.progress .done { color: var(--fg); }
.progress .now { color: var(--fg); font-weight: 600; }
.progress .now::before { border-color: var(--accent); background: var(--accent-soft); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar-in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.nav-it { position: relative; height: var(--tabbar-h); display: flex; justify-content: center; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; }
.nav-it[aria-current="page"] { color: var(--accent); font-weight: 700; }
.nav-it[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 2px; background: var(--accent); }
.nb { font-size: 11px; line-height: 17px; min-width: 17px; padding: 0 5px; border-radius: 999px; background: var(--wait); color: var(--on-accent); font-weight: 700; text-align: center; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 20; max-width: calc(100% - 32px); background: var(--fg); color: var(--bg); font-size: 14px; padding: 10px 14px; border-radius: 10px; }
.trip-foot { padding: 12px 14px 14px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
