:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17202a;
  --muted: #5d6b78;
  --line: #d9dee3;
  --accent: #1f6feb;
  --good: #1a7f37;
  --bad: #b42318;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --card: #17212b;
    --text: #e6edf3;
    --muted: #93a1ad;
    --line: #2a3742;
    --accent: #4c9aff;
    --good: #3fb950;
    --bad: #f85149;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.4 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

a {
  color: var(--accent);
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.org {
  font-weight: 600;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
}

.status.live {
  color: var(--good);
  border-color: var(--good);
}

.status.down {
  color: var(--bad);
  border-color: var(--bad);
}

main {
  max-width: 72rem;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  margin: 1rem;
}

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

button,
input,
select {
  font: inherit;
  padding: 0.4rem 0.7rem;
  border-radius: 0.4rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

button.on {
  border-color: var(--accent);
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.chip {
  border: 1px solid var(--line);
  border-left-width: 0.4rem;
  border-radius: 0.4rem;
  padding: 0.2rem 0.6rem;
}

.board {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.board th,
.board td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

.board th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

.board .num {
  text-align: right;
}

.board .types {
  color: var(--muted);
  font-size: 0.8rem;
}

.links {
  margin-bottom: 0;
}

#map {
  height: 26rem;
  border-radius: 0.5rem;
  overflow: hidden;
  margin: 0.5rem 0;
}

.lighting {
  display: flex;
  gap: 0.25rem;
}

.lighting .k-btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}

.worker-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.worker-dot.at-location {
  opacity: 0.55;
}

.chart-controls {
  justify-content: flex-start;
  gap: 1rem;
}

.loc-bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(31, 111, 235, 0.78);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 600 0.75rem/1 system-ui, sans-serif;
  cursor: pointer;
}

/* MapLibre's popups are white whatever the theme, so their charts are dark. */
.maplibregl-popup-content {
  color: #17202a;
}

.chart {
  font-size: 0.8rem;
  margin: 0.25rem 0 0.5rem;
}

.chart svg {
  display: block;
  margin-top: 0.35rem;
  overflow: visible;
}

.chart svg text {
  fill: currentColor;
  font-size: 11px;
}

.chart .spark {
  color: var(--accent);
}

.spark-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.area-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 0.75rem;
}

@media (max-width: 480px) {
  #map {
    height: 20rem;
  }
}

.invite {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.invite label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.invite .wide {
  flex: 1 1 100%;
}

.invite textarea {
  font: inherit;
  width: 100%;
  box-sizing: border-box;
}

.invites {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

.invites td,
.invites th {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.invites img {
  background: #fff;
  padding: 0.25rem;
  border-radius: 0.25rem;
}

.invites .link {
  word-break: break-all;
  font-size: 0.8rem;
}

.sheet {
  display: none;
}

@media print {
  body.printing-invites > :not(#invite-sheet) {
    display: none !important;
  }

  body.printing-invites {
    background: #fff;
    color: #000;
  }

  body.printing-invites .sheet {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5in;
  }

  .sheet .slip {
    break-inside: avoid;
    border: 1px dashed #888;
    padding: 0.25in;
    text-align: center;
    font-size: 11pt;
  }

  .sheet .slip img {
    width: 2.2in;
    height: 2.2in;
  }

  .sheet .slip .name {
    font-size: 14pt;
    font-weight: bold;
    margin: 0.1in 0 0;
  }

  .sheet .slip .link {
    word-break: break-all;
    font-size: 7pt;
    color: #444;
  }
}

@media (max-width: 40rem) {
  .board th:nth-child(6),
  .board td:nth-child(6),
  .board th:nth-child(7),
  .board td:nth-child(7) {
    display: none;
  }
}

h3 {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.file input {
  max-width: 14rem;
}

.loc-form {
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.loc-form .fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.5rem 1rem;
}

.loc-form .fields label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.loc-form .fields .wide {
  grid-column: 1 / -1;
}

.loc-form .search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: flex-end;
  margin-bottom: 0.75rem;
}

.loc-form .search label {
  display: flex;
  flex: 1 1 18rem;
  flex-direction: column;
  gap: 0.25rem;
}

.loc-form .search p,
.loc-form .search .results {
  flex-basis: 100%;
  margin: 0;
}

.results {
  padding-left: 1.25rem;
}

.results button {
  padding: 0.15rem 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.credit {
  font-size: 0.8rem;
}

.search-hit {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #f5a623;
  color: #000;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.workers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.bad {
  color: #ff6b6b;
}

.signin {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.signin label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 16rem;
}
