:root {
  --navy: #0F1424;
  --navy-2: #1A2242;
  --navy-3: #232C52;
  --coral: #FF8A5B;
  --coral-ink: #C2501F;
  --yellow: #FFC845;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --line: #E2E5EE;
  --ink: #141826;
  --muted: #555E73;
  --income: #3F5EE0;
  --expense: #E0602F;
  --good: #16794F;
  --bad: #B42318;
  --radius: 14px;
  --display: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
a { color: var(--coral-ink); }
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* Buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--navy); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--navy-2); }
.btn.coral { background: var(--coral); color: var(--navy); }
.btn.coral:hover { background: #ff9c73; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #EDEFF5; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--bad); border-color: #F2C9C5; }
.btn.danger:hover { background: #FDF0EF; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--income); outline-offset: 2px;
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid #C9CEDB; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
.field { min-width: 0; }

/* ---------- Public site ---------- */
.site-header {
  background: var(--navy); color: #fff;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 4vw, 48px);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 20px; }
.brand img { width: 40px; height: 40px; }
.brand .hope { color: var(--coral); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.site-nav a.tab { color: #D7DBE8; text-decoration: none; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.site-nav a.tab:hover { color: #fff; background: var(--navy-2); }
.site-nav a.tab[aria-current="page"] { color: #fff; background: var(--navy-3); }

.hero {
  position: relative; overflow: hidden; background: var(--navy); color: #fff;
  padding: clamp(56px, 10vw, 120px) clamp(16px, 4vw, 48px) clamp(64px, 10vw, 130px); text-align: center;
}
.hero .deco { position: absolute; pointer-events: none; }
.hero-inner { position: relative; max-width: 760px; margin: 0 auto; }
.hero img.mark { width: 120px; height: 120px; }
.hero h1 { font-size: clamp(40px, 7vw, 72px); font-weight: 800; margin-top: 12px; letter-spacing: -0.5px; }
.hero h1 span { color: var(--coral); }
.hero .motto { font-size: clamp(18px, 2.4vw, 22px); color: #D7DBE8; margin: 12px 0 0; }

.section { max-width: 960px; margin: 0 auto; padding: 56px clamp(16px, 4vw, 48px); }
.section h2 { font-size: 30px; margin-bottom: 12px; }
.section p { color: var(--muted); font-size: 18px; max-width: 640px; }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 24px; }
.info-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.info-card h3 { font-size: 19px; margin-bottom: 6px; }
.info-card p { font-size: 15px; margin: 0; }

.construction { text-align: center; padding: 80px 16px; }
.construction .icon { width: 72px; height: 72px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 20px; background: #FFF1E9; color: var(--coral-ink); }
.construction h2 { font-size: 34px; }
.construction p { margin: 10px auto 0; color: var(--muted); font-size: 18px; }

.site-footer { text-align: center; color: var(--muted); font-size: 14px; padding: 32px 16px 48px; }

.banner-msg { max-width: 960px; margin: 16px auto 0; padding: 0 clamp(16px, 4vw, 48px); }
.notice { padding: 14px 16px; border-radius: 12px; border: 1px solid; font-weight: 500; }
.notice.bad { background: #FDF0EF; border-color: #F2C9C5; color: #8A1C12; }
.notice.info { background: #EEF2FF; border-color: #C9D3FB; color: #1E2F8F; }

/* ---------- App ---------- */
.app-header { position: sticky; top: 0; z-index: 10; }
.app-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.user-box { display: flex; align-items: center; gap: 10px; color: #D7DBE8; font-size: 14px; flex-wrap: wrap; }
.role-badge { background: var(--navy-3); color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.user-box .btn.ghost { color: #fff; border-color: #3A4570; }
.user-box .btn.ghost:hover { background: var(--navy-2); }

.app-main { max-width: 1200px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 64px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 30px; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.toolbar .field { width: auto; }
.toolbar select { width: auto; min-width: 120px; }

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card h2 { font-size: 19px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat .label { color: var(--muted); font-size: 14px; font-weight: 600; }
.stat .value { font-family: var(--display); font-size: 30px; font-weight: 800; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart svg { width: 100%; height: auto; display: block; }

.cat-row { padding: 10px 0; border-top: 1px solid var(--line); }
.cat-row:first-of-type { border-top: 0; }
.cat-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.cat-row .top b { font-weight: 600; }
.cat-row .nums { color: var(--muted); white-space: nowrap; }
.bar { height: 8px; border-radius: 999px; background: #ECEEF4; margin-top: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.over { color: var(--bad); font-weight: 700; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 700; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 4px; }
tr.archived td { color: var(--muted); }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill.income { background: #EAEFFF; color: #2A44B8; }
.pill.expense { background: #FFEDE4; color: #A8461C; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.planned-input { max-width: 160px; text-align: right; margin-left: auto; }

.goal { padding: 12px 0; border-top: 1px solid var(--line); }
.goal:first-of-type { border-top: 0; }
.goal .top { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.goal .dates { color: var(--muted); font-size: 13px; }

.activity li { padding: 10px 0; border-bottom: 1px solid var(--line); list-style: none; display: flex; gap: 12px; flex-wrap: wrap; }
.activity { padding: 0; margin: 0; }
.activity .when { color: var(--muted); font-size: 13px; min-width: 150px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 20, 36, .25); z-index: 50; max-width: calc(100% - 32px);
}
#toast.bad { background: var(--bad); }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }

@media print {
  .site-header, .toolbar, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; }
}
