:root {
  --bg: #f4f0e8;
  --panel: rgba(255, 252, 247, 0.92);
  --panel-strong: #fffdf9;
  --line: #d8cfc1;
  --text: #1f1a17;
  --muted: #6a5f55;
  --accent: #1d6b57;
  --accent-strong: #12483b;
  --secondary: #efe2cc;
  --danger: #9a3b31;
  --success: #2d7a54;
  --shadow: 0 18px 40px rgba(62, 43, 25, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(
      circle at top left,
      rgba(29, 107, 87, 0.18),
      transparent 25%
    ),
    linear-gradient(135deg, #f7f4ee 0%, #efe7da 100%);
}

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

.page-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.topnav {
  display: flex;
  gap: 14px;
}

.topnav a,
.chip,
.button {
  border-radius: 999px;
  transition: 180ms ease;
}

.hero,
.dashboard-grid,
.tracker-layout {
  display: grid;
  gap: 24px;
}

.hero {
  position: relative;
  z-index: 1;
  grid-template-columns: 1.3fr 0.9fr;
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 2.5rem 10rem;
}

.hero-copy {
  z-index: 1;
}

.hero-copy h1 {
  font-size: clamp(1.8rem, 5vw, 3.8rem);
  line-height: 1.15;
  /* max-width: 12ch; */
  margin: 0 0 16px;
  text-wrap: pretty;
}

.hero-text,
.muted,
.tracker-card p,
.empty-state {
  color: var(--muted);
}

.hero-card,
.panel,
.metric-card {
  background: var(--panel);
  border: 1px solid rgba(216, 207, 193, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.hero-card,
.panel {
  border-radius: 28px;
  padding: 24px;
}

.landing-shell {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 120px);
  display: grid;
  align-items: center;
}

.landing-background,
.landing-background-overlay {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 50vw);
  right: calc(50% - 50vw);
  pointer-events: none;
}

.landing-background {
  z-index: 0;
  overflow: hidden;
}

.landing-background-image {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: translateY(50px);
  animation: landing-background-enter 1.8s ease-out 0.2s forwards;
}

.landing-background-overlay {
  z-index: 0;
  background: #fff;
  opacity: 0.1;
  animation: landing-background-overlay-enter 2.1s ease-out 0.2s forwards;
}

@keyframes landing-background-enter {
  from {
    opacity: 1;
    transform: translateY(-50px);
  }

  to {
    opacity: 0.2;
    transform: translateY(0);
  }
}

/* @keyframes landing-background-overlay-enter {
  from {
    opacity: 0.3;
  }

  to {
    opacity: 0.9;
  }
} */

.metric-card + .metric-card {
  margin-top: 16px;
}

.metric-card {
  border-radius: 22px;
  padding: 18px;
}

.metric-label,
.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
}

.hero-actions,
.view-switcher,
.tag-list,
.tracker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

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

.button,
button {
  border: none;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-secondary,
.chip,
.topnav a {
  background: var(--secondary);
  padding: 10px 16px;
}

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

.button-danger:hover {
  opacity: 0.92;
}

.chip-active {
  background: var(--accent);
  color: #fff;
}

.auth-wrap {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 140px);
}

.auth-panel {
  width: min(100%, 480px);
}

.auth-link-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

.auth-link-row a {
  color: var(--accent-strong);
  font-weight: 700;
}

.stack-form {
  display: grid;
  gap: 14px;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.dashboard-grid,
.dashboard-shell {
  display: grid;
  gap: 24px;
}

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

.dashboard-shell {
  grid-template-columns: 1fr;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.profile-page-shell {
  width: min(100%, 1200px);
  margin: 0 auto;
}

.panel-nested {
  padding: 20px;
}

.profile-inline-actions {
  display: flex;
  gap: 12px;
  margin: 16px 0;
}

.security-form {
  margin-top: 12px;
}

.security-placeholder {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(29, 107, 87, 0.08);
}

.security-stack {
  display: grid;
  gap: 18px;
  margin-bottom: 20px;
}

.security-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.security-section-head h3 {
  margin: 0 0 6px;
}

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

.security-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #dbe5f2;
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
}

.security-table th,
.security-table td {
  padding: 14px 18px;
  border-bottom: 1px solid #e3eaf4;
  text-align: left;
}

.security-table thead th {
  background: #f5f8fc;
  color: #627892;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.security-empty-state {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed #cfdceb;
  color: #5a6d83;
  background: #f9fbfe;
}

.inline-action-form {
  margin: 0;
}

.authenticator-name-cell {
  display: grid;
  gap: 4px;
}

.authenticator-name-cell span {
  color: #6d8198;
  font-size: 0.92rem;
}

.security-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.security-action-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid #cfdceb;
  background: #fff;
  color: #31445c;
  font-weight: 700;
}

.security-action-chip-danger {
  color: #b3264b;
  border-color: #f0c8d4;
  background: #fff7fa;
}

.security-footer-actions {
  display: flex;
}

.security-primary-button {
  min-width: 200px;
  background: #111b33;
}

.security-primary-button:hover {
  background: #0a1328;
}

.verification-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid #d8e2f0;
  background: #f8fbff;
}

.verification-banner strong {
  display: block;
  margin-bottom: 6px;
}

.backup-code-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.backup-code-summary .metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
}

.backup-code-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(29, 107, 87, 0.08);
}

.backup-code-panel-success {
  border-color: #9ae8cb;
  background: #edfff6;
}

.backup-code-panel-success strong {
  color: #08745b;
  font-size: 1.05rem;
}

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

.backup-code-item {
  width: 100%;
  justify-content: center;
  background: #fff;
  border-color: #cfe7dd;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.backup-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.authenticator-setup-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.qr-panel {
  display: grid;
  gap: 12px;
}

.qr-code-box {
  display: grid;
  place-items: center;
  width: 220px;
  height: 220px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid #d4deeb;
  background: #fff;
}

.qr-code-box img,
.qr-code-box canvas {
  display: block;
  max-width: 180px;
  max-height: 180px;
}

.authenticator-modal-panel {
  max-width: 860px;
  padding: 28px 28px 30px;
}

.authenticator-modal-head {
  align-items: flex-start;
  margin-bottom: 22px;
}

.authenticator-modal-head h2 {
  margin: 0 0 8px;
  font-size: 2rem;
}

.authenticator-close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid #cad7e7;
  background: #fff;
  color: #6a809b;
}

.security-field-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5f748e;
  font-size: 0.82rem;
  font-weight: 700;
}

.secret-pill-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secret-pill-input {
  border-radius: 999px;
  border-color: #d3ddec;
  background: #f8fbff;
  font-weight: 700;
  color: #43566f;
}

.secret-copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid #d3ddec;
  background: #fff;
  color: #61758f;
}

.secret-copy-button.copied {
  color: #08745b;
  border-color: #9ae8cb;
}

.security-save-button {
  width: 100%;
  min-height: 56px;
  background: #111b33;
  color: #fff;
  font-weight: 700;
}

.danger-zone-panel {
  border-color: rgba(154, 59, 49, 0.35);
}

.panel-wide {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.tracker-card,
.tag-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.tracker-manage-card {
  flex-wrap: wrap;
}

.tracker-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.dashboard-hero-panel .section-head {
  margin-bottom: 10px;
}

.dashboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 22px;
}

.dashboard-tab-panel[hidden] {
  display: none !important;
}

.category-form-grid {
  grid-template-columns: 2fr 1fr 1fr;
  align-items: end;
}

.category-table-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.category-table-panel h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

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

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

.drag-handle {
  width: 36px;
  color: var(--muted);
  cursor: grab;
}

.category-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--text);
}

.icon-danger {
  background: rgba(154, 59, 49, 0.14);
  color: var(--danger);
}

.category-table tbody tr.dragging {
  opacity: 0.5;
}

.tag-card {
  width: auto;
}

.tag-card button,
.inline-delete button {
  background: transparent;
  color: var(--danger);
  padding: 0;
}

.flash,
.inline-error {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.flash-success {
  background: rgba(45, 122, 84, 0.12);
  color: var(--success);
}

.flash-error,
.inline-error {
  background: rgba(154, 59, 49, 0.12);
  color: var(--danger);
}

.tracker-layout {
  grid-template-columns: 340px minmax(0, 1fr);
  align-items: start;
}

.tracker-screen {
  margin: -24px;
}

.tracker-toolbar {
  grid-template-columns: 320px 1fr;
  align-items: end;
  gap: 24px;
  padding: 20px 24px 12px;
}

.tracker-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.tracker-year {
  margin: 0;
}

.view-switcher-bar {
  width: max-content;
  background: var(--secondary);
  border-radius: 999px;
  padding: 6px;
  gap: 6px;
  justify-self: end;
  margin-left: auto;
}

.view-switcher-bar .chip {
  background: transparent;
  padding: 10px 18px;
}

.view-switcher-bar .chip-active {
  background: var(--accent);
}

.tracker-grid-panel {
  padding: 0;
}

.form-help {
  margin: -4px 0 2px;
  font-size: 0.9rem;
}

.budget-table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
}

.budget-table {
  width: 100%;
  min-width: 1400px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel-strong);
  font-size: 1rem;
}

.budget-table th,
.budget-table td {
  padding: 5px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

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

/* .budget-table th:not(:first-child),
.budget-table td:not(:first-child) {
  width: 100px;
  min-width: 100px;
  max-width: 100px;
} */

.budget-table th:last-child,
.budget-table td:last-child {
  padding: 0 10px;
  text-align: left;
}

.budget-table thead th {
  position: sticky;
  top: 0;
  background: #f1eadc;
  z-index: 2;
  font-size: 1rem;
  font-weight: 700;
}

.budget-table thead th .period-heading,
.budget-table thead th .period-date {
  display: block;
}

.budget-table thead th .period-heading {
  margin-bottom: 2px;
}

.budget-table thead th small {
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

small {
  font-size: 12px;
  font-style: italic;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fffdf9;
  min-width: 320px;
  font-size: 1rem;
  font-weight: 700;
}

.sticky-head {
  z-index: 3;
}

.section-row td,
.section-row .sticky-col {
  background: #e9dbc0;
  font-weight: 700;
}

.category-row td,
.category-row .sticky-col {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.total-cell,
.budget-table tfoot th {
  background: #f7f1e4;
  font-weight: 700;
}

.budget-table tfoot .net-total-row th {
  padding-bottom: 10px;
}

.item-name {
  font-weight: 700;
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px !important;
}

.item-cell {
  padding: 0 0 0 18px !important;
  margin: 0 !important;
}

.item-edit-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.item-edit-button i {
  font-size: 0.8rem;
}

.tracker-modal {
  width: min(760px, calc(100vw - 32px));
  border: none;
  background: transparent;
  padding: 0;
}

.tracker-modal::backdrop {
  background: rgba(25, 18, 13, 0.55);
  backdrop-filter: blur(4px);
}

.modal-panel {
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-close {
  min-width: 96px;
}

.modal-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-delete-form {
  margin: 0;
}

.split-equal {
  grid-template-columns: 1fr 1fr;
}

.split-third {
  grid-template-columns: 1fr 1fr 1fr;
}

.compact-form {
  margin-bottom: 18px;
}

.hidden-form {
  display: none;
}

.delete-code-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(29, 107, 87, 0.12);
  border: 1px solid var(--line);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

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

@media (max-width: 960px) {
  .hero,
  .dashboard-grid,
  .tracker-layout,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .page-shell {
    padding: 16px;
  }

  .tracker-screen {
    margin: -16px;
  }

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

  .split-fields,
  .split-equal,
  .tracker-toolbar {
    grid-template-columns: 1fr;
  }

  .backup-code-summary,
  .backup-code-grid,
  .authenticator-setup-grid {
    grid-template-columns: 1fr;
  }

  .security-section-head,
  .backup-code-actions,
  .security-actions,
  .verification-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .qr-code-box {
    width: 100%;
    max-width: 220px;
  }

  .tracker-actions {
    flex-wrap: wrap;
  }
}
