:root {
  --ink: #1b242c;
  --muted: #5d6b76;
  --paper: #efe7db;
  --card: #fffdf8;
  --line: #e3d9cb;
  --rail: #172229;
  --rail-text: #e7efe9;
  --teal: #0e6e68;
  --teal-deep: #0a4e4a;
  --amber: #a15c12;
  --good: #1f7a45;
  --bad: #9c3b32;
  --shadow: 0 12px 30px rgba(36, 28, 18, 0.06);
  color-scheme: light;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal-deep); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail {
  background: var(--rail);
  color: var(--rail-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(160deg, #1aa399, #0e6e68);
}
.brand strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand span { display: block; color: #9fb0aa; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  color: var(--rail-text);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 8px;
}
.nav a[aria-current="page"], .nav a:hover { background: rgba(255, 255, 255, 0.08); }
.who { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.who strong { display: block; }
.who span, .muted { color: var(--muted); }
.who span { color: #9fb0aa; font-size: 13px; }
.who button, .ghost, .text-button {
  background: transparent;
  border: 0;
  color: #d5e4df;
  padding: 6px 0;
}
.main { padding: 28px 32px 64px; max-width: 1180px; }
.top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; }
h1 { font-size: 32px; line-height: 1.1; margin: 0; font-weight: 650; letter-spacing: -0.03em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lede { margin: 6px 0 0; color: var(--muted); max-width: 62ch; }

.filters, .row, .actions, .chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card, .stat, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.stats { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin: 16px 0 22px; }
.stat { padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.panel { padding: 14px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.item, .board-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  display: block;
}
.item:hover, .board-card:hover { border-color: #c9bba6; }
.item small, .board-card small { color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 16px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: #f7f1e8; }
tr:last-child td { border-bottom: 0; }
.click td { cursor: pointer; }
.click:hover td { background: #fbf7f1; }

.pill, .chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  background: #efe6da;
}
.stage-new { background: #e5f3f2; color: var(--teal-deep); }
.stage-working, .stage-replied { background: #e7eef8; color: #23486e; }
.stage-meeting, .stage-proposal { background: #f8efd8; color: #7a4e10; }
.stage-won { background: #e5f5ea; color: var(--good); }
.stage-passed, .stage-not_a_fit { background: #f6e7e4; color: var(--bad); }
.product-tmc { background: #e7eef8; }
.product-portobserver { background: #e5f3f2; }
.product-baytracker { background: #f8efd8; }
.territory-amy { box-shadow: inset 3px 0 0 #2f7d4a; }
.territory-clem { box-shadow: inset 3px 0 0 #2a5f8a; }
.territory-josh { box-shadow: inset 3px 0 0 #b86a1a; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: #fff;
  border: 1px solid #d9d0c3;
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
textarea { min-height: 88px; width: 100%; }
.primary, .secondary {
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid transparent;
}
.primary { background: var(--teal); color: white; }
.primary:hover { background: var(--teal-deep); }
.secondary { background: #fff; border-color: #d9d0c3; }
.layout { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 16px; }
.section { margin-top: 16px; }
.message { min-height: 1.2em; margin: 8px 0; }
.message.error { color: var(--bad); }
.message.ok { color: var(--good); }
.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #172229;
  color: #e7efe9;
  padding: 12px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login h1 { margin-bottom: 8px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 10px; overflow-x: auto; }
.board h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.badge-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.badge-card img { width: 100%; height: 180px; object-fit: cover; background: #e7dfd2; display: block; }
.badge-card div { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.capture input[type="file"] { padding: 16px; background: #fff; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { padding: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .who { margin-top: 0; border-top: 0; }
  .stats, .columns, .layout { grid-template-columns: 1fr; }
  .main { padding: 18px 14px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
