:root {
  color-scheme: light;
  --bg: #f2f6f3;
  --surface: #ffffff;
  --ink: #152326;
  --muted: #637174;
  --line: #d8e2df;
  --primary: #17616d;
  --primary-strong: #0e4a55;
  --income: #167f59;
  --expense: #c84b3a;
  --balance: #294f9b;
  --soft: #e7f2f0;
  --shadow: 0 10px 28px rgba(29, 48, 53, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(23, 97, 109, .12), transparent 260px),
    var(--bg);
  color: var(--ink);
}

.is-hidden {
  display: none !important;
}

button, input, select, textarea {
  font: inherit;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  text-align: center;
}

.app {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 14px;
}

.topbar .icon-btn:last-child {
  color: #a63b2e;
}

.user-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .84rem;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--primary);
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.55rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

.icon-btn, .chip-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 1.5rem;
}

.month-strip {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  margin-bottom: 12px;
}

.chip-btn {
  border-radius: 8px;
  font-size: 1.45rem;
  min-height: 44px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  min-height: 44px;
}

textarea {
  resize: vertical;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.agreement-card {
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--income);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.agreement-card.expired,
.agreement-card.inactive {
  border-left-color: var(--expense);
}

.agreement-card span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  margin-bottom: 3px;
}

.agreement-card strong {
  display: block;
  font-size: .95rem;
}

.agreement-card p {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 10px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  margin-bottom: 4px;
}

.kpi strong {
  display: block;
  font-size: clamp(.92rem, 4vw, 1.2rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.income strong { color: var(--income); }
.expense strong { color: var(--expense); }
.balance strong { color: var(--balance); }

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 8px 0;
  background: rgba(242, 246, 243, .94);
  backdrop-filter: blur(10px);
}

.tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  background: var(--surface);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.view { display: none; }
.view.active { display: block; }

.panel, .form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.panel-head span {
  color: var(--muted);
  font-size: .82rem;
  text-align: right;
}

canvas {
  display: block;
  width: 100%;
  height: 240px;
}

.form-panel {
  display: grid;
  gap: 12px;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented input { display: none; }

.segmented label {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 0;
  color: var(--muted);
  background: var(--surface);
}

.segmented input:checked + label {
  background: var(--soft);
  color: var(--primary-strong);
}

.primary {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.primary.small {
  min-height: 44px;
  padding: 0 12px;
}

button:disabled,
input:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.toolbar, .inline-form {
  display: grid;
  grid-template-columns: 1fr 128px;
  gap: 8px;
  margin: 10px 0;
}


.range-report-panel {
  display: grid;
  gap: 10px;
}

.range-report-panel .panel-head {
  margin-bottom: 0;
}

.range-report-panel .panel-head span {
  color: var(--primary-strong);
  font-size: 1rem;
  font-weight: 900;
}

.range-report-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.range-report {
  display: grid;
  gap: 8px;
}

.range-report-summary,
.range-report-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 10px;
}

.range-report-summary {
  display: grid;
  gap: 3px;
}

.range-report-summary strong {
  color: var(--ink);
}

.range-report-summary span {
  color: var(--muted);
  font-size: .82rem;
}

.range-report-list {
  display: grid;
  gap: 6px;
}

.range-report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: .86rem;
}

.range-report-row span {
  min-width: 0;
  color: var(--muted);
}

.range-report-row strong {
  color: var(--expense);
  white-space: nowrap;
}

.compact-empty {
  padding: 14px 10px;
}
.movement-list, .category-list {
  display: grid;
  gap: 8px;
}

.movement-card, .category-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.movement-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.movement-card h3 {
  margin: 0 0 4px;
  font-size: .98rem;
}

.movement-card p {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.amount {
  font-weight: 900;
  white-space: nowrap;
}

.amount.income { color: var(--income); }
.amount.expense { color: var(--expense); }

.delete-btn {
  grid-column: 1 / -1;
  justify-self: end;
  border: 1px solid #f0c7c0;
  background: #fff5f3;
  color: #a63b2e;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
}

.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-users {
  display: grid;
  gap: 10px;
}

.admin-stats,
.export-grid,
.budget-list {
  display: grid;
  gap: 8px;
}

.admin-stats {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 10px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfdfc;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
}

.stat-box strong {
  display: block;
  font-size: 1rem;
}

.export-grid {
  grid-template-columns: 1fr 1fr;
}

.export-grid button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--primary);
  border-radius: 8px;
  min-height: 42px;
  font-weight: 800;
}

.budget-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px 64px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fbfdfc;
}


.budget-info {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.budget-info strong {
  font-size: .88rem;
}

.budget-info span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
  line-height: 1.3;
}

.budget-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eeec;
}

.budget-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--income);
  transition: width .2s ease, background .2s ease;
}

.budget-meter i.warning {
  background: #c98522;
}

.budget-meter i.over {
  background: var(--expense);
}
.budget-row input {
  min-height: 38px;
  padding: 8px;
}

.budget-row button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-weight: 800;
}

.admin-user-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.admin-user-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.admin-user-card h3 {
  margin: 0 0 3px;
  font-size: .98rem;
}

.admin-user-card p {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.status-pill {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
  background: #e7f6ee;
  color: var(--income);
}

.status-pill.expired,
.status-pill.inactive {
  background: #fff0ed;
  color: var(--expense);
}

.status-pill.soon {
  background: #fff8df;
  color: #8a6500;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-actions button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  min-height: 38px;
  color: var(--primary);
  font-weight: 800;
}

.monthly-balances {
  display: grid;
  gap: 8px;
}

.month-balance-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.month-balance-row strong {
  font-size: .82rem;
}

.balance-track {
  height: 12px;
  border-radius: 999px;
  background: #edf2f0;
  overflow: hidden;
}

.balance-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: var(--balance);
}

.balance-fill.negative {
  background: var(--expense);
}

.month-balance-row span:last-child {
  min-width: 92px;
  text-align: right;
  font-weight: 800;
  font-size: .82rem;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 26px 12px;
}

@media (max-width: 390px) {
  .app { padding-inline: 10px; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .kpis { grid-template-columns: 1fr; }
  .toolbar, .inline-form, .range-report-filters { grid-template-columns: 1fr; }
  .two-cols, .admin-actions, .export-grid, .admin-stats { grid-template-columns: 1fr; }
  .budget-row { grid-template-columns: 1fr 52px; }
  .budget-row .budget-info { grid-column: 1 / -1; }
}

.savings-list {
  display: grid;
  gap: 10px;
}

.savings-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.savings-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.savings-card h3 {
  margin: 0 0 3px;
  font-size: .98rem;
}

.savings-card p {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.savings-balance {
  color: var(--income);
  font-weight: 900;
  white-space: nowrap;
}

.savings-history {
  display: grid;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.savings-history-row {
  display: grid;
  grid-template-columns: 82px 1fr auto;
  gap: 8px;
  color: var(--muted);
  font-size: .8rem;
}

.savings-history-row strong {
  color: var(--income);
}

@media (max-width: 390px) {
  .savings-history-row { grid-template-columns: 1fr; }
}

.savings-report {
  display: grid;
  gap: 12px;
}

.savings-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.savings-report section,
.savings-report-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfc;
}

.savings-report h3 {
  margin: 0 0 8px;
  font-size: .9rem;
}

.savings-report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: .82rem;
}

.savings-report-row:first-of-type {
  border-top: 0;
}

.savings-report-row span {
  min-width: 0;
}

.savings-report-row strong {
  color: var(--income);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .savings-report-grid { grid-template-columns: 1fr; }
  .savings-card header { display: grid; }
}
.icon-svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-only {
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.budget-save-btn {
  width: 44px;
  justify-self: end;
}
.add-category-btn {
  min-width: 58px;
}

.delete-btn.icon-only {
  width: 42px;
  min-height: 38px;
}