/* SECTION: Design Tokens */
:root {
  /* Colors */
  --color-bg-primary: #0f172a; /* deep slate */
  --color-bg-elevated: #020617;
  --color-surface: #020617;
  --color-surface-soft: #020617;
  --color-text: #e5e7eb;
  --color-text-muted: #9ca3af;
  --color-border: rgba(148, 163, 184, 0.5);
  --color-accent: #38bdf8; /* sky */
  --color-accent-soft: rgba(56, 189, 248, 0.08);
  --color-safe: #4ade80; /* green */
  --color-negative: #fb7185; /* red */

  /* Accent RGB for glows */
  --accent-rgb: 56, 189, 248;

  /* Typography */
  --font-sans: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;

  /* Sizing & Layout */
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;

  --shadow-soft:
    0 1px 2px rgba(15, 23, 42, 0.4),
    0 10px 30px rgba(15, 23, 42, 0.8);

  --transition-fast: 0.16s ease-out;
  --transition-med: 0.24s ease-out;
}

/* Google Font Import */
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

/* SECTION: Base Layout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  background-color: var(--color-bg-primary);
  color: var(--color-text);
}

.app {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 32px 16px;
  position: relative;
  overflow: hidden;
  background-color: var(--color-bg-primary);
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 22px 32px;
  border-radius: 24px;
  backdrop-filter: blur(26px);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 55%),
    radial-gradient(circle at bottom right, rgba(52, 211, 153, 0.06), transparent 55%),
    rgba(15, 23, 42, 0.86);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

@media (min-width: 768px) {
  .shell {
    padding: 32px 32px 36px;
  }
}

/* SECTION: Background Atmosphere */
.gradient-mesh {
  background:
    radial-gradient(at 40% 10%, rgba(56, 189, 248, 0.25) 0, transparent 55%),
    radial-gradient(at 80% 80%, rgba(52, 211, 153, 0.25) 0, transparent 55%),
    radial-gradient(at 0% 60%, rgba(244, 114, 182, 0.16) 0, transparent 55%),
    var(--color-bg-primary);
}

.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.floating-shape {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.3;
  mix-blend-mode: screen;
  animation: float 12s ease-in-out infinite alternate;
}

.floating-shape--one {
  top: -120px;
  left: -60px;
  background: #38bdf8;
}

.floating-shape--two {
  bottom: -140px;
  right: -40px;
  background: #22c55e;
}

@keyframes float {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(10px, -10px, 0) scale(1.05);
  }
}

/* SECTION: Header */
.header {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 28px;
}

@media (min-width: 720px) {
  .header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
  }
}

.header__title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
  font-weight: 700;
}

.app-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-muted);
}

.header__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.header__pill {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.55);
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.8),
    rgba(15, 23, 42, 0.9)
  );
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.header__pill-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
}

.header__pill-value {
  font-weight: 600;
}

/* SECTION: Grid Layout */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.9fr);
  gap: 18px;
}

@media (max-width: 960px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* SECTION: Panels */
.panel {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: radial-gradient(circle at top, rgba(148, 163, 184, 0.08), transparent 55%),
    rgba(15, 23, 42, 0.98);
  padding: 18px 18px 18px;
}

@media (min-width: 768px) {
  .panel {
    padding: 20px 20px 20px;
  }
}

.panel--income {
  box-shadow: 0 18px 40px rgba(34, 197, 94, 0.15);
}

.panel--expenses {
  box-shadow: 0 18px 40px rgba(248, 113, 113, 0.12);
}

.panel--summary {
  box-shadow: 0 20px 45px rgba(56, 189, 248, 0.28);
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.16), transparent 55%),
    radial-gradient(circle at bottom, rgba(52, 211, 153, 0.18), transparent 45%),
    rgba(15, 23, 42, 0.98);
}

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

.panel__header--summary {
  margin-bottom: 12px;
}

.panel__title {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.04em;
}

.panel__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.panel__total {
  margin: 0;
  text-align: right;
}

.panel__total-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
}

.panel__total-value {
  font-size: 18px;
  font-weight: 600;
}

/* SECTION: Forms & Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field__label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.field__control {
  display: flex;
}

.input,
.select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.8);
  background-color: rgba(15, 23, 42, 0.9);
  color: var(--color-text);
  font: inherit;
  outline: none;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast),
    transform var(--transition-fast);
}

.input::placeholder {
  color: rgba(148, 163, 184, 0.7);
}

.input:focus,
.select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.6);
  transform: translateY(-1px);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-text) 50%),
    linear-gradient(135deg, var(--color-text) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.entry-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

@media (min-width: 720px) {
  .entry-form {
    gap: 10px;
  }
}

/* SECTION: Segmented control for expenses */
.field__control--segmented {
  border-radius: 10px;
  background-color: rgba(15, 23, 42, 0.9);
  padding: 2px;
  border: 1px solid rgba(148, 163, 184, 0.8);
  gap: 2px;
}

.segment {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

.segment--active {
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.32), transparent 70%),
    rgba(15, 23, 42, 0.95);
  color: var(--color-text);
  transform: translateY(-0.5px);
}

.segment:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.6);
}

/* SECTION: Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-med),
    color var(--transition-med),
    border-color var(--transition-med),
    box-shadow var(--transition-med),
    transform var(--transition-fast);
}

.btn--primary {
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: #0b1120;
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.35);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(56, 189, 248, 0.5);
}

.btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.45);
}

.btn--ghost {
  background: rgba(15, 23, 42, 0.9);
  color: var(--color-text);
  border-color: rgba(148, 163, 184, 0.7);
}

.btn--ghost:hover {
  background: rgba(15, 23, 42, 1);
  transform: translateY(-1px);
}

.btn--ghost:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.8);
}

/* SECTION: Entry List */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
}

.entry-item {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 7px 8px;
  border-radius: 10px;
  background-color: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(30, 64, 175, 0.7);
}

.entry-item__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-item__amount {
  font-variant-numeric: tabular-nums;
}

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

.entry-item__btn {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background-color: rgba(15, 23, 42, 0.9);
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

.entry-item__btn:hover {
  background-color: rgba(15, 23, 42, 1);
  color: var(--color-accent);
  transform: translateY(-1px);
}

.entry-item__btn:active {
  transform: translateY(0);
}

/* SECTION: Expense Columns */
.expense-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 640px) {
  .expense-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

.expense-column__title {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* SECTION: Summary */
.summary-main {
  padding: 14px 14px 16px;
  border-radius: 16px;
  margin-bottom: 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.6);
}

.summary-main__label {
  margin: 0 0 3px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.summary-main__value {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: -0.03em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-main__hint {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.summary-breakdown {
  margin: 0 0 14px;
  padding: 0;
}

.summary-breakdown__row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--color-text-muted);
}

.summary-breakdown__row + .summary-breakdown__row {
  margin-top: 4px;
}

.summary-breakdown__row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

/* SECTION: Overview text */
.overview {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  background-color: rgba(15, 23, 42, 0.85);
}

.overview__title {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.overview__text {
  margin: 0;
  font-size: 13px;
  color: var(--color-text);
}

/* SECTION: Footer */
.footer {
  margin-top: 22px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.footer__text {
  margin: 0;
}

.footer__highlight {
  color: var(--color-accent);
}

/* SECTION: Bottom Navigation */
.bottom-nav {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  margin-top: 20px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.5);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  backdrop-filter: blur(18px);
  z-index: 5;
}

.bottom-nav__item {
  flex: 1;
  border-radius: 999px;
  border: none;
  padding: 8px 10px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

.bottom-nav__item--active {
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.32), transparent 70%),
    rgba(15, 23, 42, 0.95);
  color: var(--color-text);
  transform: translateY(-1px);
}

.bottom-nav__label {
  white-space: nowrap;
}

/* SECTION: Tabs */
.tab-section {
  display: none;
}

.tab-section--active {
  display: contents;
}

/* SECTION: Utility */
.shadow-soft {
  box-shadow: var(--shadow-soft);
}

[aria-live] {
  min-height: 1em;
}

/* Scrollbars (WebKit) */
.entry-list::-webkit-scrollbar {
  width: 6px;
}

.entry-list::-webkit-scrollbar-track {
  background: transparent;
}

.entry-list::-webkit-scrollbar-thumb {
  background: rgba(124, 139, 160, 0.6);
  border-radius: 999px;
}
