:root {
  --paper: #f3eee3;
  --ink: #1c1916;
  --muted: #6b6258;
  --rule: #d4c9b4;
  --green: #215c39;
  --green-soft: #d7eadb;
  --red: #8f2d2d;
  --red-soft: #f4d6d6;
  --navy: #243447;
  --card: #fffcf6;
  --shadow: 0 1px 0 rgba(28, 25, 22, 0.06);
  --gap: 1rem;
  --radius: 4px;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

h1,
h2,
p {
  margin: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ---------- Layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 0.9rem 1.4rem;
  background: var(--navy);
  color: var(--paper);
}

.topbar__brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: inherit;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.95rem;
}

.topbar__link {
  color: inherit;
}

.topbar__user {
  opacity: 0.85;
}

.topbar__form {
  display: flex;
  margin: 0;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 3rem;
}

/* ---------- Page head ---------- */

.page-head {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.page-head__title {
  font-size: 1.7rem;
}

.lede,
.hint,
.aside,
.breadcrumb,
.note {
  color: var(--muted);
  margin: 0;
}

.breadcrumb {
  font-size: 0.9rem;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.3rem;
}

.row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.day-nav {
  display: flex;
  gap: 0.9rem;
  margin: 0;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ---------- Alerts ---------- */

.alert {
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.alert--ok {
  background: var(--green-soft);
}

.alert--error {
  background: var(--red-soft);
  color: var(--red);
}

.empty {
  padding: 1rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background: var(--card);
}

/* ---------- Surfaces ---------- */

.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 26rem;
  margin: 0 auto;
  padding: 1.4rem;
}

/* ---------- Cards ---------- */

.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  list-style: none;
  margin: 0;
  padding: 0;
}

.card {
  flex: 1 1 260px;
}

.card__link {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  padding: 1rem 1.1rem 1.1rem;
  color: inherit;
  text-decoration: none;
}

.card__title {
  font-size: 1.2rem;
}

.card__period,
.card__pct {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.card.is-overspent {
  outline: 2px solid var(--red);
}

/* ---------- Stats ---------- */

.stats {
  display: flex;
  gap: 0.6rem;
  margin: 0;
}

.stats__item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

.stats__label {
  font-size: 0.75rem;
  color: var(--muted);
}

.stats__value {
  margin: 0;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ---------- Summary ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.summary__item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 140px;
  padding: 0.8rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.summary__label {
  color: var(--muted);
  font-size: 0.8rem;
}

.summary__value {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.summary.is-overspent {
  outline: 2px solid var(--red);
}

.neg {
  color: var(--red);
  font-weight: 650;
}

/* ---------- Progress bar ---------- */

.progress {
  height: 8px;
  background: #e6ddcc;
  border-radius: 999px;
  overflow: hidden;
}

.progress__fill {
  display: block;
  height: 100%;
  background: var(--green);
}

.progress--lg {
  height: 12px;
}

.progress--sm {
  width: 6rem;
  height: 6px;
}

.is-overspent .progress__fill {
  background: var(--red);
}

/* ---------- Forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.panel > .form,
.form.panel {
  padding: 1.2rem;
}

.form__actions {
  display: flex;
  gap: 0.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field__label {
  font-size: 0.85rem;
  color: var(--muted);
}

.input {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  width: 100%;
}

textarea.input {
  resize: vertical;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.check .input {
  width: auto;
}

.fieldset {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  padding: 0.9rem;
}

/* Inline form: a lone control such as a submit or delete button */
.form-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

/* Grid-ish record editor row (name + budget + save) */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

.form-row .input {
  flex: 1 1 8rem;
  width: auto;
}

/* Toolbar of side-by-side fields, e.g. expense entry, category add */
.form-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.7rem;
}

.form-toolbar.panel {
  padding: 1.2rem;
}

.form-toolbar .field {
  flex: 1 1 140px;
}

.form-toolbar .btn {
  flex: 0 0 auto;
}

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn--danger {
  background: var(--red);
  border-color: var(--red);
}

.btn-link {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

a {
  color: var(--green);
}

.topbar a,
.topbar .btn-link {
  color: inherit;
}

code {
  font-size: 0.9em;
}

/* ---------- Danger zone ---------- */

.danger-zone {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
  padding: 1.2rem;
  background: var(--card);
  border: 1px solid var(--red);
  border-radius: var(--radius);
}

/* ---------- Table ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.table th,
.table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tr.is-current {
  background: var(--green-soft);
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-size: 0.75rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
  }

  .page {
    padding: 1rem 0.8rem 2rem;
  }

  .stats {
    flex-wrap: wrap;
  }
}
