* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: Inter, Arial, sans-serif;
    background: #f6f7fb;
    color: #1d2433
}

header {
    height: 64px;
    background: #fff;
    border-bottom: 1px solid #e7e9ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 5
}

header nav {
    display: flex;
    gap: 18px;
    align-items: center
}

a {
    color: #3156d3;
    text-decoration: none
}

.container {
    max-width: 1500px;
    margin: 28px auto;
    padding: 0 20px
}

.panel {
    background: #fff;
    padding: 22px;
    border-radius: 14px;
    margin: 20px 0;
    box-shadow: 0 4px 20px #1f2a4410
}

.inline-form, .filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    align-items: center;
}

input, select, textarea, button {
    font: inherit
}

input, select, textarea {
    padding: 10px 12px;
    border: 1px solid #cfd5e1;
    border-radius: 8px;
    background: #fff
}

button {
    border: 0;
    border-radius: 8px;
    background: #3156d3;
    color: #fff;
    padding: 10px 14px;
    cursor: pointer
}

.danger {
    background: #c0392b
}

.link-button {
    background: transparent;
    color: #3156d3;
    padding: 0
}

.success, .error {
    padding: 12px;
    border-radius: 8px;
    margin: 10px 0
}

.success {
    background: #e8f7ed
}

.error {
    background: #fdebea;
    color: #8b241d
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff
}

th, td {
    border: 1px solid #e0e4eb;
    padding: 10px;
    text-align: left
}

.schedule-wrap {
    overflow: auto
}

.schedule-grid {
    min-width: 1100px
}

.schedule-mobile {
    display: none
}

.schedule-grid th:first-child {
    width: 85px
}

.schedule-cell {
    height: 110px;
    vertical-align: top;
    position: relative;
    padding: 6px;
    max-width: 100px;
}

.entry {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
    background: #eef2ff;
    color: #17204a;
    padding: 8px
}

.entry span {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    color: #5d6578
}

.add-entry {
    background: transparent;
    color: #8590a5;
    width: 100%;
    font-size: 20px
}

dialog {
    border: 0;
    border-radius: 14px;
    padding: 0;
    box-shadow: 0 20px 70px #0004
}

dialog form {
    min-width: 360px;
    padding: 22px;
    display: grid;
    gap: 12px
}

dialog label {
    display: grid;
    gap: 6px
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center
}

.login-card {
    width: min(390px, 90vw);
    background: #fff;
    padding: 28px;
    border-radius: 16px;
    box-shadow: 0 20px 60px #17204a18;
    display: grid;
    gap: 14px
}

.login-card label {
    display: grid;
    gap: 6px
}

.miniapp .container {
    max-width: 760px
}

.day-card {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    margin: 15px 0
}

.lesson {
    display: flex;
    gap: 16px;
    padding: 13px 0;
    border-top: 1px solid #edf0f5
}

.lesson:first-of-type {
    border-top: 0
}

.lesson time {
    font-weight: 700;
    min-width: 95px
}

.lesson p {
    margin: 5px 0 0;
    color: #697386
}

.hint {
    color: #697386
}

@media (max-width: 700px) {
    header {
        padding: 0 14px
    }

    header nav {
        gap: 10px
    }

    .container {
        margin: 16px auto;
        padding: 0 12px
    }

    .inline-form > * {
        width: 100%
    }

    .login-card {
        padding: 20px
    }
}

.row-edit {
    display: grid;
    grid-template-columns:2fr 1fr 1fr auto auto;
    gap: 8px;
    align-items: center
}

.delete-form {
    margin-top: 8px
}

.levels-table > tbody > tr > td > input {
    width: 100%;
    min-width: 0
}

@media (max-width: 900px) {
    .row-edit {
        grid-template-columns:1fr
    }
}

.bulk-form {
    margin-bottom: 24px
}

.catalog-levels {
    display: grid;
    grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px
}

.catalog-choices {
    border: 1px solid #cfd5e1;
    border-radius: 8px;
    padding: 14px;
    margin: 0 0 14px;
    min-width: 0
}

.catalog-choices legend {
    font-weight: 600;
    padding: 0 6px
}

.catalog-choices label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0
}

.catalog-choices input {
    flex-shrink: 0
}

.bulk-form .inline-form {
    align-items: center
}

.bulk-form .inline-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap
}

.schedule-grid th:first-child {
    width: 145px;
    white-space: nowrap
}

.lesson time {
    min-width: 120px;
    white-space: nowrap
}
.catalog-section > summary {
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 700;
}

.catalog-section > summary h2 {
    display: inline;
    margin: 0;
    font-size: inherit;
}

.catalog-section[open] > summary {
    margin-bottom: 20px;
}

.catalog-section > summary:focus-visible {
    outline: 2px solid #3156d3;
    outline-offset: 6px;
    border-radius: 4px;
}
.mini-group-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin: -8px 0 24px;
}
.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}

.error-card {
    width: min(100%, 560px);
    background: #fff;
    border-radius: 16px;
    padding: clamp(24px, 6vw, 48px);
    box-shadow: 0 12px 40px #17204a12;
    text-align: center;
}

.error-brand { color: #697386; }
.error-code { color: #3156d3; font-size: 4rem; font-weight: 700; margin: 20px 0; }
.error-card h1 { font-size: 1.6rem; }
.error-card p { line-height: 1.6; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 20px; margin-top: 28px; }

@media (min-width: 901px) {
    .levels-table th:nth-child(4),
    .levels-table td:nth-child(4),
    .levels-table th:last-child,
    .levels-table td:last-child {
        width: 1%;
        white-space: nowrap;
    }

    .level-actions {
        display: flex;
        gap: 8px;
    }

    .level-actions .delete-form {
        margin-top: 0;
    }

    .level-actions button {
        width: 120px;
    }
}

@media (max-width: 900px) {
    .admin-page .catalog-section > table,
    .admin-page .catalog-section > table > tbody {
        display: block;
    }

    .admin-page .catalog-section > table > tbody > tr:first-child {
        display: none;
    }

    .admin-page .catalog-section > table > tbody > tr:not(:first-child) {
        display: grid;
        gap: 12px;
        padding: 14px;
        margin-top: 14px;
        border: 1px solid #e0e4eb;
        border-radius: 10px;
    }

    .admin-page .catalog-section td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
    }

    .admin-page .catalog-section td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 6px;
        font-weight: 600;
    }

    .admin-page .catalog-section input:not([type="checkbox"]):not([type="hidden"]),
    .admin-page .catalog-section select,
    .admin-page .catalog-section button {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .admin-page .row-edit {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 700px) {
    .admin-page header {
        height: auto;
        min-height: 64px;
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px 20px;
    }

    .admin-page header nav {
        flex-wrap: wrap;
        gap: 8px 14px;
    }

    .admin-page header nav a,
    .admin-page header nav button {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .admin-page h1 {
        font-size: 1.65rem;
        overflow-wrap: anywhere;
    }

    .admin-page .panel {
        padding: 14px;
        margin: 14px 0;
        overflow-wrap: anywhere;
    }

    .admin-page .catalog-section > summary {
        font-size: 1.25rem;
    }

    .admin-page .catalog-levels {
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-page .catalog-choices legend {
        max-width: 100%;
    }

    .admin-page .filters > * {
        width: 100%;
        min-width: 0;
    }

    .admin-page .schedule-grid {
        display: none;
    }

    .admin-page .schedule-mobile {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        width: 100%;
        padding-bottom: 8px;
    }

    .admin-page .schedule-day {
        overflow: hidden;
        background: #fff;
        border: 1px solid #e0e4eb;
        border-radius: 12px;
    }

    .admin-page .schedule-day h2 {
        margin: 0;
        padding: 14px;
        background: #eef2ff;
        font-size: 1.1rem;
    }

    .admin-page .schedule-slot {
        min-height: 96px;
        max-width: none;
        border: 0;
        border-top: 1px solid #e0e4eb;
        padding: 10px;
    }

    .admin-page .schedule-slot time {
        display: block;
        margin-bottom: 8px;
        color: #5d6578;
        font-size: 0.85rem;
        font-weight: 600;
    }

    .admin-page dialog {
        width: calc(100% - 24px);
        max-width: 440px;
        max-height: calc(100dvh - 24px);
    }

    .admin-page dialog form {
        min-width: 0;
        padding: 16px;
    }

    .admin-page dialog input,
    .admin-page dialog textarea {
        width: 100%;
        min-width: 0;
    }

    .admin-page .dialog-actions {
        flex-wrap: wrap;
    }

    .admin-page .dialog-actions button {
        flex: 1 1 100px;
        min-height: 44px;
    }
}
