:root {
  --navy: #0c2340;
  --navy-2: #16345c;
  --ink: #142033;
  --muted: #5c6d80;
  --line: #d7e0ea;
  --paper: #f3f6f9;
  --white: #ffffff;
  --copper: #8d4518;
  --ok: #1c6b43;
  --ok-bg: #e5f4ec;
  --warn: #8a4b08;
  --warn-bg: #fbf1e2;
  --bad: #8d2d2d;
  --bad-bg: #fdecec;
  --shadow: 0 1px 2px rgba(12, 35, 64, 0.05), 0 10px 28px rgba(12, 35, 64, 0.05);
  --radius: 16px;
  --tap: 48px;
  --sidebar: 248px;
  color-scheme: light;
  font-family: "Liberation Sans", "Nimbus Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); }
a { color: var(--navy); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.03em; line-height: 1.15; }
h2 { font-size: 1.05rem; letter-spacing: -0.02em; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--white);
  padding: 8px 12px;
  z-index: 30;
}
.skip:focus { top: 12px; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  flex: none;
  background: var(--navy);
  color: #e7eef6;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 18px; }
.brand svg { width: 42px; height: 42px; flex: none; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1rem; letter-spacing: -0.02em; }
.brand span { color: #b7c6d8; font-size: 0.82rem; }
.brand svg path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linejoin: round; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: #e7eef6;
  text-decoration: none;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 12px;
}
.sidebar nav a[aria-current="page"], .sidebar nav a:hover { background: rgba(255, 255, 255, 0.1); }
.signout { margin-top: auto; padding: 12px 8px 0; }
.signout p { color: #b7c6d8; font-size: 0.85rem; margin-bottom: 8px; }
.signout button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  min-height: 44px;
  width: 100%;
  cursor: pointer;
}
.scrim { display: none; }
.main-wrap { flex: 1; min-width: 0; padding: 22px 28px 48px; }
.topbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.menu-btn { display: none; }
.search { display: flex; gap: 8px; flex: 1; }
.search input, .field input, .field select, .field textarea, .deal select, td select {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: var(--tap);
  padding: 10px 12px;
}
.search button, .button, .text-button {
  border: 0;
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.search button, .button { background: var(--navy); color: white; font-weight: 650; }
.button.secondary { background: var(--white); color: var(--navy); border: 1px solid var(--line); }
.button.danger { background: var(--bad); }
.button.wide { width: 100%; }
.text-button { background: transparent; color: var(--bad); min-height: 36px; padding: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid #c9d7ea;
  outline-offset: 1px;
}
textarea { min-height: 110px; resize: vertical; }

.page-head, .section-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 16px; }
.page-head { align-items: flex-start; }
.page-actions, .view-toggle { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sub, .muted, .hint, .field small { color: var(--muted); }
.sub { margin-top: 6px; }
.hint { margin: 0 0 12px; }
.card, .empty, .callout, .stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card, .empty, .callout { padding: 18px; }
.card h2, .section-head h2 { margin-bottom: 0; }
.card > h2 { margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.split { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; margin: 16px 0; }
.split.tight { grid-template-columns: 1fr 1fr; margin: 0; }
.grid-2, .grid-3, .grid-activity { display: grid; gap: 12px; }
.grid-2, .grid-activity { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1.2fr 0.6fr 0.7fr; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 650; }
.field span { font-size: 0.92rem; }
.field small { font-weight: 450; }
.save-row { display: flex; justify-content: flex-end; }
.check { display: flex; gap: 10px; align-items: center; min-height: var(--tap); }
.danger-zone { border-color: #f0d0d0; }
.quiet p, .callout p, .timeline p { white-space: pre-wrap; margin-top: 8px; }
.callout { background: #f7f1ea; border-color: #ead9c8; }
.callout h2 { color: var(--copper); }

.example-banner, .flash {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.example-banner { background: #fff6df; border: 1px solid #ead7a2; color: #6a4b10; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }
.flash ul { margin: 0; padding-left: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; min-height: 112px; }
.stat span { color: var(--muted); font-size: 0.92rem; }
.stat strong { font-size: 1.7rem; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.stat em { font-style: normal; color: var(--muted); }
.stat.bad strong { color: var(--bad); }
.bars { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; }
.bar-label { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 0.95rem; }
.bar { height: 10px; background: #e7eef5; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--navy); }
.bar > span.w-5 { width: 5%; } .bar > span.w-10 { width: 10%; } .bar > span.w-15 { width: 15%; } .bar > span.w-20 { width: 20%; }
.bar > span.w-25 { width: 25%; } .bar > span.w-30 { width: 30%; } .bar > span.w-35 { width: 35%; } .bar > span.w-40 { width: 40%; }
.bar > span.w-45 { width: 45%; } .bar > span.w-50 { width: 50%; } .bar > span.w-55 { width: 55%; } .bar > span.w-60 { width: 60%; }
.bar > span.w-65 { width: 65%; } .bar > span.w-70 { width: 70%; } .bar > span.w-75 { width: 75%; } .bar > span.w-80 { width: 80%; }
.bar > span.w-85 { width: 85%; } .bar > span.w-90 { width: 90%; } .bar > span.w-95 { width: 95%; } .bar > span.w-100 { width: 100%; }
.bar[data-stage="won"] span { background: var(--ok); }
.bar[data-stage="lost"] span { background: #9aa8b8; }
.rows { display: flex; flex-direction: column; }
.row-link, .related a {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  min-height: 64px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.row-link > span:first-child { flex: 1; min-width: 0; }
.row-link small { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.section-head a, .bar-label a, .deal > a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.deal > a { display: flex; align-items: flex-start; padding-top: 8px; }
.check input { width: 22px; height: 22px; accent-color: var(--navy); }
.row-link strong, .related strong, .deal strong { display: block; }
.row-link small, .related span, .deal p { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.related { list-style: none; padding: 0; margin: 0; }
.related li + li a { border-top: 1px solid var(--line); }
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e7eef5;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill.bad, .due.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn, .due.warn { background: var(--warn-bg); color: var(--warn); }
.due { font-size: 0.85rem; }

.view-toggle a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 12px;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--white);
}
.view-toggle a[aria-current="page"] { background: var(--navy); color: white; border-color: var(--navy); }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
@media (min-width: 1100px) {
  .board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; }
  .column { min-width: 0; scroll-snap-align: none; }
  .column[data-stage="won"], .column[data-stage="lost"] { grid-column: span 2; }
}
.column {
  flex: 0 0 270px;
  scroll-snap-align: start;
  background: #e8eef4;
  border-radius: 16px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}
.column header { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 8px; }
.column header span { color: var(--muted); font-variant-numeric: tabular-nums; }
.column-body { display: flex; flex-direction: column; gap: 8px; padding: 0 8px 8px; }
.column.drop { outline: 2px solid var(--navy); }
.deal {
  background: var(--white);
  border-radius: 14px;
  padding: 12px;
  border-top: 4px solid var(--navy);
  box-shadow: var(--shadow);
  cursor: grab;
}
.column[data-stage="contacted"] .deal { border-top-color: #24598a; }
.column[data-stage="inspection_scheduled"] .deal { border-top-color: #8a5a12; }
.column[data-stage="proposal_sent"] .deal { border-top-color: var(--copper); }
.column[data-stage="won"] .deal { border-top-color: var(--ok); }
.column[data-stage="lost"] .deal { border-top-color: #8d97a3; }
.deal a { text-decoration: none; color: inherit; }
.deal p { margin: 4px 0 8px; font-size: 0.92rem; }
.deal-meta { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.deal.dragging { opacity: 0.45; }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.facts div { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.facts span { display: block; color: var(--muted); font-size: 0.85rem; }
.facts strong { font-size: 1.15rem; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.photos figure { margin: 0; }
.photos img { width: 100%; height: 140px; object-fit: cover; border-radius: 12px; background: #e7eef5; }
.photos figcaption { margin-top: 6px; color: var(--muted); font-size: 0.9rem; }
.timeline { list-style: none; padding: 0; margin: 0 0 16px; }
.timeline li { padding: 10px 0; border-top: 1px solid var(--line); }
.timeline div { display: flex; justify-content: space-between; gap: 8px; }
.timeline time { color: var(--muted); font-size: 0.85rem; }
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.82rem; color: var(--muted); font-weight: 700; }
td select { min-height: 44px; }
.empty { text-align: left; }
.empty h2 { margin-bottom: 6px; }
.empty p { margin-bottom: 14px; color: var(--muted); }
.code, pre.code {
  font-family: ui-monospace, "Liberation Mono", monospace;
  font-size: 0.86rem;
  background: #f4f7fa;
  border-radius: 10px;
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.export-list { padding-left: 18px; }
.export-list a { display: inline-flex; min-height: 36px; align-items: center; }
.contact-lines { margin-top: 12px; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--navy);
  padding: 24px;
}
.login-card {
  width: min(440px, 100%);
  background: var(--white);
  border-radius: 20px;
  padding: 28px;
}
.login-card h1 { margin: 8px 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.brand.light svg path { stroke: var(--navy); }

@media (max-width: 980px) {
  .stats, .facts { grid-template-columns: 1fr 1fr; }
  .split, .split.tight, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    min-width: 84px;
    padding: 0 14px;
    border-radius: 12px;
    background: var(--navy);
    color: white;
    font-weight: 700;
  }
  .sidebar { display: none; }
  .nav-toggle:checked ~ .app .sidebar {
    display: flex;
    position: fixed;
    z-index: 25;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    height: 100vh;
  }
  .nav-toggle:checked ~ .app .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 18, 32, 0.45);
    z-index: 20;
  }
  .main-wrap { padding: 14px 14px 36px; }
  .topbar { flex-wrap: wrap; }
  .search { width: 100%; flex-basis: 100%; }
  .page-head, .section-head { flex-direction: column; align-items: stretch; }
  .page-actions .button, .save-row .button, .card .button { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-activity { grid-template-columns: 1fr; }
  .column { flex-basis: 85vw; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 8px 0; border-bottom: 8px solid var(--paper); }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 8px 14px; }
  table.stack td::before { content: attr(data-label); color: var(--muted); }
  .table-wrap { background: transparent; border: 0; }
}
@media (max-width: 560px) {
  .stats, .facts { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .scrim, .menu-btn, .signout { display: none !important; }
  .main-wrap { padding: 0; }
}
