:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #18365d;
  --muted: #607086;
  --primary: #18365d;
  --primary-dark: #0f2748;
  --accent: #1f8a84;
  --accent-dark: #156d69;
  --accent-soft: #e8f6f4;
  --line: #dce6ef;
  --track: #e9eef4;
  --income: #1f8a84;
  --expense: #ef7b45;
  --balance: #18365d;
  --focus: #ffbf47;
  --shadow: 0 18px 45px rgba(24, 54, 93, 0.10);
  --shadow-soft: 0 8px 22px rgba(24, 54, 93, 0.08);
  font-size: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, rgba(31, 138, 132, 0.10), transparent 28rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, #eef3f7 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.app-header {
  color: var(--text);
  padding: 2.6rem 1rem 2rem;
  text-align: center;
}
.app-header div, .container, .app-footer { max-width: 980px; margin: 0 auto; }
.kicker {
  margin: 0 0 .75rem;
  color: var(--accent-dark);
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-size: .78rem;
}
h1 { margin: 0; font-size: clamp(2.15rem, 7vw, 4rem); line-height: 1.02; letter-spacing: -.04em; }
.lead { max-width: 46rem; margin: 1rem auto 0; font-size: 1.16rem; color: #41516a; }
.container { padding: 1rem; }

.card, .summary-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}
.card { padding: 1.15rem; margin: 1rem 0; }
h2 { margin: 0 0 .8rem; font-size: 1.35rem; letter-spacing: -.02em; }
h3 { margin: 1.2rem 0 .6rem; font-size: 1.1rem; }
p { margin: .5rem 0; }
.small { color: var(--muted); font-size: .95rem; }

.privacy-note {
  border-left: 8px solid var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), #fff 42%);
}
.month-card {
  background: #ffffff;
}
.big-month { font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 950; margin: .2rem 0 0; color: var(--primary); }
.month-picker { display: grid; gap: .35rem; min-width: min(100%, 18rem); }
.month-picker span { font-size: .95rem; color: var(--muted); font-weight: 800; }
.month-year-select { display: grid; grid-template-columns: 1.4fr 1fr; gap: .5rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.summary-grid { display: grid; gap: .8rem; grid-template-columns: repeat(3, 1fr); margin: 1rem 0; }
.summary-card {
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.summary-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: var(--accent);
}
.summary-card.expense::before { background: var(--expense); }
.summary-card.balance::before { background: var(--primary); }
.summary-card span { display: block; color: var(--muted); font-weight: 900; letter-spacing: .02em; }
.summary-card strong { display: block; margin-top: .3rem; font-size: clamp(1.45rem, 5vw, 2.05rem); color: var(--text); }

.bar-chart { display: grid; gap: .8rem; margin-top: 1rem; }
.bar-row { display: grid; grid-template-columns: 8rem 1fr 7rem; align-items: center; gap: .7rem; }
.bar-label, .bar-value { font-weight: 900; }
.bar-value { text-align: right; white-space: nowrap; }
.bar-track { height: 1.65rem; background: var(--track); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; width: 0%; min-width: 0; border-radius: 999px; transition: width .3s ease; }
.income-bar { background: linear-gradient(90deg, var(--accent), #2bb6aa); }
.expense-bar { background: linear-gradient(90deg, var(--expense), #ff9d68); }
.category-box { border-top: 1px solid var(--line); margin-top: 1.1rem; padding-top: .2rem; }
.category-overview { display: grid; gap: .65rem; }
.category-row { display: grid; grid-template-columns: minmax(6rem, 12rem) 1fr auto; align-items: center; gap: .6rem; }
.category-name { font-weight: 900; }
.category-amount { font-weight: 900; white-space: nowrap; }
.category-track { height: 1rem; background: var(--track); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.category-bar { height: 100%; background: linear-gradient(90deg, var(--expense), #ff9d68); border-radius: 999px; }
.no-chart-data { color: var(--muted); background: #f8fafc; border: 2px dashed var(--line); border-radius: 18px; padding: 1rem; }

form { display: grid; gap: .8rem; }
fieldset { margin: 0; border: 0; padding: 0; }
legend, label { font-weight: 900; }
.type-toggle { display: grid; gap: .6rem; }
.type-toggle label {
  display: flex; align-items: center; gap: .6rem;
  background: #f8fafc; border: 2px solid var(--line); border-radius: 16px; padding: .85rem;
}
.type-toggle label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.type-toggle input { width: 1.3rem; height: 1.3rem; accent-color: var(--accent); }
input, select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: .85rem;
  background: white;
  color: var(--text);
}
.money-input { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; }
.money-input span { font-weight: 950; font-size: 1.3rem; }
.primary, .secondary, .danger {
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  padding: .75rem 1.1rem;
  font-weight: 950;
}
.primary { background: var(--accent); color: white; box-shadow: 0 12px 26px rgba(31, 138, 132, .22); }
.primary:hover { background: var(--accent-dark); }
.secondary { background: white; color: var(--primary); border: 2px solid var(--line); }
.secondary:hover { border-color: var(--accent); color: var(--accent-dark); }
.danger { background: #fff2ec; color: #9a4119; border: 2px solid #ffd1bd; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.button-row { display: flex; flex-wrap: wrap; gap: .7rem; }

.entry-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .7rem; }
.entry-item {
  display: grid;
  gap: .4rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: .95rem;
  background: #fff;
  box-shadow: 0 4px 14px rgba(24, 54, 93, 0.06);
}
.entry-top { display: flex; justify-content: space-between; gap: .8rem; align-items: start; }
.entry-title { font-weight: 950; }
.entry-amount { font-weight: 950; font-size: 1.2rem; white-space: nowrap; }
.entry-meta { color: var(--muted); }
.empty-state { margin-top: 1rem; color: var(--muted); background: #f8fafc; border: 2px dashed var(--line); border-radius: 18px; padding: 1rem; }
details { margin-top: .8rem; }
summary { font-weight: 950; cursor: pointer; padding: .6rem 0; }

.app-footer {
  padding: 2rem 1rem 2.5rem;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
  margin-top: 1.5rem;
}
.app-footer p { margin: .2rem 0; }
.app-footer .credit { color: var(--primary); font-weight: 900; }
.app-footer .advice-note { margin: .9rem auto; max-width: 32rem; line-height: 1.5; }
.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  background: var(--primary-dark); color: white; padding: .8rem 1rem;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 10;
}
@media (max-width: 700px) {
  :root { font-size: 17px; }
  .app-header { text-align: left; padding-top: 1.6rem; }
  .lead { margin-left: 0; margin-right: 0; }
  .summary-grid { grid-template-columns: 1fr; }
  .bar-row, .category-row { grid-template-columns: 1fr; gap: .25rem; }
  .bar-value, .category-amount { text-align: left; }
  .card { border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
