:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #697684;
  --line: #d7dee7;
  --panel: #ffffff;
  --page: #f4f7f9;
  --nav: #1f3141;
  --nav-soft: #2f485b;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warn: #b45309;
  --bad: #b42318;
  --good: #067647;
  --blue: #2563eb;
  --shadow: 0 16px 40px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

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

button.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.32);
  color: #fff;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
}

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

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

.sidebar {
  background: var(--nav);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
}

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

.brand-mark {
  align-items: center;
  background: #dbeafe;
  border-radius: 7px;
  color: #1e3a8a;
  display: inline-flex;
  font-weight: 900;
  height: 46px;
  justify-content: center;
  width: 46px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.auth-panel h2,
.locked-state h2 {
  margin: 0;
}

.brand h1 {
  font-size: 1.12rem;
}

.brand p,
.hint,
.eyebrow {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.auth-panel,
.session-panel {
  background: var(--nav-soft);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.auth-panel input,
.auth-panel select {
  border-color: transparent;
}

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

.nav-button {
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  justify-content: flex-start;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 22px;
}

.topbar .eyebrow {
  color: var(--muted);
}

.topbar h2 {
  font-size: 1.8rem;
}

.month-pill {
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  color: #075985;
  font-weight: 800;
  padding: 8px 14px;
}

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

.locked-state {
  display: grid;
  gap: 14px;
  max-width: 780px;
  padding: 24px;
}

.locked-state p {
  color: var(--muted);
  margin: 0;
}

.inline-form {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 150px auto;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.6rem;
}

.split-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 18px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.stacked-form {
  display: grid;
  gap: 13px;
  padding: 18px;
}

.cash-flow,
.item-list,
.due-list,
.priority-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.flow-row,
.item-row,
.due-row,
.priority-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.item-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.row-title {
  display: block;
  font-weight: 800;
}

.row-meta {
  color: var(--muted);
  display: block;
  font-size: 0.88rem;
  margin-top: 3px;
}

.income-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.amount {
  font-weight: 900;
}

.positive {
  color: var(--good);
}

.negative {
  color: var(--bad);
}

.warning {
  color: var(--warn);
}

.danger-button {
  background: #fee4e2;
  color: var(--bad);
  min-height: 36px;
}

.danger-button:hover {
  background: #fecaca;
}

.text-button {
  background: transparent;
  color: var(--bad);
  font-size: 0.82rem;
  min-height: 0;
  padding: 0;
}

.text-button:hover {
  background: transparent;
  color: #7a271a;
  text-decoration: underline;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  text-align: left;
  white-space: nowrap;
}

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

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

.hidden,
.view {
  display: none;
}

.view.active {
  display: block;
}

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

  .sidebar {
    min-height: auto;
  }

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

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

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

  .topbar {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .item-row,
  .flow-row,
  .due-row,
  .priority-row {
    grid-template-columns: 1fr;
  }
}
