:root{
    --bg-top:#e7f3fb;
    --bg-bottom:#f7fbfe;
    --panel:#ffffff;
    --panel-border:#cfe1ee;
    --text:#173447;
    --muted:#5d7788;
    --shadow:0 18px 42px rgba(22,62,92,0.12);
    --week-bleue:#4F9CE8;
    --week-blanche:#ffffff;
    --week-jaune:#FFD84D;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
    font-family:"Segoe UI",Tahoma,Geneva,Verdana,sans-serif;
    color:var(--text);
    background:
        radial-gradient(circle at top left, rgba(102,181,238,0.32), transparent 28%),
        radial-gradient(circle at top right, rgba(255,216,77,0.18), transparent 24%),
        linear-gradient(180deg,var(--bg-top),var(--bg-bottom));
    min-height:100vh;
}

.offline-app{
    width:min(1180px, calc(100vw - 24px));
    margin:12px auto 24px;
}

.offline-header{
    display:flex;
    justify-content:space-between;
    gap:16px;
    align-items:flex-start;
    padding:20px 22px;
    border:1px solid rgba(255,255,255,0.72);
    border-radius:24px;
    background:linear-gradient(135deg, rgba(10,94,149,0.96), rgba(22,138,204,0.92));
    color:#fff;
    box-shadow:var(--shadow);
}

.offline-kicker{
    margin:0 0 6px;
    text-transform:uppercase;
    letter-spacing:.12em;
    font-size:12px;
    opacity:.82;
}

.offline-header h1{
    margin:0;
    font-size:clamp(26px, 4vw, 40px);
    line-height:1.05;
}

.offline-subtitle{
    margin:8px 0 0;
    font-size:15px;
    opacity:.92;
}

.offline-header-actions{
    display:flex;
    flex-direction:column;
    gap:10px;
    align-items:flex-end;
}

.offline-header-links{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    justify-content:flex-end;
}

.offline-user{
    padding:10px 14px;
    border-radius:999px;
    background:rgba(255,255,255,0.16);
    font-weight:700;
    white-space:nowrap;
}

.offline-link{
    color:#fff;
    text-decoration:none;
    font-weight:700;
    padding:10px 14px;
    border-radius:999px;
    border:1px solid rgba(255,255,255,0.22);
    background:rgba(255,255,255,0.1);
}

.offline-link.offline-link-soft{
    background:rgba(255,255,255,0.04);
}

.offline-main{
    display:grid;
    gap:16px;
    margin-top:16px;
}

.offline-panel{
    background:rgba(255,255,255,0.9);
    border:1px solid var(--panel-border);
    border-radius:24px;
    box-shadow:var(--shadow);
    padding:18px;
    backdrop-filter:blur(8px);
}

.panel-head{
    display:flex;
    justify-content:space-between;
    gap:12px;
    align-items:flex-start;
    margin-bottom:14px;
}

.panel-head h2{
    margin:0;
    font-size:clamp(20px, 3vw, 28px);
}

.panel-head p{
    margin:0;
    color:var(--muted);
    font-size:15px;
    text-align:right;
}

.panel-head-copy{
    display:grid;
    gap:6px;
}

.offline-board-title{
    margin:0;
    font-size:clamp(18px, 2.6vw, 24px);
    font-weight:900;
    color:#0f5f93;
}

.is-hidden{
    display:none !important;
}

.panel-head-absents{
    align-items:center;
}

.offline-board-actions{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
    justify-content:flex-end;
}

.offline-filter-block{
    display:grid;
    gap:8px;
}

.offline-filter-block label{
    font-size:13px;
    font-weight:800;
    text-transform:uppercase;
    letter-spacing:.08em;
    color:#406275;
}

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

.offline-filter-grid > .offline-filter-block:first-child{
    grid-column:span 2;
}

.class-chip-row{
    display:flex;
    gap:10px;
    overflow:auto;
    padding-bottom:4px;
}

.class-chip-row::-webkit-scrollbar{height:8px}
.class-chip-row::-webkit-scrollbar-thumb{background:#b8d0df;border-radius:999px}

.class-chip,
.segment-btn,
.nav-btn{
    border:1px solid #c8dae8;
    background:#f6fbff;
    color:var(--text);
    border-radius:18px;
    font:inherit;
}

.class-chip{
    min-width:86px;
    padding:14px 16px;
    font-weight:800;
    font-size:18px;
    white-space:nowrap;
}

.class-chip.active{
    background:linear-gradient(135deg, #1182cb, #0a5e95);
    color:#fff;
    border-color:#0a5e95;
    box-shadow:0 12px 24px rgba(15,123,194,0.28);
}

.period-segment{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.segment-btn{
    flex:1 1 170px;
    padding:14px 16px;
    font-weight:800;
    font-size:16px;
    white-space:nowrap;
}

.segment-btn.active{
    background:linear-gradient(180deg, #1a8ed6, #0d679f);
    color:#fff;
    border-color:#0b679f;
}

.period-nav{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
}

.nav-btn{
    padding:14px 10px;
    font-size:28px;
    line-height:1;
    font-weight:900;
    background:linear-gradient(180deg, #ffffff, #e6f2fb);
}

.nav-btn:disabled{opacity:.45}

.period-input-block input{
    width:100%;
    min-height:52px;
    padding:12px 14px;
    border-radius:16px;
    border:1px solid #c7dae7;
    background:#f8fbfe;
    color:var(--text);
    font:inherit;
    font-size:18px;
    font-weight:700;
}

.period-input-block.is-hidden{display:none}

.offline-agenda-callout{
    display:flex;
    justify-content:space-between;
    gap:16px;
    align-items:center;
    border:1px solid #d7e5ef;
    border-radius:20px;
    padding:16px 18px;
    background:linear-gradient(180deg,#fbfdff,#eef7fd);
}

.offline-agenda-callout p{
    margin:0;
    color:var(--muted);
    font-size:16px;
}

.offline-agenda-btn{
    border:1px solid #0b679f;
    border-radius:999px;
    padding:14px 18px;
    background:linear-gradient(180deg,#1a8ed6,#0d679f);
    color:#fff;
    font:inherit;
    font-size:18px;
    font-weight:900;
    cursor:pointer;
    box-shadow:0 12px 24px rgba(15,123,194,0.24);
    white-space:nowrap;
}

.mini-chip-group{
    display:inline-flex;
    flex-wrap:wrap;
    gap:6px;
}

.mini-chip{
    border:1px solid #bad4e8;
    border-radius:999px;
    background:#fff;
    color:#2e5a78;
    font:inherit;
    font-size:0.88rem;
    font-weight:700;
    padding:6px 11px;
    cursor:pointer;
}

.mini-chip.active{
    color:#fff;
    background:linear-gradient(135deg,#0f7dc1,#14a6df);
    border-color:#0a6aa5;
    box-shadow:0 0 0 2px rgba(17,149,214,0.16),0 5px 10px rgba(9,80,124,0.24);
}

.modal{
    position:fixed;
    inset:0;
    display:none;
    z-index:120;
}

.modal.open{display:block}

.modal-backdrop{
    position:absolute;
    inset:0;
    background:rgba(12,34,49,0.58);
}

.modal-dialog{
    position:relative;
    z-index:1;
    margin:5vh auto;
    width:min(1320px, calc(100vw - 24px));
    max-height:88vh;
    overflow:hidden;
    border-radius:18px;
    background:#fff;
    border:1px solid #cfe1ee;
    box-shadow:0 24px 60px rgba(16,54,84,0.28);
    display:flex;
    flex-direction:column;
}

.modal-header{
    padding:14px 16px;
    border-bottom:1px solid #d8e6ef;
    display:flex;
    justify-content:space-between;
    gap:12px;
    align-items:center;
}

.modal-header h3{
    margin:0;
    font-size:clamp(22px, 3vw, 30px);
}

.modal-close-btn{
    border:1px solid #c7dce9;
    border-radius:999px;
    width:40px;
    height:40px;
    background:#f6fbff;
    color:#244c68;
    font:inherit;
    font-size:26px;
    line-height:1;
    cursor:pointer;
}

.modal-body{
    padding:16px;
    overflow:auto;
}

.agenda-modal-body{
    display:grid;
    gap:10px;
}

.scope-note{
    margin:2px 0 12px;
    color:#43627a;
    font-size:0.96rem;
}

.agenda-toolbar{
    display:flex;
    gap:10px;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
}

.agenda-class-group .mini-chip{
    font-size:0.82rem;
    padding:5px 10px;
}

.agenda-year-wrap{
    border:1px solid #d3e4f1;
    border-radius:12px;
    padding:10px;
    background:#f8fcff;
}

.agenda-year-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    margin-bottom:10px;
    color:#315d7b;
}

.agenda-year-head h4{
    margin:0;
    font-size:1.35rem;
    letter-spacing:0.02em;
}

.agenda-year-head p{
    margin:0;
    font-size:0.85rem;
    color:#476b82;
}

.agenda-months-grid{
    display:grid;
    gap:10px;
    grid-template-columns:repeat(4, minmax(220px, 1fr));
}

.agenda-month-card{
    background:#fff;
    border:1px solid #cce0ef;
    border-radius:12px;
    padding:8px;
    box-shadow:0 5px 14px rgba(17,74,112,0.08);
}

.agenda-month-title{
    border:1px solid #c8ddee;
    background:#f2f9ff;
    color:#2f5f7f;
    font-weight:800;
    border-radius:10px;
    width:100%;
    text-align:left;
    padding:7px 10px;
    min-height:34px;
    font:inherit;
}

.agenda-month-title.interactive,
.agenda-week-chip.interactive{
    cursor:pointer;
    transition:transform 120ms ease, box-shadow 130ms ease;
}

.agenda-month-title.interactive:hover,
.agenda-week-chip.interactive:hover{
    transform:translateY(-1px);
    box-shadow:0 5px 11px rgba(23,84,125,0.2);
}

.agenda-month-title.active-target{
    border-color:#0f7bc1;
    box-shadow:0 0 0 2px rgba(16,145,211,0.2);
}

.agenda-month-weeks{
    margin-top:8px;
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:6px;
}

.agenda-week-chip{
    border:1px solid #bcd3e5;
    border-radius:9px;
    background:#fff;
    min-height:34px;
    padding:4px 5px;
    display:grid;
    gap:2px;
    align-content:center;
    text-align:center;
    color:#184666;
    font:inherit;
}

.agenda-week-chip.active-target{
    box-shadow:0 0 0 2px rgba(16,145,211,0.2),0 5px 10px rgba(9,80,124,0.24);
}

.agenda-week-number{
    font-size:0.78rem;
    font-weight:800;
}

.agenda-week-range{
    font-size:0.69rem;
    color:#1f5376;
}

.agenda-week-chip.color-bleue{
    background:var(--week-bleue);
    color:#fff;
    border-color:rgba(0,0,0,0.16);
}

.agenda-week-chip.color-bleue .agenda-week-range{color:#fff}

.agenda-week-chip.color-jaune{
    background:var(--week-jaune);
    border-color:rgba(0,0,0,0.16);
    color:#423100;
}

.agenda-week-chip.color-jaune .agenda-week-range{color:#423100}

.agenda-week-chip.color-blanche{
    background:var(--week-blanche);
    border-color:rgba(0,0,0,0.16);
    color:#1e3443;
}

.agenda-week-chip.color-blanche .agenda-week-range{color:#1e3443}

.agenda-week-chip.holiday-week{
    background:linear-gradient(180deg,#9aa4af,#87939f) !important;
    border-color:#768391 !important;
    color:#122232 !important;
}

.agenda-week-chip.holiday-week .agenda-week-range{color:#1d2f40 !important}

.offline-board{
    display:grid;
    gap:14px;
}

.week-group{
    border:1px solid #d5e3ec;
    border-radius:20px;
    overflow:hidden;
    background:#fff;
}

.week-head{
    display:flex;
    justify-content:space-between;
    gap:10px;
    align-items:center;
    padding:14px 16px;
    border-bottom:1px solid #d8e5ee;
}

.week-head.week-bleue{background:rgba(79,156,232,0.22)}
.week-head.week-blanche{background:#fff}
.week-head.week-jaune{background:rgba(255,216,77,0.35)}
.week-head.holiday{background:rgba(123,134,147,0.26)}

.week-title{
    display:grid;
    gap:4px;
}

.week-title strong{font-size:20px}

.week-title span{
    color:var(--muted);
    font-size:14px;
}

.week-color-badge{
    padding:10px 14px;
    border-radius:999px;
    border:1px solid rgba(0,0,0,0.08);
    font-weight:900;
    font-size:14px;
    white-space:nowrap;
}

.week-color-badge.week-bleue{background:var(--week-bleue);color:#fff}
.week-color-badge.week-blanche{background:var(--week-blanche);color:#1e3443}
.week-color-badge.week-jaune{background:var(--week-jaune);color:#423100}

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

.day-card{
    min-height:176px;
    border-radius:22px;
    border:1px solid #d8e5ee;
    background:linear-gradient(180deg,#fdfefe,#eef7fd);
    padding:16px 14px;
    display:grid;
    align-content:start;
    gap:12px;
    transition:background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.day-card.is-holiday{
    background:linear-gradient(180deg,#8994a0,#737d89);
    color:#fff;
}

.day-card.is-empty{
    background:linear-gradient(180deg,#ffffff,#f2f7fb);
}

.day-card.has-absent{
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.55), 0 8px 18px rgba(168,41,41,0.12);
    cursor:pointer;
}

.day-top{
    display:block;
}

.day-title{display:grid;gap:4px}
.day-title strong{font-size:21px;line-height:1.15}
.day-title span{font-size:15px;color:inherit;opacity:.82}

.day-status{
    font-size:14px;
    font-weight:900;
    border-radius:999px;
    padding:7px 10px;
    background:rgba(15,123,194,0.12);
    color:#0b679f;
}

.day-card.is-holiday .day-status{
    background:rgba(255,255,255,0.18);
    color:#fff;
}

.day-main{display:grid;gap:8px}

.day-type-badges{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
}

.day-type-chip{
    display:inline-flex;
    align-items:center;
    border-radius:999px;
    padding:5px 9px;
    color:#fff;
    font-size:12px;
    font-weight:900;
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.18);
}

.day-full-count{font-size:clamp(54px, 8vw, 72px);line-height:.95;font-weight:900}
.day-full-label{font-size:18px;font-weight:800}
.day-split{display:grid;gap:8px}

.day-split-line{
    display:flex;
    justify-content:space-between;
    align-items:baseline;
    gap:12px;
    padding:10px 12px;
    border-radius:16px;
    background:rgba(255,255,255,0.5);
}

.day-split-line strong{font-size:18px}
.day-split-line span{font-size:32px;font-weight:900;line-height:1}
.day-holiday-text{font-size:22px;font-weight:900;line-height:1.15}
.day-empty-value{font-size:clamp(42px, 6vw, 58px);font-weight:900;line-height:1;color:#3f647a}
.day-empty-label{font-size:18px;color:var(--muted);font-weight:800}

.empty-state{
    padding:22px;
    border-radius:20px;
    border:1px dashed #b9cedd;
    color:var(--muted);
    text-align:center;
    font-size:18px;
    background:#f9fcff;
}

.offline-day-details{
    display:grid;
    gap:10px;
}

.offline-day-type-list{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.offline-day-type-chip{
    display:inline-flex;
    align-items:center;
    border-radius:999px;
    padding:7px 12px;
    color:#fff;
    font-size:14px;
    font-weight:900;
}

.offline-discipline-row{
    border:1px solid #d7e5ef;
    border-radius:16px;
    padding:12px 14px;
    background:linear-gradient(180deg,#fcfeff,#f3f9fd);
}

.offline-discipline-head{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px;
    margin-bottom:8px;
}

.offline-discipline-head strong{
    font-size:24px;
    color:#214d6e;
}

.offline-discipline-pill{
    display:inline-flex;
    align-items:center;
    border-radius:999px;
    padding:6px 12px;
    color:#fff;
    font-size:15px;
    font-weight:900;
}

.offline-discipline-stats{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}

.offline-discipline-stats span{
    padding:6px 10px;
    border-radius:999px;
    background:#eaf4fb;
    color:#335d78;
    font-size:14px;
    font-weight:700;
}

@media (max-width: 1080px){
    .offline-filter-grid{grid-template-columns:repeat(2, minmax(0,1fr))}
    .agenda-months-grid{grid-template-columns:repeat(2, minmax(220px, 1fr))}
    .days-grid{grid-template-columns:repeat(2, minmax(0,1fr))}
}

@media (max-width: 720px){
    .offline-app{width:min(100vw - 12px, 100%)}
    .offline-header{
        flex-direction:column;
        align-items:stretch;
        padding:18px;
    }
    .offline-header-actions{align-items:stretch}
    .offline-header-links{justify-content:stretch}
    .panel-head{flex-direction:column}
    .panel-head p{text-align:left}
    .offline-board-actions{
        width:100%;
        justify-content:stretch;
    }
    .offline-filter-grid,
    .days-grid,
    .agenda-months-grid{grid-template-columns:1fr}
    .offline-filter-grid > .offline-filter-block:first-child{
        grid-column:auto;
    }
    .segment-btn{
        flex:1 1 calc(50% - 8px);
    }
    .week-head{flex-direction:column;align-items:flex-start}
    .class-chip{min-width:74px;font-size:16px;padding:12px 14px}
    .day-card{min-height:160px}
    .offline-agenda-callout{flex-direction:column;align-items:stretch}
    .modal-dialog{
        width:min(100vw - 12px, 100%);
        margin:2vh auto;
        max-height:94vh;
    }
}
