:root {
  --navy: #001740;
  --navy-2: #0c2d63;
  --gold: #eec643;
  --gold-soft: #fff5cc;
  --ink: #101418;
  --muted: #676b73;
  --surface: #f6f8fb;
  --panel: #ffffff;
  --line: #e4e9f0;
  --green: #2f8f68;
  --warm: #dd785e;
  --blue: #3277b8;
  --shadow: 0 20px 60px rgba(0, 23, 64, 0.1);
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f6f8fb;
  color: var(--ink);
}

.site-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% -14%, rgba(238, 198, 67, 0.22), transparent 32rem),
    linear-gradient(rgba(0, 23, 64, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 23, 64, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, #fbfcfe 0%, #f6f8fb 58%, #ffffff 100%);
  background-size: auto, 32px 32px, 32px 32px, auto;
}

.app-shell {
  position: relative;
  z-index: 1;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100% - 28px, 1120px);
  margin: 0 auto 56px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  background: rgba(246, 248, 251, 0.88);
  backdrop-filter: blur(16px);
}

.topbar-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  text-decoration: none;
}

.brand strong,
h1,
h2,
h3,
.section-kicker,
.pillar-trigger {
  font-family: "Inter Tight", Inter, system-ui, sans-serif;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.logo-wrap {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(238, 198, 67, 0.65);
  border-radius: 14px;
  background: var(--navy);
}

.logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.icon-button {
  display: inline-grid;
  position: relative;
  z-index: 5;
  width: 44px;
  height: 44px;
  place-items: center;
  pointer-events: auto;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 50%;
  background: white;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0, 23, 64, 0.08);
  cursor: pointer;
}

.auth-button {
  min-height: 40px;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 999px;
  background: white;
  color: var(--navy);
  padding: 0 14px;
  font-size: 0.86rem;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 23, 64, 0.08);
}

.section-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dashboard-panel,
.pillar,
.settings-dialog form {
  border: 1px solid rgba(0, 23, 64, 0.1);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.dashboard-panel {
  margin-top: 18px;
  overflow: hidden;
}

.dashboard-head {
  display: flex;
  position: relative;
  z-index: 2;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dashboard-head h2 {
  margin: 2px 0 0;
  color: var(--navy);
  font-size: 1.55rem;
}

.dashboard-actions {
  display: inline-flex;
  flex: 0 0 auto;
  position: relative;
  z-index: 4;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.dashboard-status {
  flex: 1 0 100%;
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.range-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 999px;
  background: white;
  box-shadow: 0 8px 24px rgba(0, 23, 64, 0.08);
}

.range-button {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: var(--navy);
  padding: 0 12px;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.range-button.is-active {
  background: var(--navy);
  color: white;
}

.icon-button.is-refreshing span {
  animation: refresh-spin 0.7s linear infinite;
}

#tracker-refresh-button {
  width: 48px;
  height: 48px;
  min-width: 48px;
  touch-action: manipulation;
}

#tracker-refresh-button span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  pointer-events: none;
}

@keyframes refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.secondary-button,
.entry-actions button {
  min-height: 36px;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 999px;
  background: white;
  color: var(--navy);
  font-size: 0.96rem;
  font-weight: 900;
}

.secondary-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
}

.text-button {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 4px;
}

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

.metric {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric:nth-child(even) {
  border-right: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric-top {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-add-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 50%;
  background: white;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(0, 23, 64, 0.08);
}

.metric-add-button:active {
  transform: translateY(1px);
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--navy);
  font-family: "Inter Tight", Inter, system-ui, sans-serif;
  font-size: clamp(1.45rem, 8vw, 2.35rem);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-saved strong,
.metric-rate strong {
  color: var(--green);
}

body.is-all-time .dashboard-panel {
  border-color: rgba(238, 198, 67, 0.7);
  background:
    linear-gradient(180deg, rgba(238, 198, 67, 0.1), transparent 36%),
    var(--navy);
  box-shadow: 0 24px 70px rgba(0, 23, 64, 0.26);
}

body.is-all-time .dashboard-head {
  background: linear-gradient(90deg, rgba(238, 198, 67, 0.12), transparent 62%);
  border-bottom-color: rgba(238, 198, 67, 0.32);
}

body.is-all-time .dashboard-panel .section-kicker {
  color: rgba(238, 198, 67, 0.9);
}

body.is-all-time .dashboard-head h2 {
  color: white;
}

body.is-all-time .range-toggle {
  border-color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.13);
  box-shadow: none;
}

body.is-all-time .range-button {
  color: white;
}

body.is-all-time .range-button:not(.is-active) {
  color: rgba(255, 255, 255, 0.7);
}

body.is-all-time .range-button.is-active {
  background: white;
  color: var(--navy);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55) inset;
}

body.is-all-time .dashboard-actions .icon-button,
body.is-all-time .metric-add-button {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.96);
  color: var(--navy);
}

body.is-all-time .metric {
  position: relative;
  background: rgba(255, 255, 255, 0.035);
  border-color: rgba(255, 255, 255, 0.18);
}

body.is-all-time .metric span {
  color: rgba(238, 198, 67, 0.92);
}

body.is-all-time .metric strong {
  margin-top: 14px;
  color: white;
}

.pillars {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.pillar {
  overflow: hidden;
}

.pillar-trigger {
  display: flex;
  width: 100%;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: white;
  color: var(--ink);
  padding: 0 18px;
  font-size: 1.22rem;
  font-weight: 900;
  text-align: left;
}

.pillar-trigger > span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.pillar-icon {
  display: inline-grid;
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 34%, #ffe99f 0%, #ffdc78 62%, #f4cb59 100%);
  color: var(--navy);
  box-shadow: 0 8px 18px rgba(238, 198, 67, 0.18);
}

.pillar-icon svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pillar-trigger i {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  font-style: normal;
}

.pillar-trigger[aria-expanded="true"] i {
  transform: rotate(45deg);
}

.pillar-body {
  padding: 0 14px 16px;
  border-top: 1px solid var(--line);
}

.entry-form,
.calculator-form {
  display: grid;
  gap: 12px;
  padding-top: 16px;
}

.entry-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  overflow: visible;
  padding-bottom: 4px;
}

.category-chip {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 999px;
  background: white;
  color: var(--navy);
  padding: 0 7px;
  font-size: clamp(0.82rem, 3.05vw, 0.96rem);
  font-weight: 900;
  line-height: 1.05;
}

.calculator-actions {
  display: flex;
}

.category-chip.is-active {
  border-color: var(--gold);
  background: var(--navy);
  color: white;
}

.category-edit-chip {
  border-color: rgba(238, 198, 67, 0.92);
  background: #fff4bd;
  color: var(--navy);
  box-shadow: 0 8px 18px rgba(238, 198, 67, 0.18);
}

.field,
.filters label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span,
.filters span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.field input,
.field select,
.filters input,
.filters select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 52px;
  border: 1px solid #d8e0ea;
  border-radius: 14px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
}

.field-row,
.filters,
.insight-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}

.primary-button {
  min-height: 54px;
  border: 2px solid var(--gold);
  border-radius: 999px;
  background: var(--navy);
  color: white;
  font-weight: 900;
}

.form-status {
  min-height: 22px;
  margin: -2px 2px 0;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 800;
}

.review-panel {
  width: 100%;
  min-width: 0;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfcfe;
  overflow: hidden;
}

summary {
  min-height: 54px;
  padding: 16px;
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.filters {
  padding: 0 12px 12px;
}

.entry-list,
.month-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
  min-width: 0;
}

.entry-item {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.entry-item strong {
  display: block;
  color: var(--ink);
  font-weight: 900;
}

.entry-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.entry-actions button {
  padding: 0 12px;
}

.currency-groups {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0 12px 12px;
}

.currency-total {
  display: flex;
  min-width: 0;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--navy);
  padding: 0 12px;
  text-align: left;
}

.currency-total b {
  font-size: 0.95rem;
  font-weight: 900;
}

.currency-total span {
  min-width: 0;
  color: rgba(103, 107, 115, 0.74);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
}

.currency-total.is-active {
  border-color: var(--gold);
  background: var(--navy);
  color: white;
}

.currency-total.is-active span {
  color: rgba(255, 255, 255, 0.74);
}

.entry-edit-form {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
}

.entry-edit-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.past-months {
  border-top: 1px solid var(--line);
}

.month-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  overflow: hidden;
}

.month-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 14px;
}

.month-group summary strong {
  color: var(--navy);
  font-size: 0.98rem;
}

.month-group summary span {
  color: rgba(103, 107, 115, 0.62);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.month-group .entry-list {
  padding-top: 0;
}

.results-strip {
  margin-top: 16px;
  padding: 20px 14px;
  border: 1px solid rgba(238, 198, 67, 0.46);
  border-radius: 18px;
  background:
    linear-gradient(rgba(0, 23, 64, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 23, 64, 0.035) 1px, transparent 1px),
    white;
  background-size: 32px 32px;
  text-align: center;
}

.results-strip p {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.74rem;
}

.results-strip h2 {
  display: flex;
  max-width: 860px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 auto;
  color: var(--ink);
  line-height: 1.05;
  text-wrap: balance;
}

.result-phrase {
  max-width: 100%;
  font-size: clamp(1.72rem, 5.15vw, 3.05rem);
  font-weight: 900;
  line-height: 1.08;
}

.result-years-badge {
  display: inline-block;
  color: var(--navy);
  background: var(--gold-soft);
  border: 1px solid rgba(238, 198, 67, 0.6);
  border-radius: 10px;
  padding: 0 9px 3px;
  line-height: 0.95;
  vertical-align: 0.03em;
}

.result-value {
  display: inline-block;
  color: var(--navy);
  background: var(--gold-soft);
  border: 1px solid rgba(238, 198, 67, 0.6);
  border-radius: 14px;
  padding: 2px 12px 5px;
  font-size: clamp(2.35rem, 8.4vw, 3.9rem);
  font-weight: 900;
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.chart-card {
  position: relative;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.chart-card h3,
.top-expenses h3 {
  margin: 0 0 10px;
  color: var(--navy);
  font-size: 1.18rem;
}

.chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  color: var(--navy);
  font-size: 0.9rem;
  font-weight: 900;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.future-marker,
.contribution-marker {
  width: 30px;
  height: 4px;
  border-radius: 999px;
  background: var(--gold);
}

.contribution-marker {
  background: var(--navy);
}

canvas {
  display: block;
  width: 100%;
  max-height: 520px;
}

.table-wrap {
  overflow-x: auto;
  padding: 0 12px 12px;
}

table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

.insight-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.insight-card,
.top-expenses {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.insight-card b {
  display: block;
  color: var(--navy);
  font-size: 1rem;
  margin-bottom: 4px;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.top-expenses {
  margin-top: 12px;
}

.top-expenses ol {
  margin: 0;
  padding-left: 22px;
}

.top-expenses li {
  margin: 8px 0;
  color: var(--muted);
}

.privacy-note {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(0, 23, 64, 0.06);
  border-radius: 20px;
  background: rgba(238, 243, 249, 0.56);
  color: var(--ink);
}

.privacy-note p {
  width: 100%;
  max-width: none;
  margin: 0;
  color: rgba(79, 89, 103, 0.44);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: justify;
  text-align-last: center;
}

.settings-dialog {
  width: min(420px, calc(100% - 28px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(0, 23, 64, 0.38);
}

.settings-dialog form {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.settings-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-dialog h2 {
  margin: 0;
  color: var(--navy);
}

.auth-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.45;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.entry-edit-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background: rgba(0, 23, 64, 0.38);
  -webkit-overflow-scrolling: touch;
}

.category-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 1210;
  display: none;
  align-items: flex-end;
  justify-content: center;
  overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background: rgba(0, 23, 64, 0.4);
  -webkit-overflow-scrolling: touch;
}

.category-editor-overlay.is-open {
  display: flex;
}

.category-editor-panel {
  width: min(560px, 100%);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: 1px solid rgba(0, 23, 64, 0.1);
  border-radius: 24px 24px 20px 20px;
  background: rgba(255, 255, 255, 0.98);
  padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  box-shadow: 0 30px 80px rgba(0, 23, 64, 0.3);
  -webkit-overflow-scrolling: touch;
}

.category-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.category-editor-header h3 {
  margin: 2px 0 0;
  color: var(--navy);
  font-size: clamp(1.55rem, 6vw, 2rem);
  line-height: 1.05;
}

.category-editor-header .icon-button {
  width: 52px;
  height: 52px;
  min-width: 52px;
  font-size: 1.4rem;
}

.category-editor-list {
  display: grid;
  gap: 9px;
}

.category-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(0, 23, 64, 0.1);
  border-radius: 16px;
  background: #fbfcfe;
}

.category-editor-row.is-hidden {
  opacity: 0.56;
}

.category-editor-row input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid #d8e0ea;
  border-radius: 12px;
  background: white;
  color: var(--navy);
  padding: 0 12px;
  font-weight: 900;
}

.category-editor-actions {
  display: grid;
  grid-template-columns: 40px 40px minmax(68px, 1fr) minmax(76px, 1fr);
  gap: 7px;
}

.category-editor-actions button {
  min-height: 40px;
  border: 1px solid rgba(0, 23, 64, 0.12);
  border-radius: 999px;
  background: white;
  color: var(--navy);
  font-weight: 900;
}

.category-editor-actions button:disabled {
  opacity: 0.34;
}

.category-add-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.category-editor-status {
  min-height: 18px;
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

@media (min-width: 620px) {
  .category-editor-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .category-editor-actions {
    width: 280px;
  }
}

@media (min-width: 720px) {
  .category-editor-overlay {
    align-items: center;
  }

  .category-editor-panel {
    border-radius: 22px;
    padding: 22px;
  }
}

.entry-edit-overlay.is-open {
  display: flex;
}

.entry-edit-panel {
  width: min(520px, 100%);
  max-height: calc(100dvh - 24px);
  margin: 0;
  border: 1px solid rgba(0, 23, 64, 0.1);
  border-radius: 24px 24px 20px 20px;
  background: rgba(255, 255, 255, 0.98);
  padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 23, 64, 0.28);
  -webkit-overflow-scrolling: touch;
}

.entry-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 2px;
}

.entry-edit-header .icon-button {
  width: 52px;
  height: 52px;
  min-width: 52px;
  font-size: 1.4rem;
}

.entry-edit-panel .auth-actions {
  margin-top: 4px;
}

.entry-edit-panel h3 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.55rem, 6vw, 2rem);
  line-height: 1.05;
}

.entry-edit-panel .field {
  gap: 6px;
}

.entry-edit-panel .field input,
.entry-edit-panel .field select {
  min-height: 58px;
}

@media (min-width: 720px) {
  .entry-edit-overlay {
    align-items: center;
  }

  .entry-edit-panel {
    border-radius: 22px;
    padding: 22px;
  }
}

@media (min-width: 480px) {
  .auth-actions {
    grid-template-columns: 1fr 1fr;
  }

  .auth-actions .primary-button,
  .auth-actions .secondary-button {
    width: 100%;
    grid-column: auto;
  }
}

@media (min-width: 720px) {
  .app-shell {
    width: min(100% - 48px, 1120px);
  }

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

  .metric {
    border-bottom: 0;
  }

  .metric:nth-child(even) {
    border-right: 1px solid var(--line);
  }

  .metric:last-child {
    border-right: 0;
  }

  .pillar-body {
    padding: 0 18px 20px;
  }

  .calculator-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

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

  .category-grid {
    grid-template-columns: repeat(5, minmax(0, max-content));
    justify-content: start;
    gap: 9px;
  }

  .category-chip {
    width: auto;
    min-width: 104px;
    padding: 0 14px;
    font-size: 0.98rem;
  }

  .category-grid,
  .primary-button,
  .calculator-actions,
  .form-status,
  .chart-card,
  .results-strip {
    grid-column: 1 / -1;
  }

  .secondary-button {
    font-size: 1.08rem;
  }

  .filters,
  .currency-groups,
  .insight-layout,
  .insight-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .entry-item {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (max-width: 520px) {
  .dashboard-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .dashboard-actions {
    width: 100%;
    justify-content: space-between;
  }

  .range-toggle {
    flex: 1 1 auto;
  }

  .range-button {
    padding: 0 9px;
    font-size: 0.72rem;
  }

  .filters {
    padding-inline: 10px;
  }

  .entry-list,
  .month-list,
  .currency-groups {
    padding-inline: 10px;
  }

  .field input,
  .field select,
  .filters input,
  .filters select {
    padding-inline: 12px;
  }

  input[type="date"],
  input[type="month"] {
    min-height: 48px;
    height: 48px;
    font-size: 1rem;
    line-height: 1.2;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
  }

  input[type="date"]::-webkit-date-and-time-value,
  input[type="month"]::-webkit-date-and-time-value {
    min-height: 1.2em;
    text-align: left;
  }

  input[type="date"]::-webkit-calendar-picker-indicator,
  input[type="month"]::-webkit-calendar-picker-indicator {
    margin-left: 4px;
  }
}

body.is-all-time .metric,
body.is-all-time .metric:nth-child(even),
body.is-all-time .metric:last-child {
  border-color: rgba(255, 255, 255, 0.18);
}
