:root {
  --navy: #123b5d;
  --navy-2: #0d2c46;
  --blue: #48a8df;
  --cyan: #47d5dc;
  --ink: #172633;
  --muted: #637383;
  --line: #dbe4eb;
  --surface: #ffffff;
  --background: #f3f7f9;
  --green: #1c8b62;
  --red: #c84b51;
  --amber: #b77716;
  --shadow: 0 10px 30px rgba(23, 38, 51, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--background); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell, .installer-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf4f7; }
.login-panel, .installer { width: min(560px, 100%); padding: 36px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; }
.login-panel { width: min(430px, 100%); }
.login-panel img, .installer img { display: block; width: 220px; max-width: 70%; margin: 0 auto 28px; }
h1, h2, p { margin-top: 0; }
.login-panel h1, .installer h1 { text-align: center; margin-bottom: 8px; }
.login-panel > p, .installer > p { text-align: center; color: var(--muted); margin-bottom: 28px; }
label { display: grid; gap: 7px; font-weight: 650; color: #334757; }
input, select, textarea { width: 100%; padding: 11px 12px; color: var(--ink); background: white; border: 1px solid #bccbd5; border-radius: 6px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(72, 168, 223, .14); }
textarea { min-height: 90px; resize: vertical; }
.login-panel form { display: grid; gap: 17px; }
.primary, .secondary, .icon-button { min-height: 40px; border-radius: 6px; border: 1px solid transparent; font-weight: 700; }
.button-link { display: inline-flex; align-items: center; text-decoration: none; }
.primary { padding: 10px 16px; color: white; background: var(--navy); }
.primary:hover { background: var(--navy-2); }
.secondary { padding: 9px 14px; color: var(--navy); background: white; border-color: #b9cad6; }
.icon-button { width: 40px; padding: 0; color: var(--navy); background: white; border-color: var(--line); font-size: 20px; }
.form-error { min-height: 20px; color: var(--red); }
.alert { padding: 12px 14px; margin-bottom: 18px; border-radius: 6px; }
.alert.error { color: #852c31; background: #fdecee; border: 1px solid #efbdc0; }
.alert.success { color: #176748; background: #e7f6ef; border: 1px solid #aadcc6; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; color: white; background: var(--navy); overflow-y: auto; }
.brand { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 9px; padding: 7px 7px 22px; }
.brand img { width: 42px; height: 42px; object-fit: contain; }
.brand strong { font-size: 16px; }
.brand span { padding: 3px 6px; font-size: 10px; font-weight: 800; border: 1px solid rgba(255,255,255,.4); border-radius: 4px; }
#main-nav { display: grid; gap: 3px; }
.nav-button { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 8px 11px; color: #d8e9f4; background: transparent; border: 0; border-radius: 6px; text-align: left; }
.nav-button > span { display: grid; place-items: center; width: 22px; font-weight: 800; }
.nav-button:hover, .nav-button.active { color: white; background: rgba(255,255,255,.13); }
.nav-button.logout { margin-top: auto; }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 74px; display: flex; align-items: center; gap: 16px; padding: 12px 25px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 1px 0 0; font-size: 22px; }
.topbar #page-eyebrow { color: var(--muted); font-size: 12px; }
#menu-button { display: none; }
.profile-chip { margin-left: auto; display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 24px; }
#profile-initials, .avatar-large { display: grid; place-items: center; color: white; background: var(--blue); border-radius: 50%; font-weight: 800; }
#profile-initials { width: 34px; height: 34px; }
.content { padding: 24px; }
.welcome { min-height: 155px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px 30px; color: white; background: var(--navy); border-radius: 8px; }
.welcome span { color: #bce9f5; text-transform: capitalize; }
.welcome h2 { margin: 6px 0; font-size: 32px; }
.welcome p { margin: 0; color: #d9e9f2; }
.avatar-large { width: 78px; height: 78px; flex: 0 0 78px; font-size: 25px; background: var(--cyan); color: var(--navy); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric { min-height: 116px; display: grid; gap: 4px; padding: 16px; color: var(--ink); text-align: left; background: white; border: 1px solid var(--line); border-radius: 7px; }
.metric strong { font-size: 28px; color: var(--navy); }
.metric small, .metric span { color: var(--muted); }
.panel { margin-top: 18px; padding: 20px; background: white; border: 1px solid var(--line); border-radius: 7px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-head h2 { margin-bottom: 4px; font-size: 19px; }
.panel-head p { margin: 0; color: var(--muted); }
.panel-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 13px; color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; font-weight: 700; white-space: nowrap; }
.tab.active { color: var(--navy); border-bottom-color: var(--blue); }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.choice-grid label, .check-line { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.choice-grid input, .check-line input { width: auto; }
.subject-checks { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-bottom: 8px; }
.subject-checks label { display: flex; align-items: center; gap: 8px; padding: 8px; background: #f4f7f9; border: 1px solid var(--line); border-radius: 5px; font-weight: 600; }
.subject-checks input { width: auto; }
fieldset { padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
legend { padding: 0 6px; font-weight: 750; }
.empty-state, .loading { padding: 34px 20px; color: var(--muted); text-align: center; border: 1px dashed #c7d5df; border-radius: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h2 { margin: 10px 0 0; font-size: 17px; }
.form-grid small { color: var(--muted); font-weight: 400; }
.form-grid.compact { grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto; }
.align-end { align-self: end; }
.week-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.week-state-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 13px; margin-bottom: 12px; background: white; border: 1px solid var(--line); border-radius: 6px; }
.week-nav, .actions { display: flex; align-items: center; gap: 9px; }
.status { display: inline-flex; padding: 5px 9px; color: var(--navy); background: #eaf2f7; border-radius: 4px; font-size: 12px; font-weight: 800; text-transform: capitalize; }
.status.liberada { color: #176748; background: #e1f3ea; }
.status.encerrada { color: #5b6370; background: #e8ebee; }
.week-board { display: grid; gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.excel-week { font-size: calc(14px * var(--schedule-zoom, 1)); }
.day-sheet { min-width: 760px; background: white; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.day-sheet > header { position: sticky; left: 0; display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; color: white; background: var(--navy); }
.day-sheet > header div { display: flex; align-items: center; gap: 12px; }
.day-sheet > header span { font-weight: 800; }
.small { min-height: 32px; padding: 5px 9px; }
.schedule-matrix { display: grid; grid-template-columns: calc(84px * var(--schedule-zoom,1)) repeat(var(--teacher-count), minmax(calc(145px * var(--schedule-zoom,1)), 1fr)); min-width: max-content; }
.matrix-head, .matrix-time { min-height: 42px; display: grid; place-items: center; padding: 7px; background: #edf3f6; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-weight: 750; text-align: center; }
.matrix-time { color: var(--muted); font-size: .82em; }
.matrix-time small { display: block; font-size: .8em; }
.matrix-cell { min-height: calc(54px * var(--schedule-zoom,1)); display: grid; align-content: center; gap: 3px; padding: 7px; text-align: left; color: var(--ink); background: white; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; }
.matrix-cell strong, .matrix-cell small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-cell small { color: var(--muted); }
.matrix-cell.atividade { color: #176748; background: #e5f6ed; }
.matrix-cell.aula { border-left: 4px solid var(--blue); background: #edf7fd; }
.matrix-cell.reuniao, .matrix-cell.planejamento { border-left: 4px solid var(--amber); background: #fff7e5; }
.matrix-cell.home_office { border-left: 4px solid #7b62a8; background: #f4f0fa; }
.matrix-cell.unavailable { place-items: center; color: #9c3d42; background: repeating-linear-gradient(135deg,#f9ebec,#f9ebec 8px,#f5dfe1 8px,#f5dfe1 16px); font-size: .8em; }
.empty-day { width: 100%; min-height: 90px; color: var(--muted); background: white; border: 0; }
.day-column { min-height: 410px; background: #eaf0f4; border: 1px solid #d4dfe6; border-radius: 7px; overflow: hidden; }
.day-column > header { display: flex; justify-content: space-between; gap: 9px; padding: 11px; color: white; background: var(--navy); font-size: 12px; }
.day-entries { display: grid; gap: 7px; padding: 8px; }
.schedule-entry, .empty-slot { width: 100%; min-height: 75px; display: grid; gap: 4px; padding: 9px; color: var(--ink); text-align: left; background: white; border: 1px solid #c8d6df; border-left: 4px solid var(--blue); border-radius: 5px; }
.schedule-entry.atividade { border-left-color: var(--green); background: #eff9f4; }
.schedule-entry.reuniao { border-left-color: var(--amber); background: #fff8e9; }
.schedule-entry time { color: var(--muted); font-size: 11px; }
.schedule-entry small { color: var(--muted); }
.empty-slot { place-items: center; color: var(--muted); border-style: dashed; }
.extraordinary { margin-top: 22px; }
.extraordinary .schedule-entry { display: inline-grid; width: min(310px, 100%); margin: 0 8px 8px 0; }
.fixed-grid { display: grid; grid-template-columns: 70px repeat(5, minmax(135px, 1fr)); min-width: 800px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.fixed-head, .fixed-time { display: grid; place-items: center; min-height: 40px; padding: 6px; font-weight: 750; background: #eaf1f5; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fixed-cell { min-height: 48px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fixed-cell.active { color: #176748; background: #e5f6ed; }
.fixed-cell.blocked { color: #9c3d42; background: repeating-linear-gradient(135deg,#f8e8e9,#f8e8e9 8px,#f4dddf 8px,#f4dddf 16px); }
#fixed-grid { overflow-x: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); background: #f3f7f9; font-size: 12px; text-transform: capitalize; }
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(8, 28, 43, .58); }
.modal { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px; background: white; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head { margin-bottom: 20px; }
.modal-head span { color: var(--muted); font-size: 12px; }
.modal-head h2 { margin: 2px 0 0; }
.modal-actions { justify-content: flex-end; margin-top: 20px; }
.agenda-day { margin-top: 16px; }
.agenda-day h3 { margin-bottom: 8px; color: var(--navy); }
.agenda-row { display: grid; grid-template-columns: 100px minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 12px; border-bottom: 1px solid var(--line); }
.agenda-row time { color: var(--navy); font-weight: 800; }
.agenda-row div { display: grid; gap: 4px; }
.agenda-row small { color: var(--muted); }
.star-picker { display: flex; gap: 5px; }
.star-picker button { padding: 0; color: #e0a526; background: transparent; border: 0; font-size: 32px; }
.report-list { display: grid; gap: 12px; }
.report-card { padding: 16px; border: 1px solid var(--line); border-radius: 6px; }
.report-card header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.report-card header div { display: grid; gap: 4px; }
.report-card header small { color: var(--muted); }
.report-card header > span { color: #e0a526; }
.report-card p { margin: 7px 0; }
.settings-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.settings-section { padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.settings-section header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.settings-section h3 { margin: 0; }
.catalog-item { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.catalog-item small, .muted { color: var(--muted); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 50; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 15px 0 35px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  #menu-button { display: inline-grid; place-items: center; }
  .topbar { padding: 10px 14px; }
  .topbar h1 { font-size: 18px; }
  #profile-name { display: none; }
  .content { padding: 14px; }
  .welcome { min-height: 132px; padding: 20px; }
  .welcome h2 { font-size: 25px; }
  .avatar-large { width: 58px; height: 58px; flex-basis: 58px; font-size: 18px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric { min-height: 102px; padding: 12px; }
  .week-toolbar, .panel-head { align-items: flex-start; flex-direction: column; }
  .week-toolbar .actions { width: 100%; overflow-x: auto; padding-bottom: 4px; }
  .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .choice-grid { grid-template-columns: 1fr; }
  .subject-checks { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .align-end { align-self: stretch; }
  .week-state-bar { align-items: flex-start; flex-direction: column; }
  .day-sheet { min-width: 680px; }
  .agenda-row { grid-template-columns: 76px minmax(0,1fr); }
  .agenda-row button { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: 1fr; }
}
