/* Tally — travel-ledger look
   paper #FAFAF6 · ink #1E2B2F · sea teal #0E6E62 · brick #B4372E */

:root {
  --paper:  #FAFAF6;
  --card:   #FFFFFF;
  --ink:    #1E2B2F;
  --muted:  #5C6B6E;
  --line:   #DDDFD6;
  --accent: #0E6E62;
  --accent-ink: #0A554C;
  --neg:    #B4372E;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2 { font-family: var(--display); line-height: 1.1; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 750; }
h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: .01em; }

a { color: var(--accent-ink); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: .9rem; }
.pos { color: var(--accent-ink); }
.neg { color: var(--neg); }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.brand {
  font-family: var(--display); font-weight: 800; font-size: 1.3rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em;
}
.brand-dot { color: var(--accent); }
.brand-big { font-size: 1.6rem; margin: 0 0 1rem; }
.topnav { display: flex; align-items: center; gap: .8rem; }
.whoami { font-size: .9rem; color: var(--muted); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 1.6rem clamp(1rem, 4vw, 2.5rem) 3rem; }
.footer {
  max-width: 1080px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 2rem;
  color: var(--muted); font-size: .8rem;
}

.eyebrow { margin: 0 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.eyebrow a { text-decoration: none; color: var(--muted); }
.eyebrow a:hover { color: var(--accent-ink); }

/* ---------- layout ---------- */
.grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.2rem;
}

.flash {
  background: #E8F3EF; border: 1px solid #BFDCD3; color: var(--accent-ink);
  border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem;
}
.error {
  background: #FBEDEB; border: 1px solid #ECC5C0; color: var(--neg);
  border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem;
}
.notice {
  background: #FFF7E0; border: 1px solid #EADFAF;
  border-radius: 8px; padding: .6rem .9rem; margin: 0 0 1rem; font-size: .9rem;
}

/* ---------- forms ---------- */
.stack { display: grid; gap: .85rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
@media (max-width: 480px) { .row-2 { grid-template-columns: 1fr; } }

label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], select {
  font: inherit; font-weight: 400;
  padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

fieldset.participants {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: .7rem .9rem .8rem; margin: 0;
  display: flex; flex-wrap: wrap; gap: .4rem .9rem;
}
fieldset.participants legend {
  font-size: .85rem; font-weight: 600; padding: 0 .3rem;
  display: flex; gap: .6rem; align-items: baseline;
}
.check { flex-direction: row; align-items: center; gap: .4rem; font-weight: 400; display: flex; }
.split-preview { width: 100%; margin: .2rem 0 0; }
.linklike {
  background: none; border: none; padding: 0; font: inherit; font-size: .8rem;
  color: var(--accent-ink); text-decoration: underline; cursor: pointer;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font: inherit; font-weight: 600; font-size: .9rem;
  padding: .55rem 1rem;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--neg); border-color: transparent; }
.btn-sm { padding: .25rem .6rem; font-size: .8rem; }
.btn-wide { width: 100%; margin-top: .8rem; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0 0; }

/* ---------- auth ---------- */
.auth-hero { max-width: 560px; margin: 2.5rem auto 1.6rem; text-align: center; }
.auth-hero .lede { color: var(--muted); }
.auth-card { max-width: 460px; margin: 0 auto; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tab {
  padding: .5rem .9rem; text-decoration: none; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: .9rem;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- dashboard ---------- */
.trip-card {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  text-decoration: none; color: inherit;
  transition: border-color .12s ease;
}
.trip-card:hover { border-color: var(--accent); }
.trip-card h2 { margin-bottom: .1rem; font-size: 1.15rem; }
.trip-balance { font-size: .9rem; text-align: right; white-space: nowrap; }
.trip-balance.pos { color: var(--accent-ink); }
.trip-balance.neg { color: var(--neg); }
.empty { text-align: center; color: var(--muted); }

/* ---------- trip page ---------- */
.trip-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 1rem; }

.invite .invite-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.invite .invite-row input { flex: 1 1 260px; font-family: var(--mono); font-size: .82rem; }

.expense-list { list-style: none; margin: 0; padding: 0; }
.expense-list li {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 0; border-bottom: 1px dashed var(--line);
}
.expense-list li:last-child { border-bottom: none; }
.expense-main { flex: 1; display: grid; }
.expense-main .muted { font-size: .8rem; }
.expense-amount { white-space: nowrap; font-weight: 600; }

/* ---------- the receipt (signature element) ---------- */
.receipt {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 1.1rem 1.2rem 1.4rem;
  margin-bottom: 1.6rem;
  position: relative;
  box-shadow: 0 6px 14px -10px rgba(30, 43, 47, .35);
}
.receipt::after {                       /* perforated tear-off edge */
  content: "";
  position: absolute; left: 0; right: 0; bottom: -9px; height: 10px;
  background:
    linear-gradient(-45deg, transparent 70%, var(--card) 71%) 0 0 / 14px 10px repeat-x,
    linear-gradient(45deg,  transparent 70%, var(--card) 71%) 7px 0 / 14px 10px repeat-x;
  filter: drop-shadow(0 2px 2px rgba(30, 43, 47, .12));
}
.receipt h2 {
  text-transform: uppercase; letter-spacing: .14em; text-align: center;
  font-size: .85rem; margin-bottom: .9rem;
}
.receipt-lines { list-style: none; margin: 0; padding: 0; }
.receipt-lines li { display: flex; align-items: baseline; gap: .4rem; padding: .3rem 0; font-size: .95rem; }
.receipt-lines .dots { flex: 1; border-bottom: 2px dotted var(--line); transform: translateY(-4px); }
.all-square {
  text-align: center; color: var(--accent-ink); font-weight: 700;
  font-family: var(--mono); margin: 1rem 0 0;
}

.settle-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.settle-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .6rem;
  padding: .55rem 0; border-bottom: 1px dashed var(--line); font-size: .92rem;
}
.settle-list li:last-child { border-bottom: none; }

.settle-history { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.settle-history li {
  display: flex; justify-content: space-between; gap: .6rem; padding: .35rem 0;
}

details summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
details[open] summary { margin-bottom: .8rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
