:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-soft: #f8f9fb;
    --text: #1d2430;
    --muted: #687385;
    --line: #dce1e8;
    --accent: #315f8f;
    --accent-dark: #24496f;
    --danger: #a63434;
    --success: #28764b;
    --shadow: 0 14px 40px rgba(25, 36, 50, 0.16);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
.site-header { background: #172332; color: white; border-bottom: 1px solid #101923; }
.header-inner { max-width: 1400px; margin: auto; padding: 22px 28px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.site-header p { margin: 4px 0 0; color: #c9d3de; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.count-pill { padding: 7px 11px; border: 1px solid #425264; border-radius: 999px; color: #e8edf3; white-space: nowrap; }
.page-shell { max-width: 1400px; margin: 0 auto; padding: 22px 28px 40px; }
.page-shell.narrow { max-width: 860px; }
.filter-bar { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(180px, .45fr) 130px auto; gap: 12px; align-items: end; background: var(--surface); border: 1px solid var(--line); padding: 14px; margin-bottom: 16px; }
label > span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; border: 1px solid #bac3ce; border-radius: 5px; background: white; color: var(--text); padding: 9px 10px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(49,95,143,.17); border-color: var(--accent); }
.filter-actions { display: flex; gap: 7px; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; border: 1px solid var(--accent); border-radius: 5px; background: var(--accent); color: white; text-decoration: none; padding: 9px 13px; cursor: pointer; font-weight: 700; }
.button:hover { background: var(--accent-dark); }
.button-secondary { background: transparent; border-color: #738295; }
.button-secondary:hover { background: #243345; }
.button-quiet { background: white; color: var(--text); border-color: #bac3ce; }
.button-quiet:hover { background: #f0f2f5; }
.notice { padding: 13px 15px; margin-bottom: 16px; background: #edf1f5; border-left: 4px solid #75869a; }
.notice.success { background: #edf8f1; border-color: var(--success); }
.notice.error { background: #fff0f0; border-color: var(--danger); }
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); }
.movie-table { width: 100%; border-collapse: collapse; min-width: 850px; }
.movie-table th, .movie-table td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.movie-table th { position: sticky; top: 0; z-index: 1; background: #edf0f4; color: #384555; font-size: 12px; text-transform: uppercase; letter-spacing: .035em; }
.movie-table tbody tr:hover { background: #f7f9fb; }
.sort-link { color: inherit; text-decoration: none; }
.select-col { width: 38px; text-align: center !important; }
.select-col input { width: 16px; height: 16px; }
.ref-cell { color: var(--muted); white-space: nowrap; }
.movie-link { width: 100%; display: flex; gap: 11px; align-items: center; border: 0; padding: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.movie-link:hover strong { color: var(--accent); text-decoration: underline; }
.movie-link img { width: 38px; height: 53px; object-fit: cover; border-radius: 3px; background: #e3e7ec; flex: none; }
.movie-link span { display: flex; flex-direction: column; min-width: 0; }
.movie-link strong { font-size: 14px; }
.movie-link small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 720px; }
.list-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--muted); padding: 12px 2px; }
.pagination { display: flex; align-items: center; gap: 12px; }
.enquiry-panel { background: var(--surface); border: 1px solid var(--line); margin-top: 12px; }
.enquiry-panel summary { padding: 12px 14px; cursor: pointer; font-weight: 700; }
.enquiry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid var(--line); padding: 14px; }
.enquiry-grid .full { grid-column: 1 / -1; }
.empty-state { text-align: center; background: var(--surface); border: 1px solid var(--line); padding: 55px 20px; }
.empty-state h2 { margin-top: 0; }
.site-footer { max-width: 1400px; margin: 0 auto; padding: 0 28px 30px; color: var(--muted); font-size: 12px; }
dialog { border: 0; padding: 0; border-radius: 8px; box-shadow: var(--shadow); color: var(--text); }
dialog::backdrop { background: rgba(10,18,28,.62); }
.movie-dialog { width: min(1050px, calc(100vw - 34px)); max-height: calc(100vh - 34px); overflow: auto; }
.dialog-close { position: sticky; float: right; top: 8px; right: 8px; z-index: 4; border: 0; border-radius: 50%; width: 34px; height: 34px; background: rgba(22,32,44,.88); color: white; font-size: 24px; cursor: pointer; }
.dialog-content { min-height: 240px; }
.loading { padding: 70px; text-align: center; color: var(--muted); }
.movie-detail { display: grid; grid-template-columns: 300px 1fr; min-height: 500px; }
.detail-cover { background: #18212c; padding: 28px; display: flex; align-items: flex-start; justify-content: center; }
.detail-cover img { width: 100%; max-height: 500px; object-fit: contain; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.cover-placeholder { width: 100%; aspect-ratio: 2/3; display: grid; place-items: center; color: #adbac8; border: 1px dashed #596a7d; }
.detail-body { padding: 30px; }
.detail-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.detail-heading h2 { margin: 2px 0; font-size: 29px; line-height: 1.15; }
.eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; }
.alternate-title { margin: 5px 0 0; color: var(--muted); font-size: 16px; }
.rating-badge { flex: none; background: #e9f0f7; color: #214a73; border-radius: 6px; padding: 8px 10px; font-weight: 800; }
.meta-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.meta-chips span { background: #eef1f4; border-radius: 999px; padding: 5px 9px; color: #475567; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin: 20px 0; }
.detail-grid div { border-top: 1px solid var(--line); padding-top: 8px; }
.detail-grid dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.detail-grid dd { margin: 2px 0 0; }
.description h3 { margin-bottom: 5px; }
.description p, .comments p { white-space: normal; }
.comments { margin: 18px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.comments summary { cursor: pointer; font-weight: 700; }
.external-link { margin-top: 8px; }
.confirm-dialog { width: min(500px, calc(100vw - 34px)); padding: 24px; }
.confirm-dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.message-preview { background: var(--surface); border: 1px solid var(--line); padding: 18px; }
.message-preview pre { margin: 0; white-space: pre-wrap; font: inherit; }
.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; }
code { background: #eef1f4; padding: 1px 4px; border-radius: 3px; }
@media (max-width: 850px) {
    .header-inner { align-items: flex-start; flex-direction: column; padding: 18px; }
    .page-shell { padding: 16px 12px 30px; }
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .movie-detail { grid-template-columns: 1fr; }
    .detail-cover { padding: 20px; }
    .detail-cover img { max-width: 280px; }
    .detail-body { padding: 22px; }
}
@media (max-width: 560px) {
    .filter-bar, .enquiry-grid, .detail-grid { grid-template-columns: 1fr; }
    .search-field, .enquiry-grid .full { grid-column: auto; }
    .filter-actions .button { flex: 1; }
    .list-footer { align-items: flex-start; flex-direction: column; }
    .detail-heading { flex-direction: column; }
}

/* Chunked catalogue rebuild progress */
.import-progress { margin: 18px 0 8px; }
.import-status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.spinner {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border: 3px solid rgba(95, 115, 140, .25);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: import-spin .8s linear infinite;
}
.progress-track {
    width: 100%;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(95, 115, 140, .18);
}
.progress-track > span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: currentColor;
    transition: width .2s ease;
}
.progress-percent { margin-top: 6px; text-align: right; font-variant-numeric: tabular-nums; }
@keyframes import-spin { to { transform: rotate(360deg); } }
