:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --ink: #18201c;
  --muted: #667068;
  --line: #dfe4dc;
  --accent: #1f7a5b;
  --accent-strong: #13523e;
  --danger: #b4413c;
  --shadow: 0 14px 50px rgba(34, 42, 36, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

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

.login-panel {
  display: grid;
  gap: 22px;
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h2,
.sidebar h1 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  margin: 6px 0 0;
  color: var(--muted);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: #eef1ea;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar a {
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.sidebar a:hover {
  background: #fff;
}

.sidebar .ghost {
  margin-top: auto;
}

main {
  min-width: 0;
}

.app-shell main {
  display: grid;
  gap: 22px;
  padding: 28px;
}

.topbar,
.panel-heading,
.account-row,
.budget-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.metrics article {
  display: grid;
  gap: 8px;
  min-height: 112px;
  padding: 18px;
}

.metrics span,
.budget-meta,
.account-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metrics strong {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  gap: 22px;
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel h3 {
  margin: 0;
}

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

.account-row,
.budget-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.account-row strong,
.account-row span {
  display: block;
}

.debt-account b {
  color: var(--danger);
}

.budget-row {
  display: grid;
  gap: 10px;
}

.budget-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ebe4;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.ghost,
.text-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost:hover,
.text-button:hover {
  background: #f2f4f0;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
}

.danger {
  color: var(--danger);
}

.full {
  width: 100%;
  margin-top: 14px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  margin-top: 12px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.right {
  text-align: right;
}

.amount {
  color: var(--danger);
  font-weight: 800;
}

.amount.income {
  color: var(--accent);
}

.empty,
.empty-cell {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    grid-template-columns: repeat(3, max-content);
    overflow-x: auto;
  }

  .metrics,
  .content-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .actions button {
    width: 100%;
  }

  .metrics,
  .content-grid {
    grid-template-columns: 1fr;
  }
}
