:root {
  --color-primary: #ce0f69;
  --color-secondary-teal: #009ca6;
  --color-secondary-purple: #68478d;
  --color-tertiary-gold: #ffb81c;
  --color-tertiary-black: #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Several elements below set `display` via a class of equal specificity
   to the UA [hidden] rule, which would otherwise silently win by source
   order and keep them visible while "hidden". Force it explicitly. */
[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f4f5f7;
  color: var(--color-tertiary-black);
}

a {
  color: inherit;
}

/* ---------------------------------------------------------------------
   App shell / nav
   --------------------------------------------------------------------- */

.app-shell {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-shell.wide {
  max-width: 900px;
}

.nav-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border-radius: 16px;
  padding: 14px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 0.88rem;
  font-weight: 600;
  color: #6b7280;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background: #f4f5f7;
  color: var(--color-tertiary-black);
}

.nav-link.active {
  color: var(--color-primary);
  background: rgba(206, 15, 105, 0.08);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-email {
  font-size: 0.8rem;
  color: #6b7280;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-logout:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */

.card {
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.card.accent {
  border-top: 6px solid transparent;
  border-image: linear-gradient(
    90deg,
    var(--color-primary),
    var(--color-secondary-teal),
    var(--color-secondary-purple),
    var(--color-tertiary-gold)
  );
  border-image-slice: 1;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin-bottom: 4px;
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

h2 {
  font-size: 1.1rem;
}

.subtitle {
  font-size: 0.9rem;
  color: #6b7280;
  line-height: 1.4;
}

.status {
  font-size: 0.9rem;
  color: #6b7280;
  text-align: center;
  padding: 40px 0;
}

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

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  color: #ffffff;
  background: var(--color-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
  text-decoration: none;
}

.btn-primary:hover {
  box-shadow: 0 0 0 3px rgba(206, 15, 105, 0.12);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--color-tertiary-black);
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
  text-decoration: none;
}

.btn-secondary:hover {
  border-color: var(--color-primary);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-text {
  display: inline-block;
  padding: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
  text-decoration: none;
}

.btn-text:hover {
  color: var(--color-tertiary-black);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
  color: #6b7280;
  background: #f9fafb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  background: rgba(206, 15, 105, 0.1);
  color: var(--color-primary);
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid > .input-group {
  min-width: 0;
}

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

@media (max-width: 620px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.input-group {
  margin-bottom: 20px;
}

.input-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.field-hint {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 6px;
  line-height: 1.4;
}

.text-input,
.text-select,
textarea.text-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-tertiary-black);
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.text-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(206, 15, 105, 0.12);
}

.text-select {
  cursor: pointer;
}

/* iOS Safari renders a native date input's value centered and at a
   larger system font size by default, and its widget "shell" paints
   wider than the declared box. Stripping the native appearance makes
   Safari respect our own border/box instead of its own. */
input[type="date"].text-input {
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}

input[type="date"].text-input::-webkit-date-and-time-value {
  text-align: left;
}

.text-input:disabled,
.text-select:disabled {
  background: #f4f5f7;
  color: #9ca3af;
  cursor: not-allowed;
}

.form-error {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
}

.form-success {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-secondary-teal);
}

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

/* ---------------------------------------------------------------------
   Auth gate
   --------------------------------------------------------------------- */

.auth-landing {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  margin: 40px auto;
}

.hero-copy {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.hero-copy h1 {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.hero-tagline {
  font-size: 1rem;
  color: #6b7280;
  line-height: 1.5;
  margin-bottom: 22px;
}

.hero-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.hero-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: #374151;
  line-height: 1.4;
}

.hero-features li::before {
  content: "✓";
  flex-shrink: 0;
  color: var(--color-secondary-teal);
  font-weight: 700;
}

.auth-shell {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------------------------------------------------------------------
   Tables (generic)
   --------------------------------------------------------------------- */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6b7280;
  padding: 0 14px 10px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid #f0f1f3;
  vertical-align: middle;
}

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

.cell-strong {
  font-weight: 600;
}

.cell-muted {
  color: #6b7280;
}

.cell-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #6b7280;
}

.empty-state p {
  font-size: 0.9rem;
  margin-top: 6px;
}

/* Category / frequency badges, used in the expenditure table */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-need {
  color: var(--color-primary);
  background: rgba(206, 15, 105, 0.1);
}

.badge-need .dot {
  background: var(--color-primary);
}

.badge-want {
  color: var(--color-secondary-teal);
  background: rgba(0, 156, 166, 0.1);
}

.badge-want .dot {
  background: var(--color-secondary-teal);
}

.badge-saving {
  color: #a3730f;
  background: rgba(255, 184, 28, 0.16);
}

.badge-saving .dot {
  background: var(--color-tertiary-gold);
}

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.divider {
  height: 1px;
  background: #f0f1f3;
  margin: 20px 0;
}

/* ---------------------------------------------------------------------
   Monthly summary — result rows, category dots, breakdown bar
   --------------------------------------------------------------------- */

.results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 10px;
  background: #f9fafb;
}

.result-row.emphasis {
  background: rgba(206, 15, 105, 0.06);
}

.result-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.needs .dot { background: var(--color-primary); }
.wants .dot { background: var(--color-secondary-teal); }
.savings .dot { background: var(--color-tertiary-gold); }

.result-label div {
  display: flex;
  flex-direction: column;
}

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.result-percent {
  font-size: 0.8rem;
  color: #6b7280;
}

.result-amount {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-amount.positive {
  color: var(--color-secondary-teal);
}

.result-amount.negative {
  color: var(--color-primary);
}

.bar {
  display: flex;
  width: 100%;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  background: #e5e7eb;
  margin-top: 4px;
}

.bar-segment {
  height: 100%;
}

.bar-needs { background: var(--color-primary); }
.bar-wants { background: var(--color-secondary-teal); }
.bar-savings { background: var(--color-tertiary-gold); }

.explainer {
  width: 100%;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.explainer summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-tertiary-black);
}

.explainer summary::-webkit-details-marker {
  display: none;
}

.explainer summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

.explainer summary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-right: 2px solid #6b7280;
  border-bottom: 2px solid #6b7280;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.explainer[open] summary::after {
  transform: rotate(-135deg);
}

.explainer[open] summary {
  border-bottom: 1px solid #f0f1f3;
}

.explainer-content {
  padding: 4px 24px 24px;
}

.explainer-content h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-primary);
  margin-top: 18px;
  margin-bottom: 6px;
}

.explainer-content h2:first-child {
  margin-top: 0;
}

.explainer-content p {
  font-size: 0.9rem;
  line-height: 1.55;
  color: #374151;
}

.explainer-content ul {
  margin-top: 4px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.explainer-content li {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #374151;
}

/* ---------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------- */

.powered-by a {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #6b7280;
  font-size: 0.85rem;
  transition: color 0.15s ease;
}

.powered-by a:hover {
  color: var(--color-tertiary-black);
}

.powered-by-logo {
  width: 20px;
  height: 20px;
  border-radius: 5px;
}

.powered-by strong {
  color: var(--color-primary);
  font-weight: 700;
}

/* ---------------------------------------------------------------------
   Responsive (mobile)
   --------------------------------------------------------------------- */

@media (max-width: 640px) {
  .nav-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .nav-user {
    justify-content: space-between;
  }

  .card {
    padding: 20px;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .card-header .header-actions,
  .card-header > .btn-primary,
  .card-header > .btn-secondary {
    width: 100%;
  }

  .header-actions .btn-primary,
  .header-actions .btn-secondary {
    width: 100%;
  }

  .data-table td,
  .data-table th {
    padding: 10px 8px;
  }
}
