/* Paleta tomada de craken.app: azul pizarra profundo, blanco hueso, azul eléctrico, celeste y amarillo CTA.
   Tipografía: Space Grotesk (títulos, cifras) + Inter (texto). */
:root {
  --navy-950: #0a1020;
  --navy-900: #0f172a;   /* fondo principal de craken.app */
  --navy-800: #16213a;
  --navy-700: #1e2b47;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #f8fafc;
  --text-2: rgba(248, 250, 252, 0.78);
  --text-3: rgba(248, 250, 252, 0.64);  /* contraste ≥ 4.5:1 sobre el fondo */
  --blue: #1d4ed8;       /* botón "Acceso." */
  --blue-hover: #2563eb;
  --sky: #38bdf8;        /* acentos */
  --yellow: #fde047;     /* CTA "Hablar con Ventas" */

  --ok: #22c55e;
  --low: #fde047;
  --warn: #fb923c;
  --down: #ef4444;

  --radius: 14px;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(29, 78, 216, 0.25), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(56, 189, 248, 0.10), transparent 60%),
    var(--navy-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -0.01em; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(14px, 3vw, 32px);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand-mark { width: 48px; height: auto; flex: none; display: block; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.35rem; }
.badge-demo {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.06em;
  color: var(--yellow); border: 1px solid rgba(253, 224, 71, 0.4);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.badge-demo.live { color: var(--sky); border-color: rgba(56, 189, 248, 0.4); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.clock { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 0.9rem; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.speed { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-3); }
select, input[type="search"] {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; outline: none;
}
select option { background: var(--navy-800); }
select:focus, input:focus { border-color: var(--sky); }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.icon-btn {
  background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line-strong);
  border-radius: 8px; width: 36px; height: 36px; cursor: pointer;
}
.btn-primary {
  background: var(--blue); border: 0; border-radius: 999px; padding: 8px 16px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn-primary:hover { background: var(--blue-hover); }
.btn-cta { background: var(--yellow); color: var(--navy-900); border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 700; cursor: pointer; }
.btn-ghost { background: transparent; border: 1px solid var(--blue); border-radius: 8px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn-ghost:hover { background: rgba(29, 78, 216, 0.2); }
.count { background: var(--down); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 0.75rem; min-width: 20px; text-align: center; }
.count.zero { background: rgba(255, 255, 255, 0.2); }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px;
  padding: 24px clamp(14px, 3vw, 32px); max-width: 1600px; margin: 0 auto;
}
.hero h1 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); line-height: 1.1; }
.hero p { color: var(--text-2); max-width: 720px; margin: 8px 0 20px; line-height: 1.5; }

.downtime-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  border: 1px solid rgba(239, 68, 68, 0.45); background: linear-gradient(90deg, rgba(239, 68, 68, 0.18), rgba(239, 68, 68, 0.04));
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 0.92rem;
}
.downtime-banner strong { font-family: var(--font-head); }
.downtime-banner .muted { color: var(--text-2); }
.downtime-banner a { color: inherit; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--text-3); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .value { font-family: var(--font-head); font-weight: 700; font-size: 1.6rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 0.85rem; color: var(--text-2); font-weight: 500; }
.kpi .sub { color: var(--text-2); font-size: 0.8rem; margin-top: 2px; }
.kpi.accent { border-color: rgba(56, 189, 248, 0.35); }
.kpi.danger .value { color: var(--down); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04); border-radius: 999px;
  padding: 6px 12px; font-size: 0.85rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip.active { background: var(--text); color: var(--navy-900); border-color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.chip .dot.ok { --c: var(--ok); } .chip .dot.low { --c: var(--low); } .chip .dot.warn { --c: var(--warn); } .chip .dot.down { --c: var(--down); }
.chip .n { font-variant-numeric: tabular-nums; opacity: 0.7; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tools input { min-width: 220px; }

/* ---------- Tarjetas de pozo ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
  position: relative; background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: rgba(56, 189, 248, 0.5); transform: translateY(-1px); }
.card::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.card.ok { --c: var(--ok); } .card.low { --c: var(--low); } .card.warn { --c: var(--warn); } .card.down { --c: var(--down); }
.card.down { border-color: rgba(239, 68, 68, 0.45); background: linear-gradient(180deg, rgba(239, 68, 68, 0.10), rgba(255, 255, 255, 0.02)); }
.card.warn { border-color: rgba(251, 146, 60, 0.35); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head h3 { font-size: 1.1rem; }
.card-head .meta { color: var(--text-3); font-size: 0.78rem; margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 600; padding: 4px 9px; border-radius: 999px; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.pill.ok { --c: var(--ok); } .pill.low { --c: var(--low); } .pill.warn { --c: var(--warn); } .pill.down { --c: var(--down); }
.pill.down::before, .pill.warn::before { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.rate { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin: 14px 0 6px; }
.rate .big { font-family: var(--font-head); font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.rate .big small { font-size: 0.9rem; color: var(--text-2); font-weight: 500; }
.rate .exp { color: var(--text-3); font-size: 0.78rem; margin-top: 4px; }
.spark { width: 120px; height: 38px; flex: none; }
.bar { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--c); border-radius: 99px; transition: width .6s; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 8px; margin-top: 14px; }
.metric .k { color: var(--text-3); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.metric .v { font-family: var(--font-head); font-weight: 600; font-size: 0.98rem; font-variant-numeric: tabular-nums; }
.metric .v.neg { color: var(--warn); } .metric .v.bad { color: var(--down); }
.card-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 0.76rem; color: var(--text-3); }
.card-foot .reason { color: var(--text-2); text-align: right; }
.empty { color: var(--text-3); padding: 40px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------- Panel de alertas ---------- */
.alerts-panel {
  position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); display: flex; flex-direction: column;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tab { flex: 1; background: transparent; border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px; cursor: pointer; font-size: 0.85rem; }
.tab.active { background: rgba(56, 189, 248, 0.15); border-color: var(--sky); }
.alert-list { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.alert { border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 10px; padding: 10px 12px; background: rgba(255, 255, 255, 0.03); font-size: 0.85rem; cursor: pointer; }
.alert.critica { --c: var(--down); } .alert.alta { --c: var(--warn); } .alert.media { --c: var(--low); }
.alert.acked { opacity: 0.6; }
.alert.resolved { opacity: 0.5; border-left-color: var(--text-3); }
.alert .row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.alert .who { font-family: var(--font-head); font-weight: 600; }
.alert .sev { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c); font-weight: 700; }
.alert p { margin: 4px 0 6px; color: var(--text-2); line-height: 1.4; }
.alert .when { color: var(--text-3); font-size: 0.75rem; }
.alert .ack { background: transparent; border: 1px solid var(--line-strong); border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; cursor: pointer; }
.only-mobile { display: none; }

/* ---------- Drawer detalle ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 50;
  background: var(--navy-900); border-left: 1px solid var(--line-strong); overflow-y: auto;
  transform: translateX(100%); transition: transform .25s ease; padding: 20px 22px 40px;
}
.drawer.open { transform: none; }
.drawer .d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer h2 { font-size: 1.7rem; }
.drawer .sub { color: var(--text-2); font-size: 0.88rem; margin-top: 4px; }
.d-section { margin-top: 22px; }
.d-section h3 { font-size: 0.95rem; color: var(--text-2); margin-bottom: 10px; font-weight: 600; }
.d-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.d-kpis .kpi { padding: 10px 12px; }
.d-kpis .kpi .value { font-size: 1.2rem; }
.chart { display: block; width: 100%; height: auto; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 10px; }
.legend { display: flex; gap: 14px; font-size: 0.78rem; color: var(--text-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.demo-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.note { font-size: 0.78rem; color: var(--text-3); margin-top: 8px; line-height: 1.4; }
.drawer .d-actions { display: flex; gap: 8px; align-items: center; }
.impact.warn { border-color: rgba(251, 146, 60, 0.4); background: rgba(251, 146, 60, 0.08); }
.impact { border: 1px solid rgba(239, 68, 68, 0.4); background: rgba(239, 68, 68, 0.08); border-radius: 10px; padding: 12px 14px; font-size: 0.88rem; line-height: 1.5; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--navy-800); border: 1px solid var(--line-strong); border-left: 4px solid var(--c); border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); font-size: 0.88rem; animation: slidein .25s ease; cursor: pointer; }
.toast.critica { --c: var(--down); } .toast.alta { --c: var(--warn); } .toast.media { --c: var(--low); }
.toast strong { font-family: var(--font-head); display: block; margin-bottom: 2px; }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }

.site-foot { padding: 0 clamp(14px, 3vw, 32px) 20px; max-width: 1600px; margin: 24px auto 0; }
.foot-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; border-top: 1px solid var(--line-strong); padding-top: 22px; font-size: 0.8rem; color: var(--text-2); }
.vrgl { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-2); }
.vrgl img { width: 28px; height: auto; mix-blend-mode: lighten; } /* el fondo oscuro del recorte se funde con la página */
.vrgl-text { display: flex; flex-direction: column; line-height: 1.25; }
.vrgl .url { color: var(--sky); }
.vrgl:hover .url { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .alerts-panel {
    position: fixed; inset: auto 0 0 0; top: auto; max-height: 75vh; z-index: 45; border-radius: 16px 16px 0 0;
    background: var(--navy-900); transform: translateY(100%); transition: transform .25s ease;
  }
  .alerts-panel.open { transform: none; }
  .only-mobile { display: inline-block; }
}
@media (max-width: 640px) {
  .foot-inner { flex-direction: column; text-align: center; }
  .top-actions { flex: 1; justify-content: flex-end; gap: 6px; }
  .brand-name { font-size: 1.15rem; }
  .speed select { padding: 6px; }
  .btn-primary { padding: 8px 12px; }
  .btn-primary .lbl { display: none; }
  .btn-primary::before { content: '⚠'; }
  .speed span, .clock { display: none; }
  .speed select { max-width: 96px; }
  .badge-demo { display: none; }
  .tools, .tools input, .tools select { width: 100%; min-width: 0; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .value { font-size: 1.3rem; }
  .d-kpis { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
}
