/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:        #1D9E75;
  --teal-dark:   #0F6E56;
  --teal-light:  #E1F5EE;
  --blue:        #185FA5;
  --blue-light:  #E6F1FB;
  --amber:       #BA7517;
  --amber-light: #FEF3C7;
  --green:       #15803D;
  --green-light: #DCFCE7;
  --red:         #B91C1C;
  --red-light:   #FEE2E2;
  --gray-50:     #F8FAFC;
  --gray-100:    #F1F5F9;
  --gray-200:    #E2E8F0;
  --gray-400:    #94A3B8;
  --gray-600:    #475569;
  --gray-800:    #1E293B;
  --gray-900:    #0F172A;
  --font-sans:   'Inter', system-ui, sans-serif;
  --font-mono:   'IBM Plex Mono', 'Fira Mono', monospace;
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --header-h:    52px;
  --sidebar-w:   200px;
}

html { font-size: 14px; }

body {
  font-family: var(--font-sans);
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--gray-900);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 100%;
  padding: 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon { width: 28px; height: 28px; }

.brand-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 10px;
  color: var(--gray-400);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-left: 1px solid rgba(255,255,255,0.12);
  padding-left: 8px;
  margin-left: 2px;
}

.header-nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--gray-400);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
}

.nav-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-link.active { color: #fff; background: rgba(255,255,255,0.10); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
button { cursor: pointer; font-family: var(--font-sans); font-size: 13px; }

.btn-primary {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: var(--teal);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary svg { width: 14px; height: 14px; }

.btn-ghost {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: transparent;
  color: var(--gray-400);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  transition: color 0.15s, border-color 0.15s;
}
.btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,0.25); }
.btn-ghost svg { width: 14px; height: 14px; }

.btn-danger {
  padding: 6px 12px;
  background: var(--red-light);
  color: var(--red);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
}
.btn-danger:hover { background: #fca5a5; }

.btn-danger-ghost {
  display: flex; align-items: center; gap: 5px;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  color: var(--gray-400);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-danger-ghost:hover { color: var(--red); border-color: #fca5a5; background: var(--red-light); }
.btn-danger-ghost svg { width: 14px; height: 14px; }

/* ── Sections ─────────────────────────────────────────────────────────────── */
main { min-height: calc(100vh - var(--header-h)); }

.section { display: none; }
.section.active { display: block; }

.section-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.section-head h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.section-desc { font-size: 13px; color: var(--gray-600); }

/* ── Map layout ───────────────────────────────────────────────────────────── */
#map { position: relative; }

.map-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.map-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-block {
  padding: 14px 14px;
  border-bottom: 1px solid var(--gray-100);
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray-400);
  margin-bottom: 8px;
}

.mode-buttons { display: flex; flex-direction: column; gap: 4px; }

.mode-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 12px;
  transition: all 0.15s;
}
.mode-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.mode-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.mode-btn.active {
  background: var(--teal-light);
  color: var(--teal-dark);
  border-color: var(--teal);
  font-weight: 500;
}

.type-buttons { display: flex; flex-direction: column; gap: 4px; }

.type-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  background: transparent;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: all 0.15s;
}
.type-btn:hover { background: var(--gray-100); }
.type-btn.active { border-color: var(--gray-400); color: var(--gray-900); font-weight: 500; }

.type-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.type-dot.type-square { border-radius: 2px; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-600);
  cursor: pointer;
  padding: 3px 0;
}
.toggle-row input { accent-color: var(--teal); cursor: pointer; }

.legend-list { display: flex; flex-direction: column; gap: 6px; }
.leg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--gray-600);
}

.stats-block { }
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.stat-card {
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-n { font-family: var(--font-mono); font-size: 20px; font-weight: 600; color: var(--gray-800); line-height: 1; }
.stat-n.green { color: var(--green); }
.stat-n.amber { color: var(--amber); }
.stat-n.blue  { color: var(--blue); }
.stat-l { font-size: 10px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Map canvas area ──────────────────────────────────────────────────────── */
.map-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--gray-100);
}

#map-canvas {
  display: block;
  cursor: crosshair;
}

.map-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.75);
  color: #fff;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
  pointer-events: none;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

/* ── POP detail panel ─────────────────────────────────────────────────────── */
.pop-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}

.pop-panel[hidden] { display: none; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
  font-weight: 500;
  font-size: 13px;
  color: var(--gray-800);
  flex-shrink: 0;
}

.panel-close {
  background: transparent;
  border: none;
  color: var(--gray-400);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.panel-close:hover { background: var(--gray-100); color: var(--gray-800); }

.panel-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 14px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }

.form-field label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
}

.form-field input,
.form-field select {
  padding: 6px 9px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s;
  width: 100%;
}
.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-light);
}

.panel-actions {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--gray-100);
  margin-top: auto;
}
.panel-actions .btn-primary { flex: 1; justify-content: center; }

/* ── Register table ───────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: #fff;
}

#reg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#reg-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

#reg-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#reg-table tr:last-child td { border-bottom: none; }
#reg-table tr:hover td { background: var(--gray-50); }

.empty-row td {
  text-align: center;
  color: var(--gray-400);
  padding: 32px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.status-active   { background: var(--green-light);  color: var(--green); }
.status-installed{ background: var(--amber-light);  color: var(--amber); }
.status-planned  { background: #FEF9C3;             color: #92400E; }
.status-inactive { background: var(--red-light);    color: var(--red); }

/* ── About ────────────────────────────────────────────────────────────────── */
.about-inner { max-width: 900px; }

.about-hero {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gray-200);
}
.about-hero h2 { font-size: 24px; font-weight: 600; margin-bottom: 8px; color: var(--gray-900); }
.about-hero p  { font-size: 15px; color: var(--gray-600); line-height: 1.7; max-width: 600px; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.about-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.about-icon {
  width: 36px; height: 36px;
  background: var(--teal-light);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  color: var(--teal-dark);
}
.about-icon svg { width: 18px; height: 18px; }

.about-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--gray-800); }
.about-card p  { font-size: 12px; color: var(--gray-600); line-height: 1.6; }

.about-howto {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.about-howto h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--gray-800); }
.howto-list { padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.howto-list li { font-size: 13px; color: var(--gray-600); line-height: 1.6; }
.howto-list strong { color: var(--gray-800); }

.about-footer { font-size: 12px; color: var(--gray-400); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 20px;
  z-index: 999;
  pointer-events: none;
}
.toast[hidden] { display: none; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .brand-sub { display: none; }
  .header-actions .btn-ghost { display: none; }
  .map-sidebar { width: 160px; }
  .pop-panel { width: 100%; }
  .brand-name { font-size: 13px; }
}
