:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #e5eefc;
  --muted: #a7b4cc;
  --accent: #5eead4;
  --accent-strong: #22c55e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(94, 234, 212, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  color: var(--text);
}

body {
  min-height: 100vh;
}

.shell {
  width: min(1680px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0;
}

.hero {
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 0.8rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.95;
}

.lede {
  max-width: min(90ch, 100%);
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.records-grid {
  display: grid;
  gap: 18px;
}

.bottom-layout {
  margin-top: 16px;
  display: grid;
  gap: 16px;
  align-items: start;
}

.bottom-layout__main,
.bottom-layout__side {
  min-width: 0;
}

.panel-wide {
  margin-top: 16px;
}

.card {
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--card);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.card strong {
  display: block;
  font-size: 1.8rem;
  margin-top: 8px;
}

.card-positive {
  border-color: rgba(94, 234, 212, 0.35);
}

.card-positive strong {
  color: var(--accent);
}

.card-negative {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.08);
}

.card-negative strong {
  color: #fb7185;
}

.card-neutral {
  border-color: rgba(148, 163, 184, 0.3);
}

.label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
}

.panel h2 {
  margin: 0 0 12px;
}

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

.panel__lede {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.panel-minimal {
  padding: 16px 18px;
}

.panel-minimal .panel__header {
  margin-bottom: 12px;
}

.panel-minimal .history-grid {
  gap: 10px;
  margin-bottom: 10px;
}

.panel-minimal .history-card {
  padding: 14px;
}

.panel-minimal .history-card strong {
  font-size: 1.3rem;
}

.section-kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 0.75rem;
}

.entry-form {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font: inherit;
}

.field input::placeholder {
  color: rgba(229, 238, 252, 0.45);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(94, 234, 212, 0.45);
  outline-offset: 2px;
}

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

.button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font: inherit;
  cursor: pointer;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #052014;
  font-weight: 700;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.button-secondary.is-active {
  background: rgba(94, 234, 212, 0.2);
  border: 1px solid rgba(94, 234, 212, 0.45);
}

.button-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

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

.list-header h3 {
  margin: 0;
}

.list-header span {
  color: var(--muted);
}

.entry-list {
  display: grid;
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
  max-height: 780px;
  border-radius: 16px;
}

.table-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 12px;
}

.control-field {
  display: grid;
  gap: 6px;
}

.control-field span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.control-field input,
.control-field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font: inherit;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.compact-table th,
.compact-table td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  vertical-align: middle;
}

.compact-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  z-index: 1;
}

.compact-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-amount {
  font-weight: 700;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-btn {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.add-row td {
  background: rgba(255, 255, 255, 0.03);
}

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

.inline-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 1fr) minmax(120px, 0.8fr) minmax(140px, 0.9fr) auto;
  gap: 8px;
  align-items: center;
}

.inline-grid input,
.inline-grid select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  font: inherit;
}

.inline-error {
  margin: 8px 0 0;
  color: #fca5a5;
  font-size: 0.83rem;
}

.history-row {
  background: rgba(255, 255, 255, 0.02);
}

.history-panel {
  display: grid;
  gap: 10px;
  padding: 8px 0;
}

.history-panel strong {
  font-size: 0.9rem;
  color: var(--text);
}

.history-panel p {
  margin: 0;
  color: var(--muted);
}

.entry {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.entry__main,
.entry__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.entry__main strong {
  font-size: 1rem;
}

.entry__main span,
.entry__meta span {
  color: var(--muted);
  font-size: 0.9rem;
}

.entry__amount {
  color: var(--text) !important;
  font-weight: 700;
}

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

.empty {
  margin: 0;
  color: var(--muted);
  padding: 4px 0 0;
}

.error {
  color: #fca5a5;
  font-size: 0.85rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.history-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.history-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
}

.history-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.history-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.snapshot-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 14px;
  align-items: end;
  min-height: 180px;
  margin: 18px 0 20px;
}

.snapshot-bar {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.snapshot-bar__track {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: end;
  justify-content: center;
  padding: 10px 0 0;
}

.snapshot-bar__pair {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  width: 80%;
  height: 100%;
}

.snapshot-bar__fill {
  flex: 1;
  border-radius: 8px 8px 4px 4px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  min-width: 0;
}

.snapshot-bar__fill.is-zero {
  height: 0 !important;
  box-shadow: none;
}

.snapshot-bar__fill.is-positive {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
}

.snapshot-bar__fill.is-negative {
  background: linear-gradient(180deg, #fb7185, #ef4444);
}

.snapshot-bar span {
  color: var(--muted);
  font-size: 0.78rem;
}

.chart-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 2px;
}

.chart-legend__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend__item::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.chart-legend__item--asset::before {
  background: var(--accent);
}

.chart-legend__item--liability::before {
  background: #ef4444;
}

.history-list {
  display: grid;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 0.85rem;
}

.history-item__date {
  color: var(--muted);
  min-width: 96px;
}

.history-item__amount {
  flex: 1;
  color: var(--text);
}

.history-item__actions {
  display: flex;
  gap: 4px;
}

.footer {
  margin-top: 20px;
  padding: 18px 20px 28px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.footer p {
  margin: 0;
}

.footer h2 {
  margin: 8px 0 10px;
  color: var(--text);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
}

.footer__lede {
  max-width: 64ch;
}

.panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 24px, 960px);
    padding: 40px 0;
  }

  .inline-grid {
    grid-template-columns: 1fr;
  }

  .table-controls {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    margin-top: 14px;
  }

  .panel__header,
  .entry__main,
  .entry__meta {
    flex-direction: column;
    align-items: start;
  }
}

@media (min-width: 1200px) {
  .bottom-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(380px, 0.75fr);
    align-items: start;
  }
}
