:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --surface-1: #151b28;
  --surface-2: #1b2334;
  --surface-3: #232d42;
  --border: #263049;
  --text-primary: #e9edf5;
  --text-secondary: #9aa4b8;
  --text-muted: #6b7690;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  /* categorical (validado para fondo oscuro) */
  --s1: #338ced; --s2: #e76624; --s3: #00a888; --s4: #d28e05;
  --s5: #e24d8b; --s6: #0aac23; --s7: #9887ef; --s8: #eb6263;
  /* estados */
  --good: #22c55e; --warn: #f59e0b; --bad: #ef4444; --info: #38bdf8;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text-primary); font-size: 14px; }
a { color: var(--accent-2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #111728, #0c111d); border-right: 1px solid var(--border);
  padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; background: var(--grad); display: grid; place-items: center; font-weight: 800; box-shadow: 0 6px 20px rgba(124, 92, 255, .45); }
.brand b { font-size: 16px; display: block; }
.brand small { color: var(--text-muted); font-size: 11.5px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-secondary);
  font-weight: 500; transition: .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text-primary); }
.nav a.active { background: rgba(124, 92, 255, .14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.sidebar .foot { margin-top: auto; padding: 12px; color: var(--text-muted); font-size: 12px; }
main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.topbar p { margin: 4px 0 0; color: var(--text-secondary); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: 1fr 1fr; } }
.menu-btn { display: none !important; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 250px; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex !important; }
  main { padding: 18px 14px 60px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

/* ---------- cards ---------- */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card .sub { color: var(--text-secondary); font-size: 12.5px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.kpi { position: relative; overflow: hidden; }
.kpi .icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; }
.kpi .icon svg { width: 21px; height: 21px; }
.kpi .val { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.kpi .lbl { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.kpi .extra { color: var(--text-muted); font-size: 12px; margin-top: 8px; }
.kpi::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: var(--glow, rgba(124, 92, 255, .12)); filter: blur(8px); }
.chart-box { position: relative; height: 270px; }
.chart-box.sm { height: 210px; }

/* ---------- botones / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface-2);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13px; transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #33405f; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 6px 18px rgba(124, 92, 255, .35); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .4); color: #fca5a5; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
label.f small { display: block; color: var(--text-muted); margin-top: 5px; font-size: 12px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .2); }
textarea { min-height: 90px; resize: vertical; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; margin-bottom: 14px; }
.switch input { display: none; }
.switch i { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); position: relative; transition: .2s; flex: none; }
.switch i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 19px; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); position: sticky; top: 0; }
tr:hover td { background: rgba(255, 255, 255, .02); }
td .path { color: var(--text-secondary); font-size: 12px; word-break: break-all; }
td .name { font-weight: 600; word-break: break-word; }
.empty { text-align: center; color: var(--text-muted); padding: 40px 10px; }

/* ---------- badges y barras ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-secondary); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-move { background: rgba(34, 197, 94, .13); color: #4ade80; }
.b-replace { background: rgba(124, 92, 255, .16); color: #b4a3ff; }
.b-exists, .b-dup_batch { background: rgba(148, 163, 184, .13); color: #cbd5e1; }
.b-review, .b-wait { background: rgba(245, 158, 11, .14); color: #fbbf24; }
.b-dup { background: rgba(236, 72, 153, .14); color: #f9a8d4; }
.b-ignore { background: rgba(100, 116, 139, .12); color: #94a3b8; }
.b-done { background: rgba(34, 197, 94, .13); color: #4ade80; }
.b-error, .b-done_errors { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.b-running, .b-analyzing, .b-queued { background: rgba(56, 189, 248, .14); color: #7dd3fc; }
.b-planned { background: rgba(245, 158, 11, .14); color: #fbbf24; }
.b-undone, .b-cancelled { background: rgba(148, 163, 184, .13); color: #cbd5e1; }
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--grad); transition: width .5s; }
.bar.warn > i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.bar.stripes > i { background-image: linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%), var(--grad); background-size: 18px 18px, 100% 100%; animation: move 1s linear infinite; }
@keyframes move { to { background-position: 18px 0, 0 0; } }
.storage-item { margin-bottom: 16px; }
.storage-item .top { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 13px; }
.storage-item .top span { color: var(--text-secondary); }
.task { padding: 12px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task .top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; align-items: center; }
.task .msg { color: var(--text-secondary); font-size: 12.5px; margin-top: 6px; }
.seg { display: flex; height: 14px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface-1); }
.seg > i { display: block; height: 100%; }
.seg > i:first-child { border-radius: 4px 0 0 4px; } .seg > i:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12.5px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 7px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.tab.active { background: rgba(124, 92, 255, .16); border-color: rgba(124, 92, 255, .5); color: #fff; }
.tab b { margin-left: 6px; color: var(--text-primary); }

/* ---------- modal y toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(3, 6, 14, .7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 20px 22px; }
.modal footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.picker-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 10px; }
.picker-list div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.picker-list svg { width: 18px; height: 18px; flex: none; color: var(--accent-2); }
.picker-list div:hover { background: var(--surface-2); }
.crumbs { font-size: 13px; color: var(--text-secondary); word-break: break-all; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s; }
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--good); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 15% 10%, rgba(124, 92, 255, .22), transparent 60%), radial-gradient(700px 500px at 90% 90%, rgba(34, 211, 238, .16), transparent 60%), var(--bg); }
.login .card { width: min(400px, 100%); padding: 32px; box-shadow: var(--shadow); }
.login .brand { padding: 0 0 24px; }
.muted { color: var(--text-secondary); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hr { height: 1px; background: var(--border); margin: 16px 0; }
.help { background: rgba(56, 189, 248, .07); border: 1px solid rgba(56, 189, 248, .25); border-radius: 12px; padding: 12px 14px; color: #bae6fd; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.list-card { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-card:last-child { border-bottom: 0; }
.list-card .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: rgba(124, 92, 255, .14); color: #b4a3ff; flex: none; }
.list-card .ic svg { width: 22px; height: 22px; }
.list-card .grow { flex: 1; min-width: 200px; }
.list-card .grow b { font-size: 15px; }
.spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: sp .8s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
