:root {
  color: #1c2430;
  background: #efeae2;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  --ink: #1c2430;
  --muted: #667085;
  --line: #e3ddd3;
  --paper: #fffcf8;
  --bg: #efeae2;
  --pine: #1f6b4a;
  --pine-dark: #14382c;
  --sidebar: #14211c;
  --danger: #8d2f2f;
  --warn: #8a5a12;
  --info: #24527a;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--pine-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: Literata, Georgia, serif; font-weight: 560; margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -0.03em; }
h2 { font-size: 1.05rem; }

.app { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; }

.sidebar {
  background: var(--sidebar);
  color: #e7f2ec;
  padding: 1.1rem 0.85rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.brand { padding: 0 0.55rem; }
.brand strong {
  display: block;
  font-family: Literata, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 560;
}
.brand span { color: #b7cfc4; font-size: 0.86rem; }
.nav-group { display: grid; gap: 0.15rem; margin-top: 0.7rem; }
.nav-label {
  margin: 0.35rem 0.55rem 0.15rem;
  color: #8eaea0;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sidebar a.nav {
  display: block;
  color: #d7ebe3;
  text-decoration: none;
  padding: 0.38rem 0.55rem;
  border-radius: 8px;
}
.sidebar a.nav.active, .sidebar a.nav:hover { background: #1d3b31; color: white; }

.main { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1.4rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.role { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.86rem; }
.role select { width: auto; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.5rem; }

.view { padding: 1.25rem 1.4rem 2.5rem; display: grid; gap: 1rem; }
.lede { margin: 0.25rem 0 0; color: var(--muted); max-width: 68ch; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.stat { padding: 0.9rem 1rem; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; }
.stat strong { display: block; margin-top: 0.2rem; font-size: 1.25rem; font-variant-numeric: tabular-nums; font-weight: 650; }
.stat em { display: block; margin-top: 0.15rem; color: var(--muted); font-style: normal; font-size: 0.84rem; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem 1rem;
}
.panel-head, .page-head, .filters {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: end;
}
.filters { align-items: end; margin-bottom: 0.7rem; }
.page-head { align-items: start; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.45rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 0.94rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sub { display: block; color: var(--muted); font-size: 0.82rem; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 650;
  background: #f3efe8;
  color: var(--ink);
}
.pill.final, .pill.posted, .pill.paid { background: #e5f3ec; color: var(--pine-dark); }
.pill.draft { background: #f3efe8; color: #5c5346; }
.pill.partial { background: #f8f1de; color: var(--warn); }
.pill.unpaid { background: #eef2f6; color: var(--info); }
.pill.overdue { background: #f8e8e6; color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 1rem; align-items: start; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem 1rem; margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }
.facts dd { margin: 0.1rem 0 0; }
.facts .wide { grid-column: 1 / -1; }

.field { display: grid; gap: 0.25rem; }
.field label { font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.field input, .field select {
  width: 100%;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}
.field small { color: var(--danger); min-height: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.form-error { color: var(--danger); margin: 0; }
.saved { color: var(--pine); margin: 0; }

.actions { display: flex; gap: 0.5rem; align-items: center; }
button, .button {
  background: var(--pine);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
button.ghost, a.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  text-decoration: none;
}
.empty { color: var(--muted); margin: 0.4rem 0; }
.crumb { margin: 0 0 0.3rem; color: var(--muted); font-size: 0.88rem; }
.note { color: var(--muted); font-size: 0.88rem; margin: 0.4rem 0 0; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 0.8rem; }
  .stats, .grid-2, .form-grid, .facts { grid-template-columns: 1fr; }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--line); }
}
