:root {
  --bg: #eaf4ff;
  --bg-alt: #d6e7fb;
  --panel: rgba(246, 251, 255, 0.84);
  --panel-strong: #f8fbff;
  --line: rgba(28, 64, 108, 0.12);
  --text: #16324f;
  --muted: #5d7694;
  --accent: #2563eb;
  --accent-2: #38bdf8;
  --positive: #0f8a5f;
  --negative: #b7472a;
  --shadow: 0 18px 50px rgba(37, 99, 235, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(56, 189, 248, 0.24), transparent 20rem),
    radial-gradient(circle at 88% 10%, rgba(37, 99, 235, 0.2), transparent 22rem),
    radial-gradient(circle at 50% 100%, rgba(125, 211, 252, 0.12), transparent 28rem),
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 48%, #deecfb 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 60px;
}

.auth-card,
.composer-panel,
.month-card {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
}

.auth-card {
  min-height: calc(100vh - 92px);
  border-radius: 36px;
  padding: clamp(24px, 4vw, 48px);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
  align-items: end;
}

.auth-copy {
  align-self: center;
  max-width: 640px;
}

.auth-copy h1,
.hero h2 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.lede {
  margin: 14px 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 800;
}

.auth-form,
.table-panel,
.chart-panel,
.summary-metric,
.stat-pill {
  border-radius: var(--radius-xl);
  background: rgba(250, 253, 255, 0.78);
  border: 1px solid var(--line);
}

.auth-form {
  padding: 28px;
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.table-head span,
.summary-metric span,
.stat-label,
.helper-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.form-error {
  min-height: 1.25rem;
  margin: -4px 0 0;
  color: var(--negative);
  font-size: 0.92rem;
  font-weight: 700;
}

.form-status {
  grid-column: 1 / -1;
  min-height: 1.25rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.form-status.is-success {
  color: var(--positive);
}

.form-status.is-error {
  color: var(--negative);
}

.field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
}

.composer-panel .eyebrow {
  margin-bottom: 8px;
}

.composer-panel .field span {
  font-size: 0.88rem;
}

.composer-panel .primary-btn,
.composer-panel .secondary-btn {
  padding: 11px 16px;
}

.field input:focus {
  outline: 2px solid rgba(14, 122, 101, 0.22);
  border-color: rgba(14, 122, 101, 0.35);
}

.remember-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.sign-btn,
.category-tag-label,
.add-option {
  border: 0;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.sign-btn:hover,
.category-tag-label:hover,
.add-option:hover {
  transform: translateY(-1px);
}

.primary-btn {
  padding: 14px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%);
  color: #f9f6f0;
  font-weight: 700;
}

.secondary-btn,
.ghost-btn {
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border: 1px solid var(--line);
}

.icon-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lock-icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.dashboard {
  display: grid;
  gap: 22px;
}

.hidden {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(45, 36, 24, 0.34);
  backdrop-filter: blur(10px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 28px;
  background: rgba(248, 252, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.modal-title {
  margin: 0;
  font-size: 1.55rem;
}

.modal-message {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

body[data-authenticated="false"] #dashboard {
  display: none;
}

body[data-authenticated="true"] #authCard {
  display: none;
}

body[data-authenticated="false"] .floating-entry-btn,
body[data-authenticated="false"] #entryModalBackdrop {
  display: none;
}

.hero {
  padding: 12px 4px 8px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
}

.hero h2 {
  font-size: clamp(2.25rem, 5vw, 4.5rem);
}

.hero-stats {
  display: flex;
  gap: 14px;
  align-items: center;
}

.stat-pill {
  min-width: 240px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
}

.stat-pill strong,
.summary-metric strong {
  font-size: 1.15rem;
}

.delta {
  font-weight: 800;
}

.delta.positive,
.positive {
  color: var(--positive);
}

.delta.negative,
.negative {
  color: var(--negative);
}

.composer-panel,
.month-card {
  border-radius: 32px;
  padding: 22px;
}

.composer-panel {
  padding: 18px;
}

.entry-modal-backdrop {
  z-index: 45;
}

.entry-modal-panel {
  width: min(920px, 100%);
  max-height: min(88vh, 860px);
  overflow-y: auto;
}

.entry-modal-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.entry-modal-close {
  font-size: 1.55rem;
  line-height: 1;
}

.panel-head,
.month-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-head {
  gap: 12px;
}

.panel-head h3,
.month-head h3,
.table-head h4 {
  margin: 0;
  font-size: 1.45rem;
}

.sign-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
}

.sign-btn {
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.sign-btn.is-active {
  background: var(--text);
  color: #fff8ef;
}

.entry-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.field-wide,
.form-actions {
  grid-column: 1 / -1;
}

.category-picker {
  position: relative;
}

.category-tags {
  margin-top: 6px;
  padding: 6px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(248, 252, 255, 0.98);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px;
  max-height: 19.25rem;
  overflow-y: auto;
}

.category-tag {
  min-height: 40px;
  padding: 4px 4px 4px 10px;
  border-radius: 14px;
  border: 1px solid rgba(53, 41, 24, 0.12);
  background: rgba(255, 255, 255, 0.86);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.category-tag.is-selected {
  background: rgba(14, 122, 101, 0.12);
  border-color: rgba(14, 122, 101, 0.28);
  box-shadow: inset 0 0 0 1px rgba(14, 122, 101, 0.12);
}

.category-tag-label {
  max-width: 100%;
  padding: 5px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.category-tag-label:hover {
  color: var(--accent);
}

.add-option {
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.category-status {
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.52);
  width: 100%;
}

.category-status-error {
  color: var(--negative);
}

.category-delete-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(115, 101, 80, 0.18);
  background: rgba(115, 101, 80, 0.06);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.category-delete-btn:hover:not(:disabled) {
  background: var(--muted);
  color: #fff8ef;
  border-color: var(--muted);
  transform: translateY(-1px);
}

.category-delete-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.category-delete-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.months-stack {
  display: grid;
  gap: 20px;
}

.floating-entry-btn {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 35;
  width: 68px;
  height: 68px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%);
  color: #fff8ef;
  box-shadow: 0 22px 42px rgba(14, 122, 101, 0.26);
  cursor: pointer;
  font-size: 2.3rem;
  line-height: 1;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.floating-entry-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 28px 48px rgba(14, 122, 101, 0.3);
  filter: saturate(1.05);
}

.months-empty {
  padding: 20px 4px;
  color: var(--muted);
}

.summary-cluster {
  display: flex;
  gap: 12px;
}

.summary-metric {
  padding: 14px 16px;
  min-width: 190px;
  display: grid;
  gap: 4px;
}

.month-body {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.chart-panel,
.table-panel {
  padding: 18px;
}

.pie-wrap {
  position: relative;
  width: 220px;
  margin: 0 auto;
}

.pie-chart {
  width: 100%;
  height: auto;
  transform: rotate(-90deg);
}

.pie-base,
.pie-segment {
  fill: none;
  stroke-width: 3.8;
}

.pie-base {
  stroke: rgba(53, 41, 24, 0.09);
}

.seg-1 {
  stroke: #0e7a65;
}

.seg-2 {
  stroke: #d17d3f;
}

.seg-3 {
  stroke: #c95f48;
}

.seg-4 {
  stroke: #76985a;
}

.seg-5 {
  stroke: #8d7c63;
}

.pie-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.pie-center span {
  color: var(--muted);
  font-size: 0.82rem;
}

.pie-center strong {
  font-size: 1.4rem;
}

.legend {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  color: var(--text);
}

.legend div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-empty {
  color: var(--muted);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.dot.seg-1 {
  background: #0e7a65;
}

.dot.seg-2 {
  background: #d17d3f;
}

.dot.seg-3 {
  background: #c95f48;
}

.dot.seg-4 {
  background: #76985a;
}

.dot.seg-5 {
  background: #8d7c63;
}

.table-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.table-scroll {
  margin-top: 14px;
  max-height: 420px;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(53, 41, 24, 0.08);
}

th {
  position: sticky;
  top: 0;
  background: #eef6ff;
  z-index: 1;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.table-action-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(183, 71, 42, 0.22);
  background: rgba(183, 71, 42, 0.08);
  color: var(--negative);
  cursor: pointer;
  transition:
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.table-action-btn:hover:not(:disabled) {
  background: var(--negative);
  color: #fff8ef;
  border-color: var(--negative);
  transform: translateY(-1px);
}

.table-action-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.trash-icon {
  width: 16px;
  height: 16px;
}

.category-group-row td {
  padding: 8px 16px 4px;
  background: #eef6ff;
  border-bottom: none;
}

.category-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.empty-row td {
  color: var(--muted);
}

.month-loading {
  min-height: 240px;
  display: grid;
  place-items: center;
}

.loading-wrap {
  display: grid;
  gap: 12px;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.loading-gif {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 4px solid rgba(14, 122, 101, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.month-loading-text {
  font-size: 0.92rem;
}

.month-error {
  color: var(--negative);
}

.muted-card {
  background: rgba(251, 247, 239, 0.6);
}

.mini-preview {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 18px;
  align-items: center;
}

.mini-preview p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.mini-bars {
  height: 120px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.mini-bars span {
  flex: 1;
  height: var(--h);
  border-radius: 999px 999px 10px 10px;
  background: linear-gradient(180deg, #d17d3f 0%, #0e7a65 100%);
}

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

@media (max-width: 980px) {
  .auth-card,
  .month-body {
    grid-template-columns: 1fr;
  }

  .hero,
  .panel-head,
  .month-head,
  .table-head,
  .mini-preview {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-stats,
  .summary-cluster {
    flex-wrap: wrap;
  }

  .entry-modal-tools {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .auth-card,
  .composer-panel,
  .month-card {
    border-radius: 24px;
    padding: 18px;
  }

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

  .entry-modal-panel {
    max-height: min(92vh, 860px);
    padding: 16px;
  }

  .floating-entry-btn {
    right: 18px;
    bottom: 18px;
    width: 60px;
    height: 60px;
    border-radius: 20px;
    font-size: 2.05rem;
  }

  .hero h2,
  .auth-copy h1 {
    font-size: clamp(2.2rem, 11vw, 3.8rem);
  }

  .summary-metric,
  .stat-pill {
    min-width: 0;
  }

  th,
  td {
    padding: 12px;
    font-size: 0.92rem;
  }
}
