:root {
  --forest: #123a2b;
  --forest-2: #1b5039;
  --forest-3: #2c6a4c;
  --cream: #f6f1e4;
  --paper: #fffdf7;
  --ink: #1d2a22;
  --muted: #586457;
  --line: #ded6c3;
  --gold: #a97b23;
  --danger: #8f2f2a;
  --warn: #8a6212;
  --ok: #2f6b4f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 58, 43, 0.08), 0 8px 24px rgba(18, 58, 43, 0.06);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--forest-2); text-underline-offset: 2px; }
a:hover { color: var(--forest); }

h1, h2, h3, h4 { font-family: var(--font); line-height: 1.2; margin: 0 0 0.5rem; color: var(--forest); }
h1 { font-size: clamp(1.6rem, 3vw, 2.15rem); letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.75rem; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--forest); color: #fff;
  padding: 0.75rem 1rem; z-index: 100; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: linear-gradient(175deg, #0f3325 0%, #16432f 60%, #123a2b 100%);
  color: #ece6d4; padding: 1.5rem 1.1rem; display: flex; flex-direction: column; gap: 1.4rem;
}
.brand { display: flex; gap: 0.7rem; align-items: center; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(236, 230, 212, 0.55);
  display: grid; place-items: center; font-family: var(--font); font-size: 1.1rem; color: #f3ecd8;
  flex: none;
}
.brand-name { font-family: var(--font); font-size: 1.05rem; letter-spacing: 0.02em; color: #f7f1e1; line-height: 1.15; }
.brand-sub { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.14em; color: #b9c6b4; }

.nav { display: flex; flex-direction: column; gap: 0.15rem; }
.nav a {
  color: #dfe6d7; text-decoration: none; padding: 0.55rem 0.7rem; border-radius: 8px;
  font-size: 0.92rem; display: flex; justify-content: space-between; gap: 0.5rem; align-items: center;
}
.nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 600; }
.nav-count {
  background: rgba(246, 241, 228, 0.16); border-radius: 999px; padding: 0 0.45rem;
  font-size: 0.72rem; min-width: 1.4rem; text-align: center;
}
.signout { margin-top: 0.8rem; }
.signout button {
  background: transparent; border: 1px solid rgba(169, 184, 164, 0.5); border-radius: 6px;
  color: #cfd9c9; font: inherit; font-size: 0.74rem; padding: 0.3rem 0.6rem; cursor: pointer;
}
.signout button:hover { background: rgba(255, 255, 255, 0.08); }
.sidebar-foot { margin-top: 1.2rem; font-size: 0.72rem; color: #a9b8a4; line-height: 1.5; }
.sidebar-foot strong { color: #e6dfc9; font-weight: 600; }

.main { min-width: 0; padding: 1.6rem clamp(1rem, 3vw, 2.4rem) 3rem; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.topbar .eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.7rem; color: var(--muted); font-weight: 700; }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.2rem;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.card-head h2, .card-head h3 { margin: 0; }
.card-sub { color: var(--muted); font-size: 0.86rem; }

.grid { display: grid; gap: 1.2rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem; margin-bottom: 1.3rem; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
.stat-value { font-family: var(--font); font-size: 1.75rem; color: var(--forest); margin-top: 0.2rem; }
.stat-note { font-size: 0.8rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 8px; border: 1px solid transparent;
  padding: 0.5rem 0.9rem; font-size: 0.88rem; font-weight: 600; font-family: var(--sans);
  cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn-primary { background: var(--forest-2); color: #fdf9ee; }
.btn-primary:hover { background: var(--forest); color: #fff; }
.btn-secondary { background: transparent; color: var(--forest-2); border-color: var(--line); }
.btn-secondary:hover { background: #efe7d4; color: var(--forest); }
.btn-danger { background: transparent; color: var(--danger); border-color: #e0c4be; }
.btn-danger:hover { background: #f6e6e2; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.9rem; }
.toolbar form { margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table-wrap { overflow-x: auto; margin: 0 -0.2rem; padding: 0 0.2rem; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #faf5e8; }
tr.is-issue td { background: #fbf3e2; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 600; border-top: 2px solid var(--forest); background: #f4eedd; }

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem; border-radius: 999px; padding: 0.12rem 0.55rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; border: 1px solid transparent; white-space: nowrap;
}
.badge-ok { background: #e5f0e6; color: #1f5b3c; border-color: #c6dcc8; }
.badge-warn { background: #f8edd2; color: #6d4c07; border-color: #ead8ae; }
.badge-danger { background: #f7e5e1; color: #8f2f2a; border-color: #e8c9c2; }
.badge-muted { background: #edeadf; color: #4d5a4d; border-color: #ddd7c7; }
.badge-info { background: #e4ece6; color: #24503a; border-color: #c9d9cd; }

.alert { border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1rem; border: 1px solid; font-size: 0.9rem; }
.alert-error { background: #fbeae6; border-color: #e3c2ba; color: #6f241f; }
.alert-warn { background: #fbf2dc; border-color: #e6d3a4; color: #604510; }
.alert-ok { background: #e8f2e9; border-color: #c4dbc7; color: #1f5237; }
.alert-info { background: #eef2e8; border-color: #d6ddcb; color: #33452f; }
.alert ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }

.field { margin-bottom: 0.85rem; }
.field label, .field .label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 0.25rem; color: var(--ink); }
.field .hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="date"],
input[type="password"], input[type="url"], input[type="file"], select, textarea {
  width: 100%; border: 1px solid #cfc7b3; border-radius: 8px; padding: 0.5rem 0.6rem;
  font: inherit; font-size: 0.9rem; background: #fffefa; color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--forest-3); }
textarea { min-height: 8rem; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.8rem; }
.field-inline { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 0.45rem; align-items: center; font-size: 0.85rem; }

.tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: 0.45rem 0.8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; font-size: 0.88rem; }
.tabs a[aria-current="page"] { color: var(--forest); border-color: var(--forest-2); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.empty { color: var(--muted); font-style: italic; padding: 1.2rem 0; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

.pill-list { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.pill-list li { background: #efe8d7; border: 1px solid var(--line); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.8rem; }

.inline-form { display: inline; margin: 0; }
.line-edit { display: grid; grid-template-columns: minmax(160px, 2.2fr) 90px 110px 140px 120px auto; gap: 0.5rem; align-items: end; }
.line-edit .field { margin: 0; }
.line-edit label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; font-size: 0.9rem; margin: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 0.9rem 0.9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 0.35rem; width: 8px; height: 8px; border-radius: 50%; background: var(--forest-3); }
.timeline .when { font-size: 0.75rem; color: var(--muted); }

.proposal-total { background: var(--forest); color: #f6f1e4; border-radius: var(--radius); padding: 1rem 1.2rem; }
.proposal-total .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: #cdd9c8; }
.proposal-total .value { font-family: var(--font); font-size: 1.9rem; }

.exports { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.sample-note { border-left: 3px solid var(--gold); background: #faf3df; padding: 0.5rem 0.8rem; font-size: 0.82rem; color: #5c4a1a; border-radius: 0 8px 8px 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; padding: 1rem; }
  .nav { flex-direction: row; overflow-x: auto; padding-bottom: 0.3rem; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main { padding-top: 1.1rem; }
  .line-edit { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.print-only { display: none; }

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .sidebar, .no-print, .skip-link { display: none !important; }
  .main { padding: 0; }
  .card, .proposal-sheet { border: 0; box-shadow: none; padding: 0; margin: 0; }
  .print-only { display: block; }
  a { color: #000; text-decoration: none; }
  .print-header { display: flex; justify-content: space-between; border-bottom: 2px solid #123a2b; padding-bottom: 0.6rem; margin-bottom: 1rem; }
  .print-brand { font-family: var(--font); font-size: 16pt; color: #123a2b; }
  table { font-size: 10pt; }
  tr { break-inside: avoid; }
  .page-break { break-before: page; }
  .signature { margin-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
  .signature div { border-top: 1px solid #333; padding-top: 0.3rem; font-size: 9pt; }
  .signature .line { border-top: 1px solid #333; height: 2.2rem; margin-bottom: 0.3rem; }
  .signature .blank { border-top: none; height: 2.2rem; }
  @page { margin: 16mm; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
