:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #5c677d;
  --accent: #0b6e4f;
  --warn: #9c2f00;
  --ok: #0a8f3d;
  --line: #d8dde7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(160deg, #f2f7ff 0%, var(--bg) 40%, #eef6ef 100%);
  color: var(--ink);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  background: #0f172a;
  color: #fff;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand { font-weight: 700; letter-spacing: 0.4px; }
.nav { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.nav a { color: #dbeafe; text-decoration: none; }
.nav a:hover { color: #fff; }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #f8fafc;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
}

.page { max-width: 1200px; margin: 1rem auto 2rem; padding: 0 1rem; }

.site-footer {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border-top: 1px solid #d8dde7;
  background: #f8fafc;
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  color: #475569;
  font-size: 0.82rem;
  text-align: center;
}

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

h1, h2, h3 { margin: 0.2rem 0 0.8rem; }
.small { color: var(--muted); font-size: 0.92rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 0.8rem; }
button, .btn {
  border: 0;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.secondary, .btn.secondary { background: #334155; }
button.warn { background: var(--warn); }

label { display: block; font-size: 0.92rem; margin-bottom: 0.2rem; }
input, select, textarea {
  width: 100%;
  padding: 0.58rem 0.68rem;
  border-radius: 8px;
  border: 1px solid #c8d0df;
  background: #fff;
}
textarea { min-height: 86px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.7rem; margin-bottom: 0.7rem; }
.status { font-size: 0.95rem; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; background: #fff; }
th, td { border: 1px solid var(--line); padding: 0.48rem; text-align: left; font-size: 0.9rem; }
th { background: #f3f6fb; }

@keyframes recentRowHighlightFade {
  0% {
    background-color: #fff2b8;
  }
  100% {
    background-color: transparent;
  }
}

.recent-row-new td {
  animation: recentRowHighlightFade 1.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .recent-row-new td {
    animation: none;
    background-color: #fff2b8;
  }
}

.section-collapse {
  border: 1px solid #cfd8ea;
  border-radius: 10px;
  margin-top: 0.6rem;
  background: #ffffff;
  overflow: hidden;
}

.section-collapse > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  padding: 0.62rem 0.72rem;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.25;
  background: #eef2ff;
  color: #0f172a;
}

.section-collapse > summary::-webkit-details-marker {
  display: none;
}

.section-collapse > summary::before {
  content: '+ ';
  font-weight: 800;
}

.section-collapse[open] > summary::before {
  content: '- ';
}

.section-collapse-body {
  padding: 0.35rem 0.5rem 0.5rem;
}

.section-collapse-body table {
  margin-top: 0.25rem;
}

.pair-chart {
  display: grid;
  gap: 0.55rem;
}

.pair-bar-row {
  display: grid;
  gap: 0.2rem;
}

.pair-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.pair-route {
  font-size: 0.92rem;
  font-weight: 700;
}

.pair-count {
  min-width: 2ch;
  text-align: right;
  font-weight: 800;
  color: #0f172a;
}

.pair-bar-track {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
}

.pair-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0b6e4f 0%, #22c55e 100%);
}

.kpi { font-size: 1.4rem; font-weight: 800; }
.kpi-label { font-size: 0.86rem; color: var(--muted); }

.hero {
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid #bfdbfe;
  background: linear-gradient(120deg, #dbeafe 0%, #ecfeff 45%, #dcfce7 100%);
}

img.site-preview {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

code.inline {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 0.1rem 0.25rem;
}

.choice-block {
  margin-bottom: 0.8rem;
}

.choice-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.radio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
}

.radio-grid.two-col {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  max-width: 320px;
}

.radio-chip {
  display: block;
}

.radio-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-chip > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.5rem 0.7rem;
  border: 1px solid #c8d0df;
  border-radius: 10px;
  background: #fff;
  font-weight: 600;
  text-align: center;
}

.radio-chip input:checked + span {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.entry-compact .small {
  margin-bottom: 0.45rem;
}

.entry-compact .form-row {
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.entry-compact .choice-block {
  margin-bottom: 0.55rem;
}

.entry-compact .choice-title {
  margin-bottom: 0.2rem;
}

.entry-meta-toggle {
  margin-top: 0.65rem;
  margin-bottom: 0.35rem;
}

.entry-meta-toggle .secondary {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.entry-meta-panel {
  margin-bottom: 0;
}

.notes-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.notes-toggle-row .secondary {
  padding: 0.32rem 0.62rem;
  font-size: 0.75rem;
}

.inline-radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.inline-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.inline-radio input {
  width: auto;
  margin: 0;
}

.direction-chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  max-width: 420px;
}

.direction-chip > span {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  border-width: 2px;
  border-color: #cbd5e1;
  background: #ffffff;
}

.direction-chip .direction-icon {
  display: block;
  font-size: 1.5rem;
  line-height: 1;
}

.direction-chip .direction-icon .direction-icon-img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.direction-chip .direction-name {
  display: block;
  font-size: 0.48rem;
  font-weight: 800;
  line-height: 1.05;
}

.direction-chip input:checked + span {
  border-color: #000000;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
  background: #ecfdf5;
  color: #0f172a;
}

.vehicle-type-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.vehicle-type-chip > span {
  min-height: 84px;
  display: block;
  position: relative;
  overflow: hidden;
  padding: 0.2rem;
  border-width: 2px;
  border-color: #cbd5e1;
  background: #ffffff;
}

.vehicle-type-chip .vehicle-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.45rem;
  line-height: 1;
  transform: translateY(-3px);
  pointer-events: none;
}

.vehicle-type-chip .vehicle-name {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  display: block;
  font-size: 0.44rem;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
  color: #0f172a;
  padding: 0.12rem 0.18rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.74);
  text-shadow: none;
  pointer-events: none;
}

.vehicle-type-chip input:checked + span {
  border-color: #000000;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25);
  background: #ecfdf5;
  color: #0f172a;
}

.color-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 0.45rem;
}

.radio-chip.color-chip span {
  min-height: 52px;
  border-width: 2px;
  border-color: #94a3b8;
  font-weight: 700;
  font-size: 0.48rem;
  line-height: 1.05;
  text-shadow: 0 1px 1px rgba(15, 23, 42, 0.2);
}

.radio-chip.color-chip input:checked + span {
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.2);
  border-color: #0f172a;
}

.radio-chip.color-chip.color-white span {
  background: linear-gradient(160deg, #ffffff 0%, #f3f4f6 100%);
  color: #0f172a;
  text-shadow: none;
}

.radio-chip.color-chip.color-black-blue span {
  background: linear-gradient(135deg, #111827 0%, #1e40af 100%);
  color: #ffffff;
}

.radio-chip.color-chip.color-gray-silver span {
  background: linear-gradient(160deg, #e5e7eb 0%, #9ca3af 100%);
  color: #111827;
  text-shadow: none;
}

.radio-chip.color-chip.color-red span {
  background: linear-gradient(160deg, #b91c1c 0%, #ef4444 100%);
  color: #ffffff;
}

.radio-chip.color-chip.color-green span {
  background: linear-gradient(160deg, #166534 0%, #22c55e 100%);
  color: #ffffff;
}

.radio-chip.color-chip.color-other span {
  background: repeating-linear-gradient(135deg, #e2e8f0, #e2e8f0 8px, #cbd5e1 8px, #cbd5e1 16px);
  color: #111827;
  text-shadow: none;
}

.entry-compact textarea {
  min-height: 72px;
}

.site-map-panel {
  margin-top: 0.4rem;
}

@media (max-width: 700px) {
  .site-map-panel {
    display: none;
  }

  .site-map-panel.open {
    display: block;
  }
}

@media (max-width: 430px) {
  .direction-chip-grid {
    max-width: none;
    gap: 0.28rem;
  }

  .direction-chip > span {
    min-height: 56px;
    padding: 0.24rem 0.3rem;
    gap: 0.08rem;
  }

  .direction-chip .direction-icon .direction-icon-img {
    width: 18px;
    height: 18px;
  }

  .direction-chip .direction-name {
    font-size: 0.42rem;
  }

  .vehicle-type-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.28rem;
  }

  .vehicle-type-chip > span {
    min-height: 60px;
    padding: 0.1rem;
  }

  .vehicle-type-chip .vehicle-icon {
    font-size: 1.7rem;
    transform: translateY(-2px);
  }

  .vehicle-type-chip .vehicle-name {
    left: 3px;
    right: 3px;
    bottom: 3px;
    font-size: 0.34rem;
    line-height: 1.1;
    padding: 0.05rem 0.09rem;
  }

  .color-chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .radio-chip.color-chip span {
    min-height: 36px;
    padding: 0.35rem 0.45rem;
    font-size: 0.42rem;
    line-height: 1.05;
  }
}

@media (max-width: 390px) {
  .page {
    padding: 0 0.55rem;
  }

  .topbar {
    padding: 0.7rem 0.75rem;
  }

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

  .inline-radio-group {
    gap: 0.25rem 0.7rem;
  }

  .vehicle-type-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .color-chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  /* iOS Safari auto-zooms focused form controls when text is below 16px. */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }

  .topbar-row {
    width: 100%;
  }

  .brand {
    font-size: 0.98rem;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav {
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    width: 100%;
    padding: 0.2rem 0;
  }

  .topbar.nav-open .nav {
    display: flex;
  }

  .nav a {
    display: block;
    width: 100%;
    padding: 0.5rem 0.55rem;
    border-radius: 8px;
    background: #1e293b;
  }
}
