:root {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #20342d;
  background: #f4f5f1;
  font-synthesis: none;
  --paper: #fff;
  --line: #dde3dc;
  --muted: #67766e;
  --green: #234f3e;
  --soft: #eaf1e9;
  --danger: #a32e23;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
a {
  color: inherit;
}
button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
:focus-visible {
  outline: 3px solid #8ab9a1;
  outline-offset: 3px;
}
button,
.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 11px 17px;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover,
.button:hover {
  background: var(--soft);
}
.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.primary:hover {
  background: #173c2e;
}
.quiet {
  background: transparent;
}
.shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  background: #edf0e9;
  border-right: 1px solid var(--line);
  padding: 38px 23px;
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.brand {
  text-decoration: none;
  display: flex;
  gap: 11px;
  align-items: center;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.5px;
}
.brand-mark {
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  background: var(--green);
  border-radius: 9px;
  color: #fff;
  font-family: Georgia, serif;
  font-size: 27px;
}
.brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.5px;
  margin-top: 4px;
  color: var(--muted);
}
nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 55px;
}
nav a {
  padding: 14px 11px;
  text-decoration: none;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}
nav a span {
  font-size: 10px;
  margin-right: 9px;
  color: var(--muted);
}
nav a.active {
  background: #dce6dc;
  color: #173e2c;
}
nav a:hover {
  background: var(--line);
}
.sidebar-foot {
  margin-top: auto;
  padding: 30px 9px 0;
  font-size: 11px;
  color: var(--muted);
}
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #578463;
  margin-right: 5px;
}
.sidebar-foot p {
  line-height: 1.6;
}
main {
  padding: 44px 48px 80px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 1.7px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 13px;
}
h1 {
  font-size: 34px;
  font-weight: 550;
  letter-spacing: -1.1px;
  margin: 0 0 12px;
}
h2 {
  font-size: 20px;
  font-weight: 550;
  letter-spacing: -0.4px;
  margin: 0;
}
h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
p {
  line-height: 1.6;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}
.head-actions,
.actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  align-items: center;
}
.count {
  font-size: 14px;
  background: var(--soft);
  padding: 5px 10px;
  border-radius: 6px;
  letter-spacing: 0;
  vertical-align: middle;
  margin-left: 10px;
  color: var(--green);
}
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 24px 0 20px;
}
input,
select,
textarea {
  color: inherit;
  background: var(--paper);
  border: 1px solid #bdc9be;
  border-radius: 7px;
  min-height: 44px;
  padding: 11px 12px;
  width: 100%;
  font-size: 15px;
}
input::placeholder,
textarea::placeholder {
  color: #7b857d;
}
textarea {
  min-height: 100px;
  resize: vertical;
}
.search {
  max-width: 380px;
}
.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}
th {
  color: var(--muted);
  background: #f9faf7;
  font-size: 11px;
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}
th,
td {
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
tr:last-child td {
  border-bottom: 0;
}
td small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}
td a {
  text-decoration: none;
  font-weight: 600;
}
td a:hover {
  text-decoration: underline;
}
td strong {
  font-weight: 600;
}
.number {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--muted);
}
.badge {
  display: inline-block;
  font-size: 11px;
  white-space: nowrap;
  padding: 6px 9px;
  border-radius: 5px;
  background: #edf0eb;
  color: #506056;
}
.badge.new {
  background: #f3ead3;
  color: #7d5a16;
}
.badge.work {
  background: #e2eee8;
  color: #285e47;
}
.badge.closed {
  background: #e7e9eb;
  color: #555e67;
}
.empty {
  padding: 54px 20px;
  text-align: center;
  color: var(--muted);
  line-height: 1.7;
}
.empty strong {
  display: block;
  font-size: 18px;
  color: inherit;
  font-weight: 500;
}
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 28px;
}
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 285px;
  gap: 24px;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 23px;
  margin-bottom: 22px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  margin-bottom: 22px;
}
.panel-head button {
  font-size: 12px;
  padding: 9px 12px;
  min-height: 40px;
}
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.fact dt {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 7px;
}
.fact dd {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.fact {
  margin: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 17px;
}
.stack label {
  font-size: 12px;
  color: var(--muted);
}
.stack label input,
.stack label textarea,
.stack label select {
  margin-top: 7px;
  color: #20342d;
}
.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px;
}
.wide {
  grid-column: 1/-1;
}
.subtle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0;
}
.list-card {
  display: block;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.list-card:first-child {
  padding-top: 0;
}
.list-card:last-child {
  border: 0;
  padding-bottom: 0;
}
.list-card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.list-card p {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 0;
}
.list-card:hover h3 {
  text-decoration: underline;
}
.money-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
  padding: 23px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.money-grid span {
  font-size: 11px;
  color: var(--muted);
}
.money-grid strong {
  display: block;
  font-size: 25px;
  font-weight: 550;
  letter-spacing: -0.7px;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.money-grid .remaining strong {
  color: var(--green);
}
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}
.timeline li {
  border-left: 1px solid var(--line);
  padding: 0 0 25px 20px;
  margin-left: 4px;
  position: relative;
}
.timeline li:before {
  content: '';
  width: 7px;
  height: 7px;
  background: #7d9a87;
  border: 3px solid var(--paper);
  box-sizing: content-box;
  border-radius: 50%;
  position: absolute;
  left: -7px;
  top: 1px;
}
.timeline li:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}
.timeline h3 {
  font-size: 13px;
}
.timeline p {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 8px 0;
}
.timeline small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  display: block;
}
.timeline details {
  font-size: 12px;
  margin: 9px 0;
  color: var(--muted);
}
.timeline pre {
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.7;
}
.segment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}
.segment a {
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  padding: 10px;
  background: var(--paper);
}
.segment a.selected {
  border-color: var(--green);
  background: var(--soft);
}
dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: inherit;
  width: min(600px, calc(100% - 28px));
  max-height: 90dvh;
  box-shadow: 0 20px 80px #18352930;
}
dialog::backdrop {
  background: #10291c66;
  backdrop-filter: blur(2px);
}
#dialog-content {
  padding: 28px;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 25px;
}
.dialog-head button {
  min-width: 44px;
  padding: 0;
}
.form-error {
  color: var(--danger);
  font-size: 13px;
  white-space: pre-wrap;
}
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.check input {
  width: 20px;
  min-height: 20px;
  margin: 0 !important;
}
.check span {
  line-height: 1.6;
}
.loading {
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}
#notice {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  background: #193c2c;
  color: #fff;
  border-radius: 8px;
  padding: 14px 22px;
  z-index: 10;
  max-width: 90vw;
  font-size: 13px;
}
#preview-label {
  padding: 9px 20px;
  background: #f1deb0;
  color: #614917;
  font-size: 12px;
  text-align: center;
}
[hidden] {
  display: none !important;
}
.danger {
  color: var(--danger);
}
.nowrap {
  white-space: nowrap;
}
.break {
  overflow-wrap: anywhere;
}
.entries td {
  padding: 13px 10px;
}
.entries td button {
  padding: 8px;
  font-size: 11px;
}
.entry-date {
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 1050px) {
  .shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }
  .sidebar {
    padding: 30px 15px;
  }
  main {
    padding: 32px 26px;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .side-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }
  .brand {
    font-size: 14px;
  }
  nav a {
    font-size: 12px;
  }
}
@media (max-width: 700px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: relative;
    height: auto;
    padding: 20px 18px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    font-size: 16px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
    font-size: 24px;
  }
  nav {
    margin-top: 19px;
    flex-direction: row;
    gap: 0;
    overflow: auto;
  }
  nav a {
    border-radius: 6px 6px 0 0;
    padding: 13px 12px;
    min-height: 44px;
  }
  nav a span {
    display: none;
  }
  .sidebar-foot {
    display: none;
  }
  main {
    padding: 26px 18px 50px;
  }
  h1 {
    font-size: 28px;
  }
  .page-head {
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 22px;
  }
  .page-head .muted {
    font-size: 12px;
  }
  .eyebrow {
    font-size: 10px;
  }
  .search {
    max-width: none;
  }
  .toolbar {
    margin-top: 10px;
    flex-wrap: wrap;
  }
  .toolbar input {
    flex: 1;
    min-width: 210px;
  }
  th,
  td {
    padding: 14px 13px;
  }
  .hide-mobile {
    display: none;
  }
  .panel {
    padding: 18px;
    margin-bottom: 17px;
  }
  .panel-head {
    align-items: flex-start;
  }
  .panel-head h2 {
    font-size: 17px;
  }
  .detail-grid {
    gap: 0;
  }
  .side-details {
    display: block;
  }
  .facts {
    gap: 20px 12px;
  }
  .money-grid {
    gap: 10px;
  }
  .money-grid strong {
    font-size: 19px;
  }
  .money-grid span {
    font-size: 10px;
  }
  .grid-form {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  #dialog-content {
    padding: 21px;
  }
  .actions button {
    flex: 1;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
  .entries td {
    font-size: 12px;
  }
  .back {
    margin-bottom: 20px;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    color: #e5eee6;
    background: #16231d;
    --paper: #1c2e24;
    --line: #354a3c;
    --muted: #a5b6aa;
    --green: #568c6e;
    --soft: #2a4132;
  }
  .sidebar {
    background: #1b2a20;
  }
  .brand-mark {
    background: #456f53;
  }
  nav a.active {
    background: #344f3c;
    color: #edf7eb;
  }
  input,
  select,
  textarea {
    border-color: #526557;
  }
  .stack label input,
  .stack label textarea,
  .stack label select {
    color: #e5eee6;
  }
  th {
    background: #203326;
  }
  .count {
    color: #c1dfc6;
  }
  .badge {
    background: #364b3c;
    color: #cbdfcb;
  }
  .money-grid .remaining strong {
    color: #8cc19d;
  }
}

/* Team overview: same visual language as the existing cabinet. */
.cash {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cash-remaining {
  font-weight: 600;
  color: var(--green);
}
.dashboard-filter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  margin: 0 0 28px;
}
.dashboard-filter label {
  color: var(--muted);
  font-size: 12px;
  min-width: 210px;
  max-width: 260px;
}
.dashboard-filter select {
  margin-top: 8px;
  color: inherit;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}
.kpi {
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.kpi p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 16px;
}
.kpi strong {
  display: block;
  font-size: 40px;
  letter-spacing: -1.5px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}
.kpi small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  display: block;
}
.kpi-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}
.kpi-primary p,
.kpi-primary small {
  color: #e0ebe4;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
}
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 10px;
}
.metric-row strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  font-weight: 550;
}
.metric-row strong small {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 14px;
  display: inline-block;
  min-width: 32px;
  text-align: right;
}
.stage-number {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  margin-right: 12px;
}
.funnel-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.funnel-list li,
.status-breakdown > div {
  margin-bottom: 19px;
}
progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 4px;
  display: block;
  overflow: hidden;
  background: var(--soft);
}
progress::-webkit-progress-bar {
  background: var(--soft);
  border-radius: 4px;
}
progress::-webkit-progress-value {
  background: #668b74;
  border-radius: 4px;
}
progress::-moz-progress-bar {
  background: #668b74;
  border-radius: 4px;
}
.dashboard-grid .subtle {
  margin-top: 23px;
  font-size: 11px;
}
.attention-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 25px;
}
.attention-grid article {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.attention-grid span {
  font-size: 12px;
  align-self: center;
}
.attention-grid strong {
  font-size: 25px;
  font-weight: 550;
  color: #8b6724;
  font-variant-numeric: tabular-nums;
}
.attention-grid small {
  grid-column: 1/-1;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}
.intake-chart {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
  margin: 25px 0 0;
}
.chart-baseline {
  stroke: var(--line);
}
.chart-bar {
  fill: #648a74;
}
.chart-zero {
  fill: var(--line);
}
.chart-value {
  fill: var(--muted);
  font-size: 12px;
  text-anchor: middle;
}
.chart-date {
  fill: var(--muted);
  font-size: 12px;
}
.chart-data {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
}
.chart-data .table-wrap {
  margin-top: 12px;
  max-height: 290px;
  overflow: auto;
}
@media (max-width: 1050px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .attention-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-filter {
    align-items: flex-start;
  }
  .kpi strong {
    font-size: 36px;
  }
}
@media (max-width: 700px) {
  .dashboard-filter {
    display: block;
  }
  .dashboard-filter label {
    display: block;
    max-width: none;
  }
  .dashboard-filter p {
    margin: 16px 0 0;
  }
  .kpi-grid {
    gap: 10px;
  }
  .kpi {
    padding: 18px 14px;
  }
  .kpi strong {
    font-size: 32px;
  }
  .kpi p {
    font-size: 11px;
  }
  .kpi small {
    font-size: 10px;
  }
  .dashboard-grid {
    gap: 0;
  }
  .dashboard-money .panel-head {
    display: block;
  }
  .dashboard-money .panel-head .subtle {
    display: block;
    margin-top: 8px;
  }
  .counterparty-table table,
  .dashboard-money table {
    min-width: 650px;
  }
  .attention-grid {
    gap: 10px;
  }
  .cash {
    font-size: 12px;
  }
  .intake-chart {
    min-height: 120px;
  }
}
@media (prefers-color-scheme: dark) {
  .cash-remaining {
    color: #8cc19d;
  }
  .attention-grid strong {
    color: #d3b56f;
  }
}
