:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1b2430; --muted: #5d6b7c; --line: #dfe4ea;
  --brand: #1f3a5f; --accent: #2f6fb2; --ok: #1e7d4f; --warn: #b26a00; --bad: #b3261e;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 16px; line-height: 1.45; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: .25rem 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hint { color: var(--muted); font-size: .88rem; margin: .25rem 0 .75rem; }
.spacer { flex: 1; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--brand); color: #fff; }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.1rem; flex: 1; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar button.ghost { color: #fff; border-color: rgba(255,255,255,.35); background: transparent; }

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

button, .btn { font: inherit; font-size: .95rem; padding: .5rem .85rem; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; min-height: 40px; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); border-color: #e7b7b3; }
button.small { padding: .25rem .6rem; min-height: 32px; font-size: .85rem; }
button:disabled { opacity: .6; cursor: progress; }

input, select, textarea { font: inherit; width: 100%; padding: .55rem .6rem; border: 1px solid #c7cfd9; border-radius: 8px; background: #fff; color: var(--ink); }
input[readonly] { background: #eef1f5; }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .7rem; }
label > input, label > select, label > textarea { margin-top: .2rem; color: var(--ink); }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); }
label.check input { width: auto; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.auth { display: flex; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card button.primary { width: 100%; justify-content: center; }
.msg { min-height: 1.2em; color: var(--bad); font-size: .9rem; }
.msg.ok { color: var(--ok); }

.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input[type=search] { flex: 1; min-width: 180px; width: auto; }

.trip-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.trip-card { display: block; color: inherit; text-decoration: none; margin: 0; }
.trip-card:hover { border-color: var(--accent); }
.trip-card .dates { color: var(--muted); font-size: .9rem; }
.group-title { margin: 1.25rem 0 .5rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }

.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #e8eef6; color: var(--brand); white-space: nowrap; }
.badge.ok { background: #e3f3ea; color: var(--ok); }
.badge.warn { background: #fdf0dc; color: var(--warn); }
.badge.bad { background: #fbe5e3; color: var(--bad); }
.badges { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .4rem; }

.section-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.section-head h2 { flex: 1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .5rem; }
.total { background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.total .n { font-size: 1.2rem; font-weight: 600; }
.total .l { font-size: .8rem; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); padding: .6rem 0; display: flex; gap: .6rem; align-items: flex-start; }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .sub { color: var(--muted); font-size: .88rem; }
.timeline { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .92rem; }
.timeline li { margin: .15rem 0; cursor: pointer; }

table.charges { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.charges th, table.charges td { text-align: left; padding: .45rem .4rem; border-top: 1px solid var(--line); vertical-align: top; }
table.charges th { font-size: .8rem; color: var(--muted); font-weight: 600; border-top: 0; }
table.charges td.num, table.charges th.num { text-align: right; white-space: nowrap; }
table.charges tr { cursor: pointer; }
table.charges tr:hover td { background: #f7f9fc; }
table.charges .comment { color: var(--muted); font-size: .85rem; max-width: 380px; }

.notes { white-space: pre-wrap; overflow-wrap: anywhere; }

.dlg { border: 0; border-radius: 12px; padding: 0; width: min(560px, 96vw); max-height: 92vh; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(15,25,40,.45); }
.dlg form { padding: 1rem; display: flex; flex-direction: column; max-height: 92vh; }
.dlg #dlg-body { overflow: auto; padding: .75rem 0; }
.dlg-actions { display: flex; gap: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.multicheck { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; max-height: 180px; overflow: auto; }
.multicheck label { margin: .25rem 0; }

.toast { position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1b2430; color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 50; max-width: 92vw; }
.toast.bad { background: var(--bad); }

/* Phones: charges table becomes stacked cards, forms single column. */
@media (max-width: 700px) {
  main { padding: .75rem; }
  .grid2 { grid-template-columns: 1fr; }
  table.charges thead { display: none; }
  table.charges, table.charges tbody, table.charges tr, table.charges td { display: block; width: 100%; }
  table.charges tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .5rem; padding: .4rem .6rem; }
  table.charges td { border: 0; padding: .1rem 0; text-align: left !important; }
  table.charges td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  table.charges .comment { max-width: none; }
  .topbar nav button.ghost { padding: .35rem .55rem; font-size: .85rem; min-height: 34px; }
}

/* Trip card title: "yyyy.mm.dd-dd Place" + five progress icons, kept on one line. */
.trip-title { display: flex; align-items: center; gap: .5rem; }
.trip-title .t { flex: 1; min-width: 0; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.steps { display: inline-flex; gap: 3px; flex-shrink: 0; }
.step { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  font-size: 12px; font-weight: 700; line-height: 1; color: #fff; }
.step.done { background: #1e7d4f; }
.step.todo { background: #c62828; }
.step.mini { width: 16px; height: 16px; font-size: 10px; vertical-align: middle; }
.legend { margin: -.25rem 0 .5rem; }
.step-list { list-style: none; padding: 0; margin: 0 0 .8rem; display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .92rem; }
.step-list li { display: inline-flex; align-items: center; gap: .35rem; }
.form-heading { margin: .5rem 0 .4rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 380px) { .step { width: 18px; height: 18px; font-size: 11px; } .steps { gap: 2px; } }
