:root {
    --bg: #0f1420;
    --panel: #171e2e;
    --panel-2: #1e2739;
    --border: #2a3550;
    --text: #e6ebf5;
    --muted: #8b97b0;
    --accent: #4c8dff;
    --ok: #33c481;
    --err: #ff5d5d;
    --run: #f0b429;
    --radius: 10px;
}

* { box-sizing: border-box; }

/* Garante que o atributo HTML [hidden] sempre esconda o elemento, mesmo quando
   ha uma regra de display concorrente (ex.: .modal{display:grid},
   label{display:block}). Sem isto, esconder via JS (el.hidden=true) nao funciona. */
[hidden] { display: none !important; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.link { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--err); }

/* ---- Topbar ---- */
.topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 12px 24px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a {
    padding: 6px 12px; border-radius: 8px; color: var(--muted);
}
.topbar nav a.active, .topbar nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.logout-form { margin-left: auto; }

/* ---- Layout ---- */
.main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.main-login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 780px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}

/* ---- Form controls ---- */
label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
input, select, textarea {
    display: block; width: 100%; margin-top: 4px;
    padding: 9px 11px; background: var(--panel-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
textarea { resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; }
label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.checkbox input { width: auto; margin: 0; }
.row { display: flex; gap: 12px; }
.grow { flex: 1; }
.w120 { width: 120px; }
small { display: block; margin-top: 4px; }

.btn, .btn-ghost {
    display: inline-block; padding: 9px 16px; border-radius: 8px;
    border: 1px solid var(--border); font: inherit; cursor: pointer;
}
.btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-go { background: var(--ok); border-color: var(--ok); }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-row { display: flex; gap: 10px; margin-top: 6px; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.table tr:last-child td { border-bottom: none; }

.badge { padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.ok { background: rgba(51,196,129,.15); color: var(--ok); }
.badge.err { background: rgba(255,93,93,.15); color: var(--err); }
.badge.run { background: rgba(240,180,41,.15); color: var(--run); }

.actions-cell { display: flex; gap: 8px; }
.mini { padding: 4px 10px; font-size: .82rem; }

/* ---- Login ---- */
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px; width: 340px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-card .btn { width: 100%; margin-top: 8px; }

/* ---- Modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 520px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 1.7rem; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 8px; }
.modal-close:hover { color: var(--text); background: var(--panel-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; position: sticky; bottom: -24px; background: var(--panel); padding: 12px 0 0; }

/* ---- Preflight ---- */
.preflight-list { list-style: none; padding: 0; margin: 0; }
.preflight-list li { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; background: var(--panel-2); display: flex; gap: 8px; align-items: flex-start; }
.preflight-list li .mark { font-weight: 700; }
.pf-ok .mark { color: var(--ok); }
.pf-err .mark { color: var(--err); }
.pf-warn .mark { color: var(--run); }

/* ---- Execution / terminal ---- */
.exec-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.states { display: flex; gap: 6px; flex-wrap: wrap; }
.states span { padding: 3px 10px; border-radius: 999px; font-size: .78rem; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.states span.active { background: var(--run); color: #1a1200; border-color: var(--run); }
.states span.done { background: var(--ok); color: #04220f; border-color: var(--ok); }
.states span.failed { background: var(--err); color: #2a0000; border-color: var(--err); }

.terminal {
    background: #0a0e17; color: #cfe3ff; border: 1px solid var(--border);
    border-radius: 10px; padding: 14px; margin-top: 14px;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem;
    max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}

/* ---- Progress bar ---- */
.progress-wrap { margin-top: 16px; }
.progress-track {
    height: 14px; background: var(--panel-2); border: 1px solid var(--border);
    border-radius: 999px; overflow: hidden;
}
.progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), #6aa8ff);
    border-radius: 999px; transition: width .4s ease;
}
.progress-fill.done { background: linear-gradient(90deg, var(--ok), #5bd99b); }
.progress-fill.failed { background: linear-gradient(90deg, var(--err), #ff8a8a); }
.progress-row { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.progress-pct { font-weight: 700; font-size: 1.05rem; }
.progress-label { font-size: .85rem; }

/* ---- Info panel (sizes / rate) ---- */
.migr-info { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.info-item {
    flex: 1; min-width: 140px; background: var(--panel-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px;
}
.info-label { display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.info-val { display: block; font-size: 1.15rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.banner { padding: 12px 16px; border-radius: 10px; margin-top: 14px; font-weight: 600; }
.banner.ok { background: rgba(51,196,129,.15); color: var(--ok); border: 1px solid var(--ok); }
.banner.err { background: rgba(255,93,93,.15); color: var(--err); border: 1px solid var(--err); }
