:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0eb;
  --primary: #2459d3;
  --primary-dark: #1742a6;
  --danger: #b42318;
  --soft: #eef3ff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100svh; margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
.container { width: min(100% - 28px, 980px); margin-inline: auto; }
.site-header { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { color: var(--ink); text-decoration: none; font-weight: 750; }
nav { display: flex; align-items: center; gap: 14px; }
nav a { color: var(--primary); text-decoration: none; font-size: 14px; }
nav a.active { color: var(--primary-dark); font-weight: 700; }
.logout-form { margin: 0; }
.link-button { min-height: auto; padding: 0; border-radius: 0; background: transparent; color: var(--primary); font-size: 14px; font-weight: 400; }
.link-button:hover { background: transparent; color: var(--primary-dark); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: clamp(20px, 4vw, 36px); box-shadow: 0 12px 35px rgb(25 44 85 / 8%); margin-bottom: 28px; }
.card.narrow { max-width: 680px; margin-inline: auto; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
h1 { margin: 0 0 22px; font-size: clamp(28px, 5vw, 38px); line-height: 1.15; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.identity { max-width: 270px; overflow-wrap: anywhere; color: var(--muted); font-size: 13px; }
.expense-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full, .actions.full { grid-column: 1 / -1; }
label { font-weight: 650; font-size: 14px; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #b8c2d1; border-radius: 10px; background: white; color: var(--ink); font: inherit; font-size: 16px; }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(36 89 211 / 18%); border-color: var(--primary); }
.date-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 42px; }
.input-suffix span { position: absolute; right: 14px; top: 11px; color: var(--muted); }
button, .button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 0; border-radius: 10px; padding: 10px 18px; background: var(--primary); color: white; text-decoration: none; font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
button:hover, .button:hover { background: var(--primary-dark); }
.secondary { color: var(--primary); background: var(--soft); }
.secondary:hover { background: #dde7ff; }
.danger { background: #fff0ee; color: var(--danger); }
.danger:hover { background: #ffdcd7; }
.small { min-height: 36px; padding: 7px 11px; font-size: 13px; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 8px; }
.actions.split { justify-content: space-between; flex-wrap: wrap; }
.alert { margin: 0 0 20px; padding: 13px 15px; border-radius: 10px; background: var(--soft); }
.alert-error { color: #7a271a; background: #fff0ee; }
.alert ul { margin-bottom: 0; }
.auth-card { max-width: 520px; margin: 72px auto 28px; text-align: center; }
.auth-card p { margin-bottom: 24px; color: var(--muted); }
.auth-card .button { width: 100%; }
.errors { margin-bottom: 18px; padding: 12px; border-radius: 10px; color: #7a271a; background: #fff0ee; }
.summary { margin: 0 0 26px; border-top: 1px solid var(--line); }
.summary div { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.success-card { text-align: center; }
.success-mark { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 50%; background: #e9f8ef; color: #138a45; font-size: 34px; font-weight: 800; }
.muted { color: var(--muted); font-size: 13px; }
code { overflow-wrap: anywhere; }
.reference-add { display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: end; gap: 12px; margin-bottom: 26px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.inactive td { color: #98a2b3; }
@media (max-width: 720px) {
  body { background: var(--card); }
  .container { width: min(100% - 24px, 680px); }
  .site-header { margin-bottom: 0; }
  .header-inner { min-height: 52px; }
  .brand { display: none; }
  nav { width: 100%; min-width: 0; justify-content: space-between; gap: 4px; }
  nav a, .link-button { display: inline-flex; min-height: 44px; align-items: center; padding: 0 8px; font-size: 14px; white-space: nowrap; }
  nav a.active { box-shadow: inset 0 -3px var(--primary); }
  .logout-form { display: flex; }
  main.container { width: 100%; padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .card-heading { gap: 4px; }
  .expense-card { margin: 0; padding: 20px 16px 24px; border: 0; border-radius: 0; box-shadow: none; }
  .expense-card .eyebrow, .expense-card .identity { display: none; }
  .expense-card h1 { margin-bottom: 18px; font-size: 28px; }
  .expense-form, .reference-add { grid-template-columns: 1fr; }
  .expense-form { gap: 14px; }
  .field.full, .actions.full { grid-column: auto; }
  .field { gap: 6px; }
  input, select { min-height: 52px; border-radius: 12px; }
  textarea { min-height: 84px; border-radius: 12px; }
  .date-row { grid-template-columns: 1fr 1fr; }
  .date-row input { grid-column: 1 / -1; }
  .date-row .small { min-height: 44px; }
  .expense-form .actions { margin-top: 4px; }
  .expense-form .actions button { width: 100%; min-height: 52px; }
  .summary div { grid-template-columns: 1fr; gap: 2px; }
  .actions.split { align-items: stretch; flex-direction: column-reverse; }
  .actions.split .button, .actions.split form, .actions.split button { width: 100%; }
}

@media (max-width: 360px) {
  nav a, .link-button { padding-inline: 5px; font-size: 13px; }
  .expense-card { padding-inline: 14px; }
}
