:root {
  --bg: #0f1720;
  --page: #f4f6f8;
  --panel: #ffffff;
  --ink: #16212b;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #17b892;
  --accent-dark: #0f8f72;
  --red: #e5484d;
  --orange: #f97316;
  --yellow: #eab308;
  --grey: #94a3b8;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 23, 32, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; font-family: "Segoe UI", -apple-system, Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--page); }
a { color: var(--accent-dark); }
code { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.red { color: var(--red); } .orange { color: #c2410c; } .green { color: var(--accent-dark); }
h1 { font-size: 22px; margin: 0; }
h3 { font-size: 14px; margin: 18px 0 10px; }

/* ---------- topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 58px; background: var(--bg); color: #fff;
  display: flex; align-items: center; gap: 24px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; flex: none; }
.brand-logo { width: 32px; height: 32px; }
.brand-name { font-size: 19px; font-weight: 800; }
.b-tecnis { color: #fff; } .b-tecnis.dark { color: var(--ink); }
.b-mon { color: var(--accent); font-style: italic; }
.brand-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent);
  border: 1px solid rgba(23,184,146,0.5); border-radius: 100px; padding: 1px 8px; }
.nav { display: flex; gap: 2px; overflow-x: auto; }
.nav a { color: #94a3b8; text-decoration: none; font-size: 13.5px; font-weight: 600; padding: 8px 12px; border-radius: 7px; white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav a.active { color: #fff; background: rgba(23,184,146,0.18); }
.admin-only { display: none; } body.is-admin .admin-only { display: inline-block; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.refresh-dot { width: 8px; height: 8px; border-radius: 50%; background: #334155; }
.refresh-dot.on { animation: blink 1.2s ease; }
@keyframes blink { 0% { background: var(--accent); } 100% { background: #334155; } }

/* ---------- botones / formularios ---------- */
.btn { font: inherit; font-size: 13px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--border);
  background: #eef2f5; color: var(--ink); cursor: pointer; }
.btn:hover { background: #e2e8ee; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(229,72,77,0.08); }
.btn-ghost { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.12); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.15); }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 8px 10px; font: inherit; font-size: 13.5px;
  color: var(--ink); border: 1px solid var(--border); border-radius: 7px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23,184,146,0.3); border-color: var(--accent); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; margin: 0; }
.hint { display: block; font-weight: 400; font-size: 11.5px; margin-top: 4px; }
.form-error { margin: 6px 0 10px; padding: 8px 10px; border-radius: 7px; background: rgba(229,72,77,0.1); color: var(--red); font-size: 13px; }
.warn-text { font-size: 12.5px; color: #9a3412; background: rgba(249,115,22,0.1); padding: 8px 10px; border-radius: 7px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.inline { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

/* ---------- página ---------- */
.view { max-width: 1400px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 20px 16px; max-width: 760px; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; grid-column: 1 / -1; }
.empty h3 { color: var(--ink); font-size: 17px; }
.empty.small { padding: 24px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.back { display: inline-block; margin-bottom: 12px; font-size: 13px; text-decoration: none; }

/* contadores */
.counters { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 16px; }
.counters.small { grid-template-columns: repeat(4, 1fr); max-width: 760px; }
.counter { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.counter b { display: block; font-size: 26px; line-height: 1.1; }
.counter span { font-size: 12px; color: var(--muted); }
.counter.hot.c-offline { background: #1e293b; color: #fff; border-color: #1e293b; } .counter.hot.c-offline span { color: #cbd5e1; }
.counter.hot.c-critical { background: var(--red); color: #fff; border-color: var(--red); } .counter.hot.c-critical span { color: #fee2e2; }
.counter.hot.c-warning { background: var(--orange); color: #fff; border-color: var(--orange); } .counter.hot.c-warning span { color: #ffedd5; }
.counter.hot.c-notice { background: var(--yellow); border-color: var(--yellow); } .counter.hot.c-notice span { color: #422006; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.search { max-width: 340px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 12px; padding: 5px 11px; border-radius: 100px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.chip i { font-style: normal; font-weight: 700; margin-left: 3px; color: var(--muted); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); } .chip.active i { color: #cbd5e1; }

/* tarjetas de clientes */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.site-card { background: var(--panel); border: 1px solid var(--border); border-top: 4px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.site-card:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(15,23,32,0.14); }
.site-card.sev-offline { border-top-color: #1e293b; background: #f8fafc; }
.site-card.sev-critical { border-top-color: var(--red); }
.site-card.sev-warning { border-top-color: var(--orange); }
.site-card.sev-notice { border-top-color: var(--yellow); }
.site-card.sev-new, .site-card.sev-disabled { border-top-color: var(--grey); }
.site-card header { display: flex; align-items: flex-start; gap: 10px; }
.sc-title { flex: 1; min-width: 0; } .sc-title b { display: block; font-size: 15px; }
.sc-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); }
.sc-stats b { color: var(--ink); } .sc-stats b.red { color: var(--red); }
.sc-body { display: flex; flex-direction: column; gap: 4px; }
.site-card footer { margin-top: auto; }
.inet { font-weight: 600; } .inet-up { color: var(--accent-dark); } .inet-down { color: var(--red); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 100px; font-size: 11.5px;
  font-weight: 700; white-space: nowrap; flex: none; background: rgba(23,184,146,0.12); color: var(--accent-dark); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.pill.sev-offline { background: #1e293b; color: #fff; } .pill.sev-offline .dot { background: #94a3b8; }
.pill.sev-critical { background: rgba(229,72,77,0.12); color: var(--red); } .pill.sev-critical .dot { background: var(--red); }
.pill.sev-warning { background: rgba(249,115,22,0.14); color: #c2410c; } .pill.sev-warning .dot { background: var(--orange); }
.pill.sev-notice { background: rgba(234,179,8,0.18); color: #854d0e; } .pill.sev-notice .dot { background: var(--yellow); }
.pill.sev-new, .pill.sev-disabled, .pill.sev-off, .pill.sev-paused { background: #eef2f5; color: #475569; }
.pill.sev-new .dot, .pill.sev-disabled .dot, .pill.sev-off .dot, .pill.sev-paused .dot { background: var(--grey); }

.problem { font-size: 12.5px; padding: 4px 8px; border-radius: 6px; border-left: 3px solid var(--orange); background: rgba(249,115,22,0.08); color: #9a3412; margin-bottom: 4px; }
.problem.sev-critical { border-left-color: var(--red); background: rgba(229,72,77,0.08); color: #b4262b; }
.problem.sev-notice { border-left-color: var(--yellow); background: rgba(234,179,8,0.12); color: #713f12; }
.problem.tight { margin: 2px 0; padding: 2px 6px; font-size: 11.5px; }

/* detalle de cliente */
.site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.site-head .muted { font-size: 13px; margin-top: 4px; }
.notes { margin-top: 8px; font-size: 12.5px; background: #fffbea; border: 1px solid #f3e6b0; padding: 6px 10px; border-radius: 7px; max-width: 700px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { font: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 14px; border: none; background: none; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted); background: #f8fafb; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid #eef2f5; vertical-align: top; }
tr:last-child td { border-bottom: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.hs { font-weight: 700; font-size: 12px; }
.hs-up { color: var(--accent-dark); } .hs-down { color: var(--red); } .hs-warning { color: #c2410c; } .hs-paused, .hs-unknown { color: var(--muted); }

/* mapa de solo lectura */
.map-wrap { overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  background-image: radial-gradient(circle, #dbe2e8 1px, transparent 1px); background-size: 22px 22px; max-height: 70vh; }
.map { position: relative; min-width: 100%; }
.map > svg { position: absolute; inset: 0; pointer-events: none; }   /* solo la capa de líneas, no los íconos */
.map .conn { stroke: #94a3b8; stroke-width: 2; }
.map .conn.vm { stroke-dasharray: 5 4; stroke-width: 1.5; }
.mcard { position: absolute; width: 200px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff;
  border: 2px solid rgba(23,184,146,0.35); border-radius: 9px; box-shadow: var(--shadow); font-size: 12px; }
.mcard.st-down { border-color: var(--red); } .mcard.st-warning { border-color: var(--orange); }
.mcard.st-paused { border-style: dashed; border-color: #b6c2cf; opacity: 0.7; } .mcard.st-unknown { border-color: transparent; }
.micon { width: 26px; height: 26px; flex: none; } .micon svg { width: 100%; height: 100%; }
.mtext { flex: 1; min-width: 0; } .mtext b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mdot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.st-down .mdot { background: var(--red); } .st-warning .mdot { background: var(--orange); } .st-paused .mdot, .st-unknown .mdot { background: var(--grey); }

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,32,0.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 22px 24px; width: 480px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.secret-box { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.secret-box code { flex: 1; background: #f4f6f8; border: 1px solid var(--border); border-radius: 7px; padding: 9px 11px; font-size: 14px; overflow-wrap: anywhere; user-select: all; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 100; }
.toast.error { background: var(--red); }
.app-version { position: fixed; bottom: 6px; right: 12px; font-size: 10.5px; color: var(--muted); opacity: 0.6; pointer-events: none; }

/* ---------- login ---------- */
.login-body { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: #fff; border-radius: 14px; padding: 28px; width: 360px; max-width: 100%; box-shadow: 0 16px 50px rgba(0,0,0,0.35); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }
.login-logo { width: 46px; height: 46px; }
.login-brand .brand-name { font-size: 24px; }
.brand-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 3px; color: var(--accent-dark); font-weight: 700; }
.login-version { position: fixed; bottom: 8px; right: 12px; font-size: 11px; color: #64748b; }

@media (max-width: 900px) {
  .counters { grid-template-columns: repeat(3, 1fr); }
  .topbar { gap: 12px; padding: 0 12px; } .brand-tag { display: none; }
}
@media (max-width: 600px) {
  .grid2 { grid-template-columns: 1fr; }
  .counters, .counters.small { grid-template-columns: repeat(2, 1fr); }
  .view { padding: 14px; }
  .brand-name { display: none; }
}
