:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1f2d3d;
    --muted: #5f6b7a;
    --border: #dbe3ea;
    --accent: #0b6bcb;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
}

.container {
    width: min(1100px, 94%);
    margin: 0 auto;
}

.header {
    padding: 20px 0 8px;
}

.logo {
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.2rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    margin: 14px 0;
    box-shadow: 0 4px 15px rgba(0, 24, 52, 0.05);
}

h1,
h2 {
    margin-top: 0;
}

.upload-form {
    display: grid;
    gap: 12px;
    max-width: 540px;
}

input[type="file"],
select,
button {
    font: inherit;
}

input[type="file"],
select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    width: fit-content;
}

button:hover {
    filter: brightness(0.95);
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

.grid {
    display: grid;
    gap: 12px;
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.grid-4 div {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.grid-4 strong {
    font-size: 1.1rem;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    vertical-align: top;
}

.mono {
    font-family: Consolas, Monaco, monospace;
    font-size: 0.85rem;
}

.links {
    margin: 0;
    padding-left: 18px;
}

.alert {
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 12px;
}

.alert.error {
    border: 1px solid #f7c5c0;
    background: #fff1ef;
    color: var(--danger);
}

.subtitles {
    background: #0f1720;
    color: #d7e2ee;
    border-radius: 8px;
    padding: 12px;
    white-space: pre-wrap;
    max-height: 380px;
    overflow: auto;
}

.task-meta p {
    margin: 6px 0;
}

.hidden {
    display: none !important;
}

.task-live-header {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #c6d9ef;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.live-badge {
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 600;
    font-size: 0.9rem;
}

.live-badge.is-running {
    background: #e8f2ff;
    color: #0b6bcb;
}

.live-badge.is-ready {
    background: #eaf8ee;
    color: #1f7a3f;
}

.live-badge.is-error {
    background: #fff1ef;
    color: #b42318;
}

.progress-track {
    width: 100%;
    height: 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ecf1f7;
    overflow: hidden;
}

.progress-bar {
    width: 4%;
    height: 100%;
    background: linear-gradient(90deg, #0b6bcb 0%, #46a8ff 100%);
    transition: width 0.35s ease;
}

.stage-list {
    list-style: none;
    margin: 12px 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.stage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    transition: color 0.2s ease;
}

.stage-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid #b9c8d7;
    background: #dce5ef;
    flex: 0 0 10px;
    transition: all 0.2s ease;
}

.stage-item.is-done {
    color: #1f7a3f;
}

.stage-item.is-done .stage-dot {
    border-color: #1f7a3f;
    background: #1f7a3f;
}

.stage-item.is-active {
    color: #0b6bcb;
    font-weight: 600;
}

.stage-item.is-active .stage-dot {
    border-color: #0b6bcb;
    background: #0b6bcb;
    box-shadow: 0 0 0 4px rgba(11, 107, 203, 0.16);
    animation: pulse 1.2s infinite;
}

.stage-item.is-error {
    color: #b42318;
    font-weight: 600;
}

.stage-item.is-error .stage-dot {
    border-color: #b42318;
    background: #b42318;
    box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.14);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(11, 107, 203, 0.2);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(11, 107, 203, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(11, 107, 203, 0);
    }
}

@media (max-width: 640px) {
    th,
    td {
        padding: 8px;
        font-size: 0.9rem;
    }

    .card {
        padding: 14px;
    }
}
