:root {
  color-scheme: light;
  --bg: #f2eee4;
  --surface: #fffdf7;
  --surface-2: #e8e1d3;
  --ink: #1f312c;
  --muted: #657069;
  --line: #c8c0b2;
  --accent: #c94f3d;
  --accent-soft: #f7ded8;
  --green: #2f7658;
  --blue: #286f8f;
  --amber: #a76b11;
  --shadow: 0 18px 55px rgba(31, 49, 44, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.skip-link {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 12px; }

.app-shell { min-height: 100vh; padding: 0 16px 120px; }
.topbar, main { width: min(1220px, 100%); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.brand h1 { margin: 0; font-size: clamp(1.35rem, 4vw, 2rem); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

button, .file-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 760;
  text-decoration: none;
}
button:hover, button:focus-visible, .file-button:hover, .file-button:focus-visible {
  border-color: var(--blue);
  outline: 3px solid color-mix(in srgb, var(--blue) 18%, transparent);
  outline-offset: 2px;
}
.primary { border-color: var(--ink); background: var(--ink); color: white; }
.danger { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent); }
.icon-button { width: 40px; padding: 0; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 16px;
  padding: 22px 0 16px;
}
.hero-copy, .privacy-card, .panel, .summary-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-copy { padding: clamp(22px, 5vw, 48px); }
.eyebrow { color: var(--accent); font-size: .72rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.hero h2 { max-width: 780px; margin: 8px 0 12px; font-size: clamp(2rem, 7vw, 4.8rem); line-height: .94; letter-spacing: -.04em; }
.hero-copy > p { max-width: 720px; margin: 0; color: var(--muted); font-size: 1.03rem; line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.privacy-card { display: grid; align-content: space-between; gap: 22px; padding: 22px; background: var(--ink); color: white; }
.privacy-card p { margin: 0; color: #d9e0dc; line-height: 1.55; }
.privacy-list { display: grid; gap: 10px; }
.privacy-list span { display: flex; gap: 9px; align-items: center; font-weight: 740; }

.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; }
.month-title { text-align: center; }
.month-title strong { display: block; font-size: 1.55rem; }
.month-title span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-card { padding: 16px; box-shadow: none; }
.summary-card span { color: var(--muted); font-size: .76rem; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.summary-card strong { display: block; margin: 7px 0 3px; font-size: 1.45rem; }
.summary-card small { color: var(--muted); }
.summary-card.alert { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); background: #fff7df; }

.layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .7fr); gap: 14px; align-items: start; }
.column { display: grid; gap: 14px; }
.panel { padding: 18px; box-shadow: none; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel h3 { margin: 0; font-size: 1.25rem; }
.panel-head p, .panel > p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }

.bill-list, .loan-list { display: grid; gap: 9px; }
.bill-row, .loan-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #fffefa;
}
.bill-row.is-paid { opacity: .7; }
.bill-row.is-paid .bill-name { text-decoration: line-through; }
.status-dot { width: 12px; height: 12px; border-radius: 999px; background: var(--amber); box-shadow: 0 0 0 5px #f9edcf; }
.is-paid .status-dot { background: var(--green); box-shadow: 0 0 0 5px #dff0e6; }
.bill-name, .loan-name { font-weight: 850; }
.bill-meta, .loan-meta { margin-top: 4px; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.bill-value { text-align: right; }
.bill-value strong { display: block; }
.row-actions { display: flex; gap: 6px; margin-top: 7px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions button { min-height: 32px; padding: 0 8px; font-size: .75rem; }

.empty-state { border: 1px dashed var(--line); border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); background: #fffefa; }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 5px; }

form { display: grid; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid color-mix(in srgb, var(--blue) 18%, transparent); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.alert-box { border: 1px solid color-mix(in srgb, var(--amber) 55%, var(--line)); border-radius: 11px; padding: 12px; background: #fff7df; color: #704500; margin-bottom: 10px; }
.alert-box strong { display: block; }
.alert-box p { margin: 4px 0 0; line-height: 1.4; }
.loan-row { grid-template-columns: minmax(0, 1fr) auto; }
.loan-row.warning { border-left: 5px solid var(--amber); }
.loan-row.final { border-left: 5px solid var(--green); }
.loan-row.confirm { border-left: 5px solid var(--accent); }

.floating-guided {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 35px rgba(201, 79, 61, .35);
}

.backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(20, 31, 28, .76); }
.dialog { width: min(620px, 100%); max-height: 90vh; overflow: auto; border-radius: 18px; padding: 22px; background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dialog h2 { margin: 0; }
.dialog p { color: var(--muted); line-height: 1.55; }
.guided-bill { border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 16px 0; background: white; }
.guided-bill strong { display: block; font-size: 1.55rem; }
.guided-bill span { display: block; margin-top: 6px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 84px; z-index: 120; transform: translateX(-50%); max-width: calc(100vw - 32px); border-radius: 10px; padding: 11px 14px; background: var(--ink); color: white; box-shadow: var(--shadow); font-weight: 750; }
.hidden { display: none !important; }
footer.site-footer { width: min(1220px, 100%); margin: 28px auto 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }

@media (max-width: 900px) {
  .hero, .layout { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .app-shell { padding-inline: 12px; }
  .topbar { align-items: flex-start; }
  .brand p { display: none; }
  .top-actions button span { display: none; }
  .hero-copy { padding: 24px 18px; }
  .hero h2 { font-size: 2.55rem; }
  .summary-grid, .form-grid { grid-template-columns: 1fr; }
  .bill-row { grid-template-columns: auto minmax(0, 1fr); }
  .bill-value { grid-column: 2; text-align: left; }
  .row-actions { justify-content: flex-start; }
  .floating-guided { width: 52px; height: 52px; padding: 0; border-radius: 999px; }
  .floating-guided span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
