@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap');

:root {
  --bg: #f3f6f4;
  --bg-elevated: #ffffff;
  --ink: #14201b;
  --muted: #5f7268;
  --line: #d7e0db;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d8f3ef;
  --warn: #b45309;
  --warn-soft: #fff1de;
  --danger: #b42318;
  --ok: #157a4b;
  --shadow: 0 10px 30px rgba(20, 32, 27, 0.06);
  --radius: 18px;
  --nav-h: 72px;
  --top-h: 56px;
  --font: "Manrope", system-ui, sans-serif;
  --display: "Sora", "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #dff5f0 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e8efe9 0%, transparent 45%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--display);
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

#app { min-height: 100vh; }

.app-shell {
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--top-h) 0 var(--nav-h);
  position: relative;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 100%);
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.1rem;
  background: rgba(243, 246, 244, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(215, 224, 219, 0.8);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none !important;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(30, 79, 214, 0.25);
  flex-shrink: 0;
}

.brand-text {
  background: linear-gradient(90deg, #1e4fd6, #14b8a6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background:
    radial-gradient(800px 400px at 20% 0%, #dbeafe 0%, transparent 55%),
    var(--bg);
}

.boot-logo {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 12px 32px rgba(30, 79, 214, 0.28);
  animation: rise 0.45s ease both;
}

.top-bar-meta {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: capitalize;
}

.page-content {
  padding: 1rem 1.1rem 1.5rem;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 100%);
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none !important;
}

.nav-item .nav-icon { font-size: 1.1rem; line-height: 1; }
.nav-item.active { color: var(--accent-strong); }
.nav-item-primary .nav-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
}

.hero-summary {
  padding: 0.4rem 0 1rem;
  animation: rise 0.45s ease both;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.money {
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 700;
  color: var(--ink);
  margin: 0.2rem 0;
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  text-transform: capitalize;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1rem;
  animation: rise 0.5s ease 0.05s both;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  box-shadow: var(--shadow);
}

.stat strong { display: block; font-size: 0.98rem; margin-top: 0.2rem; }
.stat-label { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.stat-warn { background: var(--warn-soft); border-color: #f0d2a8; }

.alert-banner {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
  animation: rise 0.45s ease 0.08s both;
}

.section { margin-top: 1.25rem; animation: rise 0.5s ease 0.1s both; }
.section-head, .page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-head a { font-weight: 600; font-size: 0.9rem; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.list-row, .installment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  text-decoration: none !important;
  color: inherit;
}

.list-row > div:first-child,
.plan-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.list-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
}

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

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok { background: #dff7ea; color: var(--ok); }

.progress {
  width: 100%;
  height: 6px;
  background: #e5eeea;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.45rem;
}

.progress-lg { height: 10px; margin: 0.85rem 0; }
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #1aa89c);
  border-radius: inherit;
  transition: width 0.35s ease;
}

.filter-row {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}

.chip {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none !important;
}

.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; }
.btn-danger { background: #fff1f0; border-color: #f3c6c2; color: var(--danger); }
.btn-block { width: 100%; margin-top: 0.5rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  background: rgba(255,255,255,0.7);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.detail-hero { margin-bottom: 1rem; }
.detail-amounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.65rem;
  font-weight: 600;
  color: var(--muted);
}

.action-row {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.85rem;
}
.action-row.wrap { flex-wrap: wrap; }

.notes {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: var(--muted);
}

.installment-row.is-paid { opacity: 0.65; }
.installment-row.is-overdue:not(.is-paid) { border-color: #f0d2a8; background: #fffaf3; }

.check-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.check-label input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
}

.check-label span {
  display: flex;
  flex-direction: column;
}

.form { display: flex; flex-direction: column; gap: 0.85rem; margin-top: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 600; font-size: 0.88rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }

.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  background: white;
  color: var(--ink);
}

.textarea { resize: vertical; min-height: 90px; }
.link-btn {
  align-self: flex-start;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0;
  cursor: pointer;
}

.check-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.error { color: var(--danger); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 27, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
}

.modal {
  width: min(400px, 100%);
  background: white;
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

#blazor-error-ui {
  background: #fff1f0;
  bottom: var(--nav-h);
  box-shadow: 0 -1px 4px rgba(0,0,0,0.1);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
  color: var(--danger);
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.loading-progress {
  position: relative;
  display: block;
  width: 8rem;
  height: 8rem;
  margin: 20vh auto 1rem;
}

.loading-progress circle {
  fill: none;
  stroke: #c9ddd7;
  stroke-width: 0.6rem;
  transform-origin: 50% 50%;
  transform: rotate(-90deg);
}

.loading-progress circle:last-child {
  stroke: var(--accent);
  stroke-dasharray: calc(3.141 * 80%), 500%;
  transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}

.loading-progress-text:after {
  content: attr(data-value) '%';
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.month-cell {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 4.2rem;
}

.month-cell strong { font-size: 0.82rem; }
.month-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.month-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.month-empty { opacity: 0.55; }

.card-group-title {
  font-size: 0.95rem;
  color: var(--accent-strong);
  margin: 0.35rem 0 0.55rem;
}

.year-nav { display: flex; gap: 0.35rem; }
.static-row { cursor: default; }
.card-add-row { align-items: end; }
.card-add-row .field { flex: 1; }
select.input { appearance: auto; }
input.input::placeholder,
textarea.input::placeholder { color: #9aaba3; }

.mode-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.mode-option {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.mode-option input { margin-top: 0.2rem; accent-color: var(--accent); }
.mode-option span { display: flex; flex-direction: column; gap: 0.15rem; }
.mode-option small { color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
.mode-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mode-hint { margin: 0.65rem 0 0; font-size: 0.82rem; }
.check-label.is-locked { opacity: 0.85; }
.check-label.is-locked input { cursor: not-allowed; }

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  .stat strong { font-size: 0.9rem; }
  .month-grid { grid-template-columns: repeat(2, 1fr); }
}
