/* Steep — serif analytics on warm paper */
:root {
  --ink: #17191c;
  --paper: #ffffff;
  --mist: #f2f2f3;
  --fog: #fafafb;
  --slate: #777b86;
  --ash: #979799;
  --smoke: #a3a6af;
  --peach: #fbe1d1;
  --sienna: #5d2a1a;
  --hairline: #ececec;

  --serif: 'Newsreader', 'Noto Serif HK', 'Songti TC', ui-serif, Georgia, serif;
  --sans: 'Inter', 'Noto Sans HK', 'PingFang HK', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-card: 24px;
  --r-elevated: 20px;
  --r-input: 16px;
  --r-small: 16px;

  --shadow-artifact: 0 0 0 1px rgba(4, 23, 43, .05), 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1);
  --shadow-modal: 0 0 0 1px rgba(0, 0, 0, .05), 0 8px 40px 0 rgba(0, 0, 0, .1);
  --shadow-pop: 0 0 0 1px rgba(0, 0, 0, .05), 0 4px 24px 0 rgba(0, 0, 0, .08);

  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.wrap { max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- type ---------- */
.display, .heading-lg, .heading {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.3;
  margin: 0;
  font-optical-sizing: auto;
}
.display { font-size: clamp(44px, 8vw, 90px); letter-spacing: -0.025em; line-height: 1.15; }
.heading-lg { font-size: clamp(40px, 6.4vw, 64px); letter-spacing: -0.015em; line-height: 1.15; }
.heading { font-size: clamp(32px, 4.4vw, 44px); letter-spacing: -0.015em; }
.display em, .heading-lg em, .heading em { font-style: italic; }
.heading-sm { font: 450 22px/1.18 var(--sans); letter-spacing: -0.009em; margin: 0; }
.eyebrow { font-size: 14px; color: var(--ash); margin: 0 0 12px; letter-spacing: .02em; }
.lede { font-size: 18px; font-weight: 430; color: var(--slate); margin: 20px 0 0; max-width: 36em; }
.hint { font-size: 14px; color: var(--slate); margin: 0 0 16px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(255, 255, 255, .86); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.wordmark { font: 400 22px/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; }
.wordmark em { font-style: italic; }
.wordmark-dot { color: var(--smoke); margin: 0 4px; }
.topnav { display: flex; align-items: center; gap: 20px; font-size: 15px; }
.topnav-user { color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- buttons ---------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 9999px;
  font: 400 16px/1 var(--sans); white-space: nowrap;
  border: 1px solid var(--ink); transition: background .15s, color .15s, opacity .15s;
}
.pill-filled { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill-filled:hover { background: #2c2f34; }
.pill-ghost { background: transparent; color: var(--ink); }
.pill-ghost:hover { background: var(--mist); }
.pill-sm { height: 34px; padding: 0 14px; font-size: 14px; }
.pill-block { width: 100%; }
.pill:disabled { opacity: .45; cursor: default; }

.link {
  background: none; border: 0; padding: 2px 0; color: var(--ink); font-size: 15px;
  text-decoration: none; text-underline-offset: 3px;
}
.link:hover { text-decoration: underline; }
.link-muted { color: var(--slate); }

.round {
  width: 40px; height: 40px; flex: none; border-radius: 9999px; border: 1px solid var(--hairline);
  background: var(--paper); display: inline-grid; place-items: center; font-size: 20px; line-height: 1;
}
.round:hover { background: var(--fog); }

/* ---------- surfaces ---------- */
.card { border-radius: var(--r-card); padding: 28px 24px; }
.card-mist { background: var(--mist); }
.card-peach { background: var(--peach); color: var(--sienna); }
.artifact { background: var(--paper); border-radius: var(--r-elevated); box-shadow: var(--shadow-artifact); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.band { background: var(--fog); padding-block: 80px; margin-top: 80px; }

/* ---------- form fields ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; min-width: 0; }
.field > span, .field > label, .field-label { font-size: 14px; color: var(--slate); margin: 0; }
input, select {
  width: 100%; min-width: 0; height: 48px; padding: 0 16px;
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--r-input);
  font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--smoke); }
input:focus, select:focus { border-color: #cfd1d6; box-shadow: 0 0 0 4px rgba(23, 25, 28, .06); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23777b86' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
input[type="date"], input[type="month"] { -webkit-appearance: none; appearance: none; }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--ink); flex: none; }
.custom-input { margin-top: 0; }
.form-error { color: #9b2c1f; font-size: 14px; margin: -4px 0 14px; }

.custom-row { display: flex; gap: 6px; align-items: center; }
.custom-row .pill { height: 48px; flex: none; }
.team-block + .team-block { margin-top: 24px; }
.team-block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.team-block-head h4 { margin: 0; font: 480 16px/1.3 var(--sans); }
.team-block-head span { font-size: 13px; color: var(--ash); }
.team-add { display: flex; gap: 6px; margin-top: 10px; }
.team-add input { height: 38px; font-size: 15px; }
.team-add .pill { flex: none; }
.route-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.route-pair .swap { margin-top: 30px; font-size: 16px; }

.segmented { display: flex; gap: 6px; padding: 4px; background: var(--paper); border: 1px solid var(--hairline); border-radius: 9999px; }
.segmented button {
  flex: 1; height: 38px; border: 0; border-radius: 9999px; background: transparent; font-size: 15px; color: var(--slate);
}
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

.money { position: relative; }
.money-sign { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--slate); pointer-events: none; }
.money input { padding-left: 32px; font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login { padding-block: clamp(48px, 10vh, 120px) 80px; text-align: center; }
.login .lede { margin-inline: auto; }
.login-card { max-width: 420px; margin: 56px auto 0; padding: 28px 24px 24px; text-align: left; }

/* ---------- app hero ---------- */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px 40px; padding-block: 40px 40px; }
.hero-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav input { width: 170px; height: 40px; border-radius: 9999px; text-align: center; padding: 0 14px; }
.pill-select { position: relative; display: flex; align-items: center; height: 40px; border: 1px solid var(--hairline); border-radius: 9999px; padding-left: 16px; background: var(--paper); }
.pill-select-label { font-size: 14px; color: var(--ash); }
.pill-select select { border: 0; height: 38px; background-color: transparent; padding-left: 8px; width: auto; box-shadow: none; }

/* ---------- layout ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
.stack { display: grid; gap: 24px; min-width: 0; }
.date-field { position: relative; }
.date-field input[name="date"] { cursor: pointer; font-variant-numeric: tabular-nums; }
/* the native picker sits invisibly on top so a tap anywhere opens it (iOS/Android); desktop uses showPicker() */
#date-picker { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.date-icon {
  position: absolute; right: 16px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23777b86' stroke-width='1.3'%3E%3Crect x='1.5' y='2.5' width='13' height='12' rx='2.5'/%3E%3Cpath d='M1.5 6.5h13M5 1v3M11 1v3'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- summary (the one peach card) ---------- */
.summary { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 32px; }
.summary-label { margin: 0 0 4px; font-size: 15px; }
.summary-total { margin: 0; font: 400 clamp(44px, 6vw, 64px)/1.1 var(--serif); letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.summary-meta { margin: 6px 0 0; font-size: 15px; opacity: .8; }
.summary-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.summary-note { margin: 0; font-size: 13px; opacity: .7; }
.card-peach .pill-filled { background: var(--sienna); border-color: var(--sienna); color: var(--peach); }
.card-peach .pill-filled:hover { background: #4a2014; }

/* ---------- records ---------- */
.records { padding: 20px 8px 8px; }
.records-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 12px; min-height: 46px; }
.batch { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--slate); }
.record-list { list-style: none; margin: 0; padding: 0; }
.record {
  display: grid; grid-template-columns: auto 64px minmax(0, 1fr) auto; gap: 4px 14px; align-items: center;
  padding: 14px 12px; border-radius: var(--r-small); transition: background .12s;
}
.record + .record { box-shadow: 0 -1px 0 var(--hairline); }
.record:hover { background: var(--fog); }
.record.is-editing { background: var(--mist); }
.record-date { line-height: 1.15; }
.record-day { display: block; font: 400 26px/1 var(--serif); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.record-wd { font-size: 13px; color: var(--ash); }
.record-main { min-width: 0; }
.record-route { font-weight: 480; overflow-wrap: anywhere; }
.record-route .arrow { color: var(--smoke); margin: 0 6px; }
.record-meta { font-size: 14px; color: var(--ash); margin-top: 2px; }
.record-meta span + span::before { content: '·'; margin: 0 6px; color: var(--smoke); }
.record-side { text-align: right; }
.record-amount { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 17px; }
.record-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 4px; }
.record-actions .link { font-size: 13px; color: var(--slate); }
.record-actions .link:hover { color: var(--ink); }
.empty { padding: 48px 16px 56px; text-align: center; color: var(--slate); }
.empty-title { font: 400 26px/1.3 var(--serif); color: var(--ink); margin: 0 0 6px; }
.empty p { margin: 0; }

/* ---------- admin ---------- */
.band .heading { margin-bottom: 40px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px; align-items: start; }
.table-scroll { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-weight: 400; font-size: 13px; color: var(--ash); padding: 0 8px 10px; }
.table td { padding: 12px 8px; border-top: 1px solid #e4e4e7; vertical-align: middle; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .muted { color: var(--slate); }
.table .row-actions { text-align: right; display: flex; gap: 14px; justify-content: flex-end; }
.table .row-actions .link { font-size: 14px; }
.tag { font-size: 13px; color: var(--ash); margin-left: 6px; }
.add-user { margin-top: 28px; }
.add-user .field-label { margin-bottom: 8px; }
.add-user-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; gap: 8px; }
.add-user-row input { height: 44px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 6px 0 14px; background: var(--paper); border-radius: 9999px; font-size: 14px; }
.chips button { width: 24px; height: 24px; border: 0; border-radius: 9999px; background: transparent; color: var(--smoke); font-size: 16px; line-height: 1; }
.chips button:hover { background: var(--mist); color: var(--ink); }

.footer { padding-block: 40px; font-size: 14px; color: var(--ash); }

/* ---------- modal / toast ---------- */
.modal { border: 0; padding: 28px 24px 20px; border-radius: var(--r-card); width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-modal); color: var(--ink); }
.modal::backdrop { background: rgba(23, 25, 28, .28); }
.modal-body { color: var(--slate); margin: 10px 0 20px; }
.modal-body:empty { display: none; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#prompt-fields .field:last-child { margin-bottom: 12px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 50; max-width: calc(100vw - 32px); padding: 12px 20px; border-radius: 9999px;
  background: var(--ink); color: var(--paper); font-size: 15px; box-shadow: var(--shadow-pop);
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .add-user-row { grid-template-columns: 1fr 1fr; }
  .add-user-row input[name="password"] { grid-column: 1 / -1; }
  .add-user-row button { grid-column: 1 / -1; }
  .band { padding-block: 56px; margin-top: 56px; }
}
@media (max-width: 560px) {
  .topnav { gap: 12px; }
  .topnav-user { display: none; }
  .hero { padding-block: 24px 28px; }
  .hero-controls { width: 100%; }
  .month-nav { flex: 1; }
  .month-nav input { flex: 1; width: auto; }
  .pill-select { width: 100%; }
  .pill-select select { flex: 1; }
  .card { padding: 24px 18px; }
  .summary { padding: 28px 22px; }
  .summary-actions { align-items: stretch; width: 100%; }
  .summary-actions .pill { width: 100%; }
  .record { grid-template-columns: auto 48px minmax(0, 1fr); }
  .record-side { grid-column: 2 / -1; display: flex; justify-content: space-between; align-items: center; text-align: left; }
  .record-actions { margin-top: 0; }
  .record-day { font-size: 22px; }
  .route-pair { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .route-pair .swap { justify-self: end; margin: -10px 0 4px; }
}
