:root {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: #151922;
  --surface-2: #10141c;
  --surface-3: #090d13;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #f4f6fb;
  --muted: #9aa2af;
  --faint: #646d7c;
  --yellow: #ffc640;
  --blue: #4487ff;
  --green: #27c987;
  --teal: #27c6d8;
  --purple: #9c5cff;
  --pink: #f66aa0;
  --orange: #ff834d;
  --red: #f25563;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 25% -10%, rgba(68, 135, 255, 0.14), transparent 34%),
    radial-gradient(circle at 88% 0%, rgba(255, 198, 64, 0.08), transparent 28%),
    linear-gradient(180deg, #07090d 0%, #0a0d13 100%);
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 28px 18px 70px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(520px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 34, 0.96);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #1c2735;
  border: 1px solid var(--line-strong);
  color: var(--yellow);
  font-weight: 800;
}

.brand-row span,
.metric-card span,
.trajectory-stats span,
.modal-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-row strong {
  display: block;
  margin-top: 3px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

p {
  color: var(--muted);
}

.auth-card p {
  margin-top: 12px;
  line-height: 1.55;
}

.setup-warning {
  margin: 20px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 198, 64, 0.24);
  border-radius: 8px;
  background: rgba(255, 198, 64, 0.08);
  color: #ffe2a1;
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 12px;
  background: #0f141d;
  color: var(--text);
  outline: none;
}

.auth-form input:focus {
  border-color: rgba(255, 198, 64, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 198, 64, 0.12);
}

.auth-actions,
.head-actions,
.period-tabs,
.panel-head,
.trajectory-stats,
.modal header,
.modal footer,
.modal-summary,
.transaction-tools,
.category-pills {
  display: flex;
  align-items: center;
}

.auth-actions {
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.primary-btn {
  background: #f4f6fb;
  color: #0b0e14;
  border-color: #f4f6fb;
  font-weight: 800;
}

.secondary-btn,
.ghost-btn,
.icon-btn {
  background: #121720;
  color: #e7ebf2;
}

.secondary-btn.active,
.period-tabs button.active {
  background: var(--yellow);
  border-color: var(--yellow);
  color: #15100a;
  font-weight: 800;
}

.compact {
  height: 34px;
  font-size: 13px;
}

.auth-screen {
  min-height: calc(100vh - 98px);
  padding: 18px 0;
}

.auth-card {
  width: min(472px, calc(100vw - 54px));
  max-width: 472px;
  min-width: 0;
  padding: 50px 36px 38px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(25, 31, 43, 0.98), rgba(14, 18, 26, 0.98)),
    #151922;
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
}

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 26px;
  color: #98a6ba;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 198, 64, 0.28);
  background: linear-gradient(135deg, rgba(255, 198, 64, 0.16), rgba(39, 201, 135, 0.1));
  color: var(--yellow);
  box-shadow: 0 14px 32px rgba(255, 198, 64, 0.1);
}

.auth-card h1 {
  color: #f8fafc;
  font-size: 30px;
  line-height: 1.12;
  text-align: center;
}

.auth-card p {
  margin-top: 10px;
  color: #a2adbd;
  font-size: 17px;
  line-height: 1.45;
  text-align: center;
}

.auth-card .setup-warning:empty {
  display: none;
}

.quick-access {
  display: grid;
  gap: 14px;
  margin-top: 34px;
}

.quick-access > span,
.form-eyebrow {
  color: #9da9bb;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.google-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.055);
  color: #f8fafc;
  cursor: pointer;
  font-size: 17px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.google-auth-btn:hover {
  border-color: rgba(255, 198, 64, 0.42);
  background: rgba(255, 255, 255, 0.085);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px);
}

.google-auth-btn strong {
  min-width: 0;
}

.google-auth-btn:focus-visible,
.auth-card input:focus,
.password-toggle:focus-visible,
.text-btn:focus-visible {
  outline: 3px solid rgba(255, 198, 64, 0.18);
  outline-offset: 2px;
}

.google-mark {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  background: conic-gradient(from -45deg, #4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: Arial, sans-serif;
  font-size: 23px;
  font-weight: 800;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 30px 0 26px;
  color: #8f9cb0;
  font-size: 14px;
  font-weight: 700;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.11);
}

.auth-form {
  gap: 16px;
  margin-top: 0;
}

.auth-form label {
  gap: 9px;
  color: #f4f7fb;
  font-size: 15px;
  font-weight: 800;
  text-transform: none;
}

.auth-form input {
  height: 52px;
  border-color: rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(8, 10, 15, 0.58);
  color: var(--text);
  font-size: 16px;
}

.auth-form input::placeholder {
  color: #7f8b9c;
}

.auth-form input:focus {
  border-color: rgba(255, 198, 64, 0.72);
  box-shadow: none;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 54px;
}

.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 0 9px 9px 0;
  background: rgba(13, 17, 25, 0.94);
  color: #9ba8ba;
  cursor: pointer;
}

.auth-card .auth-actions {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.auth-card .primary-btn {
  width: 100%;
  height: 54px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #ffc640, #f15b1c);
  color: #16100a;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 18px 34px rgba(241, 91, 28, 0.26);
}

.text-btn {
  height: auto;
  border: 0;
  background: transparent;
  color: #9ca8ba;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  justify-self: center;
  padding: 6px 10px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
}

button svg {
  width: 16px;
  height: 16px;
}

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

.dashboard > *,
.page-head,
.period-tabs,
.top-metrics,
.analytics-grid,
.panel,
.metric-card {
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 2px 0;
}

.page-head p {
  margin-top: 5px;
  font-size: 13px;
}

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

.period-tabs {
  gap: 8px;
  overflow-x: auto;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 34, 0.82);
}

.period-tabs button {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.custom-range {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 34, 0.88);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #090d13;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  padding: 10px 11px;
  resize: vertical;
}

.top-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.panel,
.metric-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 34, 0.96);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
}

.metric-card {
  min-height: 112px;
  padding: 22px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  color: var(--yellow);
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 700;
}

.panel {
  padding: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-head.tight {
  margin-bottom: 8px;
}

.panel-head p {
  margin-top: 5px;
  font-size: 13px;
}

.trajectory-panel {
  min-height: 500px;
}

.trajectory-stats {
  justify-content: space-between;
  gap: 18px;
  margin: 10px 0 18px;
}

.trajectory-stats strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(34px, 6vw, 46px);
  line-height: 1;
}

.trajectory-stats small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-weight: 700;
}

.trajectory-stats .forecast {
  text-align: right;
}

.chart-card {
  position: relative;
  height: 350px;
  overflow: hidden;
}

.chart-card svg {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
}

#six-month-chart {
  width: 100%;
  height: 340px;
  overflow: hidden;
  touch-action: none;
}

.chart-tooltip {
  position: absolute;
  z-index: 3;
  display: none;
  min-width: 218px;
  max-width: min(270px, calc(100% - 16px));
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(9, 13, 19, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  color: #dfe5ef;
  pointer-events: none;
}

.chart-tooltip.show {
  display: grid;
  gap: 5px;
}

.chart-tooltip strong {
  color: #fff;
  font-size: 13px;
}

.chart-tooltip span,
.chart-tooltip small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-tooltip .positive {
  color: #7ce8b5;
}

.chart-tooltip .negative {
  color: #ff9ca5;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.legend-dot.spend {
  background: var(--yellow);
}

.legend-dot.pace {
  background: var(--muted);
}

.legend-dot.daily-good {
  background: var(--green);
}

.legend-dot.daily-over {
  background: var(--red);
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(420px, 1.28fr);
  gap: 12px;
}

.donut-layout {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: 18px;
}

.donut {
  position: relative;
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--yellow) 0deg, var(--yellow) 360deg);
}

.donut::after {
  content: "";
  position: absolute;
  inset: 48px;
  border-radius: 50%;
  background: var(--surface-2);
}

.donut-center {
  position: absolute;
  inset: 53px;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  text-align: center;
}

.donut-center span {
  color: var(--muted);
  font-size: 12px;
}

.donut-center strong {
  max-width: 72px;
  font-size: 17px;
  line-height: 1;
  white-space: nowrap;
}

.legend {
  width: 100%;
  display: grid;
  gap: 9px;
}

.legend-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px 40px;
  align-items: center;
  gap: 12px;
  color: #dbe0e9;
  font-size: 13px;
}

.legend-row button {
  justify-self: start;
  min-width: 0;
  max-width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.legend-row strong,
.legend-row span {
  text-align: right;
  white-space: nowrap;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 9px;
  border-radius: 3px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  text-align: left;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
}

td {
  color: #e7ebf2;
  font-size: 13px;
}

td strong {
  color: #fff;
}

.category-cell {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.pace-bar {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) 46px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: #1d232d;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--green);
}

.bar-fill.warn {
  background: var(--yellow);
}

.bar-fill.danger {
  background: var(--red);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(39, 201, 135, 0.11);
  color: #7ce8b5;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.warn {
  background: rgba(255, 198, 64, 0.13);
  color: #ffd77a;
}

.status-pill.danger {
  background: rgba(242, 85, 99, 0.13);
  color: #ff9ca5;
}

.transaction-tools {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.transaction-tools input {
  width: min(340px, 60vw);
}

.category-pills {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.category-pills button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #10151d;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.category-pills button.active {
  color: #0b0e14;
  background: var(--yellow);
  border-color: var(--yellow);
  font-weight: 800;
}

.amount {
  color: #ff8caf;
  font-weight: 800;
}

.positive {
  color: #7ce8b5;
}

.negative {
  color: #ff9ca5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(8px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(720px, 100%);
  max-height: min(86vh, 780px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #151922;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.expense-modal {
  max-width: 760px;
}

.modal header,
.modal footer,
.modal-summary {
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-summary {
  background: #10151d;
}

.modal-summary label {
  width: 180px;
}

.modal-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.projection-form {
  overflow-y: auto;
  padding: 14px 20px 2px;
}

.projection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.money-input {
  position: relative;
}

.money-input span {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 800;
}

.money-input input {
  padding-left: 46px;
  text-align: right;
  font-weight: 800;
}

.expense-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.span-2 {
  grid-column: 1 / -1;
}

.expense-form footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0;
  border: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #f4f6fb;
  color: #0b0e14;
  font-weight: 800;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

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

@media (max-width: 980px) {
  .page-head,
  .trajectory-stats,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .trajectory-stats .forecast {
    text-align: left;
  }

  .analytics-grid,
  .top-metrics {
    grid-template-columns: 1fr;
  }

  .donut-layout {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .chart-card {
    height: 300px;
  }

  #six-month-chart {
    height: 310px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 14px 12px 46px;
  }

  .auth-card,
  .panel,
  .metric-card {
    padding: 16px;
  }

  .auth-screen {
    align-items: start;
    padding-top: 18px;
  }

  .auth-card {
    padding: 18px 16px 22px;
  }

  .auth-brand {
    margin-bottom: 22px;
  }

  .quick-access {
    margin-top: 30px;
  }

  .google-auth-btn {
    gap: 10px;
    min-height: 56px;
    padding: 0 14px;
    font-size: 16px;
  }

  .auth-actions,
  .custom-range,
  .modal-summary,
  .modal footer {
    align-items: stretch;
    flex-direction: column;
  }

  .head-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

  .ghost-btn span {
    display: none;
  }

  .expense-form,
  .projection-row {
    grid-template-columns: 1fr;
  }

  .trajectory-stats strong {
    font-size: clamp(32px, 10vw, 40px);
  }

  .chart-tooltip {
    position: absolute;
    left: 8px !important;
    top: 8px !important;
  }

  .chart-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    font-size: 11px;
  }

  .chart-legend span {
    align-items: flex-start;
    line-height: 1.25;
  }

  .legend-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .legend-row > span {
    display: none;
  }

  .legend-row strong {
    padding-left: 21px;
    text-align: left;
  }

  .modal-summary label,
  .transaction-tools input {
    width: 100%;
  }

}
