:root {
    --blue: #004a8d;
    --orange: #f7941d;
    --bg: #f4f6f9;
    --text: #1f2933;
    --muted: #6b7280;
    --border: #d1d5db;
    --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Cabeçalho */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 4px solid var(--orange);
    box-shadow: inset 0 -8px 0 -4px var(--blue);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    min-width: 0;
}

.topbar__logo {
    height: 32px;
    width: auto;
    max-width: 30vw;
    object-fit: contain;
}

.topbar__divider {
    width: 1px;
    height: 28px;
    background: var(--border);
}

.topbar__logout {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar__user {
    font-size: .85rem;
    color: var(--muted);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Menu */

/* Menu (celular: lateral) */

.menu-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
}

.menu-toggle span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

.topbar__logout { display: none; }

.nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(82vw, 300px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .15);
    overflow-y: auto;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .25s ease, visibility .25s;
}

.nav.is-open { transform: translateX(0); visibility: visible; }

.nav__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid #e5e7eb;
}

.nav__header strong { display: block; }
.nav__header span { font-size: .8rem; color: var(--muted); }

.nav__close {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: var(--bg);
    font-size: 1rem;
    cursor: pointer;
}

.nav__section {
    margin-top: 12px;
    padding: 0 12px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.nav__link {
    padding: 14px 12px;
    border-radius: 12px;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.nav__link.is-active { background: var(--blue); color: #fff; }

.nav__logout { margin-top: auto; padding-top: 16px; }

.nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.nav-overlay.is-visible { opacity: 1; pointer-events: auto; }

body.menu-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
    .nav, .nav-overlay { transition: none; }
}

/* Estrutura */

.container {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    gap: 16px;
    align-content: start;
}

.page-header h1 { font-size: 1.3rem; color: var(--blue); }
.page-header p { color: var(--muted); font-size: .9rem; margin-top: 4px; }

.empty { text-align: center; padding: 48px 16px; display: grid; gap: 12px; justify-items: center; }

/* Rodapé */

.footer {
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
}

.footer a {
    color: var(--blue);
    font-weight: 600;
    text-decoration: none;
}

/* Botões */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}

.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:active { filter: brightness(.9); }
.btn--ghost { background: transparent; color: var(--blue); padding: 8px 12px; border: 1px solid var(--border); }
.btn--block { width: 100%; padding: 16px; }

/* Alertas */

.alert { padding: 12px 16px; border-radius: var(--radius); font-size: .95rem; }
.alert--error { background: #fdecea; color: #b42318; }
.alert--success { background: #e7f6ec; color: #146c2e; }

/* Login */

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px 0 8px;
}

.brand__logo {
    height: 48px;
    width: auto;
    max-width: 40vw;
    object-fit: contain;
}

.brand__divider {
    width: 1px;
    height: 40px;
    background: var(--border);
}

.auth {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px 20px;
    display: grid;
    gap: 16px;
}

.auth__title { font-size: 1.3rem; color: var(--blue); }
.auth__subtitle { color: var(--muted); font-size: .95rem; }

/* Formulários */

.form { display: grid; gap: 16px; }
.form__field { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }

.form__field input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}

.form__field input:focus { border-color: var(--blue); }

/* Busca */

.search__label { display: block; font-weight: 600; margin-bottom: 8px; }

.search__input {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
}

.search__input:focus { border-color: var(--blue); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.stats__item {
    background: #fff;
    border-radius: var(--radius);
    padding: 12px 8px;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
}

.stats__item span {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.search__hint { font-size: .85rem; color: var(--muted); margin-top: 8px; min-height: 1.2em; }

.alert--warning { background: #fff7e6; color: #8a5300; }

.results { display: grid; gap: 12px; }
.results:empty { display: none; }

.result {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.result__table {
    padding: 14px 16px;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: #fff;
    background: var(--muted);
}

.result--blue .result__table { background: var(--blue); }
.result--orange .result__table { background: var(--orange); }

.result__body { padding: 14px 16px 16px; display: grid; gap: 4px; }
.result__name { font-size: 1.1rem; line-height: 1.3; }
.result__meta { font-size: .85rem; color: var(--muted); }

.result__status {
    margin-top: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: 700;
    font-size: .9rem;
}

.result__status--pending { background: #fff7e6; color: #8a5300; }
.result__status--delivered { background: #e7f6ec; color: #146c2e; }

.result__actions:empty { display: none; }

/* Turmas e mesas */

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.summary__item {
    background: #fff;
    border-radius: var(--radius);
    padding: 10px 8px;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
    border-top: 4px solid var(--border);
}

.summary__item strong { display: block; font-size: 1.3rem; color: var(--text); }
.summary__item--blue { border-top-color: var(--blue); }
.summary__item--orange { border-top-color: var(--orange); }

.tabs { display: flex; gap: 8px; }

.tabs__link {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: var(--radius);
    background: #fff;
    color: var(--muted);
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
}

.tabs__link.is-active { background: var(--text); color: #fff; }

.class-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 16px;
    display: grid;
    gap: 8px;
    border-left: 6px solid var(--border);
    scroll-margin-top: 140px;
}

.class-card--blue { border-left-color: var(--blue); }
.class-card--orange { border-left-color: var(--orange); }

.class-card__header { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.class-card__code { font-weight: 700; color: var(--text); }
.class-card__name { font-size: 1.05rem; }
.class-card__teacher { font-size: .85rem; color: var(--muted); }

.class-card__actions { display: flex; gap: 8px; margin-top: 4px; }

.table-btn {
    flex: 1;
    padding: 14px 8px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius);
    border: 2px solid currentColor;
    background: #fff;
    cursor: pointer;
}

.table-btn--blue { color: var(--blue); }
.table-btn--orange { color: var(--orange); }
.table-btn--blue.is-selected { background: var(--blue); border-color: var(--blue); color: #fff; }
.table-btn--orange.is-selected { background: var(--orange); border-color: var(--orange); color: #fff; }
.table-btn--clear { flex: 0 0 auto; color: var(--muted); border-color: var(--border); font-weight: 600; }

.list-info { font-size: .85rem; color: var(--muted); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.pagination__btn {
    flex: 1;
    max-width: 140px;
    padding: 12px;
    text-align: center;
    border-radius: var(--radius);
    background: #fff;
    border: 2px solid var(--blue);
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
}

.pagination__btn.is-disabled {
    border-color: var(--border);
    color: var(--border);
    pointer-events: none;
}

.pagination__info { font-size: .9rem; color: var(--muted); white-space: nowrap; }

/* Importação */

.upload { display: grid; gap: 12px; }

.upload__area {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 32px 16px;
    background: #fff;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
}

.upload__area:focus-within { border-color: var(--blue); }

.upload__input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload__icon { font-size: 2rem; }
.upload__hint { font-size: .85rem; color: var(--muted); }
.upload__files { font-weight: 700; color: var(--blue); }

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge--success { background: #e7f6ec; color: #146c2e; }
.badge--info { background: #e8f0fb; color: var(--blue); }
.badge--error { background: #fdecea; color: #b42318; }

.class-card--error { border-left-color: #b42318; }
.class-card__stats { font-size: .9rem; }

.warnings {
    list-style: none;
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    background: #fff7e6;
    border-radius: 10px;
    font-size: .85rem;
    color: #8a5300;
}

.warnings li::before { content: "⚠ "; }

.students-list summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--blue);
    font-size: .9rem;
}

.students-list ol {
    margin-top: 8px;
    padding-left: 24px;
    display: grid;
    gap: 4px;
    font-size: .85rem;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 8px;
    position: sticky;
    bottom: 0;
    padding: 12px 0;
    background: var(--bg);
}

/* Minha mesa */

.my-table { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.my-table__label { font-size: .85rem; font-weight: 600; color: var(--muted); }

.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.segmented__btn {
    border: 0;
    background: transparent;
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .85rem;
    color: var(--muted);
    cursor: pointer;
}

.segmented__btn.is-active { background: var(--text); color: #fff; }
.segmented__btn--blue.is-active { background: var(--blue); }
.segmented__btn--orange.is-active { background: var(--orange); }

/* Campo de busca com botão 123 */

.search__field { display: flex; gap: 8px; }
.search__field .search__input { flex: 1; min-width: 0; }

.search__keyboard {
    flex: 0 0 64px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--blue);
    font-weight: 800;
    font-size: .95rem;
    cursor: pointer;
}

.search__keyboard[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Cartão: avisos, pilha e entrega */

.result__warning {
    padding: 8px 12px;
    border-radius: 10px;
    background: #fdecea;
    color: #b42318;
    font-weight: 800;
    font-size: .9rem;
}

.result__pile {
    justify-self: start;
    padding: 6px 10px;
    border-radius: 8px;
    background: #eef2f7;
    font-weight: 800;
    font-size: 1rem;
}

.result__actions { margin-top: 8px; }

.btn:disabled { opacity: .7; cursor: default; }
.btn--deliver { background: #16803c; color: #fff; font-size: 1.1rem; padding: 18px; }
.btn--deliver:active { filter: brightness(.9); }
.btn--small { padding: 6px 10px; font-size: .85rem; }

/* Progresso */

.progress {
    display: grid;
    gap: 10px;
    padding: 14px 16px;
    background: #fff;
    border-radius: var(--radius);
    border-top: 4px solid var(--text);
}

.progress[data-table="blue"] { border-top-color: var(--blue); }
.progress[data-table="orange"] { border-top-color: var(--orange); }

.progress__header { display: flex; justify-content: space-between; align-items: baseline; }
.progress__header span { font-size: 1.4rem; font-weight: 800; }

.progress__bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress__bar span { display: block; height: 100%; background: #16803c; transition: width .4s; }

.progress .stats__item { background: var(--bg); }

/* Últimas entregas */

.section-title { font-size: .95rem; margin-bottom: 8px; }

.recent__list { list-style: none; display: grid; gap: 8px; }

.recent__item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 10px;
    border-left: 4px solid var(--border);
}

.recent__info { display: grid; gap: 2px; min-width: 0; }
.recent__name { font-size: .9rem; }
.recent__delivered { font-size: .8rem; font-weight: 700; color: #146c2e; }

.recent__item--blue { border-left-color: var(--blue); }
.recent__item--orange { border-left-color: var(--orange); }

/* Aviso com desfazer */

.toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 20;
    max-width: 616px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--text);
    color: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

.toast__text { font-size: .9rem; font-weight: 600; }

.toast__action {
    background: none;
    border: 0;
    padding: 4px 8px;
    color: var(--orange);
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
}

/* Pendentes */

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.filters select {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: var(--radius);
}

.filters .btn { grid-column: 1 / -1; }

.pending-list { list-style: none; display: grid; gap: 6px; }

.pending-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 10px;
    border-left: 4px solid var(--border);
}

.pending-item--blue { border-left-color: var(--blue); }
.pending-item--orange { border-left-color: var(--orange); }

.pending-item__position { flex: 0 0 52px; font-weight: 800; color: var(--blue); }
.pending-item__body { display: grid; min-width: 0; }
.pending-item__body strong { font-size: .9rem; }

/* Relatórios */

.alert--info { background: #e8f0fb; color: var(--blue); }
.alert--info a { color: var(--blue); font-weight: 700; }

.progress--blue { border-top-color: var(--blue); }
.progress--orange { border-top-color: var(--orange); }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }

.totals__item {
    display: grid;
    gap: 2px;
    padding: 12px;
    background: #fff;
    border-radius: var(--radius);
    border-top: 4px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.totals__item--blue { border-top-color: var(--blue); }
.totals__item--orange { border-top-color: var(--orange); }
.totals__item span { font-weight: 700; }
.totals__item small { color: var(--muted); font-size: .8rem; }

.report-block { display: grid; gap: 8px; }
.report-block .section-title { margin-bottom: 0; }

.report-block__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.report-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-radius: 10px;
    color: var(--text);
    font-size: .9rem;
    text-decoration: none;
}

.sort { display: flex; gap: 4px; font-size: .8rem; }

.sort a {
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
}

.sort a.is-active { background: var(--text); color: #fff; }

.class-card--link { color: inherit; text-decoration: none; }
.class-card--link:active { filter: brightness(.97); }
.class-card .progress__bar { height: 8px; }

.filters--report input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
}

.filters--report .btn { grid-column: auto; }
.filters__full { grid-column: 1 / -1; }

.report-list { list-style: none; display: grid; gap: 8px; }

.report-item {
    display: grid;
    gap: 2px;
    padding: 12px;
    background: #fff;
    border-radius: 10px;
    border-left: 4px solid var(--border);
}

.report-item--blue { border-left-color: var(--blue); }
.report-item--orange { border-left-color: var(--orange); }
.report-item--log-delivered { border-left-color: #16803c; }
.report-item--log-undone { border-left-color: #b42318; }

.report-item__name { font-size: .95rem; }

.report-item__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.report-item__status {
    justify-self: start;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 700;
}

.report-item__status--delivered { background: #e7f6ec; color: #146c2e; }
.report-item__status--pending { background: #fff7e6; color: #8a5300; }

.report-item__history {
    margin-top: 4px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--blue);
    text-decoration: none;
}

.search-inline { display: flex; gap: 8px; }

.search-inline input {
    flex: 1;
    min-width: 0;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
}

/* Telas maiores */

@media (min-width: 768px) {
    .topbar { padding: 16px 32px; }
    .topbar__logo { height: 42px; }
    .topbar__divider { height: 36px; }
    .topbar__logout { display: flex; }

    .menu-toggle,
    .nav__header,
    .nav__section,
    .nav__logout,
    .nav-overlay { display: none; }

    .nav {
        position: static;
        width: auto;
        flex-direction: row;
        padding: 8px 32px;
        overflow-x: auto;
        transform: none;
        visibility: visible;
        box-shadow: none;
        border-bottom: 1px solid #e5e7eb;
        transition: none;
    }

    .nav__link {
        padding: 8px 14px;
        border-radius: 999px;
        color: var(--muted);
        font-size: .9rem;
        white-space: nowrap;
    }

    .nav__link.is-active { background: var(--blue); color: #fff; }

    .brand__logo { height: 60px; }
    .brand__divider { height: 52px; }
}