:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-elevated: #10141b;
  --panel: rgba(16, 20, 27, 0.92);
  --panel-strong: #151b24;
  --line: rgba(232, 238, 247, 0.12);
  --text: #f6f8fb;
  --muted: #9aa6b5;
  --soft: #cbd5e1;
  --green: #8ef0c7;
  --cyan: #62d6ff;
  --yellow: #f9c74f;
  --coral: #f9844a;
  --rose: #fb7185;
  --violet: #c4b5fd;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(rgba(7, 9, 13, 0.78), rgba(7, 9, 13, 0.92)),
    url("/assets/signal-field.svg") center top / cover fixed;
}

button,
input,
select {
  font: inherit;
}

label small {
  color: var(--muted);
  font-size: 0.76rem;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 16, 22, 0.94);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 8px;
  color: #05110d;
  background: var(--green);
  font-weight: 900;
}

.auth-copy {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 22px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.74);
}

.auth-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.auth-tabs button.active {
  color: #06100d;
  background: var(--green);
}

.auth-note {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--soft);
  background: rgba(5, 8, 12, 0.62);
}

.auth-note span {
  color: var(--muted);
  line-height: 1.45;
}

.auth-link-button {
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.75rem, 2.2vw, 2.4rem);
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.eyebrow,
.panel-header p,
.metric-card span,
.metric-card small {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--soft);
  font-size: 0.88rem;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(5, 8, 12, 0.78);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(142, 240, 199, 0.12);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  gap: 18px;
  padding: 18px 0 22px;
}

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

.topbar-actions input[type="month"] {
  width: 160px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.74);
}

.segmented button,
.tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  padding: 0 12px;
}

.segmented button.active,
.tab.active {
  color: #06100d;
  background: var(--green);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(8, 11, 16, 0.74);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid rgba(142, 240, 199, 0.44);
  color: #06100d;
  background: var(--green);
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(8, 11, 16, 0.72);
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-weight: 900;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 142px;
  display: grid;
  align-content: space-between;
  padding: 18px;
}

.metric-card strong {
  font-size: clamp(1.65rem, 5vw, 2.65rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-card.income {
  border-top: 3px solid var(--green);
}

.metric-card.expense {
  border-top: 3px solid var(--coral);
}

.metric-card.balance {
  border-top: 3px solid var(--cyan);
}

.metric-card.moves {
  border-top: 3px solid var(--yellow);
}

.dashboard-grid,
.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 16px;
}

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

.panel-header p {
  margin-top: 5px;
  font-size: 0.86rem;
}

.chart-panel canvas {
  width: 100%;
  min-height: 220px;
  display: block;
}

.category-bars,
.category-list,
.movement-list,
.debt-list {
  display: grid;
  gap: 10px;
}

.category-row {
  display: grid;
  gap: 8px;
}

.category-row-top,
.movement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 11, 16, 0.74);
  overflow-x: auto;
}

.tab {
  min-width: 120px;
}

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

.form-panel .primary-button {
  width: 100%;
  margin-top: 14px;
}

.movement-row,
.category-item,
.debt-card {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 9, 14, 0.58);
}

.movement-main {
  min-width: 0;
}

.movement-main strong {
  display: block;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movement-main span,
.movement-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.movement-amount {
  display: grid;
  justify-items: end;
  gap: 8px;
  white-space: nowrap;
}

.movement-amount strong.income {
  color: var(--green);
}

.movement-amount strong.expense {
  color: var(--coral);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.tiny-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--soft);
  background: rgba(16, 20, 27, 0.9);
  padding: 0 9px;
}

.category-item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 12px;
}

.swatch {
  width: 14px;
  height: 38px;
  border-radius: 6px;
  background: var(--green);
}

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

.debt-card {
  display: grid;
  gap: 12px;
}

.debt-card-top,
.debt-stats {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.debt-card-top > div:first-child {
  display: grid;
  gap: 8px;
}

.status-pill {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill.active {
  color: #06100d;
  background: var(--green);
}

.status-pill.paused {
  color: #211705;
  background: var(--yellow);
}

.status-pill.paid {
  color: #07131a;
  background: var(--cyan);
}

.debt-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.debt-progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.debt-stats {
  color: var(--muted);
  font-size: 0.82rem;
}

.installment-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.installment-strip span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.76rem;
  font-weight: 800;
}

.installment-strip span.partial {
  color: #211705;
  background: var(--yellow);
}

.installment-strip span.paid {
  color: #06100d;
  background: var(--green);
}

.debt-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 20;
  min-width: min(92vw, 360px);
  min-height: 42px;
  display: grid;
  place-items: center;
  transform: translate(-50%, 120px);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
  padding: 10px 14px;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 28px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

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

  .dashboard-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  }

  .workspace {
    grid-template-columns: minmax(320px, 0.45fr) minmax(0, 0.55fr);
  }

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

  .span-2 {
    grid-column: span 2;
  }

  .full-row {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1180px) {
  .workspace {
    grid-template-columns: 420px minmax(0, 1fr);
  }
}
