:root {
  --yellow: #ffd923;
  --yellow-dark: #d9b400;
  --ink: #111;
  --blue: #0645ad;
  --border: #a8a8a8;
  --soft-border: #d5d5d5;
  --shade: #f2f2f2;
  --panel: #fff;
  --good: #2c6e49;
  --bad: #9d1f1f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid #777;
  background: linear-gradient(#fff, #e9e9e9);
  color: #111;
  cursor: pointer;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 2px;
}

button:hover,
button:focus-visible {
  border-color: #111;
  outline: none;
}

button.primary {
  background: linear-gradient(#ffe45c, #f4ca18);
  border-color: #806900;
  font-weight: bold;
}

button.link-button {
  background: transparent;
  border: 0;
  color: #111;
  text-decoration: underline;
  padding: 2px 6px;
  min-height: auto;
}

button.small-button {
  min-height: 24px;
  padding: 2px 8px;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  background: var(--yellow);
  border-bottom: 2px solid #111;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px 6px;
}

.brand {
  color: #111;
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 0;
}

.brand:hover {
  text-decoration: none;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.main-nav {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--yellow-dark);
  padding-left: 12px;
}

.main-nav a {
  color: #111;
  font-weight: bold;
  padding: 6px 12px;
  border-right: 1px solid var(--yellow-dark);
}

.main-nav a:first-child {
  border-left: 1px solid var(--yellow-dark);
}

.shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px 16px 32px;
}

.side-index {
  border: 1px solid var(--border);
  background: #fafafa;
  position: sticky;
  top: 92px;
}

.side-index h2 {
  margin: 0;
  padding: 7px 10px;
  background: var(--shade);
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.side-index a {
  display: block;
  padding: 7px 10px;
  border-bottom: 1px solid #e1e1e1;
}

.side-filter {
  padding: 8px 10px;
  border-top: 1px solid #e1e1e1;
}

main {
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--shade);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

h1,
h2,
legend {
  letter-spacing: 0;
}

h1 {
  font-size: 18px;
  margin: 0;
}

h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.status-pill {
  color: var(--good);
  font-weight: bold;
}

form {
  padding: 10px;
}

fieldset {
  border: 1px solid var(--soft-border);
  margin: 0 0 10px;
  padding: 10px;
}

legend {
  font-weight: bold;
  padding: 0 5px;
}

label {
  display: grid;
  gap: 3px;
  font-weight: bold;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #8a8a8a;
  border-radius: 0;
  padding: 4px 5px;
  min-height: 28px;
  background: #fff;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #7ea4d8;
  outline-offset: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 9px 12px;
}

.activity-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 6px;
}

.activity-option {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 5px 7px;
  text-align: left;
}

.activity-option[aria-pressed="true"] {
  background: #fff6bf;
  border-color: #806900;
  box-shadow: inset 0 0 0 1px #806900;
  font-weight: bold;
}

.activity-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  color: #2f4c5f;
}

.activity-icon svg {
  display: block;
  width: 28px;
  height: 28px;
}

.activity-icon--dual-gfa,
.activity-icon--dual-navigation {
  color: #2f6f9f;
}

.activity-icon--circuits,
.activity-icon--solo-circuits {
  color: #8a5a19;
}

.activity-icon--solo-gfa,
.activity-icon--solo-navigation {
  color: #5f7f30;
}

.activity-icon--solo-hour-building {
  color: #8b3f63;
}

.nav-row,
.form-actions,
.data-actions,
.record-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.record-tools label {
  min-width: 150px;
}

.check-line {
  display: inline-flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
  font-weight: bold;
  width: auto;
}

.check-line input {
  width: auto;
  min-height: auto;
}

.route-total {
  padding: 3px 8px;
  background: #f8f8f8;
  border: 1px solid var(--soft-border);
}

.lookup-status {
  color: #555;
  font-weight: bold;
  min-height: 24px;
  padding: 3px 0;
}

.route-editor {
  margin-top: 10px;
  border: 1px solid var(--soft-border);
}

.waypoint-head,
.waypoint-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(100px, 1fr) minmax(100px, 1fr) 76px;
  gap: 6px;
  align-items: center;
}

.waypoint-head {
  background: #f6f6f6;
  border-bottom: 1px solid var(--soft-border);
  font-weight: bold;
  padding: 5px;
}

.waypoint-row {
  padding: 5px;
  border-bottom: 1px solid #ececec;
}

.waypoint-row.lookup-found input {
  border-color: #5f7f30;
}

.waypoint-row.lookup-missing input:first-child {
  border-color: var(--bad);
}

.waypoint-row:last-child {
  border-bottom: 0;
}

.waypoint-row button {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border: 1px solid var(--soft-border);
  padding: 5px 6px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6f6f6;
  white-space: nowrap;
}

th[data-sort] {
  color: var(--blue);
  cursor: pointer;
}

tbody tr:nth-child(even) {
  background: #fbfbfb;
}

.table-action {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  min-height: auto;
  text-decoration: underline;
}

.action-group {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.record-activity {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 130px;
  color: #111;
}

.record-activity .activity-icon {
  width: 24px;
  height: 24px;
}

.record-activity .activity-icon svg {
  width: 24px;
  height: 24px;
}

.record-activity span:last-child {
  white-space: nowrap;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: #666;
}

.empty-state {
  color: #555;
  text-align: center;
  padding: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--soft-border);
}

.stat-box {
  border: 1px solid var(--soft-border);
  background: #fbfbfb;
  padding: 8px;
}

.stat-box span {
  display: block;
  font-weight: bold;
  color: #444;
  margin-bottom: 2px;
}

.stat-box strong {
  display: block;
  font-size: 22px;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  padding: 10px;
}

.chart-panel {
  border: 1px solid var(--soft-border);
  padding: 8px;
  min-width: 0;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.narrow {
  padding: 0 10px 10px;
}

.data-actions {
  padding: 10px;
}

.data-actions label {
  min-width: 150px;
}

.danger {
  color: var(--bad);
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .side-index {
    position: static;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .side-index h2 {
    grid-column: 1 / -1;
  }

  .side-filter {
    grid-column: span 2;
  }

  .form-grid,
  .chart-grid,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .brand-row,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .main-nav {
    overflow-x: auto;
    padding-left: 0;
  }

  .main-nav a {
    flex: 0 0 auto;
  }

  .side-index,
  .form-grid,
  .activity-picker,
  .chart-grid,
  .stats-grid,
  .waypoint-head,
  .waypoint-row {
    grid-template-columns: 1fr;
  }

  .waypoint-head span:last-child {
    display: none;
  }

  .record-tools label,
  .data-actions label {
    min-width: 100%;
  }

  .nav-row > *,
  .form-actions > *,
  .data-actions > * {
    width: 100%;
  }

  .check-line {
    width: 100%;
  }

  button.small-button {
    min-height: 32px;
  }

  .table-wrap {
    margin: 0 -1px;
  }
}

@media print {
  .site-header,
  .side-index,
  .form-actions,
  .data-actions,
  .record-tools,
  .action-group {
    display: none !important;
  }

  .shell {
    display: block;
    padding: 0;
  }

  .panel {
    border: 0;
  }
}
