:root {
    --page: #f4f6fa;
    --surface: #ffffff;
    --surface-soft: #f2f5fa;
    --surface-strong: #e7edf5;
    --border: #dce3ee;
    --border-strong: #c2cede;
    --text: #14243a;
    --text-soft: #455770;
    --text-muted: #586982;
    --nav: #10284a;
    --nav-soft: #233d62;
    --primary: #174f9d;
    --primary-strong: #143b70;
    --primary-soft: #eaf2fe;
    --accent: #bd2340;
    --accent-soft: #ffedf1;
    --success: #138a57;
    --warning: #d88900;
    --danger: #d92742;
    --info: #009fda;
    --shadow: 0 2px 6px rgba(16, 40, 74, 0.05);
    --radius: 12px;
    --sidebar: 222px;
    --font-main: Inter, "Segoe UI", Arial, sans-serif;
    --font-mono: "Cascadia Mono", "Courier New", monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: var(--font-main);
    font-size: 14px;
    line-height: 1.45;
}

body.modal-open {
    overflow: hidden;
}

.skip-link {
    position: fixed;
    z-index: 120;
    top: 8px;
    left: 8px;
    transform: translateY(-150%);
    padding: 9px 14px;
    border-radius: 6px;
    background: var(--surface);
    color: var(--primary);
}

.skip-link:focus {
    transform: translateY(0);
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.app-modal {
    position: fixed;
    z-index: 90;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 23, 48, 0.56);
}

.app-modal[hidden] {
    display: none;
}

.modal-dialog {
    width: min(100%, 760px);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(7, 47, 103, 0.24);
}

.modal-dialog.modal-wide {
    width: min(100%, 980px);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.modal-header h2 {
    margin: 2px 0 4px;
    font-size: 1.1rem;
}

.modal-header p {
    margin: 0;
    color: var(--text-soft);
}

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

.modal-body .form-grid,
.modal-body .form-grid-3 {
    margin: 0;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--page);
}

.auth-shell {
    width: min(100%, 420px);
}

.auth-card {
    padding: clamp(22px, 6vw, 36px);
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.auth-brand {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.auth-brand .brand-mark {
    width: 122px;
    height: 47px;
}

.auth-brand h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
    line-height: 1.2;
}

.auth-brand p:last-child {
    margin: 0;
    color: var(--text-soft);
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-actions {
    display: grid;
    gap: 14px;
    margin-top: 6px;
    text-align: center;
}

.auth-link,
.contact-link {
    color: var(--primary);
    font-weight: 600;
    text-underline-offset: 3px;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 18px 13px;
    background: var(--nav);
    color: #f8fafc;
    transition: transform 180ms ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 2px 17px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    color: #ffffff;
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 73px;
    height: 36px;
    flex: none;
    border-radius: 6px;
    background: #ffffff;
    overflow: hidden;
}

.brand-mark img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.brand-copy,
.brand strong {
    display: block;
    min-width: 0;
}

.brand strong {
    font-size: 13px;
}

.nav-menu {
    display: grid;
    gap: 16px;
    margin-top: 18px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.nav-group {
    padding: 0 12px 5px;
    color: #a6bad7;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.nav-section {
    display: grid;
    gap: 2px;
}

.nav-link,
.nav-fold summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 7px 12px;
    border-radius: 7px;
    color: #e2ecfa;
    text-decoration: none;
    font-size: 13px;
    font-weight: 550;
    transition: background 140ms ease, color 140ms ease;
}

.nav-link:hover,
.nav-fold summary:hover {
    background: var(--nav-soft);
    color: #ffffff;
}

.nav-link.active {
    background: #dceaff;
    color: #0e356b;
    font-weight: 700;
}

.sidebar :focus-visible {
    outline-color: #a9d2ff;
    outline-offset: -2px;
}

.nav-fold {
    margin-top: -14px;
}

.nav-fold summary {
    justify-content: space-between;
    cursor: pointer;
}

.nav-fold summary::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-right: 2px;
    border: solid currentColor;
    border-width: 0 1px 1px 0;
    transform: rotate(45deg);
}

.nav-fold[open] summary::after {
    transform: rotate(225deg);
}

.nav-fold .nav-link {
    padding-left: 23px;
}

.content-area {
    width: calc(100% - var(--sidebar));
    min-width: 0;
    margin-left: var(--sidebar);
    padding: 0 28px 36px;
    transition: width 180ms ease, margin 180ms ease;
}

.sidebar-hidden .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
}

.sidebar-hidden .content-area {
    width: 100%;
    margin-left: 0;
}

.sidebar-backdrop {
    display: none;
}

.workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 59px;
    margin: 0 -28px 24px;
    padding: 9px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.workspace-school {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
}

.workspace-school select {
    min-height: 34px;
    padding-block: 4px;
    background: var(--surface-soft);
}

.workspace-user {
    margin-left: auto;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
}

.menu-button {
    gap: 7px;
}

.menu-glyph {
    width: 13px;
    height: 10px;
    border-block: 1px solid currentColor;
    background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-header > div:first-child {
    max-width: 760px;
}

.page-header h1 {
    margin: 0 0 5px;
    font-size: clamp(24px, 2.6vw, 34px);
    line-height: 1.15;
    color: var(--text);
    font-weight: 750;
}

.page-header p {
    margin: 0;
    color: var(--text-soft);
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.stats-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.metric-card {
    position: relative;
    display: flex;
    min-height: 88px;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    padding: 15px 16px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

a.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: 0 5px 14px rgba(16, 40, 74, 0.10);
}

.metric-card strong {
    margin: 7px 0 3px;
    font-size: 29px;
    line-height: 1;
    color: var(--primary-strong);
    font-weight: 850;
}

.metric-card.warning {
    border-left-color: var(--warning);
}

.metric-card.danger {
    border-left-color: var(--danger);
}

.metric-card.success {
    border-left-color: var(--success);
}

.metric-label {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 650;
}

.metric-note {
    color: var(--text-muted);
    font-size: 11px;
}

.dashboard-grid,
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.dashboard-grid > *,
.settings-grid > * {
    min-width: 0;
}

.panel,
.list-container {
    min-width: 0;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.panel-wide {
    grid-column: 1 / -1;
}

.panel-header,
.list-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    margin: -2px 0 15px;
}

.panel-header h2,
.list-title,
.form-title {
    margin: 0 0 3px;
    font-size: 17px;
    line-height: 1.25;
    color: var(--primary-strong);
    font-weight: 700;
}

.panel-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}

.report-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin: 28px 0 12px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--accent);
}

.report-heading h2 {
    margin: 2px 0 4px;
    font-size: 21px;
}

.purchase-report-grid {
    margin-bottom: 16px;
}

.purchase-report-grid > .panel:not(.panel-wide) {
    grid-column: 1 / -1;
}

.report-table {
    min-width: 900px;
}

.report-calm-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 13px;
    align-items: end;
}

.form-grid-3 {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.form-group {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

.form-group label,
.field-label {
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 800;
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.form-control {
    width: 100%;
    min-height: 39px;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.form-control::placeholder {
    color: #9ba6b2;
}

textarea.form-control {
    min-height: 82px;
    resize: vertical;
}

.setup-details {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    background: #f8fafc;
}

.setup-details summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
}

.code-block {
    margin: 14px 0 0;
    max-height: 360px;
    overflow: auto;
    padding: 14px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.5;
}

.form-control:focus {
    border-color: var(--info);
    box-shadow: 0 0 0 3px rgba(0, 159, 218, 0.16);
}

.compact-control {
    max-width: 260px;
}

.filter-details {
    margin: 0 0 14px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-soft);
}

.filter-details summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 650;
}

.filter-details .filter-inline {
    justify-content: flex-start;
    margin-top: 10px;
}

.filter-details label {
    display: grid;
    gap: 4px;
    min-width: 0;
    color: var(--text-soft);
    font-size: 12px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-inline {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    min-width: min(410px, 55%);
    flex-wrap: wrap;
}

.filter-inline.wide {
    min-width: min(820px, 72%);
}

.filter-inline .form-control {
    min-width: 145px;
    flex: 1 1 160px;
}

.filter-inline input[type="search"] {
    min-width: 220px;
    flex-grow: 2;
}

.filter-inline .filter-number {
    min-width: 105px;
    max-width: 125px;
    flex: 0 1 125px;
}

.filter-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    flex-wrap: wrap;
}

.result-count {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.advanced-filter-panel {
    margin: -3px 0 15px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-soft);
}

.advanced-filter-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.advanced-filter-intro strong,
.advanced-filter-intro span {
    display: block;
}

.advanced-filter-intro span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.advanced-condition-list {
    display: grid;
    gap: 7px;
}

.advanced-condition {
    display: grid;
    grid-template-columns: minmax(150px, 1.2fr) minmax(130px, 0.8fr) minmax(180px, 1.5fr) auto;
    gap: 7px;
    align-items: center;
    padding: 8px;
    border: 1px solid #bfd4ed;
    border-radius: 6px;
    background: #ffffff;
}

.advanced-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 39px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    font-weight: 700;
}

.checkbox-row input {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    cursor: pointer;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease;
}

.btn:disabled {
    opacity: .6;
    cursor: default;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-strong);
}

.btn-accent {
    background: var(--primary);
    color: #ffffff;
}

.btn-accent:hover {
    background: var(--primary-strong);
}

.btn-secondary {
    border-color: var(--border-strong);
    background: #ffffff;
    color: var(--primary);
}

.btn-secondary:hover {
    border-color: var(--info);
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.btn-danger {
    border-color: #f1c1bb;
    background: #fff;
    color: #a22337;
}

.btn-danger:hover {
    background: var(--accent-soft);
}

.btn-small {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 12px;
}

.table-responsive {
    width: calc(100% + 36px);
    margin: 0 -18px -18px;
    overflow-x: auto;
    border-radius: 0 0 var(--radius) var(--radius);
}

.custom-table {
    width: 100%;
    min-width: 610px;
    border-collapse: separate;
    border-spacing: 0;
}

.students-analysis-table {
    min-width: 850px;
}

.custom-table th,
.custom-table td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    text-align: left;
}

.custom-table th:first-child,
.custom-table td:first-child {
    padding-left: 18px;
}

.custom-table th:last-child,
.custom-table td:last-child {
    padding-right: 18px;
}

.custom-table th {
    position: sticky;
    z-index: 2;
    top: 0;
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.custom-table tbody tr:nth-child(even) {
    background: #fbfcfe;
}

.custom-table tbody tr:hover {
    background: var(--primary-soft);
}

.custom-table tbody tr:last-child td {
    border-bottom: 0;
}

.custom-table td strong {
    font-weight: 750;
}

#tabela_alunos.visualizacao-apostila-atual .col-modulo-proximo,
#tabela_alunos.visualizacao-apostila-proxima .col-modulo-atual {
    display: none;
}

.module-name {
    display: block;
    color: var(--primary-strong);
    font-size: 13px;
    line-height: 1.3;
}

.align-right {
    text-align: right !important;
}

.mono {
    color: var(--text-soft);
    font-family: var(--font-mono);
    font-size: 12px;
}

.muted-line {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.inline-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 23px;
    margin: 2px 3px 2px 0;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
}

.badge-success {
    border-color: #bde5c9;
    background: #e7f7ec;
    color: var(--success);
}

.badge-warning {
    border-color: #f0d8a2;
    background: #fff7e3;
    color: var(--warning);
}

.badge-danger {
    border-color: #f2c4bf;
    background: #fff0ee;
    color: var(--danger);
}

.badge-info {
    border-color: #addced;
    background: #e7f7fd;
    color: var(--info);
}

.badge-neutral {
    border-color: var(--border);
    background: var(--surface-soft);
    color: var(--text-soft);
}

.compact-list {
    display: grid;
    gap: 8px;
}

.compact-row,
.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #ffffff;
}

.compact-row strong,
.compact-row span {
    display: block;
}

.compact-row span {
    color: var(--text-muted);
    font-size: 11px;
}

.config-list {
    display: grid;
    gap: 7px;
}

.empty-state {
    padding: 24px;
    color: var(--text-muted);
    text-align: center;
}

.alert {
    margin-bottom: 17px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 4px solid var(--info);
    border-radius: 7px;
    background: var(--surface);
    font-weight: 700;
    box-shadow: var(--shadow);
}

.alert-success {
    border-color: #bde5c9;
    border-left-color: var(--success);
    background: #f3fbf5;
    color: var(--success);
}

.alert-warning {
    border-color: #f0d8a2;
    border-left-color: var(--warning);
    background: #fffbef;
    color: var(--warning);
}

.alert-danger {
    border-color: #f2c4bf;
    border-left-color: var(--danger);
    background: #fff5f3;
    color: var(--danger);
}

.automacao-status {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    padding: 20px;
    border: 1px solid #bde5c9;
    border-radius: var(--radius);
    background: #f3fbf5;
}

.automacao-status.needs-review { border-color: #f2c4bf; background: #fff5f3; }
.automacao-status > div { flex: 1; min-width: 0; }
.automacao-status h2 { margin: 0 0 4px; font-size: 17px; }
.automacao-status p { margin: 0; color: var(--text-soft); }
.automacao-status-icon { display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 50%; background: var(--success); color: white; font-size: 22px; font-weight: 800; }
.needs-review .automacao-status-icon { background: var(--danger); }
.automacao-folder { margin-bottom: 18px; padding: 12px 14px; border-radius: 6px; background: var(--surface-soft); }
.automacao-folder span { display: block; margin-bottom: 4px; font-size: 11px; color: var(--text-soft); }
.automacao-folder strong { font-size: 13px; overflow-wrap: anywhere; }
.automacao-files { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.automacao-file { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 7px; }
.automacao-file.is-invalid { border-color: #f2c4bf; background: #fffaf9; }
.automacao-file-heading { display: flex; align-items: center; gap: 9px; }
.automacao-file-heading h3 { flex: 1; margin: 0; font-size: 14px; }
.automacao-step { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px; background: var(--primary-soft); color: var(--primary); border-radius: 6px; font-weight: 800; }
.automacao-filename { margin: 12px 0 6px; color: var(--text-soft); overflow-wrap: anywhere; }
.automacao-file-count { margin: 0; color: var(--text-soft); }
.automacao-file-count strong { color: var(--primary-strong); font-size: 25px; }
.automacao-file-date { margin: 3px 0 12px; font-size: 11px; color: var(--text-muted); }
.automacao-file-error { color: #a91d32; font-size: 13px; overflow-wrap: anywhere; }
.automacao-columns { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-soft); }
.automacao-note { margin: 14px 0 0; font-size: 12px; color: var(--text-soft); overflow-wrap: anywhere; }
.automacao-last-date { margin: 0 0 16px; color: var(--text-soft); }
.automacao-instructions { margin: 0; padding-left: 22px; color: var(--text-soft); }
.automacao-instructions li { margin: 12px 0; padding-left: 4px; }
.automacao-instructions strong { color: var(--text); }
.automacao-help { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--text-soft); }
.automacao-help summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.automacao-help p { max-width: 100ch; }
.automacao-progress { display: flex; align-items: center; gap: 12px; }
.automacao-progress[hidden] { display: none; }
.automacao-spinner { width: 19px; height: 19px; flex: 0 0 19px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: automacao-spin 0.8s linear infinite; }
@keyframes automacao-spin { to { transform: rotate(360deg); } }
@media (max-width: 680px) {
    .automacao-files { grid-template-columns: minmax(0, 1fr); }
    .automacao-status { flex-wrap: wrap; padding: 16px; gap: 12px; }
    .automacao-status > .badge { margin-left: 52px; }
}
@media (prefers-reduced-motion: reduce) { .automacao-spinner { animation: none; } }

/* Upload de Planilhas da Automação */
.automacao-upload-box {
    margin: 10px 0 16px;
    padding: 26px 20px;
    background: #f8fafc;
    border: 2px dashed #93c5fd;
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.2s ease;
}
.automacao-upload-box.is-dragover {
    background: #eff6ff;
    border-color: var(--primary);
    transform: scale(1.008);
}
.automacao-upload-icon {
    font-size: 40px;
    margin-bottom: 6px;
    display: block;
}
.automacao-upload-title {
    margin: 0 0 6px;
    font-size: 16px;
    color: var(--primary-strong);
    font-weight: 700;
}
.automacao-upload-subtitle {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-soft);
}
.automacao-upload-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.automacao-upload-feedback {
    margin-top: 14px;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    border: 1px solid var(--border);
    display: none;
    text-align: left;
}
.automacao-card-action {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    justify-content: flex-end;
}

.dialog-backdrop {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.56);
}

.dialog {
    width: min(760px, 100%);
    max-height: min(820px, calc(100vh - 40px));
    overflow-y: auto;
    border: 1px solid var(--border);
    border-top: 5px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.26);
}

.dialog-header,
.dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 18px;
}

.dialog-header {
    position: sticky;
    z-index: 2;
    top: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.dialog-header h2 {
    margin: 0;
    font-size: 18px;
}

.dialog-header p {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: 11px;
}

.dialog-body {
    padding: 18px;
}

.dialog-footer {
    position: sticky;
    z-index: 2;
    bottom: 0;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.report-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.report-option-wide {
    grid-column: 1 / -1;
}

.report-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-soft);
}

.report-columns label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
}

.report-columns input {
    accent-color: var(--accent);
}

[hidden] {
    display: none !important;
}

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
    }

    .dashboard-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .report-calm-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid,
    .form-grid-3 {
        grid-template-columns: repeat(2, minmax(170px, 1fr));
    }

    .span-3 {
        grid-column: 1 / -1;
    }
}

@media (max-width: 860px) {
    .sidebar {
        width: min(292px, 86vw);
        transform: translateX(-100%);
        visibility: hidden;
    }

    .sidebar-hidden .sidebar,
    body:not(.sidebar-hidden) .sidebar {
        transform: translateX(-100%);
    }

    body.mobile-menu-open .sidebar {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 25;
        inset: 0;
        background: rgba(15, 23, 42, 0.48);
    }

    .mobile-menu-open .sidebar-backdrop {
        display: block;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }

    .content-area,
    .sidebar-hidden .content-area {
        width: 100%;
        margin-left: 0;
        padding: 0 14px 26px;
    }

    .workspace-toolbar {
        margin: 0 -14px 18px;
        padding-inline: 14px;
    }

    .page-header,
    .panel-header,
    .list-header {
        display: grid;
        gap: 11px;
    }

    .page-header > *,
    .panel-header > *,
    .list-header > * {
        min-width: 0;
        width: 100%;
    }

    .page-actions {
        justify-content: flex-start;
    }

    .filter-inline,
    .filter-inline.wide {
        display: grid;
        grid-template-columns: 1fr 1fr;
        min-width: 0;
        width: 100%;
    }

    .filter-inline input[type="search"] {
        grid-column: 1 / -1;
    }

    .filter-meta {
        grid-column: 1 / -1;
        margin-left: 0;
    }

    .advanced-condition {
        grid-template-columns: 1fr 1fr;
    }

    .advanced-condition .advanced-value {
        grid-column: 1 / -1;
    }

    .filter-inline .filter-number,
    .filter-inline .form-control {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .stats-grid,
    .stats-grid.compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-calm-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .workspace-toolbar {
        gap: 8px;
    }

    .workspace-school label,
    .workspace-user {
        display: none;
    }

    .workspace-logout {
        margin-left: auto;
    }

    .page-header h1 {
        font-size: 23px;
    }

    .form-grid,
    .form-grid-3,
    .filter-inline,
    .filter-inline.wide,
    .report-options-grid,
    .report-columns {
        grid-template-columns: 1fr;
    }

    .advanced-filter-intro,
    .advanced-filter-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .advanced-condition {
        grid-template-columns: 1fr;
    }

    .advanced-condition .advanced-value {
        grid-column: auto;
    }

    .span-2,
    .span-3,
    .report-option-wide,
    .filter-inline input[type="search"] {
        grid-column: auto;
    }

    .form-actions,
    .dialog-footer {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .form-actions .btn,
    .dialog-footer .btn {
        width: 100%;
    }

    .inline-actions {
        justify-content: flex-start;
    }

    .inline-actions .btn,
    .inline-form,
    .inline-form .btn {
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .content-area,
    .metric-card {
        transition: none;
    }
}

@media print {
    .sidebar,
    .workspace-toolbar,
    .page-actions,
    .form-actions,
    .filter-inline,
    .skip-link,
    .btn,
    form,
    .sidebar-backdrop {
        display: none !important;
    }

    .content-area {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .panel,
    .metric-card {
        break-inside: avoid;
        box-shadow: none;
    }
}
