:root {
    --bg: #0f172a;
    --bg-soft: rgba(255, 255, 255, .04);
    --bg-card: rgba(255, 255, 255, .06);
    --border: rgba(255, 255, 255, .10);
    --border-strong: rgba(255, 255, 255, .18);
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --accent: #0ea5e9;
    --accent-2: #38bdf8;
    --success: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
}

* { box-sizing: border-box; }
body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

header {
    padding: 24px 32px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-bottom: 1px solid var(--border);
}
header h1 { margin: 0 0 4px 0; font-size: 22px; }
header p { margin: 0; color: var(--text-dim); font-size: 13px; }

main {
    max-width: 1280px;
    margin: 24px auto;
    padding: 0 20px;
    display: grid;
    gap: 20px;
}

footer {
    text-align: center;
    color: var(--text-dim);
    padding: 24px;
    font-size: 12px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
}
.card h2 {
    margin: 0 0 16px 0;
    font-size: 16px;
    letter-spacing: .3px;
    color: var(--accent-2);
}
.card h2 small { font-weight: 400; color: var(--text-dim); font-size: 12px; }
.card h4 {
    margin: 20px 0 10px 0;
    font-size: 13px;
    color: var(--text);
    letter-spacing: .3px;
}
.card h4 small { font-weight: 400; color: var(--text-dim); font-size: 11px; }

.grid-2 {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
}
.grid-2 .span-2 { grid-column: span 2; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } .grid-2 .span-2 { grid-column: auto; } }

label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 12px; color: var(--text-dim);
}
label.check {
    flex-direction: row; align-items: center; gap: 8px;
    grid-column: span 2;
    color: var(--text);
}
label .req { color: var(--danger); }
label small { font-weight: 400; color: var(--text-dim); font-size: 10px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text);
    font-size: 13px;
    outline: 0;
    transition: border-color .15s;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .14);
}
input[type="checkbox"] { accent-color: var(--accent); }
select { cursor: pointer; }
textarea.json-area {
    width: 100%;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 11px;
    resize: vertical;
    min-height: 120px;
}

.profile-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.profile-row .grow { flex: 1; min-width: 240px; }
.profile-summary {
    margin-top: 12px; padding: 10px 14px;
    background: rgba(14, 165, 233, .06);
    border: 1px solid rgba(14, 165, 233, .2);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-dim);
    font-family: ui-monospace, Consolas, monospace;
    display: none;
}
.profile-summary.show { display: block; }
.profile-summary .row { margin: 2px 0; }
.profile-summary .row strong { color: var(--accent-2); margin-right: 8px; }

.hint {
    margin: 10px 0 0;
    color: var(--text-dim);
    font-size: 11px;
    padding: 8px 12px;
    background: rgba(14, 165, 233, .08);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}
.hint code { background: rgba(0,0,0,.3); padding: 1px 5px; border-radius: 3px; font-size: 10px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
button {
    background: var(--bg-soft);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}
button:hover:not(:disabled) {
    background: rgba(14, 165, 233, .12);
    border-color: var(--accent);
    color: var(--accent-2);
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border: 0; color: #fff;
    box-shadow: 0 4px 12px rgba(14, 165, 233, .25);
}
button.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(14, 165, 233, .4);
    color: #fff;
}
button.danger {
    border-color: rgba(239, 68, 68, .3);
    color: #fca5a5;
}
button.danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, .14);
    border-color: var(--danger);
    color: #fff;
}
button.ghost { /* default; explicit class for readability */ }

.progress { margin-top: 16px; }
.progress.hidden { display: none; }
.bar { height: 8px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    width: 0%;
    transition: width .3s;
}
#progressText { font-size: 12px; color: var(--text-dim); font-family: monospace; }
.current-step { margin-top: 10px; font-size: 12px; color: var(--text-dim); font-family: monospace; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
    background: transparent; border: 0; border-bottom: 2px solid transparent;
    padding: 8px 14px; border-radius: 0;
    color: var(--text-dim); cursor: pointer;
    font-size: 12px; font-weight: 600;
}
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.shot {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    display: flex; flex-direction: column;
    position: relative;
}
.shot.fail { border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .05); }
.shot img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    object-position: top left;
    background: #000;
    cursor: zoom-in;
}
.shot .placeholder {
    aspect-ratio: 16 / 10;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-dim);
    font-size: 36px;
}
.shot .meta { padding: 8px 10px; font-size: 11px; border-top: 1px solid var(--border); }
.shot .meta .name { color: var(--text); font-weight: 600; margin-bottom: 2px; }
.shot .meta .slug { color: var(--text-dim); font-family: monospace; }
.shot .meta .err { color: var(--danger); font-size: 10px; margin-top: 4px; word-break: break-word; }
.shot .badge { position: absolute; top: 4px; right: 4px; padding: 1px 5px; border-radius: 3px; font-size: 9px; font-weight: 700; }
.shot .shot-del {
    position: absolute; top: 4px; left: 4px;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(239, 68, 68, .8); color: #fff; border: 0;
    font-size: 14px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .15s;
    z-index: 2; padding: 0;
}
.shot:hover .shot-del { opacity: 1; }
.shot .shot-del:hover { background: #ef4444; transform: scale(1.1); }
.shot.success .badge { background: var(--success); color: #052; }
.shot.fail .badge { background: var(--danger); color: #fff; }

.logs {
    background: #020617;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    max-height: 400px;
    overflow-y: auto;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
    color: var(--text);
    white-space: pre-wrap;
    margin: 0;
}
.logs .info  { color: #cbd5e1; }
.logs .warn  { color: var(--warn); }
.logs .error { color: var(--danger); }

/* ===================== MODAL ===================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-content {
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; color: var(--accent-2); }
.modal-close {
    background: transparent; border: 0; color: var(--text-dim);
    font-size: 24px; cursor: pointer; padding: 0; width: 32px; height: 32px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 14px 22px; border-top: 1px solid var(--border);
}

/* Image preview modal */
.img-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,.85);
    display: none; align-items: center; justify-content: center;
    z-index: 99999; padding: 20px;
}
.img-modal.open { display: flex; }
.img-modal img { max-width: 95vw; max-height: 90vh; border-radius: 4px; }
.img-modal .close {
    position: absolute; top: 20px; right: 30px;
    color: #fff; font-size: 32px; cursor: pointer;
    background: rgba(0,0,0,.5); border-radius: 50%;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
}
