:root {
  color-scheme: light;
  --bg: #f4f0e7;
  --ink: #1c2426;
  --muted: #66706d;
  --line: #ddd3c4;
  --panel: #fffdfa;
  --soft: #ece6da;
  --green: #168066;
  --green-soft: #dcefe8;
  --red: #b64242;
  --red-soft: #f3dddd;
  --blue: #275f86;
  --blue-soft: #dce9f1;
  --gold: #a87320;
  --gold-soft: #f1e3c8;
  --shadow: 0 20px 55px rgba(31, 35, 33, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(39, 95, 134, 0.15), transparent 34%),
    linear-gradient(315deg, rgba(22, 128, 102, 0.13), transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.eyebrow,
h1,
h2,
p {
  margin-top: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.94;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.1rem;
}

.topbar-actions,
.row-actions {
  display: flex;
  gap: 9px;
  align-items: center;
}

.tool-button,
.mini-button,
.delete-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(31, 35, 33, 0.07);
}

.tool-button input {
  display: none;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.66);
  padding: 6px;
  border: 1px solid rgba(221, 211, 196, 0.85);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.tab.is-active {
  background: var(--ink);
  color: #fffdfa;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric,
.panel {
  border: 1px solid rgba(221, 211, 196, 0.92);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  line-height: 1;
}

.metric-balance {
  background: var(--ink);
  color: #fffdfa;
}

.metric-balance span {
  color: #cbd4d1;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

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

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

.panel {
  padding: 20px;
}

.wide-panel {
  grid-column: span 1;
}

.dashboard-grid .wide-panel {
  grid-column: 2;
  grid-row: span 2;
}

.panel-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #303838;
  font-size: 0.86rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 95, 134, 0.15);
}

.field-row,
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}

.filters {
  grid-template-columns: 130px 140px minmax(150px, 220px);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border-radius: 8px;
  background: var(--soft);
  padding: 5px;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  display: block;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
}

.segmented input:checked + label {
  background: var(--ink);
  color: #fffdfa;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  padding: 13px 16px;
  font-weight: 900;
}

.chart-wrap {
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

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

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

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

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

small {
  color: var(--muted);
}

.amount-cell {
  text-align: right;
  font-weight: 900;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.pill-paid,
.ok {
  background: var(--green-soft);
  color: var(--green);
}

.pill-pending,
.warn {
  background: var(--gold-soft);
  color: var(--gold);
}

.pill-late,
.danger {
  background: var(--red-soft);
  color: var(--red);
}

.delete-button {
  min-width: 34px;
  padding: 6px 10px;
  color: var(--red);
}

.mini-button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--green);
}

.stack-list {
  display: grid;
  gap: 10px;
}

.alert-row,
.budget-row,
.account-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.alert-row span,
.budget-row span,
.account-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.budget-row > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

meter {
  width: 100%;
  height: 12px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.empty-state {
  display: none;
  margin: 18px 0 2px;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-visible {
  display: block;
}

@media (max-width: 1040px) {
  .summary-grid,
  .dashboard-grid,
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-grid .wide-panel,
  .ledger-panel {
    grid-column: 1 / -1;
  }

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

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 22px, 1260px);
    padding-top: 18px;
  }

  .topbar,
  .summary-grid,
  .dashboard-grid,
  .workspace,
  .panel-heading,
  .field-row,
  .filters,
  .tabs,
  .account-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .chart-wrap {
    height: 220px;
  }
}
