:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #17211b;
  --muted: #657169;
  --line: #dfe5df;
  --green: #22724d;
  --green-dark: #145336;
  --red: #b3413c;
  --blue: #316a95;
  --amber: #b56a18;
  --shadow: 0 18px 40px rgba(20, 35, 28, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eef3ef 0%, var(--bg) 38%, #ffffff 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  border-color: #b9c7bd;
}

.primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.primary:hover {
  background: var(--green-dark);
}

.ghost {
  background: transparent;
}

.hidden {
  display: none !important;
}

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

.auth-panel {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 420px);
  gap: 32px;
  align-items: center;
}

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

.mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: var(--green);
  color: white;
  font-size: 38px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.brand p {
  color: var(--muted);
  font-size: 18px;
  margin-top: 10px;
  max-width: 520px;
}

.auth-form,
.side .stack,
.content article,
.metrics article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-form {
  padding: 22px;
  display: grid;
  gap: 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #edf2ee;
  border-radius: 8px;
}

.mode-switch button {
  min-height: 36px;
  border: 0;
  background: transparent;
}

.mode-switch button.active {
  background: white;
  box-shadow: 0 2px 8px rgba(25, 40, 32, 0.12);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

input:focus,
select:focus {
  border-color: var(--green);
  outline: 3px solid rgba(34, 114, 77, 0.16);
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.message.error {
  color: var(--red);
}

.register-only {
  display: none;
}

.registering .register-only {
  display: grid;
}

.admin-only {
  display: none !important;
}

.is-admin .admin-only {
  display: grid !important;
}

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

.topbar h1 {
  font-size: 34px;
}

.eyebrow {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 5px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr)) minmax(130px, 0.7fr) minmax(220px, 1.5fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.metrics strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 16px;
  align-items: start;
}

.side {
  display: grid;
  gap: 16px;
}

.side .stack {
  padding: 18px;
  display: grid;
  gap: 13px;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--ink);
  font-weight: 600;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.content {
  display: grid;
  gap: 16px;
}

.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.content article {
  padding: 18px;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar {
  display: grid;
  grid-template-columns: minmax(90px, 140px) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.bar-track {
  height: 10px;
  background: #ecf0ed;
  border-radius: 999px;
  overflow: hidden;
}

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

.split .bar-fill {
  background: var(--blue);
}

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

.table-head span {
  color: var(--muted);
  font-size: 14px;
}

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

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

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

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

.amount {
  text-align: right;
  white-space: nowrap;
}

.expense {
  color: var(--red);
}

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

.row-action {
  min-height: 32px;
  padding: 0 10px;
  margin-left: 6px;
  color: var(--red);
}

.row-action.edit {
  color: var(--blue);
}

.actions {
  white-space: nowrap;
}

.user-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
}

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

.user-row span {
  color: var(--muted);
}

@media (max-width: 980px) {
  .auth-panel,
  .workspace,
  .chart-row {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1420px);
    padding: 18px 0;
  }

  .topbar,
  .brand {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

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

  h1 {
    font-size: 38px;
  }
}
