:root {
    color-scheme: light;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #20232a;
    background: #f3f5f8;
    line-height: 1.45;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: #f3f5f8;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

input,
select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid #aeb6c2;
    border-radius: 6px;
    background: #fff;
    color: #20232a;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(84, 59, 143, 0.25);
    outline-offset: 2px;
    border-color: #5d3f95;
}

textarea {
    resize: vertical;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.2rem;
}

h2 {
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
    color: #3d4652;
}

.container {
    width: min(100%, 1800px);
    margin: 0 auto;
    padding: 1rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header form {
    margin: 0;
}

.muted {
    margin-bottom: 0;
    color: #687384;
}

.panel {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #dce1e8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(31, 38, 50, 0.05);
}

.controls {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}

.filter-fields {
    display: grid;
    width: min(100%, 860px);
    grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.6fr);
    gap: 0.75rem 1rem;
}

.filter-fields h2 {
    grid-column: 1 / -1;
    margin-bottom: 0;
}

.result-summary {
    font-weight: 700;
    white-space: nowrap;
}

.add-panel summary {
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
}

.add-panel[open] summary {
    margin-bottom: 1rem;
}

.movie-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    gap: 0.85rem 1rem;
}

.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
}

.primary-button,
.secondary-button,
.danger-button {
    min-height: 2.35rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 700;
}

.primary-button {
    background: #56398c;
    color: #fff;
}

.primary-button:hover {
    background: #442b73;
}

.secondary-button {
    border-color: #aeb6c2;
    background: #fff;
    color: #303846;
}

.secondary-button:hover {
    background: #eef1f5;
}

.danger-button {
    border-color: #b73d49;
    background: #fff;
    color: #a22431;
}

.danger-button:hover {
    background: #fff0f1;
}

.compact-button {
    min-height: 1.9rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.82rem;
}

.table-panel {
    padding: 0;
    overflow: hidden;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    min-width: 1350px;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th,
td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid #dfe3e8;
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #e8def5;
    color: #31224e;
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background: #f8f9fb;
}

tbody tr:hover {
    background: #eef8f1;
}

td {
    max-width: 260px;
    overflow-wrap: anywhere;
}

.number-column {
    width: 4rem;
    text-align: right;
}

.sort-button,
.link-button,
.icon-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
}


.sort-button {
    font-weight: 800;
}

.sort-arrow {
    display: inline-block;
    min-width: 1em;
}

.link-button {
    margin-left: 0.35rem;
    color: #55378b;
    font-size: 0.78rem;
    font-weight: 800;
    text-decoration: underline;
}

.actions {
    display: flex;
    gap: 0.4rem;
    min-width: 135px;
}

.empty-state {
    max-width: none;
    padding: 2rem;
    text-align: center;
    color: #687384;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.85rem;
    border-top: 1px solid #dfe3e8;
}

dialog {
    width: min(1100px, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 22px 70px rgba(24, 29, 39, 0.35);
}

dialog::backdrop {
    background: rgba(20, 24, 32, 0.62);
}

.dialog-form,
.description-card {
    padding: 1.25rem;
}

.dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.dialog-heading h2 {
    margin-bottom: 0;
    font-size: 1.3rem;
}

.icon-button {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    font-size: 1.7rem;
    line-height: 1;
}

.icon-button:hover {
    background: #eef1f5;
}

.description-card {
    white-space: pre-wrap;
}

#description-content {
    margin-top: 1rem;
    margin-bottom: 0;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.login-card {
    width: min(100%, 420px);
    padding: 1.5rem;
    border: 1px solid #dce1e8;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(31, 38, 50, 0.14);
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 6px;
}

.message.error {
    border: 1px solid #e3a4aa;
    background: #fff0f1;
    color: #8d202b;
}



@media (max-width: 980px) {
    .movie-form {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 700px) {
    .container {
        padding: 0.65rem;
    }

    .page-header,
    .controls {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-fields {
        grid-template-columns: 1fr;
    }

    .filter-fields h2 {
        grid-column: auto;
    }

    .page-header .secondary-button {
        width: 100%;
    }

    .result-summary {
        white-space: normal;
    }

    .movie-form {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions button {
        width: 100%;
    }

    table {
        min-width: 1150px;
    }

    .pagination {
        gap: 0.5rem;
    }

    dialog {
        width: calc(100% - 1rem);
        max-height: calc(100vh - 1rem);
    }
}
