:root {
  --bg: #ffffff;
  --panel-bg: #ffffff;
  --text: #1a1a1a;
  --border: #ddd;
  --link: #005148;
  --brand: #005148;
  --brand-contrast: #ffffff;
  --error: #b00020;
  --green: #2ecc71;
  --orange: #f39c12;
  --red: #e74c3c;
  --neutral: #7f8c8d;
}

[data-theme='dark'] {
  --bg: #121212;
  --panel-bg: #1e1e1e;
  --text: #e6e6e6;
  --border: #3a3a3a;
  --link: #4fd1b3;
  --brand: #4fd1b3;
  --brand-contrast: #0a0a0a;
  --error: #ff6b6b;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

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

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  flex-wrap: wrap;
}

header nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

main {
  padding: 1rem;
}

body:has(#map) {
  display: flex;
  flex-direction: column;
}

body:has(#map) main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  display: flex;
  flex-direction: row;
}

#map {
  flex: 1 1 auto;
  min-height: 0;
}

#lookup-panel {
  flex: 0 0 var(--panel-w, 353px);
  box-sizing: border-box;
  min-width: 0;
  padding: 1rem;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
}

#lookup-panel form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#lookup-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.field-hint {
  margin: -0.4rem 0 0;
  font-size: 0.8rem;
  color: var(--neutral, #7f8c8d);
}

#lookup-result {
  margin-top: 1rem;
  font-size: 0.9rem;
}

#lookup-result .no-coverage {
  color: var(--error);
}

#lookup-result dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
}

#lookup-result dt {
  font-weight: bold;
}

#lookup-result dd {
  margin: 0;
}

.cell-popup {
  font-size: 0.85rem;
}

/* Plan 06 E4 (2026-09-10) - the lookup result panel's "what if I add more
   subscribers" projection table, collapsed by default via <details>. */
.what-if-details {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.what-if-details summary {
  cursor: pointer;
  font-weight: bold;
}

.what-if-table {
  width: 100%;
  margin-top: 0.4rem;
  border-collapse: collapse;
}

.what-if-table th,
.what-if-table td {
  text-align: left;
  padding: 0.2rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.site-label {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  opacity: 0.9;
  pointer-events: none;
  /* The marker's own lat/lon is already offset into a gap between the
     site's sectors (see widestGapBearing in map.js) - just center the
     label box on that point. */
  transform: translate(-50%, -50%);
}

.leaflet-container.measure-cursor {
  cursor: crosshair;
}

.measure-label {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  transform: translate(-50%, -50%);
}

/* Higher specificity than leaflet.css's own ".leaflet-bar a" (loaded after
   this file) so our colors/sizing win regardless of stylesheet order. */
.leaflet-bar.leaflet-control-measure a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--panel-bg);
  color: var(--text);
  text-decoration: none;
  font-size: 1rem;
}

.leaflet-bar.leaflet-control-measure a.active {
  background: var(--brand);
}

.map-legend {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.map-legend-title {
  font-weight: bold;
  margin-bottom: 0.25rem;
}

.map-legend-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.map-legend-swatch {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 2px;
  vertical-align: middle;
}

.auth-page {
  max-width: 320px;
  margin: 4rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.auth-page #theme-toggle-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
}

.app-tagline {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

.auth-page form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

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

.form-error {
  color: var(--error);
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab-btn {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0.4rem 0.2rem;
}

.tab-btn.active {
  font-weight: bold;
  text-decoration: underline;
  color: var(--brand);
}

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

table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1rem;
}

table th,
table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-size: 0.9rem;
  white-space: nowrap;
}

.config-input {
  width: 12rem;
}

#batch-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.chip {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #fff;
}

.chip-green {
  background: var(--green);
}

.chip-orange {
  background: var(--orange);
}

.chip-red {
  background: var(--red);
}

.chip-neutral {
  background: var(--neutral);
}

.chip-fail {
  background: var(--error);
}

button,
input,
select {
  font: inherit;
}

button {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

button[type='submit'] {
  background: var(--brand);
  color: var(--brand-contrast);
  border-color: var(--brand);
}

.tab-btn,
.tab-btn.active {
  background: none;
  border: none;
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='file'],
select {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  background: var(--panel-bg);
  color: var(--text);
}

@media (max-width: 768px) {
  body:has(#map) main {
    flex-direction: column;
  }

  #lookup-panel {
    flex: 0 0 auto;
    width: auto;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  #map {
    flex: 1 1 auto;
  }
}

/* Plan 112 (2026-10-08) - drag handle between the lookup panel and the map */
#panel-resizer {
  flex: 0 0 6px;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  user-select: none;
  transition: background 0.15s;
}
#panel-resizer:hover,
#panel-resizer:focus-visible,
#panel-resizer.dragging {
  background: var(--brand);
  outline: none;
}
body.panel-resizing {
  cursor: col-resize;
  user-select: none;
}
body.panel-resizing #map {
  pointer-events: none;
}
@media (max-width: 768px) {
  #panel-resizer {
    display: none;
  }
}

/* Plan 103 (2026-10-06) - Search by IMSI (left panel, under the lookup result) */
#imsi-search {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

#imsi-search h2 {
  margin-top: 0;
}

#imsi-form .imsi-actions {
  display: flex;
  gap: 0.5rem;
}

#imsi-form .imsi-actions button[type='submit'] {
  flex: 1 1 auto;
}

#imsi-input {
  font-variant-numeric: tabular-nums;
}

#imsi-result {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

#imsi-result .imsi-line {
  margin: 0.25rem 0;
  color: var(--text);
}

#imsi-result .imsi-note {
  font-size: 0.75rem;
  color: var(--neutral);
}

#imsi-result .imsi-msg {
  margin: 0;
}

#imsi-result .imsi-error {
  color: var(--error);
}
