:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --line: #2a2f3a;
  --text: #e9ecf1;
  --muted: #9aa3b2;
  --accent: #ff5a36;
  --accent2: #ff8a6b;
  --ok: #3ccf91;
  --warn: #f5b942;
  --bad: #ff5470;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13.5px; }

/* --- botones y formularios */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ff6d4d; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13.5px; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="checkbox"] { width: auto; }
.form { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.error { color: var(--bad); margin: 0; font-size: 14px; }

/* --- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand b { color: var(--accent2); }

/* --- estructura */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: rgba(15,17,21,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#nav a { color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
#nav a:hover { color: var(--text); text-decoration: none; background: var(--panel); }
#nav a.on { color: var(--text); background: var(--panel2); }
.view { max-width: 1200px; margin: 0 auto; padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.section { margin-top: 22px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head h1, .head h2 { margin: 0; }

/* --- indicadores */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12.5px; }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar i.warn { background: var(--warn); }
.bar i.bad { background: var(--bad); }

/* --- tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #1b1f27; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.act { text-align: right; white-space: nowrap; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* --- etiquetas */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: rgba(60,207,145,.12); }
.pill.warn { color: var(--warn); background: rgba(245,185,66,.12); }
.pill.bad { color: var(--bad); background: rgba(255,84,112,.12); }
.plat { font-size: 12px; color: var(--muted); }

/* --- filtros */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 999px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--panel2); color: var(--text); border-color: #3a4150; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; }

/* --- detalle */
.detail { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 18px; align-items: start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.logs { max-height: 420px; overflow: auto; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.logs div { padding: 6px 12px; border-bottom: 1px solid var(--line); }
.logs .error { color: var(--bad); }
.logs .warn { color: var(--warn); }

/* --- diálogo y aviso */
dialog { width: min(480px, calc(100vw - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 11px 18px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 20; max-width: calc(100vw - 32px); }
.toast.bad { border-color: var(--bad); color: var(--bad); }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .topbar .brand span { display: none; }
  #nav { order: 3; flex-basis: 100%; }
  .view { padding: 16px; }
  .detail { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar input, .toolbar select { min-width: 0; width: 100%; }
  th, td { padding: 9px 10px; }
  .stat .v { font-size: 22px; }
}
