:root {
  --bg: #050505;
  --panel: #121214;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f2ed;
  --muted: #b8b8bd;
  --red: #ff2a1f;
  --green: #36d657;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.topbar,
main {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 14px;
}

h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.admin-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 12px 0;
  padding: 8px 0;
  background: linear-gradient(180deg, var(--bg) 72%, rgba(5, 5, 5, 0));
}

.admin-tabs a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #1b1b1f;
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  text-decoration: none;
  text-transform: uppercase;
}

.stats article,
.stat-grid article,
.panel,
.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats article,
.stat-grid article {
  padding: 14px;
}

.stats article.is-alert {
  border-color: rgba(255, 42, 31, 0.75);
  background: #271010;
}

.stats span,
.stat-grid span,
td,
th {
  color: var(--muted);
}

.stats strong,
.stat-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 30px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.panel {
  margin: 12px 0;
  padding: 14px;
}

.accordion {
  padding: 0;
}

.accordion > *:not(summary) {
  margin: 0 14px 14px;
}

.accordion summary {
  cursor: pointer;
  list-style: none;
  margin: 0;
  padding: 14px;
}

.accordion summary::-webkit-details-marker {
  display: none;
}

.accordion summary::after {
  content: '+';
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.accordion[open] summary::after {
  content: '−';
}

.panel-count {
  align-self: center;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.alert-panel {
  border-color: rgba(255, 42, 31, 0.65);
}

.watch-list {
  display: grid;
  gap: 8px;
}

.watch-list article {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(255, 42, 31, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 42, 31, 0.09);
}

.watch-list span {
  color: var(--muted);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

summary.panel-head {
  margin-bottom: 0;
}

details[open] > summary.panel-head {
  margin-bottom: 12px;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.status-line.is-ok {
  border-color: rgba(54, 214, 87, 0.45);
  color: var(--green);
}

.status-line.is-warning {
  border-color: rgba(245, 165, 36, 0.55);
  color: #ffd38b;
}

.status-line a {
  margin-left: auto;
  color: #fff;
  font-weight: 800;
}

#map {
  position: relative;
  display: grid;
  place-items: center;
  height: 440px;
  border-radius: 8px;
  overflow: hidden;
  background: #0b120d;
}

.map-loading {
  color: var(--muted);
  font-weight: 800;
}

.loop-key {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.loop-key span,
.route-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid color-mix(in srgb, var(--loop-color, var(--route-color)) 65%, transparent);
  border-left: 7px solid var(--loop-color, var(--route-color));
  border-radius: 8px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.06);
}

.loop-key b,
.route-pill {
  color: #fff;
  font-weight: 900;
}

.loop-key small,
.route-loops {
  color: var(--muted);
  font-size: 12px;
}

.route-loops {
  display: block;
  margin-top: 5px;
}

.notify-form {
  display: grid;
  gap: 10px;
}

input,
textarea,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #1b1b1f;
  color: var(--text);
  font: inherit;
}

button {
  border-color: var(--red);
  background: var(--red);
  font-weight: 900;
  text-transform: uppercase;
}

input[type='checkbox'] {
  min-height: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.danger-button {
  margin-top: 12px;
  background: #3a1010;
  border-color: rgba(255, 42, 31, 0.75);
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.bulk-actions label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 800;
}

.bulk-actions .danger-button {
  margin-top: 0;
}

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

.compact-table {
  margin-top: 4px;
}

.day-stats {
  margin-top: 18px;
}

.section-title,
.date-form {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin-bottom: 8px;
}

.section-title h3 {
  margin: 0;
  font-size: 20px;
}

.date-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.date-form input {
  min-width: 150px;
}

.date-form button {
  min-height: 42px;
}

.help-text {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

th,
td {
  border-top: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  white-space: nowrap;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.gallery article {
  display: grid;
  gap: 6px;
}

.gallery label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.gallery a {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.gallery img {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  object-fit: cover;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-card {
  width: min(420px, calc(100% - 28px));
  padding: 22px;
}

.login-card form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.error {
  margin-top: 12px;
  color: var(--red);
}

.notice {
  margin: 10px 0;
  color: var(--green);
}

@media (max-width: 720px) {
  .topbar {
    gap: 12px;
  }

  .topbar h1 {
    font-size: 28px;
  }

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

  .stats strong,
  .stat-grid strong {
    font-size: 24px;
  }

  .panel-head h2 {
    font-size: 19px;
  }

  .panel-count {
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #map {
    height: 360px;
  }

  .bulk-actions {
    align-items: stretch;
  }

  .section-title,
  .date-form {
    align-items: stretch;
    flex-direction: column;
  }

  .bulk-actions label,
  .bulk-actions button,
  .date-form button,
  .date-form input {
    width: 100%;
  }
}
