:root {
  --navy: #17365D; --blue: #1F5FA8; --blue-dark: #163F70; --ink: #1B2735; --muted: #556375; --sub: #3E4C5E;
  --line: #D9E2EC; --line-soft: #E6ECF2; --field: #B8C7D8; --bg: #F3F6FA; --card: #FFFFFF;
  --red: #9B2A1E; --red-line: #E2B4B0; --red-bg: #FDECEA; --amber: #8A4B0F;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; }
input, select, textarea, button { font: inherit; color: inherit; }
a { color: var(--blue); } a:hover { color: var(--blue-dark); }
h1, h2, h3 { line-height: 1.25; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

header.top { background: var(--navy); color: #fff; padding: 14px 16px; }
.wrap { max-width: 1120px; margin: 0 auto; }
header.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
header.top h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
header.top .sub { font-size: 13px; color: #C9D8EA; }
header.top .who { font-size: 13px; color: #C9D8EA; }

nav.tabs { position: sticky; top: 0; z-index: 20; background: #E4ECF5; border-bottom: 1px solid #C9D6E5; }
nav.tabs .wrap { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; scrollbar-width: thin; }
nav.tabs a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 8px; font-weight: 600;
  text-decoration: none; white-space: nowrap; background: #fff; color: var(--navy); border: 1px solid #B9CEE1; }
nav.tabs a[aria-current="page"] { background: var(--blue); color: #fff; border-color: var(--blue); }

main { max-width: 1120px; margin: 0 auto; padding: 18px 14px 80px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.tile { background: var(--bg); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.stat .label, .muted { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero { background: var(--navy); color: #fff; border-radius: 14px; padding: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.hero .label { font-size: 14px; color: #C9D8EA; }
.hero .big { font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero .note { font-size: 13px; color: #C9D8EA; }
.bigmoney { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 8px;
  border: 1px solid #B9CEE1; background: #fff; color: var(--blue); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.light { background: #fff; color: var(--navy); border-color: #fff; }
.btn.ghost-on-dark { background: transparent; color: #fff; border-color: #8FB0D6; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, nav.tabs a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .row-toggle:focus-visible { outline: 3px solid #72A5E1; outline-offset: 2px; }
.btn.small { min-height: 40px; padding: 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { min-height: 44px; padding: 8px 12px; border: 1px solid var(--field); border-radius: 8px; background: #fff; width: 100%; }
.field textarea { min-height: 70px; }
.field input[readonly] { background: var(--bg); border-color: var(--line); }
.field .hint { font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

.list { display: flex; flex-direction: column; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row .main { display: flex; flex-direction: column; gap: 3px; flex: 1 1 260px; min-width: 0; }
.row .main strong { font-size: 15px; overflow-wrap: anywhere; }
.row .amount { display: flex; flex-direction: column; align-items: flex-end; min-width: 110px; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.Paid { background: #E3F3EA; color: #1E6B43; }
.pill.Committed { background: #FBF0DC; color: #7A4E0B; }
.pill.Planning { background: #EDF0F4; color: #46566A; }
.pill.Canceled { background: #F7E4E8; color: #8A2E45; }
.due { color: var(--amber); font-size: 13px; }

.res-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.row-toggle { flex: 1 1 260px; text-align: left; border: 0; background: transparent; padding: 4px 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-height: 44px; }
.res-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; flex: 1 1 320px; font-size: 13px; }
.res-figs div { display: flex; flex-direction: column; }
.res-body { background: var(--bg); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.res-body .row { border-bottom-color: #DCE4EE; }

.alert { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--red-bg); color: #8A1C12; font-size: 14px; }
.ok-banner { margin: 0; padding: 10px 12px; border-radius: 8px; background: #E3F3EA; color: #1E6B43; font-size: 14px; }
.empty { font-size: 14px; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: 14px; max-width: min(92vw, 520px); box-shadow: 0 6px 24px rgba(0,0,0,.2); white-space: pre-line; }
#toast.error { background: #8A1C12; }

dialog { border: 0; border-radius: 14px; padding: 22px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 16px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,35,58,.55); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog p { white-space: pre-line; color: var(--sub); }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--blue); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.audit-row { font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .hero .big { font-size: 32px; }
  .row .amount { align-items: flex-start; }
  header.top h1 { font-size: 19px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color .15s ease, transform .1s ease; }
  .btn:active { transform: scale(.97); }
}
