:root {
  --bg: #f4f6f8; --surface: #ffffff; --ink: #14202b; --muted: #5d6b78; --line: #dfe4ea; --soft: #eef2f5;
  --brand: #12324a; --accent: #1f7a6d; --accent-soft: #e2f3ef;
  --ok: #1d7f4e; --ok-bg: #e3f4ea; --warn: #9a6400; --warn-bg: #fdf1dc; --bad: #b3261e; --bad-bg: #fbe5e3;
  --info: #285e9e; --info-bg: #e5eefa; --off: #66727e; --off-bg: #eceff2;
  --secret: #8a3fb0; --cm: #2b7d9a; --pvc: #6a5a2c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f161d; --surface: #16212b; --ink: #e6edf2; --muted: #9aa8b4; --line: #26343f; --soft: #1c2934;
    --brand: #0b1c29; --accent: #4cc2ad; --accent-soft: #173832;
    --ok: #5ccf91; --ok-bg: #163527; --warn: #f0b64e; --warn-bg: #3a2c12; --bad: #ff8a80; --bad-bg: #3d1d1b;
    --info: #8db8f2; --info-bg: #1a2c44; --off: #9aa6b1; --off-bg: #222e38;
    --secret: #cf9bf0; --cm: #7fcbe4; --pvc: #d6c48d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f161d; --surface: #16212b; --ink: #e6edf2; --muted: #9aa8b4; --line: #26343f; --soft: #1c2934;
    --brand: #0b1c29; --accent: #4cc2ad; --accent-soft: #173832;
    --ok: #5ccf91; --ok-bg: #163527; --warn: #f0b64e; --warn-bg: #3a2c12; --bad: #ff8a80; --bad-bg: #3d1d1b;
    --info: #8db8f2; --info-bg: #1a2c44; --off: #9aa6b1; --off-bg: #222e38;
    --secret: #cf9bf0; --cm: #7fcbe4; --pvc: #d6c48d;
    color-scheme: dark;
  }
.theme-switch { display: inline-flex; border: 1px solid rgba(255,255,255,.25); border-radius: 8px; overflow: hidden; }
.theme-switch button { background: transparent; color: #fff; border: 0; padding: 5px 9px; font: inherit; font-size: .82rem; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: rgba(255,255,255,.18); }
.theme-switch button:focus-visible { outline: 2px solid #9fd9cb; outline-offset: -2px; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.45rem; letter-spacing: -.01em; }
h3 { font-size: 1.02rem; }
h4 { font-size: .9rem; margin: 14px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
a { color: var(--accent); }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.wrap { white-space: normal; word-break: break-word; max-width: 420px; }
.eyebrow { margin: 0; font-size: .7rem; letter-spacing: .18em; font-weight: 700; color: #9fd9cb; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px;
  background: var(--brand); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 1.15rem; font-weight: 650; }
.logo { width: 34px; height: 34px; }
.logo rect { fill: #1f7a6d; } .logo circle { fill: #fff; }
.who { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.who .ns { font-family: var(--mono); background: rgba(255,255,255,.1); padding: 3px 8px; border-radius: 6px; }
.badge.readonly { background: #f0c75e; color: #2b2100; font-weight: 700; }

.tabs { display: flex; gap: 4px; align-items: center; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; overflow-x: auto; }
.tabs [role=tab] { border: 0; background: none; padding: 14px 14px 12px; font: inherit; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs [role=tab][aria-selected=true] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs [role=tab]:hover { color: var(--ink); }
.tabs .spacer { flex: 1; }
.stamp.notice { color: #b45309; white-space: normal; }
#auto-toggle[aria-pressed=false] { opacity: .7; }
.stamp { color: var(--muted); font-size: .82rem; white-space: nowrap; margin-right: 8px; }
button.ghost, .button { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 6px 12px;
  border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
.top button.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.button { background: var(--accent); color: #fff; border-color: var(--accent); padding: 10px 18px; font-weight: 600; }

main { padding: 22px 28px 60px; max-width: 1640px; margin: 0 auto; }
.panel-head { margin-bottom: 16px; }
.panel-head p { margin: 6px 0 0; max-width: 900px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card-head { margin-bottom: 12px; }
.card-head p { margin: 4px 0 0; font-size: .88rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid2 + *, .grid3 + * { margin-top: 16px; }
.card .grid2 { margin-top: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.card .stat, .engine .stat { background: var(--soft); border-color: transparent; }
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .8rem; }
.stat.good .stat-value { color: var(--ok); } .stat.warn .stat-value { color: var(--warn); } .stat.bad .stat-value { color: var(--bad); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--off-bg); color: var(--off); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.chip { background: var(--info-bg); color: var(--info); font-weight: 500; }
.badge.strong { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.digest { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 3px; }
.ctr { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.label { margin: 14px 0 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700;
  padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--soft); }
details summary { cursor: pointer; margin: 14px 0 8px; font-weight: 600; }

.alert { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert.soft { background: var(--warn-bg); color: var(--warn); }
.loading { color: var(--muted); padding: 30px 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
select { font: inherit; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

/* motores */
.engine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-bottom: 16px; }
.engine { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 12px; padding: 16px; }
.engine.off { border-top-color: var(--off); }
.engine header { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.engine .stats { margin: 12px 0 0; grid-template-columns: repeat(4, 1fr); }
.engine .stat-value { font-size: 1.15rem; }
.images { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: .86rem; }

/* grafos */
.graph-box { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); padding: 4px; }
svg.graph { display: block; font-family: system-ui, sans-serif; }
.col-head { font-size: 11px; font-weight: 700; fill: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.node rect:first-child { fill: var(--surface); stroke: var(--line); stroke-width: 1.2; }
.node .node-bar { fill: var(--off); }
.node-label { font-size: 12.5px; font-weight: 600; fill: var(--ink); }
.node-detail { font-size: 10.5px; fill: var(--muted); }
.node-internet .node-bar, .node-external .node-bar { fill: var(--info); }
.node-ingress .node-bar { fill: var(--accent); }
.node-service .node-bar { fill: #3f6fb5; }
.node-deployment .node-bar, .node-workload .node-bar { fill: var(--brand); }
.node-pod .node-bar { fill: #59708a; }
.node-ok .node-bar { fill: var(--ok); }
.node-warn .node-bar { fill: var(--warn); }
.node-warn rect:first-child { stroke: var(--warn); }
.node-secret .node-bar { fill: var(--secret); } .node-secret rect:first-child { stroke-dasharray: 4 3; }
.node-configmap .node-bar { fill: var(--cm); }
.node-pvc .node-bar { fill: var(--pvc); }
.node-missing .node-bar { fill: var(--bad); } .node-missing rect:first-child { stroke: var(--bad); stroke-dasharray: 4 3; }
.node.hot rect:first-child { stroke: var(--accent); stroke-width: 2.2; }
.node:focus { outline: none; }
.edge { fill: none; stroke: #8796a5; stroke-width: 1.4; opacity: .85; }
.edge-efectivo { stroke: var(--ok); stroke-width: 1.8; }
.edge-externo { stroke: var(--info); stroke-width: 1.6; }
.edge-parcial { stroke: var(--warn); stroke-dasharray: 5 4; stroke-width: 1.6; }
.edge-mount { stroke: #a58fbe; stroke-dasharray: 2 3; }
.edge-https { stroke: var(--accent); stroke-width: 2; }
.arrow { fill: #8796a5; } .arrow-efectivo { fill: var(--ok); } .arrow-externo { fill: var(--info); } .arrow-parcial { fill: var(--warn); }
.arrow-mount { fill: #a58fbe; } .arrow-https { fill: var(--accent); }
.edge-label { font-size: 10px; fill: var(--muted); paint-order: stroke; stroke: var(--soft); stroke-width: 3px; }
svg.focusing .edge { opacity: .14; } svg.focusing .edge.hot { opacity: 1; stroke-width: 2.6; }
svg.focusing .edge-label { opacity: .15; } svg.focusing .edge-label.hot { opacity: 1; fill: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: .82rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 18px; height: 6px; border-radius: 3px; display: inline-block; background: var(--off); }
.swatch-ok, .swatch-efectivo { background: var(--ok); } .swatch-warn, .swatch-parcial { background: var(--warn); }
.swatch-secret { background: var(--secret); } .swatch-configmap { background: var(--cm); } .swatch-pvc { background: var(--pvc); }
.swatch-externo { background: var(--info); }
.bars-box { margin: 6px 0 14px; }
svg.bars { width: 100%; height: 110px; display: block; }
.bar.deny { fill: var(--warn); } .axis { stroke: var(--line); } .tick { font-size: 10px; fill: var(--muted); }

/* login */
.login-card { max-width: 460px; margin: 10vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 34px; }
.login-card .eyebrow { color: var(--accent); }
.login-card h1, .login-card h2 { margin: 10px 0 12px; font-size: 1.6rem; }
body.login { padding: 20px; }

@media (max-width: 720px) {
  .top { padding: 12px 16px; flex-wrap: wrap; } main { padding: 16px; }
  .grid2, .grid3, .engine-grid { grid-template-columns: 1fr; }
  .stamp { display: none; }
}
