:root {
    color-scheme: light;
    --ink: #25313a;
    --muted: #68757f;
    --paper: #f1f4f5;
    --surface: #fff;
    --line: #dce3e6;
    --accent: #176b87;
    --accent-hover: #10566e;
    --success: #267653;
    --success-hover: #1d6243;
    --danger: #b94a48;
    --danger-hover: #983b3a;
    --radius: 6px;
}

* { box-sizing: border-box; }
body { margin: 24px; background: var(--paper); color: var(--ink); font-family: Arial, sans-serif; font-size: 14px; line-height: 1.45; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; }
h1 { margin: 0 0 16px; font-size: 25px; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 18px 0 10px; font-size: 16px; }
a { color: var(--accent); }
.container { max-width: 1240px; margin: 0 auto 16px; padding: 18px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 8px rgba(35, 54, 64, .045); }

button, .btn-edit-mass, .btn-sort, .btn-save, .btn-move {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 11px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
button:hover, .btn-edit-mass:hover, .btn-sort:hover, .btn-save:hover, .btn-move:hover { background: var(--accent-hover); color: #fff; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(23, 107, 135, .25); outline-offset: 2px; }
input, select, textarea { max-width: 100%; border: 1px solid #cbd5da; border-radius: 4px; background: #fff; color: var(--ink); font: inherit; }
input, select { min-height: 36px; padding: 7px 9px; margin-bottom: 10px; }
textarea { padding: 10px; }
label { color: var(--ink); }
hr { height: 1px; border: 0; background: var(--line); }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.form-group input:not([type="checkbox"]):not([type="color"]), .form-group select { width: 100%; }
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); font-weight: 600; text-decoration: none; }
.back-link:hover { color: var(--accent); }

/* Navigation */
.nav-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; }
.nav-group { position: relative; display: inline-block; }
.nav-btn { display: inline-flex; min-height: 34px; align-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: #f5f7f8; color: #394750; font-weight: 600; cursor: pointer; }
.nav-btn:hover { background: #e9eff1; }
.dropdown-content { display: none; position: absolute; top: 100%; left: 0; z-index: 10; width: max-content; min-width: 220px; max-width: calc(100vw - 24px); overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); box-shadow: 0 8px 20px rgba(35, 54, 64, .14); }
.nav-group:hover .dropdown-content, .nav-group:focus-within .dropdown-content { display: block; }
.dropdown-item { display: flex; align-items: center; padding: 8px 11px; border-bottom: 1px solid #edf0f1; }
.dropdown-item:last-child { border-bottom: 0; }
.dropdown-item:hover { background: #f4f7f8; }
.dropdown-item a.list-link { flex-grow: 1; color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap; }
.nav-home { display: inline-flex; min-height: 34px; align-items: center; padding: 7px 10px; border-radius: 4px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.nav-home:hover { background: var(--accent-hover); color: #fff; }
.nav-create { flex: 0 0 34px; width: 34px; height: 34px; min-height: 34px; margin-left: auto; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #f5f7f8; color: #394750; font-size: 20px; }
.nav-create:hover { background: #e9eff1; color: var(--ink); }
.nav-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.nav-actions .nav-create { margin-left: 0; }
.nav-add-movie { flex: 0 0 34px; width: 34px; height: 34px; min-height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #f5f7f8; color: #394750; font-size: 18px; }
.nav-add-movie:hover { background: #e9eff1; color: var(--ink); }
.button-success { background: var(--success); }
.button-success:hover { background: var(--success-hover); }
.button-danger { background: var(--danger); }
.button-danger:hover { background: var(--danger-hover); }
.button-neutral { background: #59666e; }
.button-neutral:hover { background: #46535b; }
.button-plain { min-width: 34px; padding: 6px; border-color: var(--line); background: #fff; color: var(--muted); }
.button-plain:hover { background: #f1f4f5; color: var(--ink); }
.header-icon-button { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 4px; background: #f5f7f8; color: #394750; font-size: 17px; line-height: 1; text-decoration: none; }
.header-icon-button:hover { background: #e9eff1; color: var(--ink); }

/* Movie list */
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.header-actions h1 { margin: 0; }
.list-header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 16px; }
.filter-search { flex: 1; min-width: 200px; margin-bottom: 0; }
.filter-bar select { width: auto; margin-bottom: 0; }
.result-count { margin-left: auto; color: var(--muted); white-space: nowrap; }
.movie-list { display: flex; flex-direction: column; gap: 3px; }
.movie-item { display: flex; align-items: center; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); box-shadow: 0 1px 2px rgba(35, 54, 64, .035); }
.movie-group { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: stretch; gap: 8px; }
.movie-group-films { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.movie-group-label { display: flex; align-items: center; justify-content: center; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: #f5f7f8; color: var(--accent); font-size: 30px; font-weight: 700; white-space: nowrap; }
.movie-rank { display: flex; flex: 0 0 38px; align-items: center; justify-content: flex-end; margin-right: 6px; color: var(--accent); font-size: 16px; font-weight: 700; }
.movie-poster { flex-shrink: 0; width: 92px; height: 138px; margin-right: 12px; cursor: pointer; }
.movie-poster img { display: block; width: 92px !important; height: 138px !important; border-radius: 4px; object-fit: cover; }
.movie-info { display: flex; flex-grow: 1; flex-direction: column; justify-content: center; min-width: 0; }
.movie-title-ru { color: var(--accent); font-size: 20px; font-weight: 700; text-decoration: none; }
.movie-title-ru:hover { text-decoration: underline; }
.movie-title-orig { margin-top: 3px; color: var(--muted); font-size: 14px; }
.movie-meta { margin-top: 4px; color: var(--muted); font-size: 14px; }
.movie-rating { flex-shrink: 0; margin: 0 16px 0 14px; color: var(--ink); font-size: 30px; font-weight: 700; }
.movie-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.grid-item { position: relative; box-sizing: content-box; width: 185px; height: 278px; overflow: hidden; border: 5px solid transparent; border-radius: 6px; cursor: pointer; }
.grid-item-bordered { border-color: var(--poster-border-color); }
.grid-item img { display: block; width: 185px !important; height: 278px !important; object-fit: cover; }
.no-poster, .no-poster-grid { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5px; border-radius: 4px; background: #dce3e6; color: #394750; font-weight: 700; line-height: 1.2; text-align: center; }
.no-poster { width: 92px; height: 138px; font-size: 10px; }
.no-poster-grid { width: 185px; height: 278px; font-size: 14px; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.page-indicator { padding: 7px 11px; border: 1px solid var(--line); border-radius: 4px; background: #f5f7f8; color: var(--muted); }
.empty-state { padding: 20px; color: var(--muted); text-align: center; }
.movie-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.movie-link:hover, .director-link:hover { text-decoration: underline; }
.director-link { color: #477d87; text-decoration: none; }
.movie-director { color: var(--muted); text-decoration: none; }

/* Tables and detail pages */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid #e8edef; text-align: left; vertical-align: middle; }
th { background: #f5f7f8; color: #46545d; font-size: 12px; font-weight: 700; }
tbody tr:hover { background: #f8fafb; }
.stats-box { display: flex; flex-wrap: wrap; gap: 12px 24px; color: var(--muted); }
.stats-box strong, .stats-box span { color: var(--ink); font-weight: 700; }
.role-badge { display: inline-block; margin: 2px 3px 2px 0; padding: 3px 7px; border-radius: 3px; background: #edf3f4; color: #47656e; font-size: 12px; }
.movie-layout { display: flex; align-items: flex-start; gap: 24px; }
.movie-content { flex-grow: 1; min-width: 0; }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.movie-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.movie-title-row h1 { margin: 0 0 4px; font-size: 26px; }
.movie-rating-large { color: var(--success); font-size: 28px; font-weight: 700; }
.movie-year { color: var(--muted); font-size: 14px; }
.status-block { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #f6f8f9; }
.status-controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.status-controls select { width: auto; margin-bottom: 0; }
.accolade-row { display: flex; flex-direction: column; gap: 5px; padding: 10px 0; border-bottom: 1px solid #e8edef; }
.accolade-heading, .accolade-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.accolade-year { padding: 2px 6px; border-radius: 3px; background: #f1f4f5; color: var(--muted); font-size: 12px; font-weight: 700; }
.accolade-list-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.accolade-list-link:hover, .accolade-people a:hover { color: var(--accent); text-decoration: underline; }
.accolade-rank { padding: 2px 7px; border-radius: 10px; background: #edf3f4; color: #47656e; font-size: 12px; font-weight: 600; }
.accolade-meta { color: var(--muted); font-size: 13px; }
.accolade-points { color: var(--ink); font-weight: 600; }
.accolade-divider { color: #aab6bc; }
.accolade-people { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.accolade-people a { color: var(--accent); text-decoration: none; }
.accolade-comma { color: var(--muted); }
.crew-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.crew-list li { min-width: 0; margin: 0; }
.crew-list li > div { display: flex; min-height: 42px; align-items: center; gap: 8px; padding: 6px 9px; border: 1px solid #e4e9ec; border-radius: 4px; background: #fafbfc; }
.crew-list .role { flex-shrink: 0; padding: 3px 7px; border-radius: 3px; background: #edf3f4; color: #47656e; font-size: 12px; font-weight: 700; }
.crew-list a { color: var(--accent); font-weight: 600; text-decoration: none; }
.crew-list a:hover { text-decoration: underline; }
.crew-list .crew-empty { grid-column: 1 / -1; padding: 8px 0; color: var(--muted); text-align: center; }
.accolade-group { padding: 10px 0; border-bottom: 1px solid #e8edef; }
.accolade-group:last-child { border-bottom: 0; }
.accolade-group-title { display: block; margin-bottom: 2px; color: var(--muted); font-size: 13px; font-weight: 700; }
.person-accolade-list .accolade-row { padding: 7px 0; border-bottom: 0; }
.person-filmography th { padding: 7px 9px; }
.person-filmography td { padding: 8px 9px; }
.person-filmography tbody tr:nth-child(even) { background: #fafbfc; }
.person-filmography tbody tr:hover { background: #f1f5f6; }

/* Forms and dialogs */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.editor-container { max-width: 800px; }
.settings-container { max-width: 640px; }
.hint, .form-hint { margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.form-check { margin-bottom: 12px; }
.form-check label { display: inline; }
.form-check input, label input[type="checkbox"] { min-height: auto; margin: 0 5px 0 0; vertical-align: middle; }
textarea[name="mass_data"] { width: 100%; height: 360px; font-family: Consolas, monospace; font-size: 13px; }
.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(23, 35, 42, .78); }
.modal img { max-width: 90%; max-height: 90%; border-radius: 6px; }
.modal.show { display: flex; }
.modal-content { width: 500px; max-width: 100%; max-height: 90vh; overflow-y: auto; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 16px 40px rgba(0, 0, 0, .22); }
.movie-create-modal { width: 620px; }
.movie-create-modal h2 { margin-bottom: 14px; }
.movie-create-modal > form > label { display: block; margin: 9px 0 4px; font-weight: 600; }
.movie-create-modal > form > input { width: 100%; margin-bottom: 3px; }
.new-movie-crew { min-width: 0; margin: 16px 0 10px; padding: 10px; border: 1px solid var(--line); border-radius: 5px; }
.new-movie-crew legend { padding: 0 5px; color: var(--muted); font-size: 13px; font-weight: 700; }
.new-movie-crew-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 34px; gap: 7px; margin-bottom: 7px; }
.new-movie-crew-row:last-child { margin-bottom: 0; }
.new-movie-crew-row select, .new-movie-crew-row input { width: 100%; min-width: 0; margin-bottom: 0; }
.crew-remove-row { width: 34px; min-height: 34px; padding: 0; border-color: var(--line); background: #fff; color: var(--danger); font-size: 20px; }
.crew-remove-row:hover { background: #fbefef; color: var(--danger-hover); }
.crew-add-row { min-height: 30px; margin-top: 8px; padding: 5px 8px; border-color: var(--line); background: #f5f7f8; color: var(--ink); font-size: 13px; }
.crew-add-row:hover { background: #e9eff1; color: var(--ink); }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal-actions button { flex: 1; }
.modal-panel { width: 400px; max-width: 100%; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.modal-panel input, .modal-panel select { width: 100%; margin-bottom: 9px; }
.modal-panel button { width: 100%; margin-top: 5px; }
.modal-content > form > label { display: block; margin: 8px 0 4px; font-weight: 600; }
.modal-content > form > input, .modal-content > form > button { width: 100%; margin-bottom: 8px; }
.modal-content > form:last-of-type button, .modal-content > button { width: 100%; margin-top: 8px; }
.crew-edit-item { display: flex; gap: 8px; margin-bottom: 6px; }
.crew-edit-item form { display: flex; width: 100%; gap: 6px; }
.crew-edit-item select { flex: 0 0 120px; margin-bottom: 0; }
.crew-edit-item input { flex: 1; min-width: 0; margin-bottom: 0; }
.crew-edit-item button { flex-shrink: 0; }
.crew-edit-list { max-height: 200px; overflow-y: auto; margin-bottom: 12px; }
.view-toggle { min-width: 36px; padding: 6px; }
.random-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.random-form select { min-width: 220px; margin-bottom: 0; }
.result { margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #f6f8f9; color: var(--ink); }
.color-dot { display: inline-block; width: 8px; height: 8px; margin-left: 4px; border: 1px solid rgba(0, 0, 0, .12); border-radius: 50%; }
.hidden { display: none !important; }

@media (max-width: 760px) {
    body { margin: 12px; }
    .container { padding: 14px; }
    .movie-layout { gap: 16px; }
    .filter-bar { align-items: stretch; }
    .filter-search { flex-basis: 100%; }
    .result-count { margin-left: 0; }
}

@media (max-width: 560px) {
    body { margin: 8px; }
    .container { padding: 12px; }
    .movie-item { padding: 0 6px; }
    .movie-poster { margin-right: 10px; }
    .movie-rating { margin: 0 12px 0 8px; font-size: 22px; }
    .movie-layout { flex-direction: column; }
    .movie-title-row h1 { font-size: 22px; }
    .movie-rating-large { font-size: 22px; }
    .movie-group { grid-template-columns: 76px minmax(0, 1fr); gap: 6px; }
    .movie-group-label { padding: 4px; font-size: 22px; }
    .crew-edit-item { flex-wrap: wrap; }
    .crew-edit-item select { flex-basis: 100%; }
    .new-movie-crew-row { grid-template-columns: minmax(0, 1fr) 34px; }
    .new-movie-crew-row select { grid-column: 1 / -1; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
}