:root {
  --bg: #09131d;
  --surface: rgba(9, 23, 36, 0.82);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --line: rgba(160, 189, 214, 0.16);
  --text: #edf5fb;
  --muted: #8ea5b8;
  --accent: #1bd0a5;
  --accent-soft: #79f1d6;
  --danger: #ff7c5e;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  --radius-lg: 32px;
  --radius-md: 24px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at 18% 14%, rgba(27, 208, 165, 0.2), transparent 18%),
    radial-gradient(circle at 88% 20%, rgba(77, 137, 255, 0.18), transparent 22%),
    linear-gradient(180deg, #07111a 0%, #0c1a29 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  pointer-events: none;
}

.ambient-left {
  top: -140px;
  left: -120px;
  background: rgba(27, 208, 165, 0.24);
}

.ambient-right {
  right: -160px;
  bottom: -160px;
  background: rgba(77, 137, 255, 0.24);
}

.app-shell {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.hero-panel,
.panel,
.metric-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  border-radius: 28px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent-soft);
  background: linear-gradient(135deg, rgba(27, 208, 165, 0.22), rgba(77, 137, 255, 0.16));
  border: 1px solid rgba(121, 241, 214, 0.16);
}

.brand-row h1,
.hero-panel h2,
.panel h3,
.modal-header h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.brand-row h1 {
  margin-top: 6px;
  font-size: 1.35rem;
}

.eyebrow,
.section-kicker,
.card-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.73rem;
  font-weight: 800;
  color: var(--accent-soft);
}

.brand-copy,
.section-copy,
.sheet-help,
#sheetStatus,
.legend-item span,
.totals-list span,
.expense-form label span,
.placeholder-row,
.metric-card p {
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(27, 208, 165, 0.14);
}

.primary-btn,
.secondary-btn,
.icon-btn {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, #1bd0a5 0%, #14977a 100%);
  color: #07131d;
  padding: 14px 18px;
  font-weight: 800;
  box-shadow: 0 16px 34px rgba(27, 208, 165, 0.18);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 12px 18px;
  font-weight: 700;
}

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

.hero-panel {
  border-radius: 36px;
  padding: 30px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.hero-copy {
  flex: 1.1;
}

.hero-panel h2 {
  margin-top: 8px;
  max-width: 11ch;
  font-size: clamp(2.7rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.section-copy {
  max-width: 58ch;
  font-size: 1.04rem;
  line-height: 1.55;
}

.sheet-help {
  margin: 18px 0 0;
  max-width: 62ch;
  font-size: 0.97rem;
}

.hero-stats {
  flex: 0.9;
  display: grid;
  gap: 16px;
}

.metric-card {
  min-height: 176px;
  padding: 24px;
  border-radius: 24px;
}

.metric-card-primary {
  background:
    linear-gradient(180deg, rgba(27, 208, 165, 0.16), rgba(9, 23, 36, 0.84)),
    var(--surface);
}

.metric-card strong {
  display: block;
  margin-top: 18px;
  font-size: clamp(2rem, 3vw, 3rem);
  letter-spacing: -0.05em;
}

.metric-card p {
  margin: 10px 0 0;
  font-size: 0.98rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 24px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 26px;
}

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

.panel-header-tight {
  margin-bottom: 18px;
}

.panel h3 {
  margin-top: 8px;
  font-size: 1.68rem;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.chart-wrap {
  max-width: 340px;
  min-height: 320px;
}

.legend-grid,
.totals-list {
  display: grid;
  gap: 12px;
}

.legend-item,
.total-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.legend-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.total-item strong,
.legend-item strong {
  font-size: 0.96rem;
}

.ledger-panel {
  padding-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.03);
}

th,
td {
  text-align: left;
  padding: 16px 12px;
  border-bottom: 1px solid rgba(160, 189, 214, 0.12);
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.amount-col,
.amount-cell {
  text-align: right;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(27, 208, 165, 0.12);
  color: var(--accent-soft);
  border: 1px solid rgba(27, 208, 165, 0.14);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 16, 27, 0.62);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  width: min(100%, 540px);
  background: #0f2030;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  box-shadow: 0 28px 80px rgba(8, 20, 34, 0.24);
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 800;
}

.expense-form {
  display: grid;
  gap: 16px;
}

.expense-form label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.expense-form input,
.expense-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 15px;
  color: var(--text);
}

.expense-form input:focus,
.expense-form textarea:focus {
  outline: 2px solid rgba(27, 208, 165, 0.18);
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 6px;
}

@media (max-width: 1100px) {
  .hero-panel,
  .content-grid,
  .chart-layout {
    grid-template-columns: 1fr;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .hero-panel,
  .panel,
  .modal-dialog {
    border-radius: 24px;
  }

  .hero-panel h2 {
    max-width: none;
    font-size: 2.8rem;
  }

  th,
  td {
    padding: 14px 10px;
  }

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

  .sync-indicator,
  .primary-btn {
    width: 100%;
    justify-content: center;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions button {
    width: 100%;
  }
}
