:root {
  --paper: #f4f1ea;
  --paper-deep: #e7e1d6;
  --card: #fffcf8;
  --ink: #1b2a26;
  --muted: #66706b;
  --line: #e3dbd0;
  --line-strong: #c9bfb2;
  --green: #1f4f3e;
  --food: #9a6b2f;
  --food-bg: #fbf6ee;
  --travel: #3c6d96;
  --travel-bg: #f3f7fb;
  --stay: #2d7358;
  --stay-bg: #f2f7f4;
  --danger: #8d2d2d;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 420px at 100% -10%, rgba(45, 115, 88, 0.08), transparent 55%),
    radial-gradient(900px 380px at -10% -20%, rgba(156, 107, 47, 0.07), transparent 50%),
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

img { max-width: 100%; }

button, input, a { font: inherit; }

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.mast {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 252, 248, 0.9);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 3px 0 var(--green), 0 8px 24px rgba(27, 42, 38, 0.04);
  backdrop-filter: blur(12px);
}

.mast-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: block;
  flex: none;
}

.brand-name {
  display: block;
  font-family: Palatino, "Palatino Linotype", "Book Antiqua", serif;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.brand-co {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green);
  white-space: nowrap;
}

.kicker {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.home { padding-top: 22px; }

.home-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.home-bar h1 { margin: 0; }

main { padding-bottom: 40px; }

h1, h2, p { margin-top: 0; }

h1 {
  font-family: Palatino, "Palatino Linotype", "Book Antiqua", serif;
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.lede, .hint, .quiet {
  color: var(--muted);
}

.lede { max-width: 62ch; }

.hint { font-size: 13px; margin: 0; }

.stack { display: grid; gap: 14px; }

.row-actions, .photo-actions, .split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn, .btn-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
}

.btn-primary {
  background: var(--green);
  color: white;
  border: 1px solid var(--green);
  box-shadow: 0 8px 18px rgba(31, 79, 62, 0.18);
}

.btn-primary:hover { background: #173f32; }

.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-ghost:hover { border-color: #b7cfc4; background: white; }

.btn-text {
  background: none;
  border: 0;
  color: var(--danger);
  padding: 8px 0;
  min-height: 40px;
}

.mast-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(27, 42, 38, 0.04), 0 10px 24px rgba(27, 42, 38, 0.05);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.nav-btn:hover { background: var(--paper); }

.nav-install {
  background: var(--green);
  color: #fff;
  padding: 0 16px;
}

.nav-install:hover { background: #173f32; color: #fff; }

.nav-account {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--paper);
  color: var(--green);
}

.nav-account::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  flex: none;
}

.account-menu { position: relative; }

.account-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 8;
  min-width: 140px;
  padding: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(27, 42, 38, 0.08);
}

.account-pop .btn { width: 100%; }

.install-help {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(18, 24, 21, 0.45);
}

.install-card {
  width: min(100%, 420px);
  padding: 20px;
  background: white;
  border-radius: 16px;
}

.install-card p { margin: 0 0 16px; }

.nav-google {
  display: flex;
  align-items: center;
  min-height: 40px;
}

.login-card {
  width: min(100%, 560px);
  margin: 36px auto 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(27, 42, 38, 0.06);
}

.login-card h1 { margin-bottom: 8px; }

.login-setup { margin-top: 8px; border: 0; padding: 0; }

.setup-steps {
  margin: 0 0 8px;
  padding-left: 1.2em;
  color: var(--muted);
}

.setup-steps li { margin: 6px 0; }

#google-button { min-height: 44px; margin-top: 16px; }

.claim { margin-bottom: 18px; }

.claim-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.claim-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.claim-title h1 { margin-bottom: 4px; }

.claim-title .quiet { margin: 0; }

.edit-link {
  color: var(--green);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  padding-bottom: 2px;
}

.edit-link:hover { text-decoration: underline; }

.claim-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 18px;
  margin: 16px 0 0;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.claim-facts div { min-width: 0; }

.claim-facts dt {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.claim-facts dd {
  margin: 4px 0 0;
  font-weight: 700;
  overflow-wrap: break-word;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
}

.page-head h1 { margin-bottom: 4px; }

.page-head .row-actions { justify-content: flex-end; }

.meta-line {
  margin: 2px 0 8px;
  font-weight: 650;
}

.cards { display: grid; gap: 10px; }

.card {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 20px;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(27, 42, 38, 0.04), 0 10px 28px rgba(27, 42, 38, 0.04);
}

.card:hover {
  border-color: #b7cfc4;
  box-shadow: 0 12px 32px rgba(27, 42, 38, 0.08);
}

.card h2 { margin-bottom: 2px; }

.card p { margin: 0; }

.last-added {
  display: grid;
  grid-template-columns: minmax(140px, 1.1fr) minmax(180px, 1.5fr) minmax(160px, 1fr);
  gap: 12px 18px;
  margin-top: 14px;
  padding: 14px 16px;
  background: #f7f4ee;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.last-added span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.last-added small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.last-added b {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.card .last-added { margin-top: 2px; }

fieldset.bill-kind { grid-template-columns: 1fr; }

.last-none { margin: 12px 0 0; }

.card-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.card-stats span { display: grid; gap: 2px; justify-items: start; }

.card-total { justify-items: end; text-align: right; }

.card-stats small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-stats b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.card-total b { font-size: 22px; color: var(--green); }

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  margin: 0 0 16px;
}

.meta-grid div { margin: 0; }

.meta-grid dt {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta-grid dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.sheet-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  margin-top: 0;
  overflow-x: auto;
  box-shadow: 0 10px 28px rgba(27, 42, 38, 0.04);
}

.sheet-note { margin: 10px 0 0; }

.totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.totals div {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: white;
}

.totals .tot-food { background: var(--food-bg); box-shadow: inset 0 3px 0 var(--food); }
.totals .tot-travel { background: var(--travel-bg); box-shadow: inset 0 3px 0 var(--travel); }
.totals .tot-stay { background: var(--stay-bg); box-shadow: inset 0 3px 0 var(--stay); }
.totals .tot-all {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.totals span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.totals .tot-all span { color: #d5cbb8; }

.totals strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.totals .tot-all strong { color: white; }

.ledger {
  margin: 0;
  background: white;
  border: 0;
}

.ledger-head, .entry-desk, .ledger-total {
  display: grid;
  grid-template-columns: 96px minmax(180px, 1fr) 112px 112px 112px 64px 58px;
  align-items: stretch;
  min-width: 760px;
}

.ledger-head > span,
.entry-desk > span,
.ledger-total > span {
  display: flex;
  align-items: center;
  padding: 11px 10px;
  border-left: 1px solid #e6dfd3;
  border-bottom: 1px solid #e6dfd3;
  min-height: 52px;
}

.ledger-head > span:first-child,
.entry-desk > span:first-child,
.ledger-total > span:first-child { border-left: 0; }

.ledger-head {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.ledger-head > span {
  align-items: flex-end;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
  background: #f7f4ee;
}

.head-amt {
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  line-height: 1.15;
}

.head-amt b {
  font-weight: 750;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.head-amt small {
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.ledger-head > span.col-food,
.entry-desk > span.col-food,
.ledger-total > span.col-food {
  background: var(--food-bg);
  border-left: 2px solid var(--food);
}

.ledger-head > span.col-travel,
.entry-desk > span.col-travel,
.ledger-total > span.col-travel {
  background: var(--travel-bg);
  border-left: 2px solid var(--travel);
}

.ledger-head > span.col-stay,
.entry-desk > span.col-stay,
.ledger-total > span.col-stay {
  background: var(--stay-bg);
  border-left: 2px solid var(--stay);
}

.entry {
  display: block;
  text-decoration: none;
  color: inherit;
}

.entry:hover .entry-desk > span { background: #fff; }
.entry:hover .col-food { background: #f4ead8; }
.entry:hover .col-travel { background: #e7f0f8; }
.entry:hover .col-stay { background: #e5f3ec; }

.entry-mob { display: none; }

.ledger-total > span {
  border-bottom: 0;
  font-weight: 750;
  background: #f7f4ee;
}

.amt, .sum, .totals strong { font-variant-numeric: tabular-nums; }

.amt {
  justify-content: flex-end;
  font-weight: 650;
}

.bill-y, .bill-n, .thumb, .col-bill { justify-content: center; }

.bill-y { color: var(--green); font-weight: 750; }

.bill-n { color: var(--muted); }

.thumb img, .entry-mob img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  background: white;
  border: 1px solid var(--line);
}

.what { overflow-wrap: anywhere; }

.entry-desk > span.what {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.by {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.form {
  display: grid;
  gap: 16px;
  max-width: 760px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 28px rgba(27, 42, 38, 0.04);
}

.form.login-setup {
  max-width: none;
  background: transparent;
  border: 0;
  padding: 0;
}

.field { display: grid; gap: 6px; }

.field > span, legend {
  font-weight: 700;
}

fieldset.choices {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.choice {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  cursor: pointer;
}

.choice small { color: var(--muted); }

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.choice-food { box-shadow: inset 0 3px 0 var(--food); }
.choice-local_travel { box-shadow: inset 0 3px 0 var(--travel); }
.choice-event { box-shadow: inset 0 3px 0 var(--stay); }

.choice:has(input:checked) {
  border-color: var(--ink);
}

.choice-food:has(input:checked) { background: var(--food-bg); }
.choice-local_travel:has(input:checked) { background: var(--travel-bg); }
.choice-event:has(input:checked) { background: var(--stay-bg); }

.choice:focus-within {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

input[type="text"], input[type="number"], input[type="date"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus {
  outline: 2px solid rgba(31, 79, 62, 0.35);
  border-color: var(--green);
}

.note, .error, .ok, .confirm {
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
}

.note { max-width: 70ch; }

.url {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.error {
  border-left: 3px solid var(--danger);
  background: #f8ece6;
}

.ok {
  border-left: 3px solid var(--green);
  background: #e7f2ec;
}

.confirm { display: grid; gap: 8px; max-width: 560px; }

.preview {
  background: white;
  border: 1px solid var(--line);
  padding: 8px;
}

.preview img {
  display: block;
  max-height: 320px;
  margin: 0 auto;
  object-fit: contain;
}

.skip.is-on {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.paper-page {
  width: min(100%, 860px);
  margin: 0 auto 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 16px 18px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(27, 42, 38, 0.04);
}

.page-head-block { margin-bottom: 12px; }

.page-head-block h2 { margin-bottom: 2px; }

.page-head-block p { margin: 0; }

.page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: #faf8f4;
  min-width: 0;
  overflow: hidden;
}

.tile button {
  display: block;
  width: 100%;
  height: 230px;
  padding: 0;
  border: 0;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  flex: none;
}

.frame {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  overflow: hidden;
}

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: center;
}

.tile p {
  margin: 0;
  padding: 8px 10px 0;
  font-size: 13px;
  line-height: 1.35;
}

.tile p:last-child { padding-bottom: 10px; }

.tile .cap-strong { font-weight: 700; }

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(18, 24, 21, 0.94);
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  gap: 12px;
  padding: 16px;
}

#lightbox[hidden] { display: none; }

#lightbox img {
  max-width: min(980px, 100%);
  max-height: calc(100vh - 140px);
  object-fit: contain;
  background: white;
}

#lightbox p { color: white; margin: 0; text-align: center; }

#lightbox .btn { color: white; border-color: white; }

.back { color: var(--muted); text-decoration: none; font-size: 14px; }

.back:hover { color: var(--ink); }

@media (max-width: 800px) {
  h1 { font-size: 28px; }
  .brand-name { font-size: 22px; }
  .home-bar { flex-direction: column; align-items: stretch; }
  .home-bar .btn { width: 100%; }
  .mast-inner { flex-wrap: wrap; min-width: 0; }
  .brand { min-width: 0; flex: 1 1 160px; }
  .brand-co { white-space: normal; line-height: 1.35; }
  .mast-tools { width: auto; margin-left: auto; }
  .claim-title { flex-direction: column; align-items: flex-start; }
  .claim-toolbar { flex-wrap: wrap; }
  .claim-toolbar .btn { width: auto; flex: 0 0 auto; }
  .claim-facts { grid-template-columns: 1fr 1fr; }
  .claim-facts div:nth-child(4) { grid-column: 1 / -1; }
  .last-added { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn, .row-actions .btn, .photo-actions .btn { width: 100%; }
  .row-actions, .photo-actions { flex-direction: column; align-items: stretch; }
  .card { align-items: start; }
  .card-total { justify-items: start; text-align: left; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
  .totals { grid-template-columns: 1fr 1fr; }
  .tot-all { grid-column: 1 / -1; }
  .totals strong { font-size: 18px; }
  .ledger-head, .entry-desk, .ledger-total { display: none; }
  .ledger { border: 0; background: transparent; overflow: visible; }
  .entry {
    border-bottom: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    background: white;
  }
  .entry.cat-food { border-left-color: var(--food); }
  .entry.cat-local_travel { border-left-color: var(--travel); }
  .entry.cat-event { border-left-color: var(--stay); }
  .entry-mob {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    padding: 12px 10px;
    align-items: center;
  }
  .entry-mob .what { font-weight: 700; }
  .entry-mob .sum { font-size: 18px; margin: 0; }
  .mob-meta { color: var(--muted); font-size: 13px; }
  .tile button { height: 168px; }
}

@media (min-width: 760px) {
  fieldset.choices { grid-template-columns: 1fr 1fr 1fr; }
  fieldset.bill-kind { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .card-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-grid { gap: 8px; }
}
