/* StringFlow - UI styles. Sober, light, Google-Agenda inspired. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --text: #1f2330;
    --muted: #6b7280;
    --muted-2: #9aa1ad;
    --border: #e4e7ec;
    --border-strong: #d3d8e0;
    --primary: #2f6fed;
    --primary-dark: #2257c5;
    --primary-soft: #e9f0fe;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --success: #16a34a;
    --warn: #b45309;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, .12);
    --shadow-lg: 0 20px 48px rgba(16, 24, 40, .22);
    --sidebar-w: 264px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ---------------- Layout ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 14px;
    gap: 14px;
    overflow-y: auto;
    z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 4px 4px; }
.brand__logo {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.brand__logo img { width: 100%; height: 100%; display: block; }
.brand__name { font-size: 18px; font-weight: 700; letter-spacing: 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 56px;
    flex: 0 0 56px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: 16px; font-weight: 650; margin: 0; }
.topbar__spacer { flex: 1; }
.topbar__menu { display: none; }
.topbar__save { margin-left: 4px; }
.topbar__save[hidden] { display: none; }

.view { display: none; flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.view.is-active { display: block; }
#view-calendar.is-active { display: flex; flex-direction: column; }

/* ---------------- Buttons ---------------- */
.btn {
    appearance: none;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 550;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background .12s, border-color .12s, box-shadow .12s, opacity .12s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn--danger { color: var(--danger); border-color: #f0c7c7; }
.btn--danger:hover { background: var(--danger-soft); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--block { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.ico { font-size: 1.05em; line-height: 1; }

.icon-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--muted);
    width: 32px; height: 32px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------------- Mini calendar ---------------- */
.mini-cal { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.mini-cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-cal__title { font-weight: 600; font-size: 13px; text-transform: capitalize; }
.mini-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.mini-cal__dow { text-align: center; font-size: 10.5px; color: var(--muted-2); padding: 2px 0; font-weight: 600; }
.mini-day {
    position: relative;
    aspect-ratio: 1 / 1;
    border: none; background: transparent; cursor: pointer;
    border-radius: 50%;
    font-size: 12px; color: var(--text);
    display: flex; align-items: center; justify-content: center;
}
.mini-day:hover { background: var(--surface-2); }
.mini-day.is-other { color: var(--muted-2); }
.mini-day.is-today { color: var(--primary); font-weight: 700; }
.mini-day.is-selected { background: var(--primary); color: #fff; }
.mini-day.has-events::after {
    content: ""; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; border-radius: 50%; background: var(--primary);
}
.mini-day.is-selected.has-events::after { background: #fff; }

/* ---------------- Nav ---------------- */
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav__item {
    appearance: none; border: none; background: transparent; text-align: left;
    padding: 9px 11px; border-radius: 8px; cursor: pointer;
    font-size: 14px; color: var(--text); font-weight: 500;
    display: flex; align-items: center; gap: 10px;
}
.nav__item:hover { background: var(--surface-2); }
.nav__item.is-active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; }
.nav__item--utility {
    color: var(--muted);
    font-size: 13.5px;
}
.nav__item--utility:hover {
    color: var(--text);
}
.sidebar__foot { margin-top: auto; color: var(--muted-2); font-size: 11.5px; text-align: center; padding-top: 8px; }

/* ---------------- Panels ---------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel--narrow { max-width: 720px; }
.panel--settings { max-width: 1180px; }
.panel__head {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel__title { font-size: 15px; font-weight: 650; }
.panel__subtitle { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.panel__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel__actions--search { flex-wrap: nowrap; }
.panel__actions--search .panel__search {
    width: 320px;
    max-width: 34vw;
    flex: 0 0 auto;
}

/* ---------------- Calendar ---------------- */
#calendar {
    flex: 1; min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 12px;
}
.fc {
    --fc-border-color: var(--border);
    --fc-page-bg-color: var(--surface);
    --fc-neutral-bg-color: var(--surface-2);
    --fc-today-bg-color: #eef4ff;
    --fc-event-border-color: transparent;
    font-size: 13px;
}
.fc .fc-toolbar-title { font-size: 18px; font-weight: 650; text-transform: capitalize; }
.fc .fc-button {
    box-shadow: none; font-size: 13px; font-weight: 550; text-transform: capitalize; padding: 6px 11px;
}
/* Selectors use both classes (+ states) so they beat FullCalendar's own
   injected styles, which otherwise force white text on hover. */
.fc .fc-button.fc-button-primary {
    background: var(--surface); border-color: var(--border-strong); color: var(--text);
}
.fc .fc-button.fc-button-primary:hover {
    background: var(--surface-2); border-color: var(--border-strong); color: var(--text);
}
.fc .fc-button.fc-button-primary:disabled {
    background: var(--surface); border-color: var(--border); color: var(--muted-2); opacity: 1;
}
/* Active (selected) view = blue background, white text, even on hover. */
.fc .fc-button.fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button.fc-button-primary:not(:disabled).fc-button-active:hover,
.fc .fc-button.fc-button-primary:not(:disabled):active {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.fc .fc-button.fc-button-primary:focus,
.fc .fc-button.fc-button-primary:focus-visible {
    box-shadow: 0 0 0 2px var(--primary-soft); outline: none;
}
.fc .fc-col-header-cell-cushion { color: var(--muted); font-weight: 600; padding: 8px 4px; text-decoration: none; }
.fc .fc-daygrid-day-number { color: var(--muted); text-decoration: none; padding: 4px 6px; }
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number { color: var(--primary); font-weight: 700; }
.fc .fc-daygrid-day.sf-selected-date .fc-daygrid-day-frame,
.fc .fc-timegrid-col.sf-selected-date .fc-timegrid-col-frame {
    background: rgba(47, 111, 237, .08);
    box-shadow: inset 0 0 0 2px rgba(47, 111, 237, .78);
}
.fc .fc-daygrid-day.sf-selected-date .fc-daygrid-day-number {
    min-width: 24px;
    margin: 2px 2px 0 0;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 750;
    text-align: center;
}
.fc .fc-col-header-cell.sf-selected-date {
    background: var(--primary-soft);
}
.fc .fc-col-header-cell.sf-selected-date .fc-col-header-cell-cushion {
    color: var(--primary-dark);
    font-weight: 750;
}
.fc-event { cursor: pointer; border-radius: 5px; padding: 1px 2px; font-weight: 500; }
.fc-event:hover { filter: brightness(.96); }
.fc .fc-timegrid-event .fc-event-main { padding: 2px 4px; }
.sf-ev-amount { opacity: .85; font-weight: 400; }

/* ---------------- Cards (students) ---------------- */
.cards { padding: 14px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
    border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 14px; background: var(--surface);
    cursor: pointer; transition: box-shadow .12s, border-color .12s;
}
.card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.card__name { font-weight: 650; font-size: 14.5px; }
.card__line { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.card__rate { display: inline-block; margin-top: 9px; font-size: 12px; color: var(--primary-dark); background: var(--primary-soft); padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.empty { padding: 38px 18px; text-align: center; color: var(--muted); }

/* ---------------- Tables ---------------- */
.table-wrap { padding: 6px 8px 12px; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.tag--ok { background: #e7f6ec; color: var(--success); }

/* ---------------- Summary ---------------- */
.summary { margin: 14px 18px 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface-2); }
.summary__stats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 8px; }
.summary__stat b { font-size: 20px; display: block; }
.summary__stat span { color: var(--muted); font-size: 12px; }
.summary ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }
.summary .err { color: var(--danger); }

/* ---------------- Forms ---------------- */
.form { padding: 16px 18px; display: flex; flex-direction: column; gap: 13px; }
.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.settings-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 13px;
}
.settings-form {
    padding: 0;
    gap: 0;
}
.settings-center {
    display: grid;
    grid-template-columns: 254px minmax(0, 1fr);
    align-items: start;
    min-height: min(720px, calc(100vh - 136px));
}
.settings-nav {
    position: sticky;
    top: 0;
    z-index: 2;
    align-self: start;
    max-height: calc(100vh - 122px);
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-right: 1px solid var(--border);
    background: #fbfcfe;
}
.settings-nav__item {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    transition: background .12s, border-color .12s, box-shadow .12s;
}
.settings-nav__item:hover {
    background: var(--surface);
    border-color: var(--border);
}
.settings-nav__item.is-active {
    background: var(--primary-soft);
    border-color: #c9d9fb;
    color: var(--primary-dark);
    box-shadow: inset 3px 0 0 var(--primary);
}
.settings-nav__item:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.settings-nav__ico {
    width: 22px;
    flex: 0 0 22px;
    text-align: center;
    line-height: 1.2;
}
.settings-nav__item strong {
    display: block;
    font-size: 13.5px;
    line-height: 1.15;
}
.settings-nav__item small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.25;
}
.settings-nav__item.is-active small { color: var(--primary-dark); }
.settings-content {
    min-width: 0;
    padding: 16px;
}
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 13px;
    max-width: 850px;
}
.settings-section[hidden] { display: none; }
.settings-section__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 2px;
}
.settings-section__head h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0;
}
.settings-section__head p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}
.settings-note-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.settings-note {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 12px;
}
.settings-note__title {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 5px;
}
.settings-note p {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
}
.settings-about-list {
    margin: 0;
    display: grid;
    gap: 8px;
}
.settings-about-list div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.settings-about-list div:last-child { border-bottom: none; }
.settings-about-list dt {
    color: var(--muted);
    font-size: 13px;
}
.settings-about-list dd {
    margin: 0;
    font-weight: 650;
    text-align: right;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.field--inline { flex-direction: row; align-items: center; gap: 8px; }
.field--inline > span { white-space: nowrap; }
.field--check { flex-direction: row; align-items: center; gap: 8px; }
.field--check > span { color: var(--text); font-weight: 500; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text); background: var(--surface); font-family: inherit;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; }
.output { padding: 9px 0; font-weight: 650; font-size: 15px; color: var(--text); }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.fieldset--tight { padding: 10px 12px; gap: 8px; }
.fieldset legend { font-size: 12.5px; font-weight: 650; color: var(--muted); padding: 0 6px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.form__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------- Modals ---------------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(17, 24, 39, .45); animation: fade .12s ease; }
.modal__dialog {
    position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
    background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .14s ease;
}
.modal__dialog--wide { max-width: 720px; }
.modal__dialog--student { max-width: 920px; }
.modal--sm .modal__dialog { max-width: 420px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.modal__title { font-size: 17px; font-weight: 650; margin: 0; }
.modal__body { padding: 6px 18px 4px; color: var(--text); }
.modal__foot { display: flex; align-items: center; gap: 8px; padding: 14px 18px 18px; }
.modal__foot .spacer, .spacer { flex: 1; }

.about-app {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 16px;
}
.about-app__logo {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
}
.about-app__name {
    font-size: 18px;
    font-weight: 750;
}
.about-app p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}
.about-list {
    margin: 0;
    border-top: 1px solid var(--border);
}
.about-list div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.about-list dt {
    color: var(--muted);
    font-size: 13px;
}
.about-list dd {
    margin: 0;
    font-weight: 650;
    text-align: right;
}
.changelog {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.changelog__release {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 15px;
    background: var(--surface);
}
.changelog__version {
    color: var(--primary-dark);
    font-weight: 750;
    margin-bottom: 8px;
}
.changelog ul {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}
.changelog li {
    margin: 5px 0;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------------- Toasts ---------------- */
.toast-wrap { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast {
    background: #20242e; color: #fff; padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow-md);
    font-size: 13.5px; display: flex; gap: 9px; align-items: flex-start; animation: pop .14s ease;
}
.toast--success { background: #15803d; }
.toast--error { background: #b91c1c; }
.toast--info { background: #1f2937; }
.toast__close { margin-left: auto; cursor: pointer; opacity: .8; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1240px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-note-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; transform: translateX(-100%);
        transition: transform .2s ease; box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: translateX(0); }
    .topbar__menu { display: inline-flex; }
    .grid-2 { grid-template-columns: 1fr; }
    .settings-layout { grid-template-columns: 1fr; }
    .settings-center {
        display: block;
        min-height: 0;
    }
    .settings-nav {
        position: sticky;
        top: 0;
        max-height: none;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 10px 12px;
    }
    .settings-nav__item {
        flex: 0 0 178px;
        align-items: flex-start;
    }
    .settings-nav__item.is-active {
        box-shadow: inset 0 -3px 0 var(--primary);
    }
    .settings-content {
        padding: 14px;
    }
    .settings-section {
        max-width: none;
    }
    .settings-note-grid {
        grid-template-columns: 1fr;
    }
    .reminder-recap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel__actions { width: 100%; }
    .panel__actions--search {
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
    }
    .panel__actions--search .panel__search {
        order: 1;
        width: 100%;
        max-width: none;
    }
    .panel__actions--search .btn {
        order: 2;
        width: 100%;
        justify-content: center;
    }
    .sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
    .sidebar-scrim[hidden] { display: none; }
}

@media (max-width: 520px) {
    .reminder-recap { grid-template-columns: 1fr; }
    .settings-nav {
        padding: 8px;
    }
    .settings-nav__item {
        flex-basis: auto;
        min-width: 126px;
        padding: 9px;
        align-items: center;
    }
    .settings-nav__ico {
        width: 18px;
        flex-basis: 18px;
    }
    .settings-nav__item small {
        display: none;
    }
    .settings-section__head h2 {
        font-size: 17px;
    }
    .settings-content {
        padding: 12px;
    }
}

/* ===================== Auth pages ===================== */
.auth-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #eef3fe 0%, #f6f7f9 55%, #f6f7f9 100%);
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 26px 24px 22px;
}
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.auth-brand__logo { width: 34px; height: 34px; flex: 0 0 auto; display: block; }
.auth-title { font-size: 20px; font-weight: 650; margin: 16px 0 2px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.auth-form { display: flex; flex-direction: column; gap: 13px; padding: 4px 0 2px; }
.auth-form .field > span { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.auth-links a { color: var(--primary-dark); text-decoration: none; font-size: 13px; font-weight: 550; }
.auth-links a:hover { text-decoration: underline; }
.auth-links--login {
    justify-content: space-between;
    margin-top: 15px;
}
.auth-switch {
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}
.auth-switch a {
    color: var(--primary-dark);
    font-weight: 650;
    text-decoration: none;
}
.auth-switch a:hover { text-decoration: underline; }
.auth-check {
    align-items: flex-start;
    gap: 9px;
    color: var(--text);
    line-height: 1.45;
}
.auth-check input {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    accent-color: var(--primary);
}
.auth-check a,
.terms-box a {
    color: var(--primary-dark);
    font-weight: 650;
    text-decoration: none;
}
.auth-check a:hover,
.terms-box a:hover { text-decoration: underline; }
.auth-captcha {
    display: flex;
    justify-content: center;
    min-height: 78px;
    overflow: hidden;
}
.auth-captcha .h-captcha {
    transform-origin: top center;
}
.terms-box {
    margin: 2px 0 14px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.58;
}
.terms-box p { margin: 0 0 9px; }
.terms-box p:last-child { margin-bottom: 0; }

.alert { border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13.5px; margin-bottom: 14px; border: 1px solid transparent; }
.alert a { color: inherit; font-weight: 650; }
.alert--error { background: var(--danger-soft); color: #9a1c1c; border-color: #f3c9c9; }
.alert--success { background: #e7f6ec; color: #15692f; border-color: #bce6c9; }
.alert--info { background: var(--primary-soft); color: var(--primary-dark); border-color: #cfe0fb; }

/* ===================== First-login wizard ===================== */
.wizard {
    width: 100%; max-width: 600px; margin: 0 auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; box-shadow: var(--shadow-md); padding: 26px 26px 20px;
}
.wizard__head { margin-bottom: 8px; }
.wizard__progress { height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: 14px; }
.wizard__progress span { display: block; height: 100%; background: var(--primary); transition: width .2s ease; }
.wizard__form { padding: 16px 0 0; }
.wz-step__title { font-size: 15px; font-weight: 650; margin: 0 0 12px; }
.wizard__nav { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.wz-note { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }

/* Segmented choice (tax regime) */
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg__opt {
    flex: 1 1 210px; display: flex; align-items: center; gap: 9px;
    padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 10px;
    cursor: pointer; font-size: 13.5px; font-weight: 500;
    transition: border-color .12s, background .12s, box-shadow .12s;
}
.seg__opt:hover { background: var(--surface-2); }
.seg__opt input { accent-color: var(--primary); width: 16px; height: 16px; }
.seg__opt.is-checked { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); color: var(--primary-dark); }

/* ===================== User chip (sidebar) ===================== */
.sidebar__foot { margin-top: auto; padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.userchip { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 9px; min-width: 0; }
.userchip__avatar {
    flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.userchip__email { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__ver { color: var(--muted-2); font-size: 11px; text-align: center; }

@media (max-width: 520px) {
    .auth-links { flex-direction: column; }
}

@media (max-width: 380px) {
    .auth-captcha { min-height: 72px; }
    .auth-captcha .h-captcha { transform: scale(.9); }
}

/* Clickable user chip */
.userchip { width: 100%; cursor: pointer; text-align: left; font: inherit; transition: border-color .12s, box-shadow .12s; }
.userchip:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* "Se déconnecter" — red with glow */
#btn-logout {
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, .35);
    background: transparent;
    box-shadow: 0 0 8px rgba(220, 38, 38, .18);
    transition: background .15s, box-shadow .15s, border-color .15s;
}
#btn-logout:hover {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: rgba(220, 38, 38, .55);
    box-shadow: 0 0 16px rgba(220, 38, 38, .45);
}
#btn-logout:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220, 38, 38, .35); }

/* ===================== Account modal (tabs) ===================== */
.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.tab {
    appearance: none; border: none; background: transparent; cursor: pointer;
    padding: 11px 12px; font-size: 13.5px; font-weight: 550; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tab[disabled] { color: var(--muted-2); cursor: not-allowed; }
.tabpane[hidden] { display: none; }

/* ===================== Student folder ===================== */
.student-tabpane[hidden] { display: none; }
.student-folder {
    padding: 14px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.student-summary {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}
.student-summary__grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
}
.student-summary__stat {
    min-width: 0;
    padding: 11px 12px;
    border-right: 1px solid var(--border);
}
.student-summary__stat:last-child { border-right: none; }
.student-summary__stat b {
    display: block;
    font-size: 16px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.student-summary__stat span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 2px;
}
.student-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}
.student-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.student-section__head h3 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 650;
}
.student-list {
    display: flex;
    flex-direction: column;
}
.student-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 13px;
    border-bottom: 1px solid var(--border);
}
.student-item:last-child { border-bottom: none; }
.student-item__main { min-width: 0; flex: 1; }
.student-item__title { font-weight: 650; font-size: 13.5px; }
.student-item__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}
.student-item__notes {
    margin-top: 7px;
    color: var(--muted);
    font-size: 12.5px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.student-item__side {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}
.student-table .table-wrap { padding: 0; }
.table-wrap--compact .tbl th,
.table-wrap--compact .tbl td { padding: 8px 10px; }
.student-empty,
.student-loader,
.student-error {
    padding: 18px 14px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.student-loader { background: linear-gradient(90deg, transparent, rgba(47, 111, 237, .06), transparent); }
.student-error { color: var(--danger); background: var(--danger-soft); }
.student-access {
    margin: 0 18px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 13px 14px;
    display: flex;
    flex-direction: column;
    gap: 11px;
}
.student-access[hidden] { display: none; }
.student-access__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.student-access__head h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}
.student-access__head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}
.student-access__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 860px) {
    .modal__dialog--student { max-width: 100%; }
    .student-summary__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .student-summary__stat {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .student-summary__stat:nth-last-child(-n+2) { border-bottom: none; }
    .student-item {
        flex-direction: column;
        align-items: stretch;
        gap: 9px;
    }
    .student-item__side { justify-content: flex-start; }
    .student-access__head { flex-direction: column; }
}

@media (max-width: 520px) {
    .student-tabs {
        overflow-x: auto;
        padding: 0 12px;
    }
    .student-tabs .tab {
        flex: 1 0 auto;
        min-width: 110px;
        text-align: center;
    }
    .student-folder { padding: 12px; }
    .student-summary__grid { grid-template-columns: 1fr; }
    .student-summary__stat,
    .student-summary__stat:nth-last-child(-n+2) {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .student-summary__stat:last-child { border-bottom: none; }
    .student-access { margin: 0 12px 12px; }
    .student-access__actions .btn {
        width: 100%;
        justify-content: center;
    }
}

.acc-list { display: flex; flex-direction: column; gap: 2px; }
.acc-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 2px; border-bottom: 1px solid var(--border); }
.acc-row:last-child { border-bottom: none; }
.acc-row__k { color: var(--muted); font-size: 13px; }
.acc-row__v { font-weight: 550; text-align: right; word-break: break-word; }
.account-password {
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding-top: 2px;
}
.account-password .form__actions {
    padding-top: 2px;
}

.activity { display: flex; flex-direction: column; }
.activity__item { display: flex; gap: 11px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.activity__item:last-child { border-bottom: none; }
.activity__ico {
    flex: 0 0 30px; width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.activity__main { min-width: 0; flex: 1; }
.activity__label { font-weight: 600; font-size: 13.5px; }
.activity__meta { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-word; }
.activity__time { color: var(--muted-2); font-size: 12px; white-space: nowrap; }

/* ===================== Payments ===================== */
.badge { display: inline-block; font-size: 11px; font-weight: 650; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.badge--paid { background: #e7f6ec; color: var(--success); }
.badge--partial { background: #fef3c7; color: var(--warn); }
.badge--unpaid { background: var(--danger-soft); color: var(--danger); }
.badge--overpaid { background: var(--primary-soft); color: var(--primary-dark); }
.badge--reminder { background: #f3e8ff; color: #6d28d9; }
.badge__sub { font-size: 11px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.chip { display: inline-block; font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; margin: 1px 0; }
.muted { color: var(--muted-2); }

.reminder-recap {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.reminder-recap div {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    background: var(--surface-2);
}
.reminder-recap span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.reminder-recap strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 13px;
}
.reminder-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 18px 2px; }
.filters .input { max-width: 200px; height: 38px; padding: 7px 10px; }

.pay-alloc { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.pay-alloc__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.pay-alloc__head > span { font-size: 12.5px; font-weight: 650; color: var(--muted); }
.pay-empty { color: var(--muted); font-size: 13px; padding: 8px 0; margin: 0; }
.pay-inv-row { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.pay-inv-row:last-child { border-bottom: none; }
.pay-inv-row__cb { width: 16px; height: 16px; accent-color: var(--primary); flex: 0 0 auto; }
.pay-inv-row__info { flex: 1; min-width: 0; font-size: 13.5px; }
.pay-inv-row__sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.pay-inv-row__amt { width: 116px; flex: 0 0 116px; text-align: right; }
.pay-alloc__sum { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.pay-alloc__sum b { color: var(--text); }
.pay-alloc__sum .err { color: var(--danger); font-weight: 600; }

/* Per-student recap */
.recap { margin: 14px 18px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.recap[hidden] { display: none; }
.recap__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.recap__head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.recap__table { max-height: 240px; overflow: auto; }
.recap__table .tbl th, .recap__table .tbl td { padding: 8px 14px; }
.recap__table .tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); border-bottom: none; position: sticky; bottom: 0; background: var(--surface); }
.solde { font-weight: 650; }
.solde--due { color: var(--danger); }
.solde--over { color: var(--primary-dark); }
.solde--ok { color: var(--success); }

/* ===================== SMTP / e-mail / logo ===================== */
.badge--neutral { background: var(--surface-2); color: var(--muted); }
.smtp-test { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.fieldset code, .hint code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 11.5px; white-space: nowrap; }
.hint a {
    color: var(--primary-dark);
    font-weight: 650;
    text-decoration: none;
}
.hint a:hover { text-decoration: underline; }

.mail-vars {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: -5px;
}
.mail-vars__label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}
.mail-vars__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mail-var-btn {
    position: relative;
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 20px;
    padding: 5px 9px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    transition: background .12s, border-color .12s, box-shadow .12s, transform .12s;
}
.mail-var-btn:hover {
    background: var(--primary-soft);
    border-color: #c6d7fb;
    color: var(--primary-dark);
}
.mail-var-btn:active { transform: translateY(.5px); }
.mail-var-btn:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.mail-var-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    max-width: 230px;
    padding: 7px 9px;
    border-radius: 7px;
    background: #20242e;
    color: #fff;
    box-shadow: var(--shadow-sm);
    font-size: 12px;
    font-weight: 500;
    white-space: normal;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    transition: opacity .12s, transform .12s;
}
.mail-var-btn[data-tooltip]:hover::after,
.mail-var-btn[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.template-preview {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.template-preview__title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.template-preview__subject {
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    padding: 8px 10px;
    font-weight: 650;
    overflow-wrap: anywhere;
}
.template-preview__body {
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface);
    padding: 10px;
    min-height: 84px;
    color: var(--text);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

@media (max-width: 520px) {
    .mail-vars__buttons { gap: 7px; }
    .mail-var-btn {
        flex: 1 1 calc(50% - 7px);
        text-align: center;
        border-radius: 8px;
        padding: 8px 9px;
    }
    .mail-var-btn[data-tooltip]::after { display: none; }
}

.logo-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-preview {
    width: 170px; height: 86px; flex: 0 0 auto; overflow: hidden;
    border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; font-size: 12.5px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { flex: 1; min-width: 220px; }
.logo-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }

/* ===================== Student portal ===================== */
.student-portal-body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
}
.student-portal {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 18px 0 34px;
}
.student-portal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.student-portal__brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.student-portal__brand img {
    width: 38px;
    height: 38px;
}
.student-portal__brand strong {
    display: block;
    font-size: 17px;
}
.student-portal__brand span {
    display: block;
    color: var(--muted);
    font-size: 12.5px;
}
.student-hero {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    margin-bottom: 14px;
}
.student-hero h1 {
    margin: 0;
    font-size: 23px;
    line-height: 1.25;
}
.student-hero p {
    margin: 5px 0 0;
    color: var(--muted);
}
.student-kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.student-kpis div {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}
.student-kpis span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 650;
    margin-bottom: 4px;
}
.student-kpis strong {
    display: block;
    font-size: 17px;
    overflow-wrap: anywhere;
}
.student-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 14px;
}
.student-panel__head {
    padding: 13px 15px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.student-panel__head h2 {
    margin: 0;
    font-size: 15px;
}

@media (max-width: 980px) {
    .student-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
    .student-portal {
        width: min(100% - 20px, 1180px);
        padding-top: 12px;
    }
    .student-portal__head {
        align-items: stretch;
        flex-direction: column;
    }
    .student-portal__head .btn { justify-content: center; }
    .student-kpis { grid-template-columns: 1fr 1fr; }
    .student-hero h1 { font-size: 20px; }
}

@media (max-width: 420px) {
    .student-kpis { grid-template-columns: 1fr; }
}
