*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #C43026;
  --primary-hover: #a32820;
  --business: #61A2D3;
  --business-dark: #4a8ab8;
  --bg: #eef4f8;
  --bg-elevated: #FFFFFF;
  --bg-card: #FFFFFF;
  --sidebar-bg: #d7eef8;
  --sidebar-text: #1a3a4d;
  --sidebar-muted: #3d6a82;
  --text: #1a1a1a;
  --text-muted: #5c6b75;
  --text-on-dark: #FFFFFF;
  --border: #d3e0e8;
  --radius: 10px;
  --danger: #C43026;
  --ok: #2f9e44;
  --warn: #d97706;
  --cyan: #61A2D3;
  --cyan-dim: #4a8ab8;
  --cyan-glow: rgba(97, 162, 211, 0.28);
  --cyan-soft: rgba(97, 162, 211, 0.14);
  --font-display: Inter, system-ui, sans-serif;
  --font-body: Inter, system-ui, sans-serif;
  --sidebar: 220px;
}

html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}
body.is-public { background: #d7eef8; color: var(--text); }
a { color: var(--business); text-decoration: none; }
a:hover { color: var(--primary); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; color: var(--primary); }

.bg-grid, .bg-glow { display: none; }
body.is-public .bg-glow { display: none; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar);
  background: var(--sidebar-bg);
  border-right: 1px solid #b5d6e8; z-index: 20;
  display: flex; flex-direction: column; padding: 1rem 0.85rem 0.85rem;
}
.brand {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem;
  color: var(--sidebar-text); margin-bottom: 1.1rem; text-decoration: none;
}
.brand img { width: 148px; height: auto; max-width: 100%; object-fit: contain; }
.brand strong { display: none; }
.brand span {
  display: block; font-family: var(--font-body); letter-spacing: 0.06em;
  font-size: 0.68rem; color: var(--sidebar-muted); text-transform: uppercase; font-weight: 600;
}
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar nav a {
  color: var(--sidebar-text); padding: 0.5rem 0.75rem; border-radius: 7px;
  font-weight: 500; font-size: 0.88rem; border: 1px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active {
  color: #fff; background: var(--business); border-color: var(--business-dark);
}
.nav-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 0.15rem; padding-bottom: 0.3rem; }
.logout { margin-top: auto; }
.nav-bottom + .logout { margin-top: 0; }
.logout button {
  width: 100%; background: transparent; border: 1px solid #8bbdd4;
  color: var(--sidebar-text); padding: 0.45rem; border-radius: 7px; cursor: pointer; font: inherit;
  font-size: 0.85rem;
}
.logout button:hover { color: #fff; background: var(--primary); border-color: var(--primary); }

.shell {
  margin-left: var(--sidebar); position: relative; z-index: 1; min-height: 100vh;
  display: flex; flex-direction: column; background: var(--bg);
}
.topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1.35rem; position: sticky; top: 0;
  background: rgba(238, 244, 248, 0.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); z-index: 10;
}
.topbar h1 {
  font-family: var(--font-display); font-size: 1.12rem; letter-spacing: 0; font-weight: 700; color: #111;
}
.server-time {
  margin-left: auto; color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums;
  font-weight: 500; white-space: nowrap;
}
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: #111; }

.content { padding: 1rem 1.35rem 1.25rem; max-width: 1120px; flex: 1; width: 100%; }
.lead { color: var(--text-muted); margin-bottom: 0.9rem; max-width: 68ch; font-size: 0.92rem; }
.section-tag {
  font-family: var(--font-display); font-size: 0.68rem; letter-spacing: 0.14em;
  color: var(--primary); font-weight: 700; text-transform: uppercase;
}
.crumbs { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 0.7rem; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.45rem; line-height: 1.4; }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.05rem; margin-bottom: 0.9rem; position: relative; overflow: hidden;
  box-shadow: 0 1px 2px rgba(26, 58, 77, 0.04);
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 3px; bottom: 0;
  background: var(--primary);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.card h2, .card h3 { font-family: var(--font-display); letter-spacing: 0; font-size: 0.98rem; font-weight: 700; }
.card h3 { margin: 0.9rem 0 0.45rem; font-size: 0.88rem; color: var(--business); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; align-items: start; }
.overview {
  display: grid; grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0.75rem; margin-bottom: 0.9rem; align-items: stretch;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.65rem; margin-bottom: 0.9rem; }
.stats.gauges { grid-template-columns: 1fr 1fr 1fr; margin: 0; }
.stats.kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; }
.stats.mini { margin: 0.7rem 0; }
.stat {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.7rem 0.8rem; box-shadow: 0 1px 2px rgba(26, 58, 77, 0.04);
}
.stat span { display: block; color: var(--text-muted); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; }
.stat strong { font-family: var(--font-display); font-size: 1.25rem; color: var(--primary); }
.stat em { display: block; margin-top: 0.2rem; font-style: normal; color: var(--text-muted); font-size: 0.72rem; }
.gauge-stat { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0.65rem 0.5rem 0.55rem; }
.gauge {
  position: relative;
  width: 86px; height: 86px;
  margin: 0.25rem 0 0.1rem;
}
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 2.8; }
.gauge-bg { stroke: #e6eef2; }
.gauge-fg {
  stroke: #2f9e44;
  stroke-linecap: round;
  transition: stroke-dasharray 0.55s ease, stroke 0.3s ease;
}
.gauge-stat .gauge strong {
  position: absolute; inset: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; font-weight: 700;
}
.gauge-stat.ok .gauge-fg, .gauge-stat.ok strong { stroke: #2f9e44; color: #2f9e44; }
.gauge-stat.warm .gauge-fg, .gauge-stat.warm strong { stroke: #e3b000; color: #c49600; }
.gauge-stat.hot .gauge-fg, .gauge-stat.hot strong { stroke: #C43026; color: #C43026; }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { text-align: left; padding: 0.42rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; }
.table.compact td, .table.compact th { padding: 0.28rem 0.35rem; font-size: 0.82rem; }
.table-wrap { overflow: auto; max-height: 70vh; }

.pill {
  display: inline-flex; align-items: center; padding: 0.08rem 0.45rem; border-radius: 999px;
  border: 1px solid rgba(97, 162, 211, 0.4); background: rgba(97, 162, 211, 0.12);
  color: #3d6f96; font-size: 0.72rem; font-weight: 600;
}
.pill.ok { color: var(--ok); border-color: rgba(47, 158, 68, 0.35); background: rgba(47, 158, 68, 0.1); }
.pill.warn { color: var(--warn); border-color: rgba(217, 119, 6, 0.35); background: rgba(217, 119, 6, 0.1); }
.pill.running, .pill.queued { color: var(--business); }
.pill.done { color: var(--ok); border-color: rgba(47, 158, 68, 0.35); background: rgba(47, 158, 68, 0.1); }
.pill.error { color: var(--primary); border-color: rgba(196, 48, 38, 0.4); background: rgba(196, 48, 38, 0.1); }
.pill.skipped { color: var(--warn); border-color: rgba(217, 119, 6, 0.35); background: rgba(217, 119, 6, 0.1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.42rem 1.15rem; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; font-size: 0.86rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; filter: brightness(1.02); }
.btn-secondary, .btn-ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover, .btn-ghost:hover { border-color: var(--business); color: var(--business); background: rgba(97,162,211,0.08); }
.btn-danger { background: transparent; color: var(--primary); border: 1px solid rgba(196,48,38,0.4); }
.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.row-actions { display: flex; gap: 0.6rem; align-items: center; }
.linkish, .row-actions button {
  background: none; border: none; color: var(--business); cursor: pointer; font: inherit; padding: 0;
}
.linkish:hover, .row-actions button:hover { color: var(--primary); }

.stack { display: flex; flex-direction: column; gap: 0.65rem; }
.stack.tight { margin-top: 0.9rem; }
.row-2, .row-3 { display: grid; gap: 0.65rem; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
[hidden] { display: none !important; }
.field span { font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
input, select, textarea {
  background: #fff; border: 1px solid #c5d4de; border-radius: 6px;
  color: var(--text); font: inherit; padding: 0.48rem 0.7rem; outline: none; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: #86b7fe; box-shadow: 0 0 0 3px rgba(97, 162, 211, 0.18);
}
.check { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--text-muted); font-size: 0.88rem; }
.check input { width: auto; margin-top: 0.2rem; }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.inline-form input { flex: 1; min-width: 180px; }
.danger-form { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px dashed var(--border); }

.flash {
  position: relative; z-index: 2; margin: 0 0 0.75rem; padding: 0.55rem 0.8rem; border-radius: 8px;
  border: 1px solid var(--border); background: #fff; font-size: 0.9rem;
}
.flash.ok { color: #1e7a32; border-color: rgba(47, 158, 68, 0.35); background: rgba(47, 158, 68, 0.08); }
.flash.err { color: #8f241c; border-color: rgba(196, 48, 38, 0.35); background: rgba(196, 48, 38, 0.08); }
.flash.warn { color: #8a5a00; border-color: rgba(217, 119, 6, 0.35); background: rgba(217, 119, 6, 0.1); }
.flash .key { display: block; margin-top: 0.4rem; word-break: break-all; color: var(--text); }

.login-scene {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: #d7eef8;
}
.login-scene img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-legend {
  position: fixed; left: 1.1rem; bottom: 3.1rem; z-index: 2;
  list-style: none; display: flex; flex-direction: column; gap: 0.28rem;
  font-size: 0.74rem; font-weight: 600; color: #1a3a4d;
  background: rgba(255,255,255,0.72); border: 1px solid #b5d6e8;
  border-radius: 10px; padding: 0.5rem 0.7rem; backdrop-filter: blur(8px);
}
.login-legend li { display: flex; align-items: center; gap: 0.4rem; }
.login-legend i { width: 22px; height: 0; display: inline-block; border-radius: 2px; }
.lg-fiber { border-top: 3px solid #61A2D3; }
.lg-cable { border-top: 3px dashed #C43026; }
.lg-radio { width: 14px; height: 14px; border: 2px solid #2E89FF; border-radius: 50%; }

.public-wrap {
  position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 1.5rem 1rem 4rem;
}
.auth-card {
  position: relative; z-index: 3;
  width: min(400px, 100%); background: rgba(255,255,255,0.95); border: 1px solid #b5d6e8;
  border-radius: 14px; padding: 1.45rem 1.35rem 1.35rem; text-align: center;
  box-shadow: 0 8px 28px rgba(26, 58, 77, 0.1);
  backdrop-filter: blur(10px);
}
.auth-logo {
  width: 188px; height: auto; max-width: 100%; object-fit: contain; margin: 0 auto 0.7rem;
  display: block; background: transparent;
}
.auth-card h1 { font-family: var(--font-display); margin: 0.2rem 0 0.35rem; letter-spacing: 0; color: #111; font-size: 1.25rem; }
.auth-card .muted { color: var(--text-muted); font-size: 0.88rem; }
.auth-card .stack { text-align: left; margin-top: 0.95rem; }
.auth-card .field span { color: var(--text-muted); }
.auth-card input {
  background: #fff; border-color: #ced4da; color: var(--text);
}
.auth-card .btn { width: 100%; }
.auth-card .section-tag { color: var(--primary); }
.logo-preview {
  display: block; max-width: 220px; max-height: 72px; object-fit: contain;
  background: #d7eef8; padding: 0.45rem 0.65rem; border-radius: 8px; border: 1px solid #b5d6e8;
}

.help, .log {
  background: #f7fafc; border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem; overflow: auto; color: var(--text-muted); font-size: 0.78rem; margin-top: 0.6rem;
  white-space: pre-wrap;
}
.mapper { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.65rem 0; }
.map-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 0.35rem; align-items: center; }
.progress { height: 7px; background: #e8e8e8; border-radius: 99px; overflow: hidden; margin: 0.65rem 0 1rem; }
.bar { height: 100%; width: 0; background: var(--business); transition: width 0.3s; }
.result {
  background: #f7fbfd; border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 0.85rem; margin-top: 0.6rem;
}
.result header { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.25rem; }
.result-addr { margin: 0.15rem 0 0.35rem; font-size: 0.92rem; }
.techs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.35rem 0; }
details summary { cursor: pointer; color: var(--business); margin: 0.3rem 0; font-size: 0.85rem; }

.kind-pick {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem;
  border: none; padding: 0; margin: 0;
}
.kind-pick legend {
  font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 0.3rem;
}
.kind-card {
  display: flex; flex-direction: column; gap: 0.18rem;
  padding: 0.65rem 0.75rem; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: #fff;
}
.kind-card input { width: auto; margin-bottom: 0.12rem; }
.kind-card strong { color: var(--text); font-size: 0.9rem; }
.kind-card span { font-size: 0.78rem; color: var(--text-muted); line-height: 1.35; }
.kind-card:has(input:checked) {
  border-color: var(--business);
  background: rgba(97, 162, 211, 0.1);
  box-shadow: 0 0 0 3px rgba(97, 162, 211, 0.16);
}
.fwa-meta { display: flex; flex-wrap: wrap; gap: 0.45rem 0.7rem; color: var(--text-muted); font-size: 0.84rem; }
.fwa-speed { font-weight: 600; color: var(--business-dark); }
.field em.hint { margin-top: 0; font-size: 0.76rem; font-style: normal; }

.site-map {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #e4f1f8;
}
.site-map-canvas {
  width: 100%;
  height: 240px;
  border: 0;
  display: block;
  background: #d7eef8;
}
.site-map-canvas.is-wide { height: 320px; }
.site-map .hint {
  margin: 0;
  padding: 0.45rem 0.7rem;
  background: #fff;
  border-top: 1px solid var(--border);
}
.site-map-overview { margin-top: 0.75rem; }
.map-link { font-size: 0.82rem; }
.map-caption { background: #fff; border-top: 1px solid var(--border); padding: 0.45rem 0.7rem 0.55rem; }
.map-caption .hint { border: 0; padding: 0.25rem 0 0; margin: 0; }
.map-legend {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.45rem 0.85rem;
  font-size: 0.76rem; font-weight: 600; color: #1a3a4d; margin: 0 0 0.1rem;
}
.map-legend li { display: flex; align-items: center; gap: 0.35rem; }
.map-legend i {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(0,0,0,0.12);
}
.cov-g { background: rgba(22, 163, 74, 0.45); }
.cov-o { background: rgba(234, 88, 12, 0.45); }
.cov-y { background: rgba(234, 179, 8, 0.45); }
.map-save { color: #1e7a32; font-size: 0.78rem; font-weight: 600; margin: 0.25rem 0 0; }

.pac-container { z-index: 12000 !important; }

.pw-wrap { display: inline-flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.pw-field {
  width: auto; min-width: 8rem; max-width: 14rem; padding: 0.28rem 0.5rem; font-size: 0.84rem;
}

.site-footer {
  margin-top: auto; padding: 0.7rem 1.35rem; border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.8rem; text-align: center; background: #fff;
}
body.is-public .site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; background: #d7eef8;
  border-top: 1px solid #b5d6e8; color: var(--text-muted);
}

@media (max-width: 1100px) {
  .stats.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .login-legend { display: none; }
}
@media (max-width: 980px) {
  .grid-2, .row-3, .kind-pick { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-110%); transition: transform 0.2s; }
  body.nav-open .sidebar { transform: none; }
  .shell { margin-left: 0; }
  .nav-toggle { display: flex; }
  .row-2 { grid-template-columns: 1fr; }
  .stats.kpis { grid-template-columns: 1fr 1fr; }
  .stats.gauges { grid-template-columns: 1fr; }
}
