:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1c2433;
  --muted: #6b7588;
  --border: #e2e6ee;
  --primary: #1f5eff;
  --primary-d: #1747c4;
  --ok: #15924a;
  --ok-bg: #e5f6ec;
  --warn: #b26a00;
  --warn-bg: #fff3dc;
  --bad: #c62828;
  --bad-bg: #fde8e8;
  --info-bg: #e8efff;
  --side: #121a2b;
  --radius: 10px;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--bad); min-height: 18px; margin: 6px 0; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex: none; background: var(--side); color: #cfd6e6; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; transition: width .18s ease; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: #fff; padding: 4px 4px 18px 10px; letter-spacing: .3px; white-space: nowrap; }
.brand-text { flex: 1; }
.ico { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-toggle { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: #8f9bb3; cursor: pointer; padding: 0; }
.nav-toggle:hover { background: #1d2740; color: #fff; }
.nav-toggle .ico { transition: transform .18s ease; }
#logout { display: flex; align-items: center; justify-content: center; gap: 8px; }
#logout .ico { width: 16px; height: 16px; }
/* Menú plegado: solo iconos (el nombre sale al pasar el ratón, por el atributo title). */
.nav-collapsed .sidebar { width: 68px; padding-left: 10px; padding-right: 10px; }
.nav-collapsed .brand { flex-direction: column; gap: 10px; padding: 4px 0 14px; }
.nav-collapsed .brand-text, .nav-collapsed .sidebar .label, .nav-collapsed #whoami { display: none; }
.nav-collapsed .nav-toggle .ico { transform: rotate(180deg); }
.nav-collapsed nav a { justify-content: center; padding: 10px 0; }
.nav-collapsed .sidebar-foot { padding: 10px 0; }
.nav-collapsed #logout { padding: 7px 0; }
.brand-lg { color: var(--text); font-size: 26px; padding: 0; }
.logo { color: #4f86ff; }
nav a { display: flex; align-items: center; gap: 12px; color: #cfd6e6; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; white-space: nowrap; }
nav a:hover { background: #1d2740; text-decoration: none; }
nav a.active { background: var(--primary); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: 22px 32px 26px; max-width: 1400px; min-width: 0; width: 100%; }

/* Barra superior: notificaciones y ayuda. */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: flex-end; align-items: center; gap: 4px; height: 52px; padding: 0 22px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar-item { position: relative; }
.topbar-btn { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: #4a5468; cursor: pointer; }
.topbar-btn:hover, .topbar-btn[aria-expanded="true"] { background: #eef2f9; color: var(--text); }
.topbar-btn .ico { width: 21px; height: 21px; }
.notif-count { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--panel); }
.notif-panel { position: absolute; right: -6px; top: 46px; width: 400px; max-width: calc(100vw - 24px); max-height: 520px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(18, 26, 43, .18); overflow: hidden; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif-head a { cursor: pointer; font-size: 12.5px; }
.notif-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif:hover { background: #f7f9fd; }
.notif.unread { background: #f3f7ff; }
.notif-dot { flex: none; width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--muted); }
.notif.bad .notif-dot { background: var(--bad); }
.notif.warn .notif-dot { background: var(--warn); }
.notif.ok .notif-dot { background: var(--ok); }
.notif.info .notif-dot { background: var(--primary); }
.notif-text { min-width: 0; }
.notif-title { font-size: 13.5px; }
.notif.unread .notif-title { font-weight: 600; }
.notif-body { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-meta { font-size: 11.5px; color: #8a94a6; margin-top: 4px; }
.notif-panel .empty { padding: 28px 16px; }
.help-list { margin: 0 0 14px; padding-left: 20px; line-height: 1.7; }
.pre-line { white-space: pre-line; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat.bad .v { color: var(--bad); }
.stat.ok .v { color: var(--ok); }
.stat.warn .v { color: var(--warn); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f9fd; }
.table-wrap { overflow-x: auto; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.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.info { background: var(--info-bg); color: var(--primary); }
.badge.grey { background: #eef0f4; color: var(--muted); }

.btn { border: 1px solid var(--border); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; }
.btn:hover { background: #f3f5f9; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--bad); border-color: #f2c4c4; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; color: #cfd6e6; border-color: #2c3a58; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12px; display: block; margin-top: 3px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 8px 10px; border: 1px solid #cdd3df; border-radius: 7px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #b8cbff; border-color: var(--primary); }
textarea { min-height: 90px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 8px 0 0; vertical-align: middle; flex: none; }
label.check { font-weight: 500; display: flex; align-items: center; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px 2px; margin: 0 0 14px; }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.progress { height: 8px; background: #e7ebf3; border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--primary); transition: width .6s; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 22, 38, .5); display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }

pre.log { background: #0f1626; color: #d7deea; padding: 14px; border-radius: 8px; max-height: 480px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.codebox { background: #0f1626; color: #d7deea; padding: 12px; border-radius: 8px; word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.notice { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; }
.notice.warn { background: var(--warn-bg); color: #6b4300; }
.notice.info { background: var(--info-bg); color: #1b3a87; }
.notice.bad { background: var(--bad-bg); color: #7a1414; }
.notice.ok { background: var(--ok-bg); color: #0f5f31; }
.notice.ransom { border: 1px solid #e9a3a3; }
.notice.ransom ol { margin: 8px 0 12px; padding-left: 20px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 10px; font-family: ui-monospace, Consolas, monospace; }
.crumbs a { cursor: pointer; }
.browser { max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.browser td { padding: 6px 10px; }
.entry-dir { cursor: pointer; font-weight: 600; }

.restore-step { margin-bottom: 20px; }
.restore-step h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; }
.step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; }
.points { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 4px; }
.point { flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 128px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.point:hover { border-color: var(--primary); }
.point.active { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(31, 94, 255, .25); }
.point.bad { border-color: var(--bad); }
.point-day { font-size: 12px; }
.point-day::first-letter { text-transform: uppercase; }
.point-time { font-size: 19px; font-weight: 700; line-height: 1.2; }
.point-meta { font-size: 11.5px; color: var(--muted); }
.point.active .point-meta { color: rgba(255, 255, 255, .85); }
.point.bad .point-meta:last-child { color: var(--bad); }
.point.active.bad .point-meta:last-child { color: #fff; }
.restore-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.restore-nav .crumbs { flex: 1; margin: 0; font-family: inherit; font-size: 13.5px; }
.restore-nav .crumbs a:last-child { color: var(--text); font-weight: 600; }
.restore-filter { width: 230px; margin: 0; flex: none; }
.browser td.cb { width: 34px; }
.entry { display: flex; align-items: center; gap: 10px; }
.entry-icon { font-size: 18px; width: 22px; text-align: center; }
.selection { margin-top: 8px; }
.selection-head { display: flex; gap: 14px; align-items: baseline; margin-bottom: 6px; }
.selection-head a { cursor: pointer; }
.sel-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sel-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 10px; border-radius: 999px; background: var(--info-bg); color: var(--primary-d); font-size: 12.5px; }
.sel-chip button { border: 0; background: none; color: inherit; font-size: 15px; line-height: 1; padding: 0 6px; cursor: pointer; }

.field { margin-bottom: 12px; }
.field-title { font-weight: 600; font-size: 13px; }
.field > .hint { font-size: 12px; color: var(--muted); display: block; margin: 3px 0 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.week { display: grid; grid-template-columns: 38px repeat(24, minmax(12px, 1fr)); gap: 2px; user-select: none; touch-action: none; margin-bottom: 8px; }
.week .hd { font-size: 10px; color: var(--muted); text-align: center; cursor: pointer; }
.week .day { font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; }
.week .slot { height: 22px; padding: 0; border: 1px solid #dfe4ee; border-radius: 4px; background: #f3f5f9; cursor: pointer; }
.week .slot:hover { border-color: var(--primary); }
.week .slot.on { background: var(--primary); border-color: var(--primary); }
.week.off { opacity: .35; pointer-events: none; }
.inline-row { font-size: 13px; margin-bottom: 8px; }
.inline-row select { display: inline-block; width: auto; margin: 0 6px; padding: 4px 8px; }
.inline-row input[type=number] { display: inline-block; width: 72px; margin: 0 6px; padding: 4px 8px; }
.inline-row.indent { margin: -6px 0 12px 26px; }
.test-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; }
.test-row input { width: 260px; margin: 0; }
.sched-summary { font-size: 12.5px; margin-bottom: 8px; }
details.adv { margin-bottom: 4px; }
details.adv summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.source-picker { margin: -4px 0 14px; }
.extra-box { border-top: 1px solid var(--border); padding-top: 12px; margin: 4px 0 14px; display: grid; gap: 6px; justify-items: start; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 6px 0 10px; }
.chips label.check { margin: 0; }
.fs-explorer { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 10px; }
.fs-explorer .browser { max-height: 300px; margin-bottom: 10px; }
.fs-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; padding: 32px; border-radius: 14px; width: 360px; border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(20,30,60,.08); }

.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1c2433; color: #fff; padding: 12px 16px; border-radius: 8px; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .main { padding: 18px; }
  .kv { grid-template-columns: 1fr; }
}
.usercode { display: inline-block; font-size: 22px; letter-spacing: 3px; padding: 6px 14px; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { flex: none; width: 30px; height: 30px; color: #4f86ff; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; fill: none; }
.brand-mark ellipse, .brand-mark .db { fill: currentColor; stroke: none; }
.brand-lg .brand-mark { width: 38px; height: 38px; color: var(--primary); }

/* ---------- Panel: widgets («portlets») al estilo de las consolas de protección ---------- */
:root {
  --s-ok: #2eb872; --s-run: #2f80ed; --s-warn: #f2a33a; --s-bad: #e5484d; --s-off: #6b7a90; --s-none: #c3cad6;
}
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.sw.ok { background: var(--s-ok); } .sw.run { background: var(--s-run); } .sw.warn { background: var(--s-warn); }
.sw.bad { background: var(--s-bad); } .sw.off { background: var(--s-off); } .sw.none { background: var(--s-none); }

.widgets { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.portlet { background: #fff; border: 1px solid #dfe4ec; border-radius: 6px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  display: flex; flex-direction: column; min-width: 0; }
.portlet.w4 { grid-column: span 4; } .portlet.w8 { grid-column: span 8; } .portlet.w12 { grid-column: span 12; }
.portlet > header { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid #edf0f5; }
.portlet > header h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: #1d2939; }
.portlet-sub { font-size: 12px; color: var(--muted); background: #f2f4f7; border-radius: 10px; padding: 1px 8px; }
.portlet-sub:empty { display: none; }
.portlet-link { margin-left: auto; font-size: 12.5px; }
.portlet-body { padding: 14px 16px; flex: 1; }
.portlet-body > .table-wrap { margin: -14px -16px; }
.portlet-body table th { background: #f8fafc; }
.portlet-body table td, .portlet-body table th { padding: 8px 16px; }

.donut-row { display: flex; align-items: center; gap: 14px; }
.chart-box { min-height: 220px; }
.donut { position: relative; width: 108px; height: 108px; flex: none; }
.donut svg { width: 100%; height: 100%; }
.donut-track { fill: none; stroke: #eef1f5; stroke-width: 15; }
.donut-seg { fill: none; stroke-width: 15; transition: stroke-width .15s; cursor: default; }
.donut-seg:hover { stroke-width: 18; }
.donut-seg.ok { stroke: var(--s-ok); } .donut-seg.run { stroke: var(--s-run); } .donut-seg.warn { stroke: var(--s-warn); }
.donut-seg.bad { stroke: var(--s-bad); } .donut-seg.off { stroke: var(--s-off); } .donut-seg.none { stroke: var(--s-none); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-size: 22px; line-height: 1.1; color: #101828; }
.donut-center span { font-size: 11px; color: var(--muted); }

.legend-list { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 0; font-size: 12px; }
.legend-list li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; padding: 4px 0; }
.legend-list li + li { border-top: 1px dashed #edf0f5; }
.legend-list li.zero { opacity: .45; }
.legend-list a, .legend-list span { color: #344054; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-list b { font-weight: 600; color: #101828; text-align: right; }
.legend-list em { font-style: normal; color: var(--muted); text-align: right; font-size: 11.5px; }

.chart-legend { display: flex; gap: 6px 14px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.chart-legend i { margin-right: -8px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: #edf0f5; }
.chart .grid-line.base { stroke: #cfd6e2; }
.chart .axis-label { font-size: 10px; fill: #8a94a6; text-anchor: middle; }
.chart .axis-label.end { text-anchor: end; }
.chart .axis-label.today { fill: var(--primary); font-weight: 700; }
.chart .bar.ok { fill: var(--s-ok); } .chart .bar.warn { fill: var(--s-warn); } .chart .bar.bad { fill: var(--s-bad); }
.chart .bar-hover { fill: transparent; }
.chart .bar-group:hover .bar-hover { fill: #f2f5fa; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hbar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: #344054; }
.hbar { height: 8px; background: #eef1f5; border-radius: 4px; margin: 5px 0 3px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 4px; background: var(--s-ok); }
.hbar-fill.run { background: var(--s-run); }
.hbar-sub { font-size: 11.5px; color: var(--muted); }

.all-good { display: flex; align-items: center; gap: 10px; padding: 18px 4px; color: #344054; }

@media (max-width: 1100px) { .portlet.w4 { grid-column: span 6; } .portlet.w8 { grid-column: span 12; } }
@media (max-width: 760px) { .portlet.w4, .portlet.w8 { grid-column: span 12; } .donut-row { flex-direction: column; align-items: stretch; } .donut { margin: 0 auto; } }
