:root {
  --ink: #14201c;
  --muted: #5a6b64;
  --line: #d4ddd8;
  --bg: #eef3f0;
  --surface: #fff;
  --accent: #1a5c45;
  --accent-2: #0d6e8a;
  --danger: #9b1c1c;
  --warn-bg: #fff8e8;
  --err-bg: #fdecec;
  --ok-bg: #e7f6ef;
  --shadow: 0 1px 2px rgba(20, 32, 28, 0.06), 0 10px 28px rgba(20, 32, 28, 0.06);
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45; font-size: 14.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.header {
  background: var(--ink); color: #f2f7f4; padding: 12px 18px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; flex-direction: column; min-width: 140px; }
.brand strong { font-size: 16px; letter-spacing: 0.02em; }
.brand span { font-size: 11px; opacity: 0.7; }
.header-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { font-size: 11.5px; border: 1px solid rgba(255,255,255,0.2); border-radius: 999px; padding: 3px 10px; opacity: 0.85; }
.nav {
  display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface);
  border-bottom: 1px solid var(--line); padding: 8px 14px; position: sticky; top: 58px; z-index: 15;
}
.nav button {
  border: 1px solid transparent; background: transparent; border-radius: 8px;
  padding: 7px 12px; font-weight: 650; font-size: 13px; color: var(--muted);
}
.nav button:hover { background: #f0f5f2; color: var(--ink); }
.nav button.active { background: #e4f0ea; color: var(--accent); border-color: #b8d4c6; }
.main { padding: 18px 20px 48px; max-width: 1200px; margin: 0 auto; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid #b5c4bc; border-radius: 7px; padding: 7px 9px; background: #fff; min-height: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(26, 92, 69, 0.28); border-color: var(--accent);
}
.field.full { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; padding: 7px 12px; border: 1px solid transparent;
  font-weight: 650; font-size: 13px; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #144a37; }
.btn-blue { background: var(--accent-2); color: #fff; }
.btn-blue:hover { background: #0a5870; }
.btn-ghost { background: #fff; border-color: #b5c4bc; }
.btn-ghost:hover { background: #f0f5f2; }
.btn-danger { background: var(--err-bg); color: var(--danger); border-color: #f0c0c0; }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 720px; }
table.data th, table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th {
  background: #f0f5f2; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); text-align: left; white-space: nowrap;
}
table.data .money { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }
table.data tfoot td { font-weight: 700; background: #f0f5f2; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: #f7faf8; }
table.data tr.neg .money { color: var(--danger); }
table.data input[type="checkbox"] { width: 16px; height: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 650; }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; font-family: var(--mono); }
.stat.ok { border-color: #b7dfc9; background: var(--ok-bg); }
.stat.bad { border-color: #f0c0c0; background: var(--err-bg); }
.alert { border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.alert ul { margin: 6px 0 0; padding-left: 1.2em; }
.alert-error { background: var(--err-bg); color: var(--danger); border: 1px solid #f0c0c0; }
.alert-warn { background: var(--warn-bg); color: #7a5a00; border: 1px solid #f0dca0; }
.alert-ok { background: var(--ok-bg); color: #0d5c42; border: 1px solid #b7dfc9; }
.alert-info { background: #e8f3f8; color: #0a4a5c; border: 1px solid #b8d8e6; }
.toast {
  position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 50;
  box-shadow: var(--shadow); max-width: 360px;
}
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 7px; border-radius: 999px; background: #e4f0ea; color: var(--accent);
}
.badge.firm { background: #e8f0f6; color: var(--accent-2); }
.badge.closed { background: #eee; color: #666; }
.recon-box {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: baseline;
  font-family: var(--mono); font-size: 13px; max-width: 520px;
}
.recon-box .lbl { font-family: var(--font); color: var(--muted); font-size: 13px; }
.recon-box .tot { font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 12px; }
}
@media print {
  .header, .nav, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .main { max-width: none; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
