/* ECCrawler panel — sistema de diseño (dark, moderno) */
:root {
  --bg: #0e1015;
  --surface: #161922;
  --surface-2: #1d212c;
  --surface-3: #242936;
  --border: #2a303c;
  --border-strong: #3a4150;
  --text: #e7e9ef;
  --text-muted: #98a1b3;
  --text-dim: #6b7488;
  --accent: #7c5cff;
  --accent-hover: #6a49f0;
  --accent-soft: rgba(124, 92, 255, .14);
  --green: #3fb950;
  --green-soft: rgba(63, 185, 80, .14);
  --amber: #d29922;
  --amber-soft: rgba(210, 153, 34, .14);
  --red: #f85149;
  --red-soft: rgba(248, 81, 73, .14);
  --blue: #58a6ff;
  --blue-soft: rgba(88, 166, 255, .14);
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.2);
  --sidebar-w: 232px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #a883ff); color: #fff; font-weight: 800; font-size: 15px;
}
.brand b { font-size: 15px; letter-spacing: -.2px; }
.brand span { color: var(--text-dim); font-size: 11px; display: block; }

.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--text-muted); font-weight: 500; transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: #cbbcff; }
.nav-link .ico { width: 18px; text-align: center; opacity: .9; }
.nav-sep { height: 1px; background: var(--border); margin: 12px 4px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-dim); font-weight: 700; padding: 16px 12px 6px; }
.sidebar .foot { margin-top: auto; padding: 8px 12px; color: var(--text-dim); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); background: rgba(14,16,21,.7);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.topbar .sub { color: var(--text-dim); font-size: 12px; margin-top: 1px; }
.content { padding: 26px 28px 60px; max-width: none; width: 100%; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 16px 18px; position: relative; overflow: hidden;
  /* las tarjetas son <a> (cada cifra lleva a su población): sin esto heredan
     subrayado y color de enlace y dejan de parecer tarjetas */
  display: block; color: inherit; text-decoration: none;
  transition: border-color .12s ease;
}
a.kpi:hover { border-color: var(--accent); }
.kpi .label { color: var(--text-muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 28px; font-weight: 720; letter-spacing: -.5px; margin-top: 8px; }
.kpi .hint { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.kpi .accent-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.kpi.green .accent-bar { background: var(--green); }
.kpi.amber .accent-bar { background: var(--amber); }
.kpi.blue .accent-bar { background: var(--blue); }

/* ---------- Cards / sections ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 22px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 14px; font-weight: 620; }
.card-head .count { color: var(--text-dim); font-size: 12px; font-weight: 500; }
.card-body { padding: 4px 0; }
.card-pad { padding: 18px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 18px; color: var(--text-dim); font-weight: 550;
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.strong { font-weight: 600; }
td.mono { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.muted { color: var(--text-dim); }
.empty { padding: 40px 18px; text-align: center; color: var(--text-dim); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; line-height: 1.4; }
.badge.green { background: var(--green-soft); color: #6fd67e; }
.badge.amber { background: var(--amber-soft); color: #e6b84a; }
.badge.red { background: var(--red-soft); color: #ff8078; }
.badge.blue { background: var(--blue-soft); color: #85c0ff; }
.badge.violet { background: var(--accent-soft); color: #b7a4ff; }
.badge.gray { background: var(--surface-3); color: var(--text-muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); }
.dot.amber { background: var(--amber); } .dot.gray { background: var(--text-dim); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: #ff8078; border-color: rgba(248,81,73,.4); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field .help { color: var(--text-dim); font-size: 12px; margin-top: 5px; }
input[type=text], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); color: var(--text); font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row-form .field { margin-bottom: 0; flex: 1; min-width: 140px; }
.inline-check { display: flex; align-items: center; gap: 8px; }
.inline-check input { width: auto; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--border); }
.pager .info { color: var(--text-dim); font-size: 12.5px; }
.pager .controls { display: flex; gap: 6px; }
.page-btn { padding: 6px 11px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: 13px; }
.page-btn:hover { background: var(--surface-3); }
.page-btn.disabled { opacity: .4; pointer-events: none; }
.page-btn.current { background: var(--accent-soft); border-color: var(--accent); color: #cbbcff; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.chip { padding: 6px 13px; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: #cbbcff; }

/* ---------- Login ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 34px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card .brand { justify-content: center; padding: 0 0 6px; flex-direction: column; text-align: center; gap: 12px; }
.login-card .logo { width: 46px; height: 46px; font-size: 20px; border-radius: 13px; }
.login-card h1 { text-align: center; font-size: 18px; margin: 4px 0 4px; }
.login-card p { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.alert { background: var(--red-soft); border: 1px solid rgba(248,81,73,.3); color: #ff8078; padding: 10px 13px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 16px; }
.notice { background: var(--green-soft); border: 1px solid rgba(63,185,80,.3); color: #6fd67e; padding: 10px 13px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 16px; }
/* .notice es de ÉXITO (verde). Un aviso de que algo no funciona pintado en
   verde se lee como lo contrario de lo que dice, así que tiene su variante. */
.notice.warn { background: var(--amber-soft); border-color: rgba(210,153,34,.35); color: #e6b84a; }

/* ---------- Bar charts (CSS) ---------- */
.barlist { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 46px; align-items: center; gap: 12px; }
.bar-row .bl { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-3); border-radius: 5px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; min-width: 3px; }
.bar-row .bv { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text); text-align: right; font-weight: 600; }
.chart-pad { padding: 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Detection result ---------- */
.detect-box { border: 1px solid var(--border-strong); border-radius: var(--r); padding: 18px; margin: 18px 0; background: var(--surface-2); }
.detect-box.ok { border-color: rgba(63,185,80,.4); }
.detect-box.warn { border-color: rgba(210,153,34,.4); }
.detect-box .dt-title { font-weight: 650; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.detect-box ul { margin: 8px 0 0 18px; color: var(--text-muted); }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .foot { display: none; }
}
