:root {
  --bg: #f3f5f8; --card: #fff; --ink: #14202e; --muted: #5d6b7c; --line: #dfe4ea;
  --brand: #12355b; --accent: #1f6fb2; --good: #1d7a4f; --goodbg: #e4f4ec;
  --warn: #a4500a; --warnbg: #fdf0df; --bad: #b3261e; --badbg: #fde8e6;
  --top: env(safe-area-inset-top, 0px); --bot: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e151d; --card: #18222e; --ink: #e8eef5; --muted: #98a6b6; --line: #2a3644;
    --brand: #0f2740; --accent: #6db3ee; --good: #6fd3a2; --goodbg: #12301f;
    --warn: #f0b36a; --warnbg: #3a2a12; --bad: #ff8a80; --badbg: #3d1a17;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
a { color: var(--accent); }
#app { max-width: 720px; margin: 0 auto; }

/* header + tabs */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--top) + 12px) 16px 12px; background: var(--brand); color: #fff;
}
.top h1 { font-size: 19px; }
.top p { font-size: 13px; opacity: .8; }
.sync {
  display: flex; align-items: center; gap: 6px; flex: none; border: 0; border-radius: 99px;
  padding: 6px 11px; font-size: 12px; background: rgba(255, 255, 255, .14); color: #fff;
}
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #9aa7b5; }
.sync.ok i { background: #5fd39a; }
.sync.busy i { background: #f4c95d; }
.sync.off i { background: #9aa7b5; }
.sync.err i { background: #ff7b72; }
/* At least a screen tall, so short tabs don't make the browser bars resize and nudge the tab bar. */
main { padding: 14px 16px calc(var(--bot) + 96px); min-height: 100vh; min-height: 100lvh; }
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--bot);
}
.tabs button {
  flex: 1; max-width: 240px; border: 0; background: none; padding: 8px 0 7px; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.tabs span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs .on { color: var(--accent); font-weight: 600; }
.tabs .on span { filter: none; opacity: 1; }
.fab {
  position: fixed; right: max(16px, calc(50% - 344px)); bottom: calc(var(--bot) + 72px); z-index: 6;
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: dark) { .fab { color: #0e151d; } }

/* shared bits */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 17px; margin-bottom: 6px; }
.card p { margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 14px; }
.tight { margin: -4px 0 0; }
.err { color: var(--bad); font-size: 13px; word-break: break-word; }
.none { color: var(--muted); font-size: 14px; padding: 6px 0; }
.pad { padding: 28px 8px; text-align: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e151d; } }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; flex: none; }
.card .btn { margin: 4px 6px 0 0; }
.group { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 8px; }

/* status + issues */
.status { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; background: var(--card); border: 1px solid var(--line); }
.status b { display: block; }
.status span { font-size: 14px; color: var(--muted); }
.status.good { background: var(--goodbg); border-color: transparent; }
.status.good b { color: var(--good); }
.status.warn { background: var(--warnbg); border-color: transparent; }
.status.warn > b { color: var(--warn); margin-bottom: 6px; }
.status li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.status li > button:first-child { flex: 1; text-align: left; border: 0; background: none; padding: 4px 0; font-size: 14px; }

/* week calendar */
.week { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
.wk-cap { font-size: 12px; color: var(--muted); padding: 8px 12px 0; }
.wk-head, .wk-nights { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding-left: 26px; }
.wd { border: 0; background: none; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.wd small { font-size: 11px; color: var(--muted); }
.wd b { width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-size: 15px; }
.wd.today b { box-shadow: inset 0 0 0 2px var(--accent); }
.wd.sel b { background: var(--accent); color: var(--card); }
.wd.out { opacity: .3; }
.wk-nights { min-height: 24px; row-gap: 2px; }
.seg {
  height: 22px; line-height: 22px; margin: 0 2px; padding: 0 4px; border: 0; border-radius: 6px; font-size: 10.5px; font-weight: 600;
  text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.seg.gap, .seg.transit, .seg.home { text-align: center; text-overflow: clip; padding: 0; letter-spacing: -.02em; }
.seg.stay { background: var(--c); color: #fff; }
.seg.gap { background: var(--badbg); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.seg.transit, .seg.home { background: var(--bg); color: var(--muted); font-weight: 500; }
.tgrid { display: grid; grid-template-columns: 26px repeat(7, minmax(0, 1fr)); margin-top: 6px; border-top: 1px solid var(--line); }
.axis { position: relative; }
.axis span { position: absolute; right: 4px; transform: translateY(-50%); font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tcol {
  position: relative; border-left: 1px solid var(--line); cursor: pointer; min-width: 0; overflow: hidden;
  background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 48px; background-position: 0 -1px;
}
.tcol.sel { box-shadow: inset 0 0 0 2px var(--accent); z-index: 2; }
.tcol.out { background: var(--bg); cursor: default; }
.band { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--c) 24%, transparent); border-left: 3px solid var(--c); }
.nostay, .k.nostay { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--bad) 45%, transparent) 0 4px, transparent 4px 8px); }
.tcol .nostay { position: absolute; left: 0; right: 0; }
.k.nostay { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 45%, transparent); }
.blk {
  position: absolute; left: 4px; right: 1px; z-index: 1; border: 0; border-radius: 5px; padding: 1px 0 0; color: #fff;
  font-size: 9.5px; line-height: 1.2; font-weight: 600; font-variant-numeric: tabular-nums; overflow: hidden;
  display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; align-items: center; column-gap: 1px;
}
.blk span { font-size: 10px; }
.blk small { width: 100%; font-size: 9px; font-weight: 500; opacity: .85; text-align: center; }
.blk.tr, .k.tr { background: #1f6fb2; }
.blk.act, .k.act { background: #8e5bb5; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 0 2px 8px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.k { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.k.room { background: color-mix(in srgb, #3b82c4 30%, transparent); border-left: 3px solid #3b82c4; }
.k.free { border: 1px solid var(--line); background: var(--card); }
.trips li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.trips em { font-style: normal; font-size: 13px; color: var(--good); }
.trips { margin-bottom: 10px; }
.welcome .back { margin: 0 0 16px; }
.tapnote { text-align: center; font-size: 12px; margin: -4px 0 12px; }
.todo { color: var(--warn) !important; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink); min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* days */
.day { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; scroll-margin-top: calc(var(--top) + 76px); }
.day.today { border-color: var(--accent); }
.day h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 11px 14px 4px; font-size: 15px; }
.day h3 em { font-style: normal; font-weight: 500; font-size: 13px; color: var(--muted); }
.day .none { padding: 4px 14px 10px; }
.ev li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.ev.card { padding: 0; overflow: hidden; }
.ev.card li:first-child, .day .ev li:first-child { border-top: 0; }
.ev .t { width: 42px; flex: none; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.ev .ic { font-size: 20px; flex: none; }
.ev div { flex: 1; min-width: 0; }
.ev b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.ev small { display: block; color: var(--muted); font-size: 13px; }
.ev code { flex: none; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip { font-size: 13px; flex: none; }
.night { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 14px; font-size: 14px; border-top: 1px solid var(--line); }
.night.stay { border-left: 5px solid var(--c); cursor: pointer; }
.night.transit, .night.home { color: var(--muted); }
.night.gap { background: var(--badbg); color: var(--bad); font-weight: 600; }

/* bookings */
.search { width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; }

/* trip tab */
.invite { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; text-align: center; font-size: 14px; overflow-wrap: anywhere; }

/* welcome */
.welcome { padding: calc(var(--top) + 28px) 18px 40px; text-align: center; }
.welcome .logo { font-size: 52px; }
.welcome h1 { font-size: 28px; margin: 4px 0 8px; }
.lead { color: var(--muted); margin-bottom: 18px; }
.hint { background: var(--warnbg); color: var(--warn); border-radius: 12px; padding: 12px; font-size: 14px; margin-bottom: 16px; text-align: left; }
.welcome form { text-align: left; }
.welcome > .btn { width: 100%; margin-top: 10px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; min-width: 0; }
input:not([type=file]):not([type=checkbox]), textarea {
  display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 9px 11px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); -webkit-appearance: none; appearance: none;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 330px) { .row { grid-template-columns: 1fr; gap: 0; } }
.form { padding: 16px; }
.form > .btn, form.card > .btn { width: 100%; margin-top: 8px; }
.files { margin: 4px 0 14px; }
.files small { color: var(--muted); font-size: 13px; }
.files li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; overflow-wrap: anywhere; }
.filebtn { margin: 6px 0 0; color: var(--ink); font-size: 15px; }

/* sheets */
#sheet, #viewer {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; display: none;
  padding-bottom: calc(var(--bot) + 24px);
}
#viewer { z-index: 30; }
#sheet.open { display: block; }
#viewer.open { display: flex; flex-direction: column; padding-bottom: var(--bot); }
#sheet > *, #viewer > * { max-width: 720px; margin-left: auto; margin-right: auto; width: 100%; }
.shead {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--top) + 10px) 12px 10px; background: var(--card); border-bottom: 1px solid var(--line);
}
.shead h2 { font-size: 16px; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shead > span { width: 50px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px; }
.grid button { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 18px 8px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.grid span { font-size: 30px; }
.detail { padding: 16px; }
.hero { text-align: center; margin-bottom: 14px; }
.hero span { font-size: 40px; }
.hero h1 { font-size: 22px; overflow-wrap: anywhere; }
.hero p { color: var(--muted); }
.conf { display: block; width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px; margin-bottom: 14px; text-align: center; }
.conf small { display: block; color: var(--muted); font-size: 12px; }
.conf code { font-size: 28px; font-weight: 700; letter-spacing: .06em; overflow-wrap: anywhere; }
.legs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.legs > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-width: 0; }
.legs small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.legs b { font-size: 26px; font-variant-numeric: tabular-nums; }
.legs span { display: block; font-size: 13px; color: var(--muted); }
.legs p { font-weight: 600; margin-top: 6px; overflow-wrap: anywhere; }
.f { display: flex; justify-content: space-between; gap: 16px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.f small { color: var(--muted); font-size: 14px; flex: none; }
.f span { text-align: right; overflow-wrap: anywhere; min-width: 0; }
.pre { white-space: pre-wrap; }
#viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.imgwrap { flex: 1; overflow: auto; }
.imgwrap img { display: block; width: 100%; }
.vnote { padding: 8px 14px; font-size: 13px; color: var(--muted); text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--bot) + 84px); transform: translate(-50%, 20px); z-index: 50;
  background: #14202e; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0;
  pointer-events: none; transition: .2s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.maplink { display: inline-block; margin-top: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 600; text-decoration: none; background: var(--bg); }
.f .maplink { margin-top: 0; }

details.card > summary { font-size: 17px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '▾'; color: var(--muted); }
details.card[open] > summary { margin-bottom: 12px; }
details.card[open] > summary::after { content: '▴'; }
details.card summary small { font-weight: 500; color: var(--muted); font-size: 13px; margin-left: 6px; margin-right: auto; }
details.card .btn.primary { width: 100%; margin-top: 8px; }
.files li { justify-content: flex-start; }
.files li input { flex: 1; min-width: 0; margin-top: 0; min-height: 38px; padding: 6px 9px; font-size: 15px; }
.files .tight { margin: 2px 0 4px; font-size: 13px; }
.gapabove { margin-top: 14px; }
.btn.wide { width: 100%; margin-top: 12px; }

/* money */
.money-hero { text-align: center; }
.money-hero > small { display: block; color: var(--muted); font-size: 13px; }
.money-hero > b { display: block; font-size: 32px; font-variant-numeric: tabular-nums; margin: 2px 0; }
.you { margin: 10px 0 0 !important; font-weight: 700; }
.you.pos, .bal .pos { color: var(--good); }
.you.neg, .bal .neg { color: var(--warn); }
.who { margin: 10px 0 0 !important; font-size: 14px; color: var(--muted); }
.chip2 { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 99px; padding: 6px 12px; margin: 4px 2px 0; font-size: 14px; }
.bal li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bal li:last-child { border-bottom: 0; }
.bal span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bal b { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.ev .amt { flex: none; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.ev .amt small { font-weight: 400; }
.people li { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.people li > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.people em { font-style: normal; font-size: 12px; color: var(--good); margin-left: 4px; }
.chips { margin: 8px 0 0 !important; }
form.inline { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
form.inline input, form.inline select { flex: 1; min-width: 0; margin-top: 0; }
form.inline .btn { flex: none; margin: 0; }
.mephone { margin: 12px 0 0; }
select {
  display: block; width: 100%; min-height: 44px; margin-top: 4px; padding: 9px 11px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink);
}
.amountrow { grid-template-columns: 1.4fr 1fr; }
@media (max-width: 330px) { .amountrow { grid-template-columns: 1.4fr 1fr; gap: 10px; } }
.splithead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.splithead small { color: var(--muted); font-size: 13px; }
.seg3 { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg3 button { border: 0; background: none; border-radius: 7px; padding: 6px 9px; font-size: 13px; color: var(--muted); }
.seg3 .on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.split { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2px 12px; margin-bottom: 4px; }
.split li { display: flex; align-items: center; gap: 10px; min-height: 46px; border-bottom: 1px solid var(--line); }
.split li:last-child { border-bottom: 0; }
.split .check { flex: 1; margin: 0; min-height: 44px; }
.split .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.split .num { width: 90px !important; flex: none; margin-top: 0 !important; min-height: 36px !important; padding: 5px 8px !important; text-align: right; }
.split .pv { min-width: 74px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#splitnote { font-size: 12px; margin: 0 0 12px; min-height: 1em; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.cardhead h2 { margin: 0 !important; }
.spend { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; margin: 4px 0 0; }
.spend li { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.curhead { font-size: 13px; font-weight: 700; color: var(--muted); margin: 10px 0 0 !important; }
.you span, .amts span { display: block; }
.you .pos, .amts .pos { color: var(--good); }
.you .neg, .amts .neg { color: var(--warn); }
.bal li.mb { align-items: flex-start; }
.bal li.mb > span { flex: 1 1 auto; min-width: 72px; }
.amts { flex: 0 1 auto; font-size: 15px; line-height: 1.45; }
.ev li.closed { opacity: .55; }
.fxcur { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; margin-bottom: 12px; }
.fxcur h3 { font-size: 14px; margin: 8px 0 2px; }
.fxrow { display: flex; align-items: center; gap: 6px; min-height: 48px; border-top: 1px solid var(--line); font-size: 14px; }
.fxrow > span:first-child { flex: 1; min-width: 0; }
.fxrow small { display: block; color: var(--muted); font-size: 12px; }
.fxrow .u { color: var(--muted); font-size: 13px; flex: none; }
.fxrow input { width: 84px !important; flex: none; margin-top: 0 !important; min-height: 36px !important; padding: 5px 8px !important; text-align: right; font-size: 15px !important; }
.fxrow.all { font-weight: 600; }
.note { background: var(--warnbg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 4px 0 12px !important; }
.ev li.srv { cursor: default; }
.here { font-style: normal; font-size: 12px; color: var(--good); flex: none; }

/* loading + install */
.spinner { width: 34px; height: 34px; margin: 6px auto 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.install { background: var(--card); border: 1px solid var(--accent); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.install h2 { font-size: 16px; margin-bottom: 4px; }
.install ol { margin: 6px 0 8px; padding-left: 20px; list-style: decimal; font-size: 14px; }
.install li { margin: 3px 0; }
.install .btn { margin: 4px 6px 0 0; }
.welcome .install { text-align: left; }
