:root {
    --ink: #162033;
    --muted: #697386;
    --line: #e6e9ef;
    --surface: #ffffff;
    --canvas: #f6f8fb;
    --navy: #17243a;
    --blue: #2864dc;
    --blue-soft: #eaf1ff;
    --green: #16845b;
    --green-soft: #e9f7f1;
    --red: #d24b4b;
    --red-soft: #fceeee;
    --amber: #a76412;
    --amber-soft: #fff3dc;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }

.topbar {
    height: 72px;
    padding: 0 max(24px, calc((100vw - 1240px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: white;
    background: var(--navy);
    box-shadow: 0 4px 20px rgba(15, 24, 40, .14);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-weight: 750; letter-spacing: -.01em; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: #2e6fe4; }
.brand-mark svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.connection { display: flex; align-items: center; gap: 8px; color: #ced7e6; font-size: 13px; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: #4dd49b; box-shadow: 0 0 0 4px rgba(77,212,155,.12); }
.connection.is-offline i { background: #ef6a6a; box-shadow: 0 0 0 4px rgba(239,106,106,.12); }

.primary-button { border: 0; border-radius: 8px; padding: 11px 16px; color: white; background: var(--blue); font-weight: 700; box-shadow: 0 4px 12px rgba(40,100,220,.22); }
.primary-button:hover { background: #1e56c2; }
.bulk-button { background: var(--green); box-shadow: 0 4px 12px rgba(22,132,91,.2); }
.bulk-button:hover { background: #106b49; }
.secondary-button, .danger-button { border: 1px solid #d6dce6; border-radius: 8px; padding: 9px 13px; font-weight: 700; background: white; }
.secondary-button { color: var(--blue); }
.secondary-button:hover { border-color: #9db8ed; background: var(--blue-soft); }
.danger-button { color: var(--red); border-color: #edc1c1; }
.danger-button:hover { background: var(--red-soft); }
.secondary-button:disabled, .danger-button:disabled { cursor: wait; opacity: .55; }
.page-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 64px; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 9px; color: var(--blue); font-size: 11px; font-weight: 850; letter-spacing: .14em; }
.hero h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); line-height: 1.13; letter-spacing: -.035em; }
.hero > div > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.last-update { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.last-update strong { color: var(--ink); font-weight: 650; }

.notice { margin-bottom: 18px; padding: 13px 16px; border: 1px solid; border-radius: 9px; font-size: 14px; }
.notice-success { color: #106242; border-color: #b9e1d1; background: var(--green-soft); }
.notice-error { color: #a43737; border-color: #f1c5c5; background: var(--red-soft); }

.download-panel { display: none; margin-bottom: 24px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 36px rgba(20,33,54,.06); }
.download-panel.is-open { display: block; animation: panel-in .2s ease-out; }
@keyframes panel-in { from { transform: translateY(-6px); opacity: 0; } }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.panel-heading h2, .section-head h2 { margin: 0; font-size: 19px; letter-spacing: -.015em; }
.panel-heading p, .section-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { width: 36px; height: 36px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 24px; line-height: 1; }
.icon-button:hover { color: var(--ink); background: #f0f2f6; }
.download-panel label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 750; }
.download-form-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: stretch; }
textarea { min-height: 88px; resize: vertical; padding: 12px 14px; color: var(--ink); border: 1px solid #d5dae3; border-radius: 8px; outline: none; }
textarea:focus, input:focus, select:focus { border-color: #7da5ee; box-shadow: 0 0 0 3px rgba(40,100,220,.1); }
.submit-button { align-self: stretch; }
.form-hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.runner-panel { margin-bottom: 24px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 28px rgba(20,33,54,.045); }
.runner-summary { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.runner-summary h2 { margin: 0; font-size: 19px; }
.runner-summary > div > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.runner-state { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; color: #596579; background: #eef1f5; font-size: 12px; font-weight: 750; }
.runner-state i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.runner-state.is-active { color: var(--blue); background: var(--blue-soft); }
.runner-state.is-idle { color: var(--green); background: var(--green-soft); }
.runner-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 17px; }
.runner-actions button:disabled { cursor: not-allowed; opacity: .48; }
.runner-message { margin-top: 13px; padding: 10px 12px; border-radius: 8px; color: #3e4b5e; background: #f1f4f8; font-size: 12px; }
.runner-message.is-success { color: #106242; background: var(--green-soft); }
.runner-message.is-error { color: #a43737; background: var(--red-soft); }
.runner-log-wrap { margin-top: 17px; overflow: hidden; border: 1px solid #273449; border-radius: 9px; background: #111a28; }
.runner-log-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; color: #c8d3e2; background: #182438; }
.runner-log-head label { font-size: 12px; font-weight: 750; }
.runner-log-head select { height: 32px; color: #dce5f2; border-color: #3a4960; background: #111a28; }
.runner-log-wrap pre { max-height: 420px; min-height: 180px; overflow: auto; margin: 0; padding: 14px; color: #dce5f2; background: #111a28; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 34px; }
.stat-card { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 18px; text-align: left; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--surface); box-shadow: 0 5px 18px rgba(20,33,54,.035); transition: transform .15s, border-color .15s; }
.stat-card:hover { transform: translateY(-2px); border-color: #ccd4e2; }
.stat-card.is-selected { border-color: #91afe9; box-shadow: 0 0 0 2px rgba(40,100,220,.08); }
.stat-card span:last-child { min-width: 0; }
.stat-card small { display: block; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.stat-card strong { display: block; margin-top: 1px; font-size: 25px; line-height: 1.15; }
.stat-icon { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 9px; font-size: 18px; font-weight: 800; }
.stat-icon.neutral { color: #536279; background: #edf0f5; }
.stat-icon.active { color: var(--blue); background: var(--blue-soft); }
.stat-icon.waiting { color: var(--amber); background: var(--amber-soft); }
.stat-icon.completed { color: var(--green); background: var(--green-soft); }
.stat-icon.failed { color: var(--red); background: var(--red-soft); }
.stat-icon.skipped { color: #697386; background: #edf0f5; }

.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 14px; }
.table-tools { display: flex; align-items: center; gap: 9px; }
.search-box { min-width: 245px; height: 39px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid #d9dee7; border-radius: 8px; background: white; color: #8690a0; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; box-shadow: none; font-size: 13px; }
select { height: 39px; padding: 0 30px 0 11px; border: 1px solid #d9dee7; border-radius: 8px; color: var(--ink); background: white; font-size: 13px; outline: none; }
.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 8px 28px rgba(20,33,54,.045); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: 12px 18px; color: #7a8494; background: #fbfcfd; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
th:first-child { width: 28%; } th:nth-child(2) { width: 12%; } th:nth-child(3) { width: 13%; } th:nth-child(4) { width: 8%; } th:nth-child(5) { width: 13%; } th:nth-child(6) { width: 12%; } th:nth-child(7) { width: 9%; } th:last-child { width: 86px; }
td { height: 72px; padding: 12px 18px; border-bottom: 1px solid #edf0f4; vertical-align: middle; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fbfcff; }
.video-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.video-icon { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 8px; color: #607087; background: #edf1f6; font-size: 16px; }
.video-copy { min-width: 0; }
.video-title { overflow: hidden; margin-bottom: 4px; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.video-subtitle { overflow: hidden; color: var(--muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--blue); background: var(--blue-soft); }
.badge.waiting { color: var(--amber); background: var(--amber-soft); }
.badge.completed { color: var(--green); background: var(--green-soft); }
.badge.failed { color: var(--red); background: var(--red-soft); }
.badge.interrupted { color: var(--amber); background: var(--amber-soft); }
.badge.skipped { color: #697386; background: #edf0f5; }
.progress-wrap { display: flex; align-items: center; gap: 9px; }
.progress-track { width: 78px; height: 5px; overflow: hidden; border-radius: 5px; background: #e8ebf0; }
.progress-bar { height: 100%; border-radius: inherit; background: var(--blue); transition: width .3s; }
.progress-wrap.done .progress-bar { background: var(--green); }
.progress-wrap.failed .progress-bar { background: var(--red); }
.progress-text { min-width: 30px; color: var(--muted); font-size: 11px; }
.duration-pill { display: inline-flex; align-items: center; min-width: 58px; padding: 5px 8px; border-radius: 7px; color: #334155; background: #f1f4f8; font-size: 12px; font-weight: 750; white-space: nowrap; }
.file-pill { max-width: 100%; display: inline-flex; align-items: center; overflow: hidden; padding: 5px 8px; border-radius: 7px; font-size: 11px; font-weight: 750; white-space: nowrap; text-overflow: ellipsis; }
.file-pill.is-present { color: var(--green); background: var(--green-soft); }
.file-pill.is-missing { color: var(--red); background: var(--red-soft); }
.file-pill.is-unknown { color: #697386; background: #edf0f5; }
.date-cell strong { display: block; font-weight: 650; }
.date-cell span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.source { max-width: 100%; display: inline-flex; align-items: center; gap: 6px; overflow: hidden; color: #556176; font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-action { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 7px; color: #6d7787; background: transparent; font-size: 20px; text-decoration: none; }
.play-action { font-size: 13px; color: var(--green); }
.row-action:hover { color: var(--blue); background: var(--blue-soft); }
.play-action:hover { color: var(--green); background: var(--green-soft); }
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state > span { width: 46px; height: 46px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 12px; color: #67768e; background: #edf1f6; font-size: 22px; }
.empty-state h3 { margin: 0; font-size: 16px; }
.empty-state p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

dialog { width: min(900px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 13px; color: var(--ink); background: white; box-shadow: 0 28px 80px rgba(12,21,36,.32); }
dialog::backdrop { background: rgba(12,20,33,.62); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 20px; }
.dialog-meta { display: flex; flex-wrap: wrap; gap: 9px 20px; padding: 12px 22px; color: var(--muted); background: #f8fafc; font-size: 12px; }
.dialog-meta .meta-path { flex-basis: 100%; overflow-wrap: anywhere; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.dialog-meta .meta-path strong { color: var(--ink); font-family: inherit; }
dialog pre { max-height: 60vh; overflow: auto; margin: 0; padding: 20px 22px; color: #dce5f2; background: #111a28; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 22px; border-top: 1px solid var(--line); background: white; }
.dialog-actions[hidden] { display: none; }
.dialog-actions > span { color: var(--muted); font-size: 12px; }
.dialog-actions > div { display: flex; gap: 9px; flex: 0 0 auto; }
.dialog-actions.is-success > span { color: var(--green); font-weight: 700; }
.dialog-actions.is-error > span { color: var(--red); font-weight: 700; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(3, 1fr); }
    .section-head { align-items: stretch; flex-direction: column; }
    th:first-child { width: 290px; }
    .table-tools { justify-content: flex-start; }
}

@media (max-width: 640px) {
    .topbar { height: 64px; padding: 0 16px; }
    .brand > span:last-child, .connection { display: none; }
    .page-shell { width: min(100% - 28px, 1240px); padding-top: 30px; }
    .hero { align-items: flex-start; flex-direction: column; gap: 12px; }
    .last-update { display: none; }
    .stats { gap: 10px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 13px; }
    .stat-icon { width: 34px; height: 34px; flex-basis: 34px; }
    .download-form-row { grid-template-columns: 1fr; }
    .runner-summary { align-items: flex-start; flex-direction: column; gap: 12px; }
    .runner-actions { flex-direction: column; }
    .runner-actions button { width: 100%; }
    .runner-log-head { align-items: stretch; flex-direction: column; }
    .table-tools { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 0; }
    .table-scroll { overflow-x: visible; }
    table, tbody { display: block; }
    thead { display: none; }
    tbody { padding: 6px 14px; }
    tbody tr { display: grid; grid-template-columns: 1fr auto; padding: 14px 0; border-bottom: 1px solid var(--line); }
    tbody tr:last-child { border-bottom: 0; }
    td { display: block; height: auto; padding: 5px 0; border: 0; }
    td:first-child { grid-column: 1 / -1; }
    td:nth-child(3) { grid-column: 1 / -1; }
    td:nth-child(4), td:nth-child(5), td:nth-child(6), td:nth-child(7) { color: var(--muted); }
    td:last-child { grid-column: 2; grid-row: 2; }
    .dialog-actions { align-items: stretch; flex-direction: column; }
    .dialog-actions > div { flex-direction: column; }
}
