:root {
  --bg: #f5f6f8;
  --bg-elevated: #ffffff;
  --border: #e2e4e9;
  --text: #1a1d23;
  --text-muted: #676c76;
  --accent: #3457d5;
  --accent-hover: #2a45ad;
  --green: #1a8a4a;
  --green-bg: #e5f6ec;
  --gray-bg: #eef0f3;
  --red: #c23b3b;
  --red-bg: #fbeaea;
  --shadow: 0 1px 2px rgba(16, 20, 30, 0.06), 0 1px 8px rgba(16, 20, 30, 0.04);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --bg-elevated: #1c1f26;
    --border: #2b2f3a;
    --text: #eef0f4;
    --text-muted: #9199a8;
    --accent: #5b7cfa;
    --accent-hover: #7691ff;
    --green: #3fcf7f;
    --green-bg: rgba(63, 207, 127, 0.12);
    --gray-bg: #262a34;
    --red: #ff6b6b;
    --red-bg: rgba(255, 107, 107, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.24);
  }
}

:root[data-theme="dark"] {
  --bg: #14161b; --bg-elevated: #1c1f26; --border: #2b2f3a; --text: #eef0f4;
  --text-muted: #9199a8; --accent: #5b7cfa; --accent-hover: #7691ff;
  --green: #3fcf7f; --green-bg: rgba(63, 207, 127, 0.12); --gray-bg: #262a34;
  --red: #ff6b6b; --red-bg: rgba(255, 107, 107, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.24);
}
:root[data-theme="light"] {
  --bg: #f5f6f8; --bg-elevated: #ffffff; --border: #e2e4e9; --text: #1a1d23;
  --text-muted: #676c76; --accent: #3457d5; --accent-hover: #2a45ad;
  --green: #1a8a4a; --green-bg: #e5f6ec; --gray-bg: #eef0f3;
  --red: #c23b3b; --red-bg: #fbeaea;
  --shadow: 0 1px 2px rgba(16, 20, 30, 0.06), 0 1px 8px rgba(16, 20, 30, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.arrow { color: var(--accent); font-weight: 700; }
.muted { color: var(--text-muted); }

/* ---------------- Login ---------------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.login-title { margin: 0 0 4px; font-size: 20px; }
.login-subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: 13px; }
.login-error {
  background: var(--red-bg); color: var(--red);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.login-form input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.login-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-block { width: 100%; margin-top: 18px; }

/* ---------------- Layout ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.ws-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.ws-indicator .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.ws-connected .dot { background: var(--green); }
.ws-connected { color: var(--green); }
.ws-disconnected .dot { background: var(--red); }

.tabs {
  display: flex; gap: 4px; padding: 8px 24px; background: var(--bg-elevated);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab-btn {
  border: none; background: transparent; color: var(--text-muted);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab-btn:hover { background: var(--gray-bg); }
.tab-btn.active { background: var(--accent); color: #fff; }

.content { padding: 20px 24px 48px; max-width: 1200px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------- Cards ---------------- */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.stat-card .stat-value { font-size: 24px; font-weight: 600; }
.stat-card .stat-value small { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.progress-track {
  margin-top: 10px; height: 6px; border-radius: 4px; background: var(--gray-bg); overflow: hidden;
}
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }

/* ---------------- Panels / boxes ---------------- */
.panel-box {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel-box-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel-box h2 { margin: 0; font-size: 15px; }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .15s ease, opacity .15s ease;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--gray-bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--gray-bg); }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge-migrado { background: var(--green-bg); color: var(--green); }
.badge-pendiente { background: var(--gray-bg); color: var(--text-muted); }
.badge-idle { background: var(--gray-bg); color: var(--text-muted); }
.badge-running { background: #fff3cd; color: #8a6400; }
.badge-done { background: var(--green-bg); color: var(--green); }
.badge-error { background: var(--red-bg); color: var(--red); }
@media (prefers-color-scheme: dark) { .badge-running { background: rgba(255, 200, 60, 0.15); color: #ffcf5c; } }
:root[data-theme="dark"] .badge-running { background: rgba(255, 200, 60, 0.15); color: #ffcf5c; }

/* ---------------- Tables ---------------- */
.list-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.list-toolbar input[type="search"] {
  flex: 1; min-width: 220px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: 13px;
}
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elevated); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.data-table th {
  text-align: left; padding: 10px 14px; background: var(--gray-bg); color: var(--text-muted);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em;
  position: sticky; top: 0;
}
.data-table td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: top; }
.data-table tr:hover td { background: var(--gray-bg); }
.data-table td.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pagination { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--text-muted); }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented-btn { border: none; background: var(--bg-elevated); color: var(--text-muted); padding: 8px 14px; font-size: 13px; cursor: pointer; }
.segmented-btn.active { background: var(--accent); color: #fff; }

/* ---------------- Console / logs ---------------- */
.console {
  background: #0e1116; color: #d4d8e0; border-radius: var(--radius); padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px;
  height: 480px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
  border: 1px solid var(--border);
}
.console-mini { height: 160px; }

/* ---------------- Toasts ---------------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; box-shadow: var(--shadow); font-size: 13px; max-width: 320px;
  animation: toast-in .2s ease;
}
.toast.toast-error { border-color: var(--red); color: var(--red); }
.toast.toast-success { border-color: var(--green); color: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .tabs { padding: 8px 16px; }
}
