/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --blue:       #2563eb;
    --blue-dark:  #1d4ed8;
    --green:      #16a34a;
    --red:        #dc2626;
    --amber:      #d97706;
    --gray-50:    #f8fafc;
    --gray-100:   #f1f5f9;
    --gray-200:   #e2e8f0;
    --gray-400:   #94a3b8;
    --gray-600:   #475569;
    --gray-800:   #1e293b;
    --white:      #ffffff;
    --radius:     10px;
    --shadow:     0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --transition: .18s ease;
}

html { font-size: 16px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Layout ── */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* ── Header ── */
.app-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.app-header .container { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700; color: var(--gray-800); }
.logo .badge {
    background: var(--blue);
    color: white;
    font-size: .65rem;
    padding: 1px 6px;
    border-radius: 99px;
    font-weight: 600;
    letter-spacing: .05em;
}
.header-nav { display: flex; gap: 20px; }
.header-nav a { color: var(--gray-600); text-decoration: none; font-size: .9rem; transition: color var(--transition); }
.header-nav a:hover { color: var(--blue); }

/* ── Hero / Single URL section ── */
.hero-section {
    padding: 52px 0 36px;
    text-align: center;
}
.hero-section h1 {
    font-size: 2rem; font-weight: 800; color: var(--gray-800);
    margin-bottom: 10px; line-height: 1.25;
}
.hero-section > p {
    color: var(--gray-600); font-size: 1.05rem;
    max-width: 560px; margin: 0 auto 28px;
}

/* Single box */
.single-box {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    padding: 28px 28px 24px;
    box-shadow: var(--shadow);
    max-width: 780px;
    margin: 0 auto;
}
.single-input-row {
    display: flex; gap: 10px; align-items: stretch;
}
.single-input-row input[type="url"] {
    flex: 1; padding: 13px 16px;
    border: 1.5px solid var(--gray-200); border-radius: 8px;
    font-size: 1rem; color: var(--gray-800);
    transition: border-color var(--transition);
    background: var(--white);
    min-width: 0;
}
.single-input-row input[type="url"]:focus {
    outline: none; border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.single-input-row input[type="url"]::placeholder { color: var(--gray-400); }
.single-input-row .btn { white-space: nowrap; padding: 13px 24px; font-size: 1rem; }

/* Result box */
.single-result {
    margin-top: 20px;
    text-align: left;
}
.result-success {
    background: #f0fdf4; border: 1px solid #bbf7d0;
    border-radius: 10px; padding: 18px 20px;
}
.result-success .result-label {
    font-size: .78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--green); margin-bottom: 6px;
}
.result-url-wrap {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.result-url {
    font-family: 'JetBrains Mono','Consolas',monospace;
    font-size: .88rem; color: var(--blue-dark);
    word-break: break-all; flex: 1;
    background: var(--white); border: 1px solid #bfdbfe;
    border-radius: 6px; padding: 8px 12px;
}
.result-meta {
    margin-top: 10px;
    display: flex; gap: 12px; flex-wrap: wrap;
}
.result-chip {
    background: var(--white); border: 1px solid var(--gray-200);
    border-radius: 99px; padding: 2px 10px;
    font-size: .75rem; color: var(--gray-600);
}
.result-image-preview {
    margin-top: 14px;
}
.result-image-preview img {
    max-height: 160px; max-width: 100%;
    border-radius: 8px; border: 1px solid var(--gray-200);
    object-fit: contain; background: var(--gray-50);
}
.result-error {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: 10px; padding: 18px 20px;
}
.result-error .result-label {
    font-size: .78rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--red); margin-bottom: 6px;
}
.result-error p { color: #991b1b; font-size: .92rem; }

.result-loading {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 0; color: var(--gray-600); font-size: .95rem;
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section sub-text */
.section-sub { color: var(--gray-600); font-size: .95rem; margin-bottom: 20px; margin-top: -12px; }

/* ── Cards ── */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 24px; color: var(--gray-800); }

/* ── Drop zone ── */
.drop-zone {
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    position: relative;
    background: var(--gray-50);
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--blue);
    background: #eff6ff;
}
.drop-zone-inner { pointer-events: none; }
.drop-zone-inner svg { margin-bottom: 12px; }
.drop-zone-inner p  { color: var(--gray-600); margin-bottom: 4px; }
.drop-zone-inner .sub  { font-size: .9rem; color: var(--gray-400); }
.drop-zone-inner .hint { font-size: .8rem; color: var(--gray-400); margin-top: 8px; }
.file-input-hidden {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* File preview */
.file-preview {
    display: flex; align-items: center; gap: 12px;
    background: #eff6ff; border: 1px solid #bfdbfe;
    border-radius: 8px; padding: 12px 16px;
    margin-top: 12px; font-size: .9rem;
}
.file-preview .file-icon { font-size: 1.4rem; }
.file-preview .file-name { font-weight: 600; color: var(--blue-dark); }
.file-preview .file-size { color: var(--gray-400); font-size: .8rem; }

/* ── Settings ── */
.settings-panel { margin-top: 24px; }
.settings-panel summary {
    cursor: pointer; font-weight: 600; color: var(--gray-600);
    padding: 10px 0; font-size: .95rem;
    list-style: none; display: flex; align-items: center; gap: 6px;
}
.settings-panel summary::-webkit-details-marker { display: none; }
.settings-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px; padding: 16px 0;
}
.field-wide { grid-column: 1 / -1; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.field input[type="text"],
.field input[type="number"] {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--gray-200); border-radius: 6px;
    font-size: .9rem; color: var(--gray-800);
    transition: border-color var(--transition);
    background: var(--white);
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.field small { display: block; font-size: .75rem; color: var(--gray-400); margin-top: 4px; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 22px; border-radius: 8px;
    font-size: .95rem; font-weight: 600; cursor: pointer;
    border: none; transition: background var(--transition), opacity var(--transition), transform var(--transition);
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primary  { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger   { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }

.form-actions { margin-top: 24px; display: flex; align-items: center; gap: 16px; }
.upload-hint  { color: var(--gray-400); font-size: .85rem; }

/* ── Progress ── */
.progress-stats {
    display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.stat-box {
    flex: 1; min-width: 100px;
    background: var(--gray-50); border: 1px solid var(--gray-200);
    border-radius: 8px; padding: 14px 16px; text-align: center;
}
.stat-box.success { background: #f0fdf4; border-color: #bbf7d0; }
.stat-box.error   { background: #fef2f2; border-color: #fecaca; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--gray-800); }
.stat-label { font-size: .75rem; color: var(--gray-400); margin-top: 2px; }

.progress-bar-wrap {
    background: var(--gray-100); border-radius: 99px;
    height: 10px; overflow: hidden; margin-bottom: 12px;
}
.progress-bar {
    height: 100%; background: linear-gradient(90deg, var(--blue), #60a5fa);
    border-radius: 99px; transition: width .4s ease;
}
.progress-status { font-size: .9rem; color: var(--gray-600); margin-bottom: 16px; }
.progress-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* ── Logs ── */
.log-panel { margin-top: 12px; }
.log-panel summary { cursor: pointer; font-weight: 600; color: var(--gray-600); padding: 8px 0; font-size: .9rem; }
.log-output {
    background: #0f172a; color: #e2e8f0;
    border-radius: 8px; padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: .78rem; line-height: 1.6;
    max-height: 320px; overflow-y: auto;
    margin-top: 8px; white-space: pre-wrap; word-break: break-all;
}
.log-info    { color: #93c5fd; }
.log-success { color: #86efac; }
.log-warning { color: #fcd34d; }
.log-error   { color: #fca5a5; }

/* ── Jobs table ── */
.table-wrap { overflow-x: auto; }
.jobs-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.jobs-table th {
    background: var(--gray-50); border-bottom: 2px solid var(--gray-200);
    padding: 10px 12px; text-align: left; font-weight: 600; color: var(--gray-600);
}
.jobs-table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); }
.jobs-table tr:last-child td { border-bottom: none; }
.jobs-table tr:hover td { background: var(--gray-50); }
.filename { font-family: monospace; font-size: .85rem; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.success-count { color: var(--green); font-size: .82rem; }

/* Status badges */
.status-badge {
    display: inline-block; padding: 2px 10px; border-radius: 99px;
    font-size: .78rem; font-weight: 600;
}
.status-pending  { background: #fef3c7; color: #92400e; }
.status-running  { background: #dbeafe; color: #1e40af; }
.status-done     { background: #d1fae5; color: #065f46; }
.status-failed   { background: #fee2e2; color: #991b1b; }
.status-stopped  { background: var(--gray-100); color: var(--gray-600); }

/* ── Footer ── */
.app-footer { border-top: 1px solid var(--gray-200); padding: 20px 0; margin-top: 40px; }
.app-footer p { font-size: .8rem; color: var(--gray-400); text-align: center; }

/* ── Utility ── */
.hidden { display: none !important; }
.empty-state { color: var(--gray-400); font-style: italic; padding: 12px 0; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .hero h1 { font-size: 1.4rem; }
    .card { padding: 20px 16px; }
    .progress-stats { gap: 10px; }
    .stat-value { font-size: 1.2rem; }
    .settings-grid { grid-template-columns: 1fr; }
}
