:root {
    --color-bg: #f1f3f2;
    --color-surface: #ffffff;
    --color-surface-muted: #f7f8f7;
    --color-border: #e1e5e3;
    --color-border-strong: #c9cfcc;
    --color-text: #1a211d;
    --color-text-muted: #667069;
    --color-text-faint: #8d978f;

    --color-primary: #1f6f4a;
    --color-primary-dark: #15573a;
    --color-primary-soft: #e8f3ee;
    --color-primary-ring: rgba(31, 111, 74, 0.18);

    --color-danger: #b3362f;
    --color-danger-dark: #8f2a25;
    --color-danger-soft: #fbeae9;
    --color-danger-border: #f0c4c1;

    --color-success: #1f6f4a;
    --color-success-soft: #e7f3ea;
    --color-success-border: #bfe0c8;

    --color-warning: #8a5a12;
    --color-warning-soft: #fbf0e0;
    --color-warning-border: #ecd2a3;

    --color-info: #1f5c8f;
    --color-info-soft: #e8f1fa;
    --color-info-border: #bdd7ef;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --sidebar-width: 256px;
    --spacing: 20px;

    --shadow-sm: 0 1px 2px rgba(20, 30, 25, 0.05);
    --shadow-md: 0 2px 10px rgba(20, 30, 25, 0.06), 0 1px 2px rgba(20, 30, 25, 0.04);
    --shadow-lg: 0 12px 32px rgba(20, 30, 25, 0.12);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 15.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-dark);
}

h1, h2, h3 {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--color-text);
}

h1 {
    font-size: 1.5rem;
    margin: 0 0 6px;
}

h2 {
    font-size: 1.1rem;
    margin: 0 0 14px;
}

.page-intro {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    margin: 0 0 20px;
    max-width: 68ch;
}

.icon {
    flex-shrink: 0;
    vertical-align: middle;
}

::selection {
    background: var(--color-primary-ring);
}

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

/* ============================================================
   Shell / sidebar layout
   ============================================================ */

.sidebar-toggle-input {
    display: none;
}

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

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    padding: 18px var(--spacing);
    font-weight: 800;
    font-size: 1.08rem;
    letter-spacing: -0.01em;
    color: var(--color-primary-dark);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.sidebar-colegio {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    line-height: 1.25;
}

.sidebar-colegio-logo {
    width: 136px;
    height: 136px;
    object-fit: contain;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.sidebar-ano-lectivo {
    display: inline-flex;
    align-self: center;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0;
}

.sidebar-ano-lectivo:hover {
    background: var(--color-primary);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    color: var(--color-text);
    font-size: 0.91rem;
    font-weight: 500;
    border-radius: var(--radius-xs);
    transition: background 0.12s ease, color 0.12s ease;
}

.sidebar-nav a:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.sidebar-nav a.active {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-weight: 700;
}

.sidebar-nav .icon {
    color: var(--color-text-faint);
}

.sidebar-group {
    margin: 0;
}

.sidebar-group summary {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    font-size: 0.91rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-radius: var(--radius-xs);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.sidebar-group summary::-webkit-details-marker,
.sidebar-group summary::marker {
    display: none;
    content: '';
}

.sidebar-group summary:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.sidebar-group[open] > summary {
    color: var(--color-text);
}

.sidebar-group summary .icon:last-child {
    margin-left: auto;
    color: var(--color-text-faint);
    transition: transform 0.15s ease;
}

.sidebar-group[open] > summary .icon:last-child {
    transform: rotate(90deg);
}

.sidebar-group > a {
    padding-left: 40px;
    font-size: 0.88rem;
}

.sidebar-nav a.active .icon,
.sidebar-nav a:hover .icon {
    color: var(--color-primary-dark);
}

.sidebar-footer {
    padding: 14px var(--spacing);
    border-top: 1px solid var(--color-border);
}

.sidebar-user {
    font-size: 0.84rem;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.sidebar-user strong {
    display: block;
    color: var(--color-text);
    font-size: 0.93rem;
    font-weight: 700;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-danger);
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.sidebar-logout:hover {
    background: var(--color-danger-soft);
    border-color: var(--color-danger-border);
}

.sidebar-backdrop {
    display: none;
}

.app-content-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px var(--spacing);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.mobile-topbar .brand {
    font-weight: 700;
    color: var(--color-primary-dark);
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    cursor: pointer;
}

.app-main {
    width: 100%;
    padding: 30px 36px;
}

@media (max-width: 860px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar-toggle-input:checked ~ .app-shell .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle-input:checked ~ .app-shell .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 20, 16, 0.45);
        z-index: 15;
    }

    .app-content-wrapper {
        margin-left: 0;
    }

    .mobile-topbar {
        display: flex;
    }

    .app-main {
        padding: 18px 16px 32px;
    }
}

/* ============================================================
   Cards
   ============================================================ */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: var(--spacing);
}

.card-footer-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--color-border);
}

/* ============================================================
   Forms — global, not scoped, so any input anywhere is styled
   ============================================================ */

.form-group {
    margin-bottom: 12px;
}

form h2 {
    margin-top: 20px;
}

form h2:first-of-type {
    margin-top: 0;
}

/* Grelha para formularios longos: os campos ocupam o espaco disponivel em
   2-3 colunas em vez de uma coluna estreita isolada no meio do ecra. Um
   campo que precise da largura toda (textarea, checkbox com descricao)
   leva a classe .form-grid-full. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 4px 24px;
}

.form-grid .form-group input,
.form-grid .form-group select {
    max-width: none;
}

.form-grid-full {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group label,
label.field-label {
    display: block;
    font-size: 0.87rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--color-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    max-width: 420px;
    padding: 9px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.93rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
    max-width: 100%;
    min-height: 56px;
}

/* Formularios de uma linha (ex: "Nova disciplina") ficam compactos, nao
   esticados a largura toda do ecra. */
.form-inline {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
    flex: 0 1 auto;
}

select {
    cursor: pointer;
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-faint);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="tel"]:hover,
select:hover {
    border-color: var(--color-text-faint);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    vertical-align: middle;
    margin-right: 6px;
}

/* Inputs embedded directly in table cells (bulk-edit screens) */
td input[type="text"],
td input[type="number"] {
    width: 100%;
    max-width: 260px;
    min-width: 110px;
    padding: 4px 10px;
    font-size: 0.88rem;
}

.input-with-icon {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input-with-icon:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.input-with-icon .input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    border-right: 1px solid var(--color-border);
}

.input-with-icon input {
    border: none !important;
    flex: 1;
    padding: 10px 12px;
    font-size: 0.95rem;
    min-width: 0;
    box-shadow: none !important;
}

.input-with-icon input:focus {
    outline: none;
}

.input-with-icon.has-toggle button {
    border: none;
    background: none;
    width: 44px;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-with-icon.has-toggle button:hover {
    color: var(--color-primary-dark);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #ffffff;
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease, transform 0.05s ease;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #ffffff;
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid var(--color-primary-dark);
    outline-offset: 2px;
}

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

.btn-secondary:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-text-faint);
    color: var(--color-primary-dark);
}

.btn-danger {
    border-color: var(--color-danger-border);
    color: var(--color-danger);
    background: var(--color-surface);
}

.btn-danger:hover {
    background: var(--color-danger-soft);
    border-color: var(--color-danger);
    color: var(--color-danger-dark);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.82rem;
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing);
    font-size: 0.9rem;
    border: 1px solid transparent;
    border-left-width: 4px;
}

.alert .icon {
    margin-top: 1px;
}

.alert-erro {
    background: var(--color-danger-soft);
    color: var(--color-danger-dark);
    border-color: var(--color-danger-border);
    border-left-color: var(--color-danger);
}

.alert-sucesso {
    background: var(--color-success-soft);
    color: var(--color-success);
    border-color: var(--color-success-border);
    border-left-color: var(--color-success);
}

.alert-aviso {
    background: var(--color-warning-soft);
    color: var(--color-warning);
    border-color: var(--color-warning-border);
    border-left-color: var(--color-warning);
}

.alert-info {
    background: var(--color-info-soft);
    color: var(--color-info);
    border-color: var(--color-info-border);
    border-left-color: var(--color-info);
}

/* ============================================================
   Tables
   ============================================================ */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    text-align: left;
    padding: 5px 12px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    white-space: nowrap;
}

th {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-surface-muted);
}

tbody tr {
    transition: background 0.1s ease;
}

tbody tr:hover {
    background: var(--color-surface-muted);
}

tbody tr:last-child td {
    border-bottom: none;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.table-actions {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
}

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

/* Celulas que tem texto mais longo (nomes, descricoes) podem quebrar linha
   normalmente; as que sao sempre curtas (numeros, estados, acoes) ficam
   numa so linha para a tabela ficar compacta. */
td.cell-wrap {
    white-space: normal;
}

/* ============================================================
   Misc: badges, stats
   ============================================================ */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    background: var(--color-surface-muted);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.badge-primary {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    border-color: var(--color-success-border);
}

.badge-danger {
    background: var(--color-danger-soft);
    color: var(--color-danger-dark);
    border-color: var(--color-danger-border);
}

.stat {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 170px;
    padding: 14px 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--color-success-soft);
    color: var(--color-primary-dark);
}

.stat .valor {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--color-primary-dark);
    letter-spacing: -0.02em;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat .rotulo {
    font-size: 0.84rem;
    color: var(--color-text-muted);
}

.stat-alerta .valor {
    color: var(--color-warning);
}

.stat-alerta .stat-icon {
    background: var(--color-warning-soft);
    color: var(--color-warning);
}

.stat-perigo .valor {
    color: var(--color-danger);
}

.stat-perigo .stat-icon {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.stat-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-row-financeiro {
    margin-top: 16px;
}

.stat-row-financeiro .stat {
    flex: 1 1 260px;
    padding: 18px 20px;
    container-type: inline-size;
}

.stat-row-financeiro .stat-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.stat-row-financeiro .valor {
    font-size: clamp(0.95rem, 7.5cqw, 1.9rem);
    white-space: nowrap;
}

.stat-content {
    min-width: 0;
}

.valor-unidade {
    font-size: 0.6em;
    font-weight: 700;
    margin-left: 2px;
}

.bar-row {
    display: grid;
    grid-template-columns: 140px 1fr 50px;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.86rem;
}

.bar-track {
    background: var(--color-border);
    border-radius: 6px;
    height: 10px;
    overflow: hidden;
}

.bar-fill {
    background: var(--color-primary);
    height: 100%;
    border-radius: 6px;
}

/* ============================================================
   Login
   ============================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing);
    background: linear-gradient(180deg, var(--color-bg) 0%, #eaf0ec 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 30px;
}

.login-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--color-primary-dark);
}

.login-header {
    text-align: center;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
}

.login-logo {
    display: block;
    margin: 0 auto 14px;
    width: 152px;
    height: 152px;
    object-fit: contain;
}

.login-card h1 {
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 0.92rem;
    margin: 0 0 18px;
}

.login-divider {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 20px 0;
}

.login-footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-faint);
    margin-top: 20px;
}

@media (max-width: 600px) {
    .login-card {
        padding: 24px;
        border-radius: 14px;
    }

    .login-logo {
        width: 96px;
        height: 96px;
    }
}

/* ============================================================
   Modals (native <dialog>)
   ============================================================ */

dialog.modal-card {
    border: none;
    padding: 0;
    width: 100%;
    max-width: 440px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: var(--color-surface);
    color: var(--color-text);
}

dialog.modal-card::backdrop {
    background: rgba(10, 20, 16, 0.45);
}

.modal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-card-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.modal-close-btn {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-xs);
}

.modal-close-btn:hover {
    background: var(--color-surface-muted);
    color: var(--color-text);
}

.modal-card-body {
    padding: 20px;
}

@media (max-width: 600px) {
    dialog.modal-card {
        max-width: calc(100vw - 32px);
    }
}

/* ============================================================
   Stepper (registo em fases)
   ============================================================ */

.stepper {
    display: flex;
    align-items: center;
    max-width: 480px;
    margin: 0 0 24px;
}

.stepper-step {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.stepper-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--color-surface-muted);
    color: var(--color-text-faint);
    border: 1px solid var(--color-border-strong);
}

.stepper-label {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--color-text-faint);
    white-space: nowrap;
}

.stepper-step.active .stepper-circle {
    background: var(--color-surface);
    border: 2px solid var(--color-primary);
    color: var(--color-primary-dark);
}

.stepper-step.active .stepper-label {
    color: var(--color-text);
}

.stepper-step.done .stepper-circle {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff;
}

.stepper-step.done .stepper-label {
    color: var(--color-text-muted);
}

.stepper-line {
    flex: 1;
    height: 2px;
    background: var(--color-border-strong);
    margin: 0 12px;
    min-width: 24px;
}

.stepper-line.done {
    background: var(--color-primary);
}

@media (max-width: 480px) {
    .stepper-label {
        display: none;
    }
}

/* ============================================================
   Documentos para imprimir (recibos, relatorios)
   ============================================================ */

.print-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
}

.doc-sheet {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 28px;
    max-width: 860px;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 14px;
    margin-bottom: 20px;
}

.doc-header .colegio-nome {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--color-primary);
}

.doc-colegio {
    display: flex;
    align-items: center;
    gap: 12px;
}

.doc-colegio-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.doc-header .doc-tipo {
    text-align: right;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.doc-header .doc-tipo strong {
    display: block;
    font-size: 1.05rem;
    color: var(--color-text);
}

.doc-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    margin-bottom: 20px;
}

.doc-field label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.doc-field .valor {
    font-size: 0.95rem;
    font-weight: 600;
}

.doc-value-box {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px;
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doc-value-box .valor-total {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-primary);
}

table.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.85rem;
}

table.doc-table th, table.doc-table td {
    text-align: left;
    padding: 7px 10px;
    border-bottom: 1px solid var(--color-border);
    white-space: normal;
}

table.doc-table th {
    color: var(--color-text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    border-bottom: 2px solid var(--color-border);
}

.doc-footer {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.doc-signature {
    margin-top: 50px;
    text-align: center;
    width: 220px;
}

.doc-signature .linha {
    border-top: 1px solid var(--color-text);
    margin-bottom: 6px;
}

/* Ao imprimir (Ctrl+P ou botao "Imprimir"), esconde todo o resto da
   aplicacao (menu lateral, barra mobile, botoes) e mostra so o documento. */
@media print {
    .app-sidebar,
    .sidebar-backdrop,
    .mobile-topbar,
    .print-toolbar {
        display: none !important;
    }

    .app-content-wrapper {
        margin-left: 0 !important;
    }

    .app-main {
        padding: 0 !important;
    }

    .doc-sheet {
        border: none;
        box-shadow: none;
        padding: 0;
        max-width: none;
    }
}
