:root {
  --bg: #eff3f8;
  --surface: #ffffff;
  --surface-strong: #0f2744;
  --surface-soft: #dce7f4;
  --surface-soft-strong: #c7d9ed;
  --text: #12304d;
  --muted: #5b748f;
  --border: #d6dfeb;
  --accent: #1f6fb2;
  --accent-soft: #d8ebfb;
  --warning: #b86b18;
  --warning-soft: #fff1dc;
  --success: #167a52;
  --success-soft: #dff4ea;
  --danger: #b13b3b;
  --danger-soft: #f8e0e0;
  --shadow: 0 18px 50px rgba(18, 48, 77, 0.12);
  --radius: 24px;
  --brand-font-body: "Avenir Next", "Segoe UI", sans-serif;
  --brand-font-display: "Space Grotesk", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--brand-font-body);
  background:
    radial-gradient(circle at top left, rgba(31, 111, 178, 0.12), transparent 26%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

body {
  padding: 0;
}

button,
input,
select {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

.gate-shell,
.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  min-height: 100vh;
}

.gate-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card,
.panel,
.hero-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(214, 223, 235, 0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gate-card {
  width: 100%;
  padding: 28px;
}

.gate-code-section {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gate-code-divider {
  position: relative;
  text-align: center;
}

.gate-code-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.gate-code-divider span {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  font-weight: 700;
}

.gate-code-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border);
}

.gate-code-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.gate-copy,
.muted-text,
.panel-note {
  color: var(--muted);
  line-height: 1.5;
}

.app-shell {
  display: flex;
  flex-direction: column;
  padding: 18px 18px 110px;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar h1,
.gate-card h1,
.panel h3,
.hero-card h2 {
  margin: 4px 0 0;
  font-family: var(--brand-font-display);
}

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

.hero-card,
.panel {
  padding: 20px;
}

.hero-balance-card {
  background:
    linear-gradient(145deg, rgba(15, 39, 68, 0.98), rgba(31, 111, 178, 0.94)),
    var(--surface-strong);
  color: #f4f8fc;
  border-color: rgba(255, 255, 255, 0.12);
}

.hero-balance-card .eyebrow {
  color: rgba(216, 235, 251, 0.88);
}

.hero-balance-card .muted-text {
  color: rgba(241, 246, 252, 0.78);
}

.hero-balance-card.is-negative {
  background:
    linear-gradient(145deg, rgba(84, 27, 27, 0.98), rgba(177, 59, 59, 0.92)),
    var(--danger);
}

.app-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 18px;
}

.view.is-active {
  display: flex;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.quick-actions-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(214, 223, 235, 0.85);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
}

.quick-actions-grid,
.health-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.quick-action-button,
.health-card {
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
}

.quick-action-button {
  padding: 14px;
  text-align: left;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  transition: 160ms ease;
}

.quick-action-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent);
}

.health-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.hero-balance-copy h2 {
  margin-top: 6px;
  font-size: clamp(2rem, 7vw, 2.8rem);
  line-height: 0.98;
}

.hero-context {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.context-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.context-pill.is-soft {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--surface-strong);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(18, 48, 77, 0.08);
}

.sync-pill.is-pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.sync-pill.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.sync-pill.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.hero-insights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 14px;
}

.hero-insight-card {
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-insight-card span {
  font-size: 0.76rem;
  color: rgba(241, 246, 252, 0.74);
}

.hero-insight-card strong {
  font-size: 1.05rem;
  color: #fff;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 112px;
}

.summary-card--expense {
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

.summary-card--expense-soft {
  background: linear-gradient(180deg, #fff 0%, #f4f8fc 100%);
}

.summary-card--warning {
  background: linear-gradient(180deg, #fff7ec 0%, #fff 100%);
  border-color: #f0d7b2;
}

.summary-card--income {
  background: linear-gradient(180deg, #eefaf4 0%, #fff 100%);
  border-color: #cfe9da;
}

.summary-card--receivable {
  background: linear-gradient(180deg, #eef7ff 0%, #fff 100%);
  border-color: #d3e6fa;
}

.summary-card--reconciled {
  background: linear-gradient(180deg, #f3f7fb 0%, #fff 100%);
}

.summary-label,
.profile-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-card strong,
.profile-item strong {
  font-size: 1.35rem;
}

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

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

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

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

.stack-form label,
.stack-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
}

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

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

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 13px 14px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(31, 111, 178, 0.18);
  border-color: var(--accent);
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 9px 12px;
}

.chip.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.primary-button,
.ghost-button,
.danger-button,
.ghost-inline-button,
.nav-button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
}

.primary-button,
.danger-button,
.ghost-button {
  padding: 13px 16px;
}

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

.danger-button {
  background: rgba(177, 59, 59, 0.12);
  color: var(--danger);
}

.ghost-button,
.ghost-inline-button {
  background: transparent;
  color: var(--accent);
}

.ghost-inline-button {
  padding: 0;
  font-weight: 700;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-empty {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.list-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 14px 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.list-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.list-card-action {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.list-card-action.is-danger {
  color: var(--danger);
  border-color: rgba(177, 59, 59, 0.22);
  background: rgba(248, 224, 224, 0.42);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.status-pill--expense {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill--income {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-pill--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill--neutral {
  background: var(--surface-soft);
  color: var(--surface-strong);
}

.list-card-top,
.list-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.list-card strong {
  font-size: 1rem;
}

.list-card small,
.list-card span {
  color: var(--muted);
}

.list-card-value {
  color: var(--surface-strong);
  font-weight: 700;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.profile-item {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 420px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  z-index: 30;
}

.toast {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(15, 39, 68, 0.94);
  color: #fff;
  box-shadow: 0 16px 32px rgba(15, 39, 68, 0.24);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(12px);
}

.toast strong {
  font-size: 0.95rem;
}

.toast span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.82rem;
}

.toast.is-success {
  background: rgba(22, 122, 82, 0.96);
}

.toast.is-warning {
  background: rgba(184, 107, 24, 0.96);
}

.toast.is-error {
  background: rgba(177, 59, 59, 0.96);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 520px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px;
  background: rgba(15, 39, 68, 0.92);
  border-radius: 24px;
  box-shadow: 0 16px 38px rgba(15, 39, 68, 0.28);
}

.nav-button {
  background: transparent;
  color: rgba(255, 255, 255, 0.74);
  padding: 12px 8px;
}

.nav-button.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

@media (max-width: 420px) {
  .summary-grid,
  .inline-fields,
  .quick-actions-grid,
  .health-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .hero-balance-row,
  .hero-context {
    align-items: flex-start;
  }

  .hero-balance-row,
  .hero-insights {
    grid-template-columns: 1fr;
  }

  .hero-balance-row {
    display: grid;
  }

  .bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-button {
    font-size: 0.76rem;
  }
}
