/* LG Backup — panel de administración. Tema claro, legible, estilo JetBackup:
   fondo gris muy claro, tarjetas blancas, barra lateral clara con acento azul,
   tablas nítidas y badges de estado. Sin modo oscuro. */

:root {
  color-scheme: light;
  --bg:        #eef1f6;
  --surface:   #ffffff;
  --surface-2: #f6f8fb;
  --border:    #e2e7ee;
  --border-2:  #cfd7e3;
  --text:      #1f2d3d;
  --text-2:    #46586e;
  --muted:     #7a8aa0;
  --primary:   #2563eb;
  --primary-d: #1d4ed8;
  --primary-bg:#eaf1ff;
  --ok:   #1a9d5a;
  --ok-bg:#e6f6ee;
  --warn: #b8770a;
  --warn-bg:#fbf1dd;
  --fail: #d93a34;
  --fail-bg:#fdeceb;
  --info-bg:#e8f0fe;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(24,39,60,.05), 0 1px 3px rgba(24,39,60,.06);
  --shadow-lg: 0 4px 16px rgba(24,39,60,.10);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }

.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), #4f83f7);
  color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.brand-name { font-weight: 700; letter-spacing: .2px; font-size: 16px; color: var(--text); }
.nav { display: flex; flex-direction: column; padding: 12px 12px; gap: 1px; overflow-y: auto; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); padding: 14px 12px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  color: var(--text-2); text-decoration: none;
  padding: 9px 12px; border-radius: 7px; font-weight: 500; font-size: 14.5px;
  border-left: 3px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-bg); color: var(--primary-d); border-left-color: var(--primary); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Content ---------- */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px; height: 60px;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 650; }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.badge { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; }
.page { padding: 26px 30px; display: flex; flex-direction: column; gap: 22px; max-width: 1200px; width: 100%; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h2 { font-size: 15.5px; margin: 0; font-weight: 650; }
.card-pad-0 { padding: 0; }
.card-pad-0 .card-head { padding: 16px 20px 0; margin-bottom: 12px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.kpi { display: flex; flex-direction: column; gap: 4px; position: relative; }
.kpi-ic { position: absolute; top: 0; right: 0; width: 34px; height: 34px; border-radius: 8px; background: var(--primary-bg); color: var(--primary); display: grid; place-items: center; }
.kpi-ic svg { width: 19px; height: 19px; }
.kpi-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi-value { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-alert .kpi-ic { background: var(--fail-bg); color: var(--fail); }
.kpi-alert .kpi-value { color: var(--fail); }

/* ---------- Health ---------- */
.health-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.seg { display: block; }
.seg-ok { background: var(--ok); } .seg-warn { background: var(--warn); } .seg-fail { background: var(--fail); }
.legend { display: flex; gap: 20px; margin-top: 13px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-fail { background: var(--fail); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; background: var(--surface-2); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table.rows-0 { padding: 0; }
.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 13px; color: var(--text-2); }

/* ---------- Pills / tags ---------- */
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; display: inline-block; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-fail, .pill-aborted { background: var(--fail-bg); color: var(--fail); }
.pill-running { background: var(--info-bg); color: var(--primary-d); }
.tag { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border-2); color: var(--text-2); background: var(--surface-2); }
.tag-priority { color: var(--primary-d); border-color: #b9d0ff; background: var(--primary-bg); }
.tag-internal { color: var(--warn); border-color: #e6d3a3; background: var(--warn-bg); }
.tag-courtesy { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn, .btn-secondary, .btn-ghost, .btn-danger {
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: 7px; border: 1px solid transparent; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px; line-height: 1;
}
.btn { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn:hover { background: var(--primary-d); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-d); background: var(--primary-bg); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--fail); border-color: #ecc3c1; }
.btn-danger:hover { background: var(--fail-bg); }
.btn svg, .btn-secondary svg, .btn-danger svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.page-actions { display: flex; justify-content: flex-end; gap: 10px; }
.form-card { max-width: 760px; }
.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form input, .form select, .form textarea {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 7px; padding: 10px 12px; font-size: 14.5px; font-family: inherit;
}
.form textarea { font-family: var(--mono); font-size: 13px; min-height: 84px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 3px solid var(--primary-bg); outline-offset: 0; border-color: var(--primary); }
.hint { font-size: 12.5px; color: var(--muted); }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 0; }
fieldset legend { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; padding: 0 6px; }

/* ---------- Flash / callouts ---------- */
.flash { background: var(--info-bg); border: 1px solid #bcd3fb; color: #1a3a7a; padding: 13px 16px; border-radius: 8px; font-size: 14px; }
.flash-ok { background: var(--ok-bg); border-color: #bfe6cf; color: #15603a; }
.flash-fail { background: var(--fail-bg); border-color: #f0c4c1; color: #8f2620; }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 28px; margin: 0; }
.kv > div { display: flex; flex-direction: column; gap: 2px; }
.kv dt { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-size: 14.5px; }

.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.actions form { margin: 0; }
/* Bloques de recuperación rápida */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.quick { margin: 0; }
.quick-card {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 16px; cursor: pointer; text-align: left; font-family: inherit; transition: border-color .12s, background .12s;
}
.quick-card:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-bg); }
.quick-card:disabled { opacity: .5; cursor: not-allowed; }
.quick-ic { font-size: 22px; line-height: 1; }
.quick-t { font-weight: 650; font-size: 14.5px; color: var(--text); }
.quick-s { font-size: 12.5px; color: var(--muted); }
.quick-all { border-color: var(--primary); background: var(--primary-bg); }
@media (max-width: 860px) { .quick-grid { grid-template-columns: repeat(2, 1fr); } }

/* Barra de selección de restauración (carrito) */
.cartbar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border: 1px solid var(--primary); border-radius: 10px;
  padding: 14px 18px; box-shadow: var(--shadow-lg); font-size: 15px;
}

/* Opciones del paso final */
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.opt-card { border: 1px solid var(--border); border-radius: 10px; padding: 18px; background: var(--surface-2); }
.opt-card h3 { margin: 0 0 8px; font-size: 15px; }
.opt-card p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.opt-card.danger { border-color: #ecc3c1; background: #fdf6f5; }
@media (max-width: 860px) { .two-cols { grid-template-columns: 1fr; } }

/* Migas de pan (navegador de restore) */
.crumbs { font-size: 14px; color: var(--muted); font-family: var(--mono); word-break: break-all; }
.crumbs a { color: var(--primary); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Paginador */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); }
.pager .btn-secondary { text-decoration: none; }

/* Indicador de pasos (fases de una restauración) */
.steps { display: flex; align-items: center; gap: 0; }
.step {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border-2); flex: none;
}
.step.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.step.done { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cf; }
.step-line { height: 2px; flex: 1; background: var(--border-2); max-width: 90px; }
.step-line.done { background: var(--ok); }

/* Panel de progreso de copia en curso */
.prog-bar { height: 14px; background: var(--surface-2); border-radius: 7px; overflow: hidden; border: 1px solid var(--border); }
.prog-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #4f83f7); width: 0; transition: width .5s ease; }
.prog-meta { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
.prog-meta b { font-weight: 700; }
.prog-current { margin-top: 8px; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Buscador (combobox) */
.combo { position: relative; }
.combo-dd { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border-2); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; z-index: 15; margin-top: 4px; }
.combo-opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.combo-opt:hover { background: var(--primary-bg); }

/* Globos de ayuda (tooltips) */
.info { display: inline-flex; width: 15px; height: 15px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--muted); font-size: 10px; font-weight: 700; font-style: normal; align-items: center; justify-content: center; cursor: help; position: relative; }
.info::after { content: attr(data-tip); position: absolute; bottom: 150%; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); padding: 8px 11px; border-radius: 7px; font-size: 12px; font-weight: 400; line-height: 1.45; white-space: normal; width: 240px; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s; z-index: 30; box-shadow: var(--shadow-lg); }
.info:hover::after { opacity: 1; visibility: visible; }

/* Spinner de carga en botones que lanzan acciones (SSH, backups…) */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: lg-spin .6s linear infinite; vertical-align: -2px; }
@keyframes lg-spin { to { transform: rotate(360deg); } }
button:disabled, .btn[aria-busy="true"] { opacity: .75; cursor: progress; pointer-events: none; }

/* Herramientas del selector (filtro + acciones rápidas) */
.picker-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.picker-tools input { flex: 1; padding: 7px 10px; border: 1px solid var(--border-2); border-radius: 7px; font-size: 13px; font-family: inherit; }
.picker-tools .btn-ghost { padding: 5px 10px; font-size: 12.5px; }
.sel-summary { font-size: 13.5px; color: var(--primary-d); background: var(--primary-bg); border: 1px solid #bcd3fb; border-radius: 8px; padding: 9px 13px; }

.picker { max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: var(--surface-2); display: flex; flex-wrap: wrap; }
.picker .chip input, fieldset label input { margin: 0 2px 0 0; }
.sub { font-size: 14px; margin: 22px 0 10px; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; font-family: var(--mono); }
.muted { color: var(--muted); }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty { text-align: center; padding: 40px 16px; }
.empty p { margin: 4px 0; }
.empty .btn { margin-top: 16px; }

/* ---------- Meters ---------- */
.meter { height: 8px; background: var(--surface-2); border-radius: 5px; overflow: hidden; min-width: 90px; }
.meter > span { display: block; height: 100%; background: var(--primary); }
.meter.warn > span { background: var(--warn); }
.meter.fail > span { background: var(--fail); }

/* ---------- Timeline (planificación) ---------- */
.tl { display: flex; flex-direction: column; gap: 8px; }
.tl-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 12px; }
.tl-label { font-size: 13px; color: var(--text-2); text-align: right; }
.tl-track { position: relative; height: 26px; background: var(--surface-2); border-radius: 6px; }
.tl-bar { position: absolute; top: 4px; height: 18px; border-radius: 4px; background: var(--primary); opacity: .85; }
.tl-axis { display: grid; grid-template-columns: repeat(24, 1fr); font-size: 10px; color: var(--muted); margin-left: 162px; }
.hist { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.hist-bar { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.hist-bar.peak { background: var(--warn); }
.hist-x { display: flex; gap: 3px; margin-top: 6px; }
.hist-x span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}

/* Resumen de estado de operaciones (dashboard) */
.queue-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.queue-box { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 9px; padding: 14px 16px; background: var(--surface-2); }
.queue-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; font-weight: 700; flex: none; }
.queue-n { display: block; font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.queue-l { display: block; font-size: 12.5px; color: var(--muted); }
@media (max-width: 860px) { .queue-grid { grid-template-columns: repeat(2, 1fr); } }

/* Interruptores on/off en tablas */
.toggle {
  width: 40px; height: 22px; border-radius: 999px; border: 1px solid var(--border-2);
  background: var(--surface-2); position: relative; cursor: pointer; padding: 0; transition: background .15s, border-color .15s;
}
.toggle span { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle.on { background: var(--ok-bg); border-color: #bfe6cf; }
.toggle.on span { transform: translateX(18px); background: var(--ok); }
