:root {
  --green-900: #033D25;
  --green-800: #0A4C31;
  --green-700: #035433;
  --green-100: #E3EEE6;
  --green-50: #F2F8F3;
  --clay: #CF680F;
  --clay-light: #F0913F;
  --clay-100: #FDEFE3;
  --clay-text: #8A4B0B;
  --ink: #15201A;
  --muted: #5B6660;
  --line: #DCE0D8;
  --line-soft: #ECEFE8;
  --ground: #F4F5F0;
  --surface: #FFFFFF;
  --danger: #A3360B;
  --radius: 12px;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; }
a { color: var(--green-700); }
a:hover { color: var(--green-900); }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--clay-light); outline-offset: 2px; }
main:focus, main:focus-visible { outline: none; }
.boot { padding: 48px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.grow1 { flex: 1; min-width: 0; }
button.avatar { border: none; cursor: pointer; width: 44px; height: 44px; }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */
/* Barra lateral com largura limitada; o conteúdo ocupa o resto e se ajusta a qualquer monitor (do celular ao ultra wide). */
.shell { display: grid; grid-template-columns: clamp(220px, 14vw, 280px) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--green-900); color: #E8EFE9; padding: 24px 16px; display: flex; flex-direction: column; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.brand strong { display: block; font-family: var(--display); font-size: 22px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; line-height: 1; }
.brand span { font-size: 12px; color: #A9C4B4; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: #C9D6CD; text-decoration: none; }
.nav a:hover { background: var(--green-800); color: #fff; }
.nav a[aria-current="page"] { background: var(--green-700); color: #fff; font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: var(--green-800); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--clay-light); color: var(--green-900); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who span { font-size: 12px; color: #A9C4B4; }
.me button { background: none; border: 1px solid #3E6F55; color: #E8EFE9; border-radius: 8px; min-height: 36px; padding: 0 10px; cursor: pointer; font-size: 13px; }
.main { width: 100%; max-width: 2400px; margin-inline: auto; min-width: 0; padding: clamp(24px, 2.2vw, 48px) clamp(20px, 3vw, 64px) 56px; display: flex; flex-direction: column; gap: clamp(20px, 1.6vw, 32px); }
@media (min-width: 2200px) { body { font-size: 16px; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 20px 16px 48px; }
  .side { position: static; height: auto; overflow: visible; padding: 16px; gap: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { min-height: 40px; padding: 0 10px; font-size: 14px; }
  .me { margin-top: 0; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.page-head h1 { font-family: var(--display); font-size: 44px; font-weight: 700; line-height: 1; margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; min-width: 0; }
.card h2 { font-size: 18px; font-weight: 600; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.grow { flex: 999 1 520px; min-width: 0; }
.aside { flex: 1 1 320px; min-width: 0; max-width: 100%; }
@media (min-width: 1100px) { .row > .aside { max-width: 460px; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-family: var(--display); font-size: 40px; font-weight: 700; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 13px; color: var(--muted); }
.stat.dark { background: var(--green-900); color: #E8EFE9; border-color: var(--green-900); }
.stat.dark .k, .stat.dark .s { color: #A9C4B4; }
.stat.dark .v { color: var(--clay-light); }
.warn-text { color: var(--clay-text); font-weight: 600; }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid #C4CBC0; background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--green-700); color: var(--ink); }
.btn.primary { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn.primary:hover { background: var(--green-900); color: #fff; }
.btn.danger { color: var(--danger); border-color: #E3B5A0; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { background: none; border: none; padding: 0; min-height: 40px; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--green-700); text-decoration: underline; }
.icon-btn { width: 44px; height: 44px; border-radius: 8px; border: 1px solid #C4CBC0; background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid #C4CBC0; background: var(--surface); font-weight: 400; font-size: 15px; width: 100%; }
.field textarea { padding: 10px 12px; min-height: 180px; font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; }
.field .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green-700); }
.checklist { max-height: min(46vh, 420px); overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.checklist .check { border-bottom: 1px solid var(--line-soft); }
.checklist .check:last-child { border-bottom: none; }
fieldset.fixed-slots { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; margin: 0; min-width: 0; }
fieldset.fixed-slots legend { font-size: 13px; font-weight: 600; padding: 0 6px; }
.field.end { justify-content: flex-end; }
.chip.slot-chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--body); font-size: 13px; background: var(--green-100); color: var(--green-900); }
.chip-x { border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; color: inherit; min-width: 24px; min-height: 24px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--line-soft); border-radius: 10px; width: fit-content; }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 8px; border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--green-900); box-shadow: 0 1px 2px rgba(3, 61, 37, .12); }

/* ---------- Tabelas e selos ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
td.r, th.r { text-align: right; }
tr.sel td { background: var(--clay-100); }
tr.up td { background: var(--green-50); }
tr.down td { background: #FDF6EC; }
tr.me td { background: #FDEBDC; font-weight: 600; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--green-100); color: var(--green-700); }
.badge.warn { background: var(--clay-100); color: var(--clay-text); }
.badge.dark { background: var(--green-900); color: var(--clay-light); }
.badge.gray { background: var(--line-soft); color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.list-item:last-child { border-bottom: none; }
.list-item .t { width: 56px; font-weight: 600; font-variant-numeric: tabular-nums; }
.list-item .grow1 { flex: 1; min-width: 0; }

/* ---------- Grade semanal ---------- */
.week { display: grid; grid-template-columns: 64px repeat(7, minmax(100px, 1fr)); gap: 6px; min-width: 820px; }
.week .dh { text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 4px; }
.week .dh.today { color: var(--green-700); }
.week .dh small { display: block; font-weight: 400; }
.week .th { font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 10px; font-variant-numeric: tabular-nums; }
.week .th small { display: block; font-weight: 400; font-size: 11px; }
.cell { width: 100%; min-width: 0; min-height: 60px; padding: 6px 8px; border-radius: 8px; text-align: left; cursor: pointer; font-size: 12px; line-height: 1.3; border: 1px dashed #B9C0B5; background: transparent; color: var(--muted); }
.cell b { display: block; font-size: 12px; }
.cell-names { list-style: none; margin: 2px 0 0; padding: 0; }
.cell-names li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-names li.absent { text-decoration: line-through; opacity: .7; }
.cell-when { display: block; margin-top: 3px; font-size: 11px; font-variant-numeric: tabular-nums; opacity: .8; }
.cell-teacher { display: block; margin-top: 3px; font-size: 11px; font-style: italic; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.slot { border: 1px solid #9CC2A8; background: var(--green-100); color: var(--green-900); border-style: solid; }
.cell.done { background: var(--green-700); color: #fff; border-color: var(--green-700); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cell.cont { opacity: .8; border-top-style: dashed; }
.cell.rent { border: 1px solid #E3B877; background: #FBEFD9; color: #6B3A08; cursor: default; }
.cell.rank { border: 1px solid #A9A1D4; background: #F0EDFA; color: #3F3475; }
.cell[aria-pressed="true"] { outline: 3px solid var(--clay-light); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .lg-slot { background: var(--green-100); border: 1px solid #9CC2A8; }
.legend .lg-done { background: var(--green-700); }
.legend .lg-rent { background: #FBEFD9; border: 1px solid #E3B877; }
.legend .lg-free { border: 1px dashed #9AA39D; }
hr.sep { border: none; border-top: 1px solid var(--line-soft); margin: 4px 0; width: 100%; }
details summary { cursor: pointer; min-height: 32px; font-weight: 600; color: var(--green-700); }

/* ---------- WhatsApp ---------- */
.bubble-wrap { padding: 14px; border-radius: 12px; background: #E9EDE4; }
.bubble { background: #fff; border-radius: 10px 10px 10px 2px; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 8px; border-radius: 6px; background: var(--line-soft); font-family: var(--mono); font-size: 12px; }

/* ---------- Ranking ---------- */
.classes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; }
.class-card { padding: 0; overflow: hidden; }
.class-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.class-letter { width: 40px; height: 40px; border-radius: 10px; background: var(--green-900); color: var(--clay-light); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 26px; font-weight: 700; }
.class-card td:first-child, .class-card th:first-child { padding-left: 20px; }
.class-card td:last-child, .class-card th:last-child { padding-right: 20px; }

/* ---------- Modal e aviso ---------- */
dialog { border: none; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(3, 61, 37, .25); }
dialog::backdrop { background: rgba(3, 30, 18, .45); }
.modal-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.modal-actions .push-left { margin-right: auto; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--green-900); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 500; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }
.toast.err { background: var(--danger); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--clay-100); color: #6B3A08; font-size: 14px; }
.notice.ok { background: var(--green-100); color: var(--green-900); }
.code-big { font-family: var(--display); font-size: 48px; font-weight: 700; letter-spacing: .12em; text-align: center; color: var(--green-900); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; background: var(--green-900); }
.auth-top { padding: 48px 24px 32px; display: flex; flex-direction: column; align-items: center; gap: 12px; color: #fff; text-align: center; }
.auth-top img { width: 112px; height: 112px; border-radius: 24px; }
.auth-top strong { font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; line-height: 1; }
.auth-top span { font-size: 14px; color: #A9C4B4; }
.auth-card { width: min(440px, 100%); background: var(--ground); border-radius: 24px 24px 0 0; padding: 28px 24px 40px; flex: 1; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 600px) { .auth-card { flex: 0 0 auto; border-radius: 24px; margin-bottom: 48px; } }
.auth-card h1 { font-size: 22px; font-weight: 600; }

/* ---------- Aluno ---------- */
.student { max-width: 720px; margin: 0 auto; padding: 0 0 40px; }
.student-top { background: var(--green-900); color: #E8EFE9; padding: 20px 20px 72px; }
.student-top .bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.student-top .bar .brand { padding: 0; }
.student-top h1 { font-family: var(--display); font-size: 36px; font-weight: 700; line-height: 1; margin-top: 18px; }
.student-body { padding: 0 16px; margin-top: -52px; display: flex; flex-direction: column; gap: 16px; }
.big-number { font-family: var(--display); font-size: 56px; font-weight: 700; line-height: 1; color: var(--green-700); }
