:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #1a1f2b;
    --muted: #637085;
    --primary: #1f6feb;
    --danger: #c82626;
    --border: #dfe6f1;
    --success: #197239;
}

* { box-sizing: border-box; }
html { background: #f2f6ff; }
body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.container {
    width: min(1100px, 94vw);
    margin: 0 auto;
}

.admin-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.admin-header-inner {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.admin-nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.35rem 0.55rem;
    border-radius: 8px;
}

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

.admin-main {
    padding: 1rem 0 2rem;
    display: grid;
    gap: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
}

.card-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric {
    margin: 0.4rem 0 0;
    font-size: 2rem;
    font-weight: 700;
}

.flash {
    padding: 0.8rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.flash-success {
    background: #e9f8ee;
    border-color: #bce7cb;
}
.flash-error {
    background: #fdecee;
    border-color: #f5c2c7;
}

.btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.stack {
    display: grid;
    gap: 0.75rem;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

input, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    font: inherit;
}

.schedule-row {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1fr 1fr 110px 120px;
}

.schedule-toolbar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: end;
}

.date-label {
    display: grid;
    gap: 0.25rem;
    min-width: 180px;
}

.daypart-container {
    display: grid;
    gap: 1rem;
}

.daypart-editor {
    border: 1px solid #cfd9ea;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
    padding: 0.8rem;
}

.daypart-editor-head {
    display: flex;
    gap: 0.65rem;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.daypart-title-input {
    font-weight: 700;
    max-width: 380px;
}

.activities-list {
    display: grid;
    gap: 0.6rem;
}

.activity-row {
    border: 1px solid #d8e0f0;
    background: #fff;
    border-radius: 12px;
    padding: 0.55rem;
    display: grid;
    grid-template-columns: 36px 72px 1fr;
    gap: 0.6rem;
    align-items: center;
}

.activity-row.dragging {
    opacity: 0.55;
    border-style: dashed;
}

.drag-handle {
    text-align: center;
    cursor: grab;
    user-select: none;
    font-size: 1.2rem;
    color: #5f6f8f;
}

.activity-preview {
    width: 72px;
    height: 72px;
    border: 1px solid #e2e8f5;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #f7f9fe;
    overflow: hidden;
}

.activity-preview img {
    width: 90%;
    height: 90%;
    object-fit: contain;
}

.preview-placeholder {
    color: #7b8397;
    font-size: 0.78rem;
}

.activity-meta {
    display: grid;
    gap: 0.45rem;
}

.activity-name {
    font-weight: 600;
    font-size: 0.95rem;
    word-break: break-word;
}

.activity-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.modal.hidden {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(22, 31, 49, 0.45);
}

.modal-content {
    position: relative;
    width: min(980px, 94vw);
    max-height: 88dvh;
    overflow: auto;
    margin: 4dvh auto 0;
    background: #fff;
    border: 1px solid #d9e3f4;
    border-radius: 14px;
    padding: 0.9rem;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
}

.picto-search-grid {
    margin-top: 0.7rem;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.picto-result {
    border: 1px solid #dbe5f5;
    border-radius: 10px;
    background: #fff;
    padding: 0.4rem;
    cursor: pointer;
    display: grid;
    gap: 0.3rem;
    text-align: left;
}

.picto-result:hover {
    border-color: #9db8ef;
    background: #f5f9ff;
}

.picto-result img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
}

.picto-result span {
    font-size: 0.78rem;
    word-break: break-word;
}

.picto-grid-admin {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.picto-tile-admin {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem;
    display: grid;
    gap: 0.4rem;
}

.picto-tile-admin img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 8px;
    background: #f6f8fc;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
th, td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 0.65rem;
    font-size: 0.95rem;
}

.inline-form {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.desktop-only {
    display: block;
}

.mobile-only {
    display: none;
}

.request-cards {
    display: grid;
    gap: 0.65rem;
}

.request-card {
    border: 1px solid #dbe3f1;
    border-radius: 12px;
    background: #fff;
    padding: 0.7rem;
    display: grid;
    gap: 0.35rem;
}

.request-card p {
    margin: 0;
    font-size: 0.92rem;
}

.status {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.82rem;
    border: 1px solid;
}
.status-pending { color: #704900; background: #fff4d6; border-color: #f5dea2; }
.status-requested { color: #1f4f8f; background: #e6f0ff; border-color: #b6cffd; }
.status-approved { color: #18592f; background: #e7f8ec; border-color: #bde7c9; }
.status-rejected { color: #8e1f25; background: #fdecee; border-color: #f3c1c5; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

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

.login-card {
    width: min(460px, 94vw);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
}

.muted { color: var(--muted); }

.child-body {
    margin: 0;
    min-height: 100dvh;
    background-color: #f2f6ff;
    background: linear-gradient(180deg, #f2f6ff 0%, #eaf0fb 100%);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.child-main {
    width: min(1100px, 95vw);
    margin: 0 auto;
    padding: 1rem 0 2rem;
}

.child-day {
    text-align: center;
    font-size: clamp(1.7rem, 5vw, 2.4rem);
    margin: 0.3rem 0 1rem;
    text-transform: capitalize;
}

.child-empty {
    text-align: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
}

.child-grid {
    display: grid;
    gap: 0.45rem;
    grid-template-columns: repeat(5, 160px);
    justify-content: start;
}

.daypart-block {
    margin-bottom: 1.25rem;
}

.daypart-title {
    margin: 0 0 0.65rem;
    font-size: 1.3rem;
    border-bottom: 2px solid #ced9ee;
    padding-bottom: 0.35rem;
}

.child-item {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
    justify-items: start;
}

.picto-wrap {
    position: relative;
    border-radius: 12px;
    background: transparent;
    overflow: hidden;
    width: 160px;
    height: 160px;
    margin: 0;
    display: grid;
    place-items: center;
}

.picto-wrap img {
    width: 138px;
    height: 138px;
    object-fit: contain;
}

.cross-overlay::before,
.cross-overlay::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 135%;
    height: 10px;
    transform-origin: center;
    border-radius: 999px;
}

.cross-overlay-gray::before,
.cross-overlay-gray::after {
    background: rgba(113, 118, 129, 0.88);
}

.cross-overlay-red::before,
.cross-overlay-red::after {
    background: rgba(206, 16, 16, 0.88);
}

.cross-overlay::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.cross-overlay::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.child-btn {
    width: 100%;
    font-size: 1.05rem;
    padding: 0.8rem;
}

.child-btn.waiting {
    background: #f3f6fe;
    color: #3a4f78;
}

.child-btn.done {
    background: #e8f7ed;
    color: var(--success);
}

.picto-click-form {
    margin: 0;
}

.picto-button {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    width: 100%;
}

.picto-button:focus-visible .picto-wrap,
.picto-button:hover .picto-wrap {
    outline: 3px solid #9fc0ff;
    outline-offset: 3px;
}

@media (max-width: 1300px) {
    .child-grid {
        grid-template-columns: repeat(4, 160px);
    }
}

@media (max-width: 1080px) {
    .child-grid {
        grid-template-columns: repeat(3, 160px);
    }
}

@media (max-width: 720px) {
    .container {
        width: 96vw;
    }

    .admin-main {
        padding-top: 0.6rem;
        gap: 0.7rem;
    }

    .card {
        border-radius: 12px;
        padding: 0.75rem;
    }

    .admin-header-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.55rem;
        padding: 0.6rem 0;
    }

    .admin-nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .admin-nav a {
        white-space: normal;
        text-align: center;
        border: 1px solid #d7deeb;
        background: #f8faff;
        font-size: 0.8rem;
        line-height: 1.2;
        padding: 0.5rem 0.35rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }

    .metric {
        font-size: 1.7rem;
    }

    .button-row {
        flex-direction: column;
    }

    .button-row .btn {
        width: 100%;
    }

    .schedule-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .date-label {
        min-width: 0;
    }

    .daypart-editor-head {
        align-items: stretch;
    }

    .daypart-title-input {
        max-width: none;
    }

    .schedule-row {
        grid-template-columns: 1fr;
    }

    .admin-nav {
        font-size: 0.9rem;
    }

    .activity-row {
        grid-template-columns: 28px 54px 1fr;
        gap: 0.45rem;
        padding: 0.45rem;
    }

    .activity-preview {
        width: 54px;
        height: 54px;
    }

    .activity-actions .btn {
        padding: 0.45rem 0.6rem;
        font-size: 0.82rem;
    }

    .modal-content {
        width: 96vw;
        margin-top: 2dvh;
        max-height: 94dvh;
    }

    .picto-search-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    table {
        min-width: 0;
    }

    .table-wrap {
        overflow: visible;
    }

    .table-wrap thead {
        display: none;
    }

    .table-wrap tbody,
    .table-wrap tr,
    .table-wrap td {
        display: block;
        width: 100%;
    }

    .table-wrap tr {
        border: 1px solid #dbe3f1;
        border-radius: 12px;
        background: #fff;
        padding: 0.4rem 0.5rem;
        margin-bottom: 0.55rem;
    }

    .table-wrap td {
        border: 0;
        padding: 0.35rem 0;
    }

    .table-wrap td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.74rem;
        color: #627188;
        margin-bottom: 0.1rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .inline-form {
        width: 100%;
    }

    .inline-form .btn {
        flex: 1 1 0;
        min-width: 0;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }

    .child-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0.2rem;
        width: 100%;
    }

    .child-main {
        width: 100%;
        padding: 0.5rem 0.35rem 1rem;
    }

    .picto-wrap {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }

    .picto-wrap img {
        width: 88%;
        height: 88%;
    }
}
