* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}
.topbar {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}
h1 { margin: 0 0 4px; font-size: 24px; }
h2 { margin-top: 0; }
.container { max-width: 1400px; margin: 25px auto; padding: 0 20px; }
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
select, input {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 15px;
}
select { min-width: 180px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
th, td { border: 1px solid #e5e7eb; padding: 9px; text-align: center; }
thead th { background: #f8fafc; }
tbody th { text-align: left; white-space: nowrap; background: #fafafa; }
.children-input { width: 80px; text-align: center; }
.children-input.saved { border-color: #22c55e; }
.required { font-size: 12px; margin-top: 5px; color: #64748b; }
.muted { color: #64748b; font-size: 13px; }
.info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.info-grid div {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.info-grid strong { font-size: 22px; }
@media (max-width: 800px) {
    .topbar { flex-direction: column; align-items: stretch; }
    .info-grid { grid-template-columns: repeat(2, 1fr); }
}
/* =========================================================
   WSPÓLNY HEADER
   ========================================================= */

.site-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.site-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;

    display: flex;
    align-items: center;
    gap: 24px;
}

.site-brand {
    margin-right: auto;
}

.site-brand h1 {
    margin: 0;
    font-size: 21px;
    line-height: 1.2;
    color: #111827;
}

.site-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: #64748b;
}


/* Nawigacja */

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-nav a {
    display: inline-block;

    padding: 8px 12px;

    border: 1px solid #cbd5e1;
    border-radius: 7px;

    background: #fff;
    color: #1f2937;

    text-decoration: none;
    font-size: 14px;
}

.site-nav a:hover {
    background: #f8fafc;
}

.site-nav a.active {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #3730a3;
    font-weight: 600;
}


/* Wybór świetlicy */

.playground-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.playground-selector label {
    font-size: 14px;
    color: #64748b;
    white-space: nowrap;
}

.playground-selector select {
    min-width: 150px;

    padding: 8px 30px 8px 10px;

    border: 1px solid #cbd5e1;
    border-radius: 7px;

    background: #fff;
    color: #1f2937;

    font-size: 14px;
}

.playground-selector select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}


/* Telefon */

@media (max-width: 850px) {

    .site-header-inner {
        flex-wrap: wrap;
        padding: 15px;
    }

    .site-brand {
        width: 100%;
    }

    .site-nav {
        flex: 1;
    }

    .site-nav a {
        flex: 1;
        text-align: center;
    }

    .playground-selector {
        flex: 1;
    }

    .playground-selector select {
        flex: 1;
    }
}

/* =========================================================
   HEADER
   ========================================================= */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
}

.topbar-title h1 {
    margin: 0;
}

.topbar-nav {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    display: inline-block;
    padding: 9px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #1f2937;
    text-decoration: none;
    white-space: nowrap;
}

.nav-btn:hover {
    background: #f8fafc;
}

.playground-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.playground-form label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.playground-form select {
    min-width: 180px;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #1f2937;
}


/* =========================================================
   WYMAGANA OBSADA
   ========================================================= */

.required {
    margin-top: 6px;
    font-size: 13px;
}

.required strong {
    font-weight: 700;
}

/* ============================================================
   ADMIN
   ============================================================ */

.admin-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
}

.admin-nav a {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #dbe2ea;
    border-radius: 7px;
    text-decoration: none;
    color: #1f2937;
    background: #fff;
}

.admin-nav a:hover {
    background: #f8fafc;
}

.admin-nav a.active {
    background: #eef2ff;
}

.actions {
    white-space: nowrap;
}

.btn {
    display: inline-block;
    padding: 9px 13px;
    border-radius: 7px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #1f2937;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover {
    background: #f8fafc;
}

.btn-primary {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.btn-primary:hover {
    background: #1f2937;
    color: #fff;
}

.btn-danger {
    color: #b91c1c;
}

.btn-danger:hover {
    background: #fef2f2;
}

.status-active {
    color: #15803d;
    font-weight: 600;
}

.status-off {
    color: #64748b;
}

.badge-good {
    color: #15803d;
    font-weight: 600;
}

.badge-warn {
    color: #b45309;
    font-weight: 600;
}

.badge-bad {
    color: #b91c1c;
    font-weight: 600;
}


/* =========================================================
   HARMONOGRAM
   ========================================================= */

.schedule-page-title {
    margin-bottom: 20px;
}

.schedule-page-title h2 {
    margin-bottom: 5px;
}

.schedule-table-wrap {
    overflow-x: auto;
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
}

.schedule-table th,
.schedule-table td {
    border: 1px solid #ddd;
    padding: 10px;
    vertical-align: top;
}

.schedule-table thead th {
    background: #f5f5f5;
    text-align: center;
}

.schedule-table .time {
    width: 120px;
    background: #fafafa;
    font-weight: 700;
}

.day-cell {
    min-width: 190px;
    height: 150px;
}

.children {
    font-size: 18px;
    font-weight: 700;
}

.required {
    color: #555;
    font-size: 13px;
    margin-top: 3px;
}

.teacher {
    background: #eef2ff;
    border-radius: 5px;
    padding: 6px 8px;
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.teacher button {
    border: 0;
    background: none;
    color: #b91c1c;
    cursor: pointer;
    font-weight: 700;
    font-size: 18px;
}

.ok {
    color: #15803d;
    font-weight: 700;
    margin-top: 8px;
    font-size: 0.7rem;
}

.missing {
    color: #b91c1c;
    font-weight: 700;
    margin-top: 8px;
    font-size: 0.7rem;
}

.add-teacher {
    width: 100%;
    margin-top: 8px;
    padding: 6px;
    border: 1px dashed #999;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
}

.add-teacher:hover {
    background: #f8fafc;
}

.children-edit {
    margin-top: 6px;
}

.children-edit input {
    width: 70px;
    padding: 4px;
}

.save-children {
    padding: 4px 7px;
    cursor: pointer;
}


/* =========================================================
   MODAL NAUCZYCIELI
   ========================================================= */

.teacher-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.teacher-modal.open {
    display: flex;
}

.teacher-modal-content {
    position: relative;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    width: 450px;
    max-width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.teacher-modal-close {
    float: right;
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}

.teacher-modal-close:hover {
    background: #f8fafc;
}

.teacher-option {
    position: relative;
    padding: 10px;
    padding-right: 90px;
    border-bottom: 1px solid #ddd;
}

.teacher-option strong {
    display: block;
}

.teacher-option small {
    display: block;
    margin-top: 3px;
    color: #64748b;
}

.teacher-option button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}

.teacher-option button:hover {
    background: #f8fafc;
}


/* ============================================================
   FORMULARZE
   ============================================================ */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

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

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

.field input,
.field textarea {
    width: 100%;
    box-sizing: border-box;
}

.field textarea {
    min-height: 100px;
    resize: vertical;
}

.error {
    padding: 12px 14px;
    margin-bottom: 20px;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
}

.page-nav {
    margin-top: 8px;
}

.page-nav a {
    color: inherit;
    text-decoration: none;
}


/* ============================================================
   RESPONSYWNOŚĆ FORMULARZY
   ============================================================ */

@media (max-width: 700px) {

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

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

}

/* ============================================================
   DOSTĘPNOŚĆ NAUCZYCIELA
   ============================================================ */

.check {
    width: 22px;
    height: 22px;
    cursor: pointer;
}

.check:disabled {
    cursor: wait;
    opacity: 0.6;
}

.saved {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

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


/* ============================================================
   PROPOZYCJA HARMONOGRAMU
   ============================================================ */

.suggest-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .55);
}

.suggest-modal[hidden] {
    display: none;
}

.suggest-modal-content {
    width: min(1100px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}

.suggest-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.suggest-modal-header h2 {
    margin: 0 0 5px;
}

.suggest-close {
    border: 0;
    background: transparent;
    font-size: 30px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
}

.suggest-day {
    padding: 20px 24px 0;
}

.suggest-day h3 {
    margin: 0 0 10px;
}

.suggest-table {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.suggest-row {
    display: grid;
    grid-template-columns: 180px 150px 1fr;
    gap: 15px;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e5e7eb;
}

.suggest-row:last-child {
    border-bottom: 0;
}

.suggest-time {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.suggest-time span {
    color: #64748b;
    font-size: 13px;
}

.suggest-children {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.suggest-children small {
    color: #64748b;
}

.suggest-teachers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.teacher-chip {
    display: inline-block;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 13px;
}

.suggest-warning {
    color: #b91c1c;
    font-weight: 600;
    font-size: 13px;
}

.suggest-none {
    color: #b91c1c;
    font-weight: 600;
}

.suggest-ok {
    color: #15803d;
}

.suggest-missing {
    color: #b91c1c;
}

.suggest-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 24px;
    margin-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.suggest-loading {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 30px;
    color: #475569;
}

.suggest-loading span {
    font-size: 13px;
    color: #94a3b8;
}

.suggest-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #475569;
    border-radius: 50%;
    animation: suggest-spin .8s linear infinite;
}

@keyframes suggest-spin {
    to {
        transform: rotate(360deg);
    }
}

.suggest-error {
    margin: 20px 24px;
    padding: 15px;
    border-radius: 8px;
    background: #fef2f2;
    color: #991b1b;
}

.suggest-empty {
    padding: 30px 24px;
    text-align: center;
    color: #64748b;
}

@media (max-width: 800px) {

    .suggest-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .suggest-modal {
        padding: 10px;
    }

    .suggest-modal-content {
        max-height: 95vh;
    }
}