:root {
  --ink: #1c1915;
  --muted: #6f675e;
  --cream: #f4efe6;
  --paper: #fffdf9;
  --stone: #e4dcd0;
  --line: #d9d0c4;
  --green: #1e4a38;
  --green-2: #2d6a4f;
  --leaf: #e7f0ea;
  --gold: #a68456;
  --shadow: 0 18px 40px rgba(48, 36, 22, 0.06);
  --serif: "Fraunces", "Palatino Linotype", serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.5;
}

h1, h2, .brand-name, .gate-copy h1 {
  font-family: var(--serif);
  font-weight: 560;
  letter-spacing: -0.03em;
}

a { color: var(--green); }
a:hover { color: #143528; }

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #17281f;
  color: #f6f1e7;
  padding: 1.25rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  padding: 0.2rem 0.45rem;
}
.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.8rem;
  background: #c4a574;
  color: #1c1915;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 650;
}
.brand-name { display: block; font-size: 1.25rem; line-height: 1; }
.brand small { color: #c9c0b4; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.68rem; }

.nav-group { margin: 0.85rem 0 0.25rem; padding: 0 0.7rem; color: #b7c3bb; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; }
.side-link {
  display: block;
  color: #f4efe6;
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: 0.7rem;
}
.side-link:hover, .side-link.active { background: rgba(255, 253, 249, 0.1); color: white; }

.side-foot { margin-top: auto; padding-top: 1rem; }
.who { color: #d9d0c4; font-size: 0.92rem; margin-bottom: 0.6rem; }
.logout-btn, .btn-ink, .btn-quiet {
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
}
.logout-btn {
  background: transparent;
  color: #f6f1e7;
  border: 1px solid rgba(246, 241, 231, 0.35);
}
.menu-toggle { display: none; }

.workspace { padding: 1.5rem 1.6rem 2.5rem; max-width: 1180px; }
.page-kicker { color: var(--gold); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 0.2rem; }
.page-title { font-size: 2.15rem; margin: 0 0 0.35rem; }
.lede { color: var(--muted); max-width: 42rem; }

.card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  box-shadow: none;
}
.card-body { padding: 1.15rem 1.2rem; }
.table { --bs-table-bg: transparent; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; border-bottom-color: var(--line); }
.record-table tbody tr:hover { background: #faf7f2; }
.record-link { font-weight: 650; text-decoration: none; }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.78rem;
  background: var(--leaf);
  color: var(--green);
  margin-right: 0.25rem;
}
.chip-empty { background: #f1ece4; color: #6f675e; }
.chip-due { background: #f8efd8; color: #7a5b24; }
.chip-overdue { background: #f3e4d8; color: #7a4332; }
.chip-current { background: var(--leaf); color: var(--green); }
.chip-demo { background: #f3ead7; color: #6d542c; }

.btn, .btn-success, .btn-outline-success, .btn-primary {
  border-radius: 999px;
}
.btn-success, .btn-primary {
  background: var(--green);
  border-color: var(--green);
}
.btn-success:hover, .btn-primary:hover { background: #16382b; border-color: #16382b; }
.btn-outline-success { color: var(--green); border-color: #b7c9bf; }
.btn-outline-success:hover { background: var(--green); border-color: var(--green); color: white; }
.btn-quiet {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-quiet:hover { background: #f4efe6; color: var(--ink); }
.count-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0 1.25rem; }
.count-pill { background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; padding: 0.75rem 0.9rem; min-width: 9rem; }
.count-pill strong { display: block; font-family: var(--serif); font-size: 1.6rem; line-height: 1.1; }
.count-pill span { color: var(--muted); font-size: 0.88rem; }
.count-track { height: 6px; background: var(--stone); border-radius: 99px; margin-top: 0.45rem; overflow: hidden; }
.count-track span { display: block; height: 100%; background: var(--green); }
@media print {
  .sidebar, .menu-toggle, .side-foot, .no-print { display: none !important; }
  .app-shell { display: block; }
  .workspace { max-width: none; padding: 0; }
  body { background: white; }
}

.form-control, .form-select, textarea, input[type="text"], input[type="password"], input[type="file"], input[type="number"], input[type="date"] {
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: white;
  padding: 0.6rem 0.75rem;
}
.form-label, fieldset legend { font-weight: 650; }
.mb-3 { margin-bottom: 1rem; }
.form-text { color: var(--muted); }

.notice, .ethics, .disclaimer {
  background: #f7f3ea;
  border: 1px solid var(--line);
  color: #3f3830;
  border-radius: 0.9rem;
  padding: 0.8rem 0.95rem;
}
.alert { border: 0; border-radius: 0.9rem; }
.alert-warning { background: #f8efd8; color: #5c4520; }
.alert-info { background: #e7f0ea; color: #1e4a38; }
.alert-danger { background: #f6e6df; color: #6a3324; }
.alert-success { background: #e7f0ea; color: #1e4a38; }

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.home-card h2 { font-size: 1.45rem; margin: 0 0 0.4rem; }
.home-card p { color: var(--muted); }
.import-card { background: #1e4a38; color: #f6f1e7; border: 0; }
.import-card p, .import-card h2 { color: #f6f1e7; }
.import-card .btn { background: #f4efe6; color: #1c1915; border: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0.8rem 0 1rem; }

.gate-body { background: #efe8dc; }
.gate {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.gate-copy { padding: 8vh 8vw; }
.gate-copy h1 { font-size: clamp(2.6rem, 5vw, 4.4rem); line-height: 1.02; margin: 0.4rem 0 1rem; }
.gate-card {
  margin: auto;
  width: min(420px, 88%);
  background: var(--paper);
  border-radius: 1.4rem;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.gate-card input { width: 100%; margin-bottom: 0.8rem; }
.gate-card label { font-weight: 650; display: block; margin-bottom: 0.25rem; }
.eyebrow { letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); font-size: 0.75rem; }

.preview-table { font-size: 0.86rem; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem 1rem; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; padding: 1rem; }
  .sidebar.open { display: flex; }
  .menu-toggle { display: inline-flex; margin-bottom: 0.8rem; }
  .workspace { padding: 1rem; }
  .home-grid, .gate, .map-grid { grid-template-columns: 1fr; }
  .gate-copy { padding: 2.5rem 1.3rem 0.5rem; }
  .page-title { font-size: 1.8rem; }
}
