:root {
    --bg: #f5f6fa;
    --card: #ffffff;
    --line: #dde1ea;
    --text: #0b1b33;
    --muted: #8492a6;
    --primary: #4326c9;
    --primary2: #4c6fff;
    --orange: #ff8b12;
    --red: #ff4545;
    --green: #1e9b61;
    --shadow: 0 8px 22px rgba(20, 25, 40, .07);
    --radius: 10px;
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55
}

a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none
}

a:hover {
    text-decoration: underline
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 18px;
    align-items: center;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .04)
}

.brand {
    font-size: 22px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap
}

.brand-icon {
    background: #1f2937;
    color: #fff;
    border-radius: 4px;
    font-size: 16px;
    padding: 1px 5px
}

.nav {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1
}

.nav a {
    padding: 8px 10px;
    border-radius: 9px;
    color: #1c2740;
    text-decoration: none;
    font-weight: 700
}

.nav a:hover,
.nav a.active {
    background: #edf0ff;
    color: var(--primary)
}

.userbox {
    display: flex;
    gap: 10px;
    align-items: center;
    white-space: nowrap;
    font-size: 13px;
    color: var(--muted)
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 18px 12px 48px
}

.footer {
    text-align: center;
    padding: 18px;
    color: var(--muted);
    font-size: 13px
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin: 0 0 18px
}

.page-title h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2
}

.page-title .lead {
    margin: 4px 0 0;
    color: var(--muted)
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px
}

.grid-5 {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px
}

.card {
    background: var(--card);
    border: 1px solid #edf0f5;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden
}

.card-body {
    padding: 26px 24px
}

.card-foot {
    border-top: 1px solid var(--line);
    background: #f6f7fc;
    padding: 16px 24px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap
}

.card h3,
.card h2 {
    margin: 0 0 14px
}

.muted {
    color: var(--muted);
    font-size: 13px
}

.truncate {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 48px
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eef1f7;
    color: #41506a;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 800
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: none
}

.btn:hover {
    text-decoration: none;
    filter: brightness(.96)
}

.btn-sm {
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 13px
}

.btn-orange {
    background: var(--orange);
    color: #081225
}

.btn-red {
    background: var(--red)
}

.btn-green {
    background: var(--green)
}

.btn-light {
    background: #eef1f7;
    color: #24314a
}

.btn-block {
    width: 100%
}

.subject-tree {
    display: none;
    margin-top: 15px;
    border-top: 1px dashed var(--line);
    padding-top: 12px
}

.subject-tree.open {
    display: block
}

.tree-section {
    margin: 10px 0
}

.tree-section strong {
    display: block;
    margin: 8px 0
}

.lesson-link {
    display: block;
    background: #f7f8fc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    margin: 6px 0;
    font-weight: 700;
    color: #1d2a42
}

.lesson-link:hover {
    background: #eef0ff;
    text-decoration: none
}

.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 18px
}

.panel h2,
.panel h3 {
    margin-top: 0
}

.collapsible {
    display: none
}

.collapsible.open {
    display: block
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px
}

.form-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px
}

.field.full {
    grid-column: 1 / -1
}

label {
    font-weight: 800;
    font-size: 13px
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd6e3;
    border-radius: 9px;
    padding: 10px 11px;
    font: inherit;
    background: #fff
}

textarea {
    min-height: 110px;
    resize: vertical
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 12px
}

.table-wrap {
    overflow: auto
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff
}

.table th,
.table td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top
}

.table th {
    background: #f3f5fb;
    font-size: 13px
}

.table tr:hover td {
    background: #fafbff
}

.alert {
    padding: 12px 14px;
    border-radius: 9px;
    margin: 0 0 14px;
    font-weight: 700
}

.alert-ok {
    background: #eaf8f0;
    color: #17643e
}

.alert-error {
    background: #ffecec;
    color: #9d1d1d
}

.alert-info {
    background: #edf2ff;
    color: #2944a0
}

.code {
    background: #0e1726;
    color: #f4f7fb;
    border-radius: 9px;
    padding: 10px;
    white-space: pre-wrap;
    overflow: auto
}

.crumbs {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px
}

.meta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0 14px
}

.question {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    margin: 14px 0;
    overflow: hidden
}

.question-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    background: #f4f6fb;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line)
}

.question-body {
    padding: 14px
}

.answer-box {
    border-left: 4px solid var(--primary2);
    background: #f7f9ff;
    padding: 10px 12px;
    margin: 8px 0;
    border-radius: 7px
}

.criteria {
    border-left: 4px solid var(--green);
    background: #f2fbf6;
    padding: 10px 12px;
    margin: 8px 0;
    border-radius: 7px
}

@media(max-width:1000px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }
    .grid-4,
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }
    .topbar {
        align-items: flex-start;
        flex-direction: column
    }
    .userbox {
        width: 100%;
        justify-content: space-between
    }
}

@media(max-width:640px) {
    .grid,
    .grid-2,
    .grid-4,
    .form-grid,
    .form-grid-2 {
        grid-template-columns: 1fr
    }
    .card-body {
        padding: 20px
    }
    .page-title {
        align-items: flex-start;
        flex-direction: column
    }
    .nav a {
        font-size: 13px;
        padding: 7px
    }
}


/* CKEditor jak w module maniek */

.ck.ck-editor {
    width: 100%;
}

.ck.ck-editor__main>.ck-editor__editable {
    min-height: 170px;
    border-radius: 0 0 9px 9px;
}

.ck.ck-editor__editable {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

.ck.ck-toolbar {
    border-radius: 9px 9px 0 0;
}

.rich-text {
    overflow: auto;
}

.rich-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    background: #fff;
}

.rich-text th,
.rich-text td {
    border: 1px solid var(--line);
    padding: 7px 9px;
    vertical-align: top;
}

.rich-text blockquote {
    border-left: 4px solid var(--primary2);
    margin: 8px 0;
    padding: 8px 12px;
    background: #f7f9ff;
    border-radius: 7px;
}

.rich-text p:first-child {
    margin-top: 0;
}

.rich-text p:last-child {
    margin-bottom: 0;
}


/* TinyMCE / treści z edytora */

.tox.tox-tinymce {
    border-radius: 10px;
    border-color: #cfd6e3;
    overflow: hidden
}

.tox .tox-toolbar__primary {
    background: #f8f9fd
}

.rich-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid #e4e8f2;
    margin: 8px 0
}

.rich-text pre,
.rich-text pre[class*="language-"] {
    background: #0e1726;
    color: #f4f7fb;
    border-radius: 9px;
    padding: 12px;
    white-space: pre-wrap;
    overflow: auto
}

.rich-text code {
    font-family: Consolas, Monaco, 'Courier New', monospace
}

.rich-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0
}

.rich-text th,
.rich-text td {
    border: 1px solid #cfd6e3;
    padding: 7px;
    vertical-align: top
}

.rich-text blockquote {
    border-left: 4px solid #cfd6e3;
    margin: 10px 0;
    padding: 6px 12px;
    color: #41506a;
    background: #f7f8fc
}


/* Podgląd PDF obok dodawania pytań i zasad oceniania */

.editor-split {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
    gap: 18px;
    align-items: start
}

.editor-main {
    min-width: 0
}

.pdf-aside {
    min-width: 0
}

.pdf-sticky {
    position: sticky;
    top: 82px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 12px
}

.pdf-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap
}

.pdf-head h2 {
    margin: 0
}

.pdf-head.compact {
    font-size: 13px;
    margin-bottom: 8px
}

.pdf-head.compact a {
    font-size: 12px
}

.pdf-frame {
    width: 100%;
    height: 72vh;
    min-height: 520px;
    border: 1px solid #cfd6e3;
    border-radius: 10px;
    background: #f6f7fb
}

.pdf-frame-short {
    height: 56vh;
    min-height: 360px
}

.pdf-empty {
    border: 1px dashed #cfd6e3;
    background: #f8f9fd;
    color: var(--muted);
    border-radius: 10px;
    padding: 16px
}

.pdf-empty.has-preview {
    border: 0;
    padding: 0;
    background: transparent
}

.hidden {
    display: none !important
}

.criteria-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px
}

.criteria-row {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafbff;
    padding: 12px
}

.criteria-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px
}

@media(max-width:1100px) {
    .editor-split {
        grid-template-columns: 1fr
    }
    .pdf-sticky {
        position: static
    }
    .pdf-frame {
        height: 60vh;
        min-height: 360px
    }
}


/* Zwijanie dużych sekcji edycji */

.section-toggle-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
    margin-bottom: 14px
}

.section-toggle-head strong {
    font-size: 18px
}

.panel[data-collapsible]>h2:first-of-type {
    display: none
}

.panel[data-collapsible]>.pdf-head:first-child {
    display: none
}

.panel[data-collapsible]>.section-toggle-head+.pdf-head {
    display: none
}

.panel[data-collapsible].is-collapsed>:not(.section-toggle-head) {
    display: none !important
}

.pdf-duo {
    align-items: start
}

.pdf-upload-strip {
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #fbfcff;
    padding: 12px;
    margin-bottom: 14px
}


/* Uniwersalne zwijanie/chowanie sekcji */

.panel-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: -6px 0 16px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow)
}

.section-toggle-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
    margin-bottom: 14px
}

.section-toggle-title {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    text-align: left;
    padding: 0
}

.section-toggle-title span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.section-toggle-title:hover {
    color: var(--primary)
}

.section-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: #eef1f7;
    color: #26334e;
    font-size: 15px;
    flex: 0 0 auto
}

.section-toggle-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto
}

.panel[data-collapsible].is-collapsed {
    padding-bottom: 12px;
    margin-bottom: 12px
}

.panel[data-collapsible].is-collapsed>.section-toggle-head {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0
}

.panel[data-collapsible]>h2:first-of-type,
.panel[data-collapsible]>h3:first-of-type {
    display: none
}

.panel[data-collapsible]>.section-toggle-head+.pdf-head {
    display: none
}

.panel[data-collapsible].is-collapsed>:not(.section-toggle-head) {
    display: none !important
}

.question[data-collapsible].is-collapsed .question-body {
    display: none
}

@media(max-width:640px) {
    .section-toggle-head {
        align-items: flex-start
    }
    .section-toggle-title {
        font-size: 16px
    }
    .panel-tools {
        align-items: flex-start
    }
}


/* Edycja lekcji przez kliknięcie */

.subpanel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcff;
    padding: 14px
}

.subpanel h3 {
    margin-top: 0
}

.panel-edit-active {
    outline: 3px solid rgba(67, 38, 201, .13)
}

.table-clickable tr[data-row-href] {
    cursor: pointer
}

.table-clickable tr[data-row-href]:hover td {
    background: #f0f3ff
}

.row-muted {
    opacity: .62
}

.check-line {
    display: flex;
    gap: 8px;
    align-items: center;
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 9px 10px;
    background: #f8f9fd
}

.check-line input {
    width: auto
}

.file-list {
    margin: 0;
    padding-left: 18px
}

.file-list li {
    margin: 0 0 10px
}


/* Panele admina/nauczyciela i zarządzanie użytkownikami */

.auth-grid {
    align-items: start
}

.inline-form {
    display: inline-flex;
    margin: 0
}

.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap
}

.actions-cell .btn {
    white-space: nowrap
}

.role-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #eef1f7;
    color: #24314a;
    font-size: 12px;
    font-weight: 800;
    padding: 3px 9px
}

.status-wait {
    background: #fff7dd;
    color: #7a4e00
}

.status-ok {
    background: #eaf8f0;
    color: #17643e
}

.status-off {
    background: #ffecec;
    color: #9d1d1d
}

.user-mini {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.user-mini strong {
    font-size: 15px
}

.user-mini span {
    font-size: 12px;
    color: var(--muted)
}


/* Kaskadowe filtry lekcji i edycji */

.cascade-filter {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfcff;
    padding: 14px
}

.cascade-filter select:disabled,
.cascade-filter input:disabled {
    background: #eef1f7;
    color: #8491a6;
    cursor: not-allowed
}

.cascade-filter .check-line {
    margin-bottom: 7px;
    justify-content: flex-start
}

.cascade-filter .check-line input:disabled+span {
    opacity: .6
}

.filter-hidden {
    display: none !important
}

.lesson-card-grid {
    align-items: start
}

.lesson-subject-card {
    transition: opacity .15s ease, transform .15s ease
}

.lesson-card-grid.has-active-subject {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.lesson-card-grid.has-active-subject .lesson-subject-card.subject-selected,
.lesson-card-grid.has-active-subject .lesson-subject-card.subject-selected-by-filter {
    grid-column: 1 / -1;
    order: -10;
    border-left-color: var(--orange);
    box-shadow: 0 14px 34px rgba(28, 38, 70, .12);
}

.lesson-card-grid.has-active-subject .lesson-subject-card:not(.subject-selected):not(.subject-selected-by-filter) {
    order: 5;
}

.lesson-card-grid.has-active-subject .lesson-subject-card:not(.subject-selected):not(.subject-selected-by-filter) .subject-tree {
    display: none !important;
}

.lesson-card-grid.has-active-subject .lesson-subject-card:not(.subject-selected):not(.subject-selected-by-filter) .card-body {
    min-height: auto;
}

.lesson-card-grid.has-active-subject .lesson-subject-card:not(.subject-selected):not(.subject-selected-by-filter) .truncate {
    max-height: 44px;
    overflow: hidden;
}

.lesson-fold {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fbfcff;
    margin: 8px 0;
    overflow: hidden
}

.lesson-fold summary {
    cursor: pointer;
    list-style: none;
    font-weight: 900;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f4f6fb
}

.lesson-fold summary::-webkit-details-marker {
    display: none
}

.lesson-fold summary::after {
    content: '▸';
    margin-left: auto;
    color: var(--muted);
    font-size: 13px
}

.lesson-fold[open]>summary::after {
    content: '▾'
}

.lesson-fold-temat {
    margin: 8px 10px;
    background: #fff
}

.lesson-fold-temat summary {
    background: #fff;
    font-weight: 800;
    color: #24314a
}

.lesson-link-list {
    padding: 4px 10px 10px
}

.lesson-empty {
    padding: 10px 12px
}

@media(max-width:740px) {
    .cascade-filter {
        padding: 12px
    }
    .lesson-fold-temat {
        margin-left: 6px;
        margin-right: 6px
    }
}

.editor-split-pdf-locked {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 42%);
    gap: 18px;
    align-items: start;
    max-height: calc(100vh - 170px);
    min-height: 620px;
    overflow: hidden;
}

.editor-split-pdf-locked .editor-main-scroll {
    max-height: calc(100vh - 190px);
    overflow-y: auto;
    overflow-x: hidden;
}


/* ==========================================================
   TYLKO STRONA: edytuj_arkusz.php
   Pełna szerokość strony + stały panel PDF po prawej.
   Działa z klasą dodaną w edytuj_arkusz.php oraz jako fallback przez :has().
   ========================================================== */

html.edytuj-arkusz-full-width body,
body.edytuj-arkusz-full-width {
    overflow-x: hidden;
}

html.edytuj-arkusz-full-width .container,
body.edytuj-arkusz-full-width .container,
.container:has(> .edit-arkusz-page.compact-pdf-editor) {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
}

.edit-arkusz-page.compact-pdf-editor {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
}

.edit-arkusz-page.compact-pdf-editor .arkusz-workspace {
    --arkusz-left-pct: 50%;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(380px, calc(var(--arkusz-left-pct) - 10px)) 12px minmax(380px, 1fr);
    gap: 8px;
    align-items: start;
}

.edit-arkusz-page.compact-pdf-editor .column-width-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--border, #d7dee8);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .05);
}

.edit-arkusz-page.compact-pdf-editor .column-width-toolbar .btn.is-active {
    background: var(--primary, #4326c9);
    color: #fff;
}

.edit-arkusz-page.compact-pdf-editor .arkusz-column-resizer {
    width: 12px;
    min-height: calc(100vh - var(--app-sticky-top, 82px) - 14px);
    border-radius: 999px;
    cursor: col-resize;
    align-self: stretch;
    background: linear-gradient(90deg, transparent 0 4px, #cbd5e1 4px 8px, transparent 8px 12px);
    opacity: .7;
}

.edit-arkusz-page.compact-pdf-editor .arkusz-column-resizer:hover,
.edit-arkusz-page.compact-pdf-editor .arkusz-column-resizer:focus,
body.is-resizing-arkusz-columns .edit-arkusz-page.compact-pdf-editor .arkusz-column-resizer {
    background: linear-gradient(90deg, transparent 0 3px, var(--primary, #4326c9) 3px 9px, transparent 9px 12px);
    opacity: 1;
    outline: none;
}

body.is-resizing-arkusz-columns {
    cursor: col-resize;
    user-select: none;
}

.edit-arkusz-page.compact-pdf-editor .arkusz-workspace-left {
    min-width: 0;
}

.edit-arkusz-page.compact-pdf-editor .arkusz-workspace-pdf {
    position: sticky;
    top: var(--app-sticky-top, 82px);
    height: calc(100vh - var(--app-sticky-top, 82px) - 14px);
    min-height: 620px;
    align-self: start;
    z-index: 10;
}

.edit-arkusz-page.compact-pdf-editor .pdf-sticky-card {
    height: 100%;
}

.edit-arkusz-page.compact-pdf-editor .pdf-panel-fixed .pdf-frame {
    height: 100%;
    min-height: 0;
}

.edit-arkusz-page.compact-pdf-editor .arkusz-workspace-left .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.edit-arkusz-page.compact-pdf-editor .arkusz-workspace-left .field.full {
    grid-column: 1 / -1;
}

@media(min-width:1700px) {
    .edit-arkusz-page.compact-pdf-editor .arkusz-workspace-left .form-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media(max-width:980px) {
    .edit-arkusz-page.compact-pdf-editor .arkusz-workspace {
        grid-template-columns: 1fr;
    }
    .edit-arkusz-page.compact-pdf-editor .arkusz-column-resizer {
        display: none;
    }
    .edit-arkusz-page.compact-pdf-editor .column-width-toolbar {
        align-items: flex-start;
    }
    .edit-arkusz-page.compact-pdf-editor .arkusz-workspace-pdf {
        position: relative;
        top: auto;
        height: 620px;
        min-height: 620px;
        order: -1;
    }
    .edit-arkusz-page.compact-pdf-editor .arkusz-workspace-left .form-grid {
        grid-template-columns: 1fr;
    }
}


/* Zarządzanie plikami w panelu admina */

.file-manager-tools {
    align-items: stretch
}

.file-manager-table code {
    font-size: 12px;
    white-space: normal;
    word-break: break-all
}

.file-manager-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px
}

.file-thumb {
    width: 58px;
    height: 44px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f6f7fb;
    display: block
}

.file-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #eef1f7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex: 0 0 auto
}

.file-actions {
    min-width: 260px
}

.file-action-details {
    position: relative;
    display: inline-flex
}

.file-action-details summary {
    list-style: none
}

.file-action-details summary::-webkit-details-marker {
    display: none
}

.rename-form {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 10;
    width: min(360px, 80vw);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow)
}

.rename-form input {
    min-width: 0
}

@media(max-width:760px) {
    .file-manager-file {
        min-width: 0
    }
    .file-actions {
        min-width: 0
    }
    .rename-form {
        left: 0;
        right: auto
    }
}

.usluga-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Segoe UI', sans-serif;
    font-size: 15px;
    transition: all 0.2s ease;
    user-select: none;
}
.usluga-inline:hover {
    background: #e9ecef;
    border-color: #ced4da;
}
.usluga-inline input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #4f8cf7;
    cursor: pointer;
}
.usluga-inline.checked {
    background: #e8f0fe;
    border-color: #4f8cf7;
}
.usluga-cena {
    color: #6c757d;
    font-size: 13px;
    font-weight: 600;
}
/* Lekcje.php - edycja inline w miejscu klikniętego elementu */
.inline-edit-panel {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 14px;
    margin: 12px 0;
    box-shadow: 0 10px 26px rgba(28, 38, 70, .08);
}
.inline-edit-panel h2,
.inline-edit-panel h3,
.inline-edit-panel h4 {
    margin-top: 0;
}
.inline-subsection {
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #fbfcff;
    padding: 12px;
    margin-top: 14px;
}
.lesson-inline-row {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    margin: 8px 0;
    overflow: hidden;
}
.lesson-inline-head {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
}
.lesson-inline-head:hover {
    background: #f0f3ff;
}
.lesson-inline-head .actions {
    flex-shrink: 0;
}
.file-edit-list {
    display: grid;
    gap: 10px;
}
.inline-file-form {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 10px;
}
@media(max-width:740px) {
    .lesson-inline-head {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* Lekcje.php - punkty lekcji edytowane bezpośrednio w miejscu punktu */
.lesson-points-section {
    border-style: solid;
}
.lesson-points-titlebar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}
.lesson-points-titlebar h3,
.lesson-points-titlebar p {
    margin-top: 0;
}
.lesson-points-titlebar .actions {
    flex-shrink: 0;
}
.inline-action-form {
    display: inline-flex;
    margin: 0;
}
.lesson-point-list {
    display: grid;
    gap: 10px;
}
.lesson-point-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
    scroll-margin-top: 92px;
}
.lesson-point-card[data-row-href] {
    cursor: pointer;
}
.lesson-point-card[data-row-href]:hover {
    border-color: #8ea2ef;
    box-shadow: 0 8px 20px rgba(28, 38, 70, .08);
}
.lesson-point-card-editing {
    padding: 14px;
    opacity: 1;
}
.lesson-point-preview {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 12px;
}
.lesson-point-preview-number {
    display: grid;
    gap: 4px;
}
.point-order-code {
    display: inline-flex;
    width: max-content;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e8edff;
    color: #2d45a0;
    font-size: 15px;
    font-weight: 800;
}
.point-own-number {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.lesson-point-preview-main {
    min-width: 0;
}
.lesson-point-preview-heading {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 5px;
}
.lesson-point-preview-action {
    flex-shrink: 0;
}
.lesson-point-inline-form {
    margin: 0;
}
.lesson-point-fields {
    display: grid;
    grid-template-columns: minmax(100px, .65fr) minmax(260px, 2.2fr) minmax(150px, .85fr);
    gap: 12px;
}
.lesson-point-fields .full {
    grid-column: 1 / -1;
}
.lesson-point-content textarea {
    min-height: 220px;
}
.lesson-point-order small {
    display: block;
    margin-top: 5px;
    color: var(--muted);
}
.lesson-point-move {
    grid-column: span 1;
}
.point-move-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.point-move-buttons .btn {
    width: 100%;
}
.lesson-point-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 14px;
}
.lesson-point-actions .btn {
    width: 100%;
}
.lesson-point-new {
    scroll-margin-top: 92px;
}
.lesson-point-new h3 {
    margin-top: 0;
}
@media(max-width:980px) {
    .lesson-point-fields {
        grid-template-columns: 1fr 1fr;
    }
    .lesson-point-title,
    .lesson-point-content {
        grid-column: 1 / -1;
    }
    .lesson-point-actions {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }
}
@media(max-width:720px) {
    .lesson-points-titlebar,
    .lesson-point-preview {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    .lesson-points-titlebar .actions,
    .lesson-point-preview-action .btn {
        width: 100%;
    }
    .lesson-point-fields,
    .lesson-point-actions {
        grid-template-columns: 1fr;
    }
    .lesson-point-fields .field,
    .lesson-point-fields .full,
    .lesson-point-title,
    .lesson-point-content {
        grid-column: 1;
    }
}

/* =========================================================
   LEKCJE.PHP — spójny wygląd filtrów, drzewa, list i formularzy
   ========================================================= */
.lessons-page {
    --lesson-primary: #3f2bbf;
    --lesson-primary-soft: #eeeaff;
    --lesson-line: #d9dfeb;
    --lesson-surface: #ffffff;
    --lesson-surface-soft: #f7f9fd;
    --lesson-text: #17233a;
    --lesson-muted: #66758f;
    width: 100%;
}

.lessons-page-title {
    padding: 4px 2px;
}

.lessons-page-title .actions {
    margin-top: 0;
}

.lessons-page .panel,
.lessons-page .subpanel,
.lessons-page .inline-subsection,
.lessons-page .inline-edit-panel {
    border-color: var(--lesson-line);
}

.lessons-page .panel {
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(23, 35, 58, .07);
}

.lessons-page .subpanel {
    position: relative;
    border: 1px solid var(--lesson-line);
    border-radius: 14px;
    background: var(--lesson-surface);
    padding: 16px;
}

.lessons-page .btn {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 14px;
    line-height: 1.15;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease, border-color .12s ease;
    box-shadow: 0 4px 12px rgba(67, 38, 201, .12);
}

.lessons-page .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(23, 35, 58, .14);
}

.lessons-page .btn:active {
    transform: translateY(0);
}

.lessons-page .btn:focus-visible,
.lessons-page .tree-icon-btn:focus-visible,
.lessons-page input:focus-visible,
.lessons-page select:focus-visible,
.lessons-page textarea:focus-visible,
.lessons-page summary:focus-visible {
    outline: 3px solid rgba(76, 111, 255, .24);
    outline-offset: 2px;
}

.lessons-page .btn-sm {
    min-height: 34px;
    padding: 7px 11px;
}

.lessons-page .btn-light {
    border-color: #d8deea;
    background: #f3f5f9;
    color: #27354d;
    box-shadow: 0 3px 9px rgba(23, 35, 58, .06);
}

.lessons-page .btn-orange {
    border-color: #ec7d08;
}

.lessons-page .btn-green {
    border-color: #168451;
}

.lessons-page .btn-red {
    border-color: #e23434;
}

.lessons-page .btn-add-main {
    background: linear-gradient(135deg, var(--primary), var(--primary2));
}

.lessons-page input,
.lessons-page select,
.lessons-page textarea {
    min-height: 42px;
    border: 1px solid #cbd4e2;
    border-radius: 10px;
    background: #fff;
    color: var(--lesson-text);
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}

.lessons-page textarea {
    min-height: 120px;
}

.lessons-page input:hover,
.lessons-page select:hover,
.lessons-page textarea:hover {
    border-color: #aebbd0;
}

.lessons-page input:focus,
.lessons-page select:focus,
.lessons-page textarea:focus {
    border-color: #6f80d9;
    box-shadow: 0 0 0 4px rgba(76, 111, 255, .11);
    outline: none;
}

.lessons-page input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    height: 18px;
    accent-color: var(--lesson-primary);
}

.lessons-page .check-line {
    min-height: 32px;
    padding: 5px 0;
    gap: 8px;
}

.lessons-filter-panel .section-toggle-head,
.lessons-add-panel .section-toggle-head {
    margin-bottom: 0;
}

.lessons-filter-panel:not(.is-collapsed) .section-toggle-head,
.lessons-add-panel:not(.is-collapsed) .section-toggle-head {
    margin-bottom: 14px;
}

.lessons-page .cascade-filter {
    border-color: var(--lesson-line);
    background: linear-gradient(180deg, #fbfcff 0%, #f5f7fc 100%);
    border-radius: 14px;
    padding: 16px;
}

.lessons-page .cascade-filter .field {
    min-width: 0;
}

.lessons-page .cascade-filter .check-line {
    display: inline-flex;
    width: max-content;
    padding: 5px 9px;
    border: 1px solid #dce2ed;
    border-radius: 999px;
    background: #fff;
}

.lessons-page .cascade-filter select:disabled {
    opacity: .66;
    cursor: not-allowed;
}

.lessons-page .cascade-filter select.filter-value-inactive {
    border-style: dashed;
    border-color: #e59a35;
    background: #fff9ef;
}

.filter-session-note {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #edf7f1;
    color: #287049;
    font-size: 12px;
    font-weight: 800;
}

.add-subpanel {
    scroll-margin-top: 92px;
}

.add-subpanel-active {
    border-color: #7c6cdb !important;
    box-shadow: 0 0 0 4px rgba(67, 38, 201, .10), 0 12px 24px rgba(23, 35, 58, .08);
}

.add-subpanel-active::before {
    content: 'Wybrany formularz';
    position: absolute;
    top: -11px;
    right: 14px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--lesson-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
}

.step-badge {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    margin-right: 6px;
    border-radius: 9px;
    background: var(--lesson-primary-soft);
    color: var(--lesson-primary);
    font-size: 13px;
}

.lesson-card-grid {
    gap: 18px;
}

.lesson-subject-card {
    border: 1px solid var(--lesson-line);
    border-radius: 16px;
    box-shadow: 0 9px 25px rgba(23, 35, 58, .07);
}

.lesson-subject-card:hover {
    border-color: #c0c9d9;
}

.lesson-subject-card .card-body {
    padding: 20px;
}

.lesson-subject-card .card-foot {
    padding: 12px 20px;
    background: #f7f8fc;
}

.subject-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.subject-card-heading h3,
.subject-card-heading p {
    margin-top: 0;
}

.subject-card-heading h3 {
    margin-bottom: 3px;
}

.tree-icon-btn {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 1px solid #d4dbe7;
    border-radius: 9px;
    background: #fff;
    color: #33415b;
    font-size: 18px;
    font-weight: 900;
    text-decoration: none;
    box-shadow: 0 3px 9px rgba(23, 35, 58, .08);
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.tree-icon-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: 0 6px 13px rgba(23, 35, 58, .13);
}

.tree-icon-edit {
    background: #fff5e8;
    border-color: #f3c68f;
    color: #a75600;
}

.tree-icon-add {
    background: #eaf8f0;
    border-color: #9cd5b5;
    color: #167346;
}

.subject-tree {
    margin-top: 14px;
    padding-top: 12px;
}

.lesson-fold {
    border-color: var(--lesson-line);
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(23, 35, 58, .035);
}

.lesson-fold > summary {
    min-height: 52px;
    padding: 9px 11px 9px 14px;
    gap: 10px;
    color: var(--lesson-text);
    transition: background .12s ease;
}

.lesson-fold > summary:hover {
    background: #eef2fa;
}

.lesson-fold[open] > summary {
    border-bottom: 1px solid var(--lesson-line);
    background: #eef2fa;
}

.lesson-fold-temat > summary,
.lesson-fold-temat[open] > summary {
    background: #fff;
}

.lesson-fold-temat > summary:hover,
.lesson-fold-temat[open] > summary:hover {
    background: #f7f9fd;
}

.lesson-summary-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.lesson-tree-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #dfe5ef;
    font-size: 14px;
}

.lesson-summary-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.lesson-fold summary::after {
    margin-left: 2px;
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: rgba(255, 255, 255, .75);
}

.lesson-empty {
    padding: 10px 12px 13px;
}

.lesson-empty-add {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px dashed #98cbb0;
    border-radius: 10px;
    background: #f1faf5;
    color: #267049;
    font-weight: 800;
    text-decoration: none;
}

.lesson-empty-add:hover {
    background: #e8f7ef;
    text-decoration: none;
}

.lesson-empty-add span {
    display: inline-grid;
    place-items: center;
    width: 25px;
    height: 25px;
    border-radius: 7px;
    background: #d9f0e4;
    font-size: 17px;
}

.lesson-link-list {
    padding: 8px 10px 11px;
}

.lesson-inline-row {
    border-color: #dce2ec;
    border-radius: 11px;
    box-shadow: 0 3px 9px rgba(23, 35, 58, .035);
}

.lesson-inline-head {
    min-height: 62px;
    padding: 11px 12px;
}

.lesson-inline-head:hover {
    background: #f4f6fb;
}

.lesson-inline-head > div:first-child {
    min-width: 0;
}

.lesson-inline-head strong {
    color: var(--lesson-text);
}

.lesson-inline-head .actions {
    margin-top: 0;
}

.lessons-page .inline-edit-panel,
.lessons-page .lesson-point-card-editing {
    border-color: #9f93e2;
    background: #fcfbff;
    box-shadow: 0 0 0 4px rgba(67, 38, 201, .08);
}

.lessons-page .lesson-point-card,
.lessons-page .inline-file-form {
    border-color: var(--lesson-line);
}

.lessons-page .lesson-point-actions,
.lessons-page .point-move-buttons {
    align-items: stretch;
}

.lessons-page button:disabled,
.lessons-page .btn:disabled {
    opacity: .48;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

@media (max-width: 980px) {
    .lessons-page .cascade-filter .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lesson-card-grid,
    .lesson-card-grid.has-active-subject {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .lessons-page-title,
    .subject-card-heading,
    .lesson-fold > summary,
    .lesson-inline-head {
        align-items: stretch;
    }

    .lessons-page-title {
        flex-direction: column;
    }

    .lessons-page-title .actions,
    .lessons-page-title .btn {
        width: 100%;
    }

    .lessons-page .cascade-filter .form-grid,
    .lessons-page .grid-2,
    .lessons-page .form-grid-2,
    .lessons-page .form-grid-4 {
        grid-template-columns: 1fr;
    }

    .lesson-fold > summary {
        flex-wrap: wrap;
    }

    .lesson-summary-actions {
        margin-left: 34px;
    }

    .lesson-fold summary::after {
        margin-left: auto;
    }

    .lesson-inline-head,
    .subject-card-heading {
        flex-direction: column;
    }

    .lesson-inline-head .actions,
    .lesson-inline-head .btn,
    .subject-card-heading .tree-icon-btn {
        width: 100%;
    }

    .subject-card-heading .tree-icon-btn {
        display: inline-flex;
    }
}

/* Dodawanie elementów bezpośrednio w miejscu kliknięcia */
.lessons-page .inline-add-panel {
    margin: 12px 0 16px;
    padding: 16px;
    border: 2px dashed var(--primary, #2563eb);
    border-radius: 12px;
    background: var(--surface, #fff);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}
.lessons-page .inline-add-panel h2 { margin: 0 0 14px; font-size: 1.15rem; }
.lessons-page .lesson-fold > .inline-add-panel { margin-left: 14px; margin-right: 10px; }
.lessons-page .subject-card-heading + .truncate + .inline-add-panel { margin-top: 14px; }
@media (max-width: 700px) {
    .lessons-page .lesson-fold > .inline-add-panel { margin-left: 4px; margin-right: 4px; padding: 12px; }
}
