:root {
  --navy: #10263f;
  --navy-2: #183b61;
  --ink: #14202b;
  --muted: #667586;
  --paper: #f7f5ef;
  --surface: #ffffff;
  --line: #d9e1e7;
  --line-strong: #bccbd7;
  --sky: #2f79b9;
  --sky-soft: #eaf3fa;
  --teal: #138a78;
  --teal-soft: #ddf4ee;
  --amber: #c47c00;
  --amber-soft: #fff2d6;
  --danger: #b84444;
  --danger-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(16, 38, 63, 0.05);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 95% 0%, rgba(47, 121, 185, 0.07), transparent 24rem),
    var(--paper);
  padding-bottom: env(safe-area-inset-bottom);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(47, 121, 185, 0.34);
  outline-offset: 1px;
}

.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;
}

.planner-shell {
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 64px;
  padding: 8px 18px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 2px 8px rgba(16, 38, 63, 0.14);
  padding-top: max(8px, env(safe-area-inset-top));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
}

.brand,
.period-controls,
.top-actions,
.section-title,
.panel-actions,
.inline-control,
.save-state,
.summary-card {
  display: flex;
  align-items: center;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  font-weight: 800;
  letter-spacing: -0.08em;
}

.brand h1 {
  margin: 0;
  font-size: clamp(18px, 2vw, 25px);
  line-height: 1;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.period-controls {
  justify-content: center;
  gap: 10px;
}

.month-field {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 180px;
  height: 42px;
  border-radius: 8px;
}

.month-label {
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.025em;
  pointer-events: none;
}

.month-picker {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.top-actions {
  justify-content: flex-end;
  gap: 8px;
}

.mobile-appbar,
.mobile-menu,
.mobile-menu-layer {
  display: none;
}

.icon-button,
.ghost-button,
.logout-button,
.solid-button,
.text-button,
.row-remove,
.statement-button {
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.icon-button,
.ghost-button,
.logout-button {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.34);
  border-radius: 7px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 26px;
  line-height: 1;
}

.ghost-button {
  min-height: 38px;
  padding: 0 13px;
  font-weight: 650;
}

.logout-button {
  min-height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  background: #fff;
  border-color: #fff;
  color: var(--navy);
}

.icon-button:hover,
.ghost-button:hover,
.logout-button:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.62);
}

.logout-button:hover {
  color: #fff;
}

.nav-budget-button.active {
  color: var(--navy);
  background: #fff;
  border-color: #fff;
}

.icon-button:active,
.ghost-button:active,
.logout-button:active,
.solid-button:active,
.text-button:active {
  transform: translateY(1px);
}

.dashboard {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.summary-card {
  min-height: 82px;
  gap: 14px;
  padding: 13px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.summary-icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  color: var(--sky);
  background: var(--sky-soft);
  border-radius: 9px;
  font-size: 22px;
  font-weight: 800;
}

.summary-card:nth-child(3) .summary-icon {
  color: var(--teal);
  background: var(--teal-soft);
}

.summary-card:nth-child(4) .summary-icon {
  color: var(--amber);
  background: var(--amber-soft);
}

.summary-label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.summary-value {
  display: block;
  color: #1559a4;
  font-size: clamp(20px, 2.2vw, 29px);
  font-weight: 760;
  letter-spacing: -0.025em;
  line-height: 1.05;
  white-space: nowrap;
}

.summary-card:nth-child(3) .summary-value {
  color: var(--teal);
}

.summary-card:nth-child(4) .summary-value {
  color: var(--amber);
}

.summary-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(350px, 1fr);
  align-items: stretch;
  gap: 10px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  gap: 12px;
  padding: 7px 11px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  gap: 8px;
  min-width: 0;
}

.section-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  color: var(--navy-2);
  background: var(--sky-soft);
  border-radius: 6px;
  font-size: 15px;
  font-weight: 800;
}

.section-title h2 {
  margin: 0;
  color: var(--navy);
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.panel-actions {
  justify-content: flex-end;
  gap: 8px;
}

.text-button,
.solid-button,
.statement-button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.text-button,
.statement-button {
  color: var(--navy-2);
  background: #fff;
  border-color: var(--line-strong);
}

.text-button:hover,
.statement-button:hover {
  color: #fff;
  background: var(--navy-2);
  border-color: var(--navy-2);
}

.solid-button {
  color: #fff;
  background: var(--navy-2);
  border-color: var(--navy-2);
}

.solid-button:hover {
  background: var(--sky);
  border-color: var(--sky);
}

.inline-control {
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.inline-control input {
  width: 72px;
  height: 30px;
  padding: 0 7px;
  color: var(--teal);
  font-weight: 750;
  text-align: right;
  border: 1px solid #a8d8ce;
  border-radius: 6px;
  background: var(--teal-soft);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th {
  height: 31px;
  padding: 5px 8px;
  color: var(--navy);
  background: #f7fafc;
  border-bottom: 1px solid var(--line-strong);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  height: 37px;
  padding: 3px 8px;
  border-bottom: 1px solid var(--line);
  color: #26394c;
  font-size: 12px;
  vertical-align: middle;
}

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

.data-table tbody tr:nth-child(even) td {
  background: rgba(234, 243, 250, 0.26);
}

.data-table tbody tr:hover td {
  background: rgba(234, 243, 250, 0.7);
}

.data-table .number,
.data-table th.number {
  text-align: right;
}

.data-table .center,
.data-table th.center {
  text-align: center;
}

.cell-input,
.cell-select {
  width: 100%;
  height: 28px;
  min-width: 0;
  padding: 2px 4px;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 12px;
}

.cell-input:hover,
.cell-select:hover {
  background: #fff;
  border-color: var(--line);
}

.cell-input:focus,
.cell-select:focus {
  background: #fff;
  border-color: var(--sky);
  outline: 2px solid rgba(47, 121, 185, 0.12);
}

.cell-input.number {
  text-align: right;
}

.amount-cell {
  color: var(--navy);
  font-weight: 650;
  text-align: right;
  white-space: nowrap;
}

.positive {
  color: var(--teal) !important;
}

.negative {
  color: var(--danger) !important;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 25px;
  padding: 2px 7px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #f2dca9;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: #bbe1d8;
}

.status-pill.late {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f4caca;
}

.row-remove {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: auto;
  color: var(--muted);
  background: transparent;
  border-radius: 5px;
  font-size: 18px;
}

.row-remove:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.row-action-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.table-total td {
  height: 38px;
  color: #1559a4;
  background: var(--sky-soft) !important;
  font-weight: 800;
  border-top: 1px solid var(--line-strong);
}

.empty-row td {
  height: 82px;
  color: var(--muted);
  text-align: center;
}

.expense-panel .data-table {
  min-width: 780px;
}

.cards-panel .data-table {
  min-width: 760px;
}

.income-panel .data-table,
.transfer-panel .data-table {
  min-width: 360px;
}

.installment-strip {
  display: flex;
  align-items: center;
  min-width: 270px;
  gap: 8px;
  padding: 5px 9px;
  color: var(--navy);
  background: var(--sky-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 650;
}

.installment-bar {
  position: relative;
  flex: 1;
  height: 5px;
  overflow: hidden;
  background: #cbdbe8;
  border-radius: 999px;
}

.installment-fill {
  height: 100%;
  background: var(--sky);
  border-radius: inherit;
  transition: width 180ms ease;
}

.installment-amount {
  white-space: nowrap;
}

.footer-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 38px;
  padding: 8px 4px 0;
  color: var(--muted);
  font-size: 11px;
}

.budget-page {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 22px 24px 12px;
}

.budget-title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.budget-title-row h2 {
  margin: 3px 0 5px;
  color: var(--navy);
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -0.035em;
}

.budget-title-row p {
  margin: 0;
  color: var(--muted);
}

.budget-title-row .back-button {
  margin: 0 0 5px;
  padding: 8px 11px;
  color: var(--navy-2);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.budget-title-row .back-button:hover {
  color: #fff;
  background: var(--navy-2);
}

.eyebrow.dark {
  color: var(--sky);
}

.budget-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.budget-summary-card {
  display: flex;
  align-items: center;
  min-height: 112px;
  gap: 15px;
  padding: 18px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.budget-card-icon {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  color: #176ac1;
  background: #e8f2ff;
  border-radius: 50%;
  font-size: 25px;
  font-weight: 800;
}

.budget-summary-card > div {
  min-width: 0;
}

.budget-summary-card span:not(.budget-card-icon) {
  display: block;
  color: var(--navy);
  font-size: 13px;
  font-weight: 750;
}

.budget-summary-card strong {
  display: block;
  margin: 3px 0;
  color: #176ac1;
  font-size: clamp(21px, 2vw, 31px);
  line-height: 1.05;
  white-space: nowrap;
}

.budget-summary-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.remaining-card .budget-card-icon {
  color: var(--amber);
  background: var(--amber-soft);
}

.remaining-card strong {
  color: var(--amber);
}

.transfer-card .budget-card-icon {
  color: var(--teal);
  background: var(--teal-soft);
}

.transfer-card strong {
  color: var(--teal);
}

.salary-panel {
  margin-bottom: 12px;
}

.salary-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
  padding: 12px;
}

.salary-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(135px, .75fr) 28px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.salary-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.budget-inline-input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 4px 7px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
}

.budget-inline-input.number {
  text-align: right;
}

.budget-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(285px, 1fr);
  align-items: start;
  gap: 12px;
}

.budget-table {
  min-width: 900px;
}

.budget-table td {
  height: 43px;
}

.budget-balance {
  color: var(--amber) !important;
  background: #fff8e9 !important;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.transfer-check {
  width: 19px;
  height: 19px;
  accent-color: var(--navy);
}

.transfer-summary-body {
  padding: 20px;
}

.transfer-summary-body > span,
.transfer-summary-body > small {
  display: block;
  color: var(--muted);
}

.transfer-summary-body > strong {
  display: block;
  margin: 7px 0 2px;
  color: var(--teal);
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: -0.035em;
}

.transfer-summary-body ul {
  margin: 18px 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  list-style: none;
}

.transfer-summary-body li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  color: #26394c;
  font-size: 13px;
}

.transfer-summary-body p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.budget-empty-note {
  color: var(--muted);
  font-size: 12px;
}

.save-state {
  gap: 6px;
}

.save-dot {
  width: 7px;
  height: 7px;
  background: var(--teal);
  border-radius: 50%;
}

.save-dot.local {
  background: #d59a37;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 11px 14px;
  color: #fff;
  background: var(--navy);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(16, 38, 63, 0.24);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal-layer {
  position: fixed;
  z-index: 15;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 27, 45, 0.64);
}

.settings-dialog {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  max-height: min(780px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(10, 27, 45, 0.28);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 13px 18px;
  color: #fff;
  background: var(--navy);
}

.settings-header h2 {
  margin: 2px 0 0;
  font-size: 24px;
  line-height: 1;
}

.eyebrow {
  color: #b9d5ec;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 7px;
  font-size: 24px;
}

.dialog-close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.settings-tabs {
  display: flex;
  gap: 3px;
  padding: 8px 12px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
}

.settings-tab {
  min-height: 39px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.settings-tab:hover,
.settings-tab.active {
  color: var(--navy);
}

.settings-tab.active {
  border-bottom-color: var(--sky);
}

.settings-body {
  min-height: 320px;
  overflow: auto;
  padding: 16px;
}

.settings-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
  padding: 11px 13px;
  color: var(--navy);
  background: var(--sky-soft);
  border: 1px solid #cadfec;
  border-radius: 8px;
}

.settings-intro strong {
  font-size: 16px;
}

.settings-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.settings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.settings-table th {
  height: 34px;
  padding: 5px 7px;
  color: var(--navy);
  background: #f7fafc;
  border-bottom: 1px solid var(--line-strong);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.settings-table td {
  height: 41px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
}

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

.settings-table .number {
  text-align: right;
}

.settings-table .center {
  text-align: center;
}

.installment-settings {
  min-width: 980px;
}

.installment-settings th:nth-child(1) { width: 18%; }
.installment-settings th:nth-child(2) { width: 18%; }
.installment-settings th:nth-child(3) { width: 12%; }
.installment-settings th:nth-child(4),
.installment-settings th:nth-child(5) { width: 12%; }
.installment-settings th:nth-child(6) { width: 11%; }
.installment-settings th:nth-child(7) { width: 13%; }
.installment-settings th:nth-child(8) { width: 4%; }

.card-settings {
  min-width: 760px;
}

.card-settings th:nth-child(1) { width: 24%; }
.card-settings th:nth-child(2) { width: 12%; }
.card-settings th:nth-child(3) { width: 18%; }
.card-settings th:nth-child(4) { width: 41%; }
.card-settings th:nth-child(5) { width: 5%; }

.setting-input {
  width: 100%;
  height: 31px;
  min-width: 0;
  padding: 3px 6px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 11px;
}

.setting-input:focus {
  border-color: var(--sky);
  outline: 2px solid rgba(47, 121, 185, 0.12);
}

.setting-input.number {
  text-align: right;
}

.paid-toggle {
  min-width: 75px;
  min-height: 28px;
  padding: 0 7px;
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #f2dca9;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
}

.paid-toggle.is-paid {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: #bbe1d8;
}

.paid-toggle:disabled {
  color: var(--muted);
  background: #f2f4f5;
  border-color: var(--line);
  cursor: default;
}

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  color: var(--muted);
  font-size: 11px;
}

.data-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.data-option {
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.data-option-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--sky);
  background: var(--sky-soft);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.data-option h3 {
  margin: 15px 0 6px;
  color: var(--navy);
  font-size: 17px;
}

.data-option p {
  min-height: 58px;
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.danger-option .data-option-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.danger-button {
  color: var(--danger);
  border-color: #eebcbc;
}

.danger-button:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.storage-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  color: #26685c;
  background: var(--teal-soft);
  border: 1px solid #bbe1d8;
  border-radius: 8px;
  font-size: 12px;
}

.storage-note span {
  color: #4b6c66;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .brand h1 {
    display: none;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(330px, 1fr);
  }

  .summary-card {
    padding-inline: 12px;
  }

  .summary-icon {
    display: none;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .brand h1 {
    display: block;
  }

  .period-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    order: 3;
  }

  .month-field {
    min-width: 150px;
  }

  .month-label {
    font-size: 20px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .expense-panel { order: 1; }
  .income-panel { order: 2; }
  .cards-panel { order: 3; }
  .transfer-panel { order: 4; }

  .data-settings-grid {
    grid-template-columns: 1fr;
  }

  .data-option {
    min-height: auto;
  }

  .data-option p {
    min-height: auto;
  }
}

@media (max-width: 580px) {
  .topbar {
    display: block;
    position: sticky;
    z-index: 10;
    top: 0;
    min-height: 58px;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  }

  .topbar > .brand,
  .topbar > .period-controls,
  .topbar > .top-actions {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .mobile-appbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 44px;
    align-items: center;
    gap: 8px;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
  }

  .mobile-brand .brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    font-size: 14px;
  }

  .mobile-month {
    min-height: 38px;
    padding: 0 8px;
    color: #dce8f2;
    background: transparent;
    border: 0;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 750;
  }

  .mobile-menu-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 9px;
    font-size: 25px;
    line-height: 1;
  }

  .mobile-menu-layer {
    position: fixed;
    z-index: 40;
    inset: 0;
    display: block;
    visibility: hidden;
    opacity: 0;
    background: rgba(9, 24, 39, 0.52);
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  .mobile-menu-layer.is-open {
    visibility: visible;
    opacity: 1;
  }

  .mobile-menu {
    position: fixed;
    z-index: 41;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: min(86vw, 330px);
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) 14px;
    background: #fff;
    box-shadow: -12px 0 36px rgba(9, 24, 39, 0.2);
    transform: translateX(105%);
    transition: transform 200ms ease;
  }

  .mobile-menu.is-open {
    transform: translateX(0);
  }

  .mobile-menu-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 2px 2px 12px 8px;
    color: var(--navy);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .mobile-menu-heading button {
    width: 40px;
    height: 40px;
    color: var(--navy);
    background: var(--sky-soft);
    border: 0;
    border-radius: 9px;
    font-size: 25px;
  }

  .mobile-nav-item {
    display: grid;
    grid-template-columns: 30px 1fr;
    align-items: center;
    min-height: 52px;
    margin: 2px 0;
    padding: 0 14px;
    color: var(--ink);
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 9px;
    font-weight: 720;
  }

  .mobile-nav-item > span:first-child {
    color: var(--muted);
    font-size: 18px;
  }

  .mobile-nav-item.active {
    color: var(--navy);
    background: var(--sky-soft);
  }

  .mobile-nav-item.active > span:first-child {
    color: var(--sky);
  }

  .mobile-logout {
    margin-top: auto;
    color: var(--danger);
    background: var(--danger-soft);
    border-top: 1px solid #f2caca;
  }

  .dashboard {
    padding: 8px;
  }

  .summary-grid {
    gap: 7px;
  }

  .summary-card {
    min-height: 88px;
    padding: 11px 12px;
  }

  .summary-value {
    font-size: 19px;
  }

  .section-title h2 {
    font-size: 15px;
  }

  .panel-header {
    flex-wrap: wrap;
  }

  .installment-strip {
    order: 3;
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  .data-table,
  .expense-panel .data-table,
  .cards-panel .data-table,
  .income-panel .data-table,
  .transfer-panel .data-table,
  .budget-table {
    min-width: 0;
    table-layout: auto;
  }

  .data-table colgroup,
  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tbody {
    padding: 8px;
  }

  .data-table tbody tr {
    margin-bottom: 9px;
    padding: 7px 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 38, 63, 0.04);
  }

  .data-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .data-table tbody tr:nth-child(even) td,
  .data-table tbody tr:hover td {
    background: transparent;
  }

  .data-table td {
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    align-items: center;
    min-height: 40px;
    height: auto;
    padding: 5px 0;
    border-bottom: 1px solid #edf1f4;
    text-align: right !important;
  }

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

  .data-table td::before {
    content: attr(data-label);
    padding-right: 10px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-align: left;
    text-transform: uppercase;
  }

  .data-table td:empty {
    display: none;
  }

  .data-table .cell-input,
  .data-table .cell-select {
    min-height: 38px;
    padding: 5px 7px;
    border-color: var(--line);
    background: #f9fbfc;
    font-size: 16px;
    text-align: right;
  }

  .data-table .cell-select {
    text-align-last: right;
  }

  .data-table .row-remove {
    width: 38px;
    height: 38px;
    margin-right: 0;
    color: var(--danger);
    background: var(--danger-soft);
  }

  .data-table .row-action-wrap {
    justify-content: flex-end;
  }

  .data-table .table-total {
    padding: 10px;
    background: var(--sky-soft);
  }

  .data-table .table-total td {
    display: flex;
    justify-content: space-between;
    border: 0;
    background: transparent !important;
  }

  .data-table .table-total td[colspan] {
    display: none;
  }

  .budget-page,
  .installment-page {
    padding: 10px 8px;
  }

  .budget-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .budget-title-row h2 {
    font-size: 29px;
  }

  .budget-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .budget-summary-card {
    min-height: 112px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
  }

  .budget-card-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 17px;
  }

  .budget-summary-card strong {
    font-size: 20px;
  }

  .salary-rows,
  .salary-row {
    grid-template-columns: 1fr;
  }

  .salary-row {
    position: relative;
    padding-right: 52px;
  }

  .salary-row .row-remove {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 36px;
    height: 36px;
  }

  .budget-layout,
  .installment-layout {
    grid-template-columns: 1fr;
  }

  .budget-table .transfer-check {
    justify-self: end;
  }

  .installment-hero {
    align-items: stretch;
    flex-direction: column;
    gap: 18px;
    padding: 18px;
  }

  .installment-hero-total {
    min-width: 0;
    text-align: left;
  }

  .installment-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .installment-tools label {
    align-items: stretch;
    flex-direction: column;
  }

  .installment-tools select,
  .installment-tools .solid-button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .schedule-month-header,
  .schedule-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .schedule-item {
    gap: 9px;
  }

  .schedule-item .paid-toggle {
    min-height: 38px;
  }

  .footer-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .modal-layer {
    padding: 0;
  }

  .settings-dialog {
    width: 100%;
    max-height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .settings-body {
    padding: 10px;
  }

  .settings-intro,
  .settings-footer,
  .storage-note {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .settings-intro p {
    text-align: left;
  }
}

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

@media print {
  .top-actions,
  .icon-button,
  .panel-actions,
  .row-remove,
  .footer-note {
    display: none !important;
  }

  .topbar {
    color: var(--navy);
    background: #fff;
    box-shadow: none;
    border-bottom: 2px solid var(--navy);
  }

  .dashboard {
    width: 100%;
    padding: 8px 0;
  }

  .panel,
  .summary-card {
    break-inside: avoid;
    box-shadow: none;
  }
}

button.summary-card {
  width: 100%;
  color: inherit;
  text-align: left;
  font: inherit;
}

.installment-summary-card {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.installment-summary-card:hover {
  border-color: #d7a342;
  box-shadow: 0 6px 20px rgba(196, 124, 0, 0.12);
  transform: translateY(-1px);
}

.installment-page {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.installment-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 24px 26px;
  color: #fff;
  background: linear-gradient(125deg, var(--navy), #17466e);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 38, 63, 0.16);
}

.back-button {
  display: block;
  margin: 0 0 18px;
  padding: 0;
  color: #c8def0;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 750;
}

.back-button:hover { color: #fff; }
.installment-hero h2 { margin: 4px 0 7px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; line-height: 1; }
.installment-hero p { max-width: 680px; margin: 0; color: #c8d9e8; font-size: 13px; }
.installment-hero-total { flex: 0 0 auto; min-width: 230px; padding: 14px 18px; text-align: right; background: rgba(255, 255, 255, 0.09); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 10px; }
.installment-hero-total span,
.installment-hero-total small { display: block; color: #c8d9e8; }
.installment-hero-total strong { display: block; margin: 3px 0; color: #ffd88c; font-size: 28px; }

.installment-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0; padding: 10px 12px; background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; }
.installment-tools label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.installment-tools select { min-width: 220px; height: 34px; padding: 0 9px; color: var(--navy); background: #fff; border: 1px solid var(--line-strong); border-radius: 6px; }
.installment-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.75fr); align-items: start; gap: 12px; }
.details-section-heading { display: flex; align-items: flex-end; justify-content: space-between; min-height: 52px; padding: 7px 2px; }
.details-section-heading h3 { margin: 2px 0 0; color: var(--navy); font-size: 19px; }
.details-section-heading > span { color: var(--muted); font-size: 11px; }
.details-section-heading .eyebrow { color: var(--sky); }
.schedule-list,
.plan-summary-list { display: grid; gap: 8px; }
.schedule-month { overflow: hidden; background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; box-shadow: var(--shadow); }
.schedule-month.is-selected { border-color: var(--sky); box-shadow: 0 0 0 2px rgba(47, 121, 185, 0.1); }
.schedule-month-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 8px 12px; background: #f7fafc; border-bottom: 1px solid var(--line); }
.schedule-month-name { color: var(--navy); font-size: 14px; font-weight: 800; }
.current-marker { margin-left: 9px; padding: 3px 7px; color: var(--sky); background: var(--sky-soft); border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.schedule-total { display: flex; align-items: center; gap: 12px; font-size: 10px; color: var(--muted); }
.schedule-total strong { min-width: 100px; color: var(--navy); font-size: 14px; text-align: right; }
.emi-list { display: grid; }
.emi-item { display: grid; grid-template-columns: 12px minmax(150px, 1fr) 120px 72px; align-items: center; gap: 10px; min-height: 54px; padding: 7px 12px; border-bottom: 1px solid var(--line); }
.emi-item:last-child { border-bottom: 0; }
.emi-item.is-paid { background: rgba(221, 244, 238, 0.24); }
.emi-marker { display: inline-block; width: 10px; height: 10px; background: #7b8fa3; border-radius: 50%; box-shadow: 0 0 0 3px rgba(123, 143, 163, 0.13); }
.emi-marker.large { width: 12px; height: 12px; }
.emi-marker[data-card-marker="fab"] { background: #2f79b9; box-shadow: 0 0 0 3px rgba(47,121,185,.14); }
.emi-marker[data-card-marker="rak"] { background: #8b5fbf; box-shadow: 0 0 0 3px rgba(139,95,191,.14); }
.emi-marker[data-card-marker="mashreq"] { background: #d47a2c; box-shadow: 0 0 0 3px rgba(212,122,44,.14); }
.emi-marker[data-card-marker="cbd"] { background: #138a78; box-shadow: 0 0 0 3px rgba(19,138,120,.14); }
.emi-marker[data-card-marker="hsbc"] { background: #d04444; box-shadow: 0 0 0 3px rgba(208,68,68,.14); }
.emi-marker[data-card-marker="enbd-noon"],
.emi-marker[data-card-marker="enbd-master"] { background: #c79a11; box-shadow: 0 0 0 3px rgba(199,154,17,.14); }
.emi-marker[data-card-marker="eislamic"] { background: #477b5d; box-shadow: 0 0 0 3px rgba(71,123,93,.14); }
.emi-copy strong,
.emi-copy span { display: block; }
.emi-copy strong { color: var(--ink); font-size: 12px; }
.emi-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.emi-amount { color: var(--navy); font-size: 12px; font-weight: 800; text-align: right; white-space: nowrap; }
.emi-status { min-height: 27px; padding: 0 8px; color: var(--amber); background: var(--amber-soft); border: 1px solid #f2dca9; border-radius: 999px; font-size: 10px; font-weight: 800; }
.emi-status.is-paid { color: var(--teal); background: var(--teal-soft); border-color: #bbe1d8; }
.plan-summary-card { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 7px 10px; padding: 13px; background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; }
.plan-summary-main strong,
.plan-summary-main span,
.plan-summary-meta strong,
.plan-summary-meta span { display: block; }
.plan-summary-main strong { color: var(--ink); font-size: 12px; }
.plan-summary-main span,
.plan-summary-meta span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.plan-summary-meta { text-align: right; }
.plan-summary-meta strong { color: var(--navy); font-size: 11px; }
.plan-progress { grid-column: 2; height: 5px; overflow: hidden; background: #dce5ec; border-radius: 99px; }
.plan-progress span { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.plan-count { color: var(--muted); font-size: 9px; text-align: right; }
.card-totals-panel { margin-top: 12px; overflow: hidden; background: #fff; border: 1px solid var(--line-strong); border-radius: 9px; box-shadow: var(--shadow); }
.card-totals-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 13px; background: #f7fafc; border-bottom: 1px solid var(--line); }
.card-totals-heading h3 { margin: 2px 0 0; color: var(--navy); font-size: 17px; }
.card-totals-heading > span { color: var(--muted); font-size: 11px; font-weight: 750; }
.card-totals-list { display: grid; }
.card-total-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 50px; padding: 9px 13px; border-bottom: 1px solid var(--line); }
.card-total-row > div strong,
.card-total-row > div span { display: block; }
.card-total-row > div strong { color: var(--ink); font-size: 11px; }
.card-total-row > div span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.card-total-row > strong { color: var(--navy); font-size: 12px; text-align: right; }
.card-totals-empty { padding: 20px 13px; color: var(--muted); font-size: 11px; text-align: center; }
.card-totals-grand { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 13px; color: var(--navy); background: var(--sky-soft); font-size: 12px; font-weight: 800; }
.card-totals-grand strong { font-size: 16px; }
.installment-empty { padding: 30px; color: var(--muted); text-align: center; background: #fff; border: 1px dashed var(--line-strong); border-radius: 9px; }

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

@media (max-width: 580px) {
  .installment-page { padding: 8px; }
  .installment-hero { align-items: stretch; flex-direction: column; padding: 18px; }
  .installment-hero-total { min-width: 0; text-align: left; }
  .installment-tools { align-items: stretch; flex-direction: column; }
  .installment-tools label { align-items: stretch; flex-direction: column; }
  .installment-tools select { width: 100%; min-width: 0; }
  .details-section-heading > span { display: none; }
  .emi-item { grid-template-columns: 12px 1fr auto; }
  .emi-amount { grid-column: 2; text-align: left; }
  .emi-status { grid-column: 3; grid-row: 1 / span 2; }
  .schedule-total span { display: none; }
  .plan-summary-card { grid-template-columns: 16px minmax(0, 1fr); }
  .plan-summary-meta { grid-column: 2; text-align: left; }
  .plan-progress { grid-column: 2; }
  .plan-count { grid-column: 2; text-align: left; }
  .top-actions .nav-budget-button { display: inline-flex; padding: 0 9px; font-size: 11px; }
  .budget-page { padding: 8px; }
  .budget-title-row { align-items: flex-start; flex-direction: column; }
  .budget-title-row .back-button { order: -1; margin-bottom: 0; color: var(--navy-2); }
  .budget-summary-grid { grid-template-columns: 1fr; gap: 8px; }
  .budget-summary-card { min-height: 86px; padding: 12px; }
  .budget-summary-card strong { font-size: 24px; }
  .salary-rows { grid-template-columns: 1fr; padding: 8px; }
  .salary-row { grid-template-columns: 1fr 1fr 28px; }
}
/* Startup failures must remain visible instead of leaving an empty white page. */
.startup-error {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf3f8;
}

.startup-error-card {
  width: min(100%, 460px);
  padding: 32px;
  border: 1px solid #d8e1ea;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 54px rgba(16, 38, 63, 0.14);
  text-align: center;
}

.startup-error-card h1 {
  margin: 18px 0 10px;
  color: #10263f;
  font-size: 24px;
}

.startup-error-card p {
  margin: 0 0 22px;
  color: #607086;
  line-height: 1.55;
}

.startup-error-card button {
  min-height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: #10263f;
  color: #fff;
  font: 700 15px/1 inherit;
}
