:root {
    --color-primary: #1e4b7a;
    --color-primary-dark: #163a5f;
    --color-bg: #f3f5f7;
    --color-card: #ffffff;
    --color-text: #1f2933;
    --color-muted: #5a6772;
    --color-success: #1f7a4d;
    --color-error: #b42318;
    --color-border: #d8dee4;
    --font-base: 16px;
    --sidebar-width: 260px;
    --control-height: 44px;
    --btn-padding-y: 0.75rem;
    --btn-padding-x: 1.1rem;
    --transition-fast: 0.15s ease;
    --transition-medium: 0.22s ease;
    --surface-hover: #eef4fa;
    --surface-muted: #f8fafc;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: var(--font-base);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.menu-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    background: var(--color-card);
    border-radius: 8px;
    cursor: pointer;
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    padding: 0;
}

.sidebar-brand {
    flex-shrink: 0;
    padding: 1.35rem 1rem 1.1rem;
    font-size: 1.15rem;
    line-height: 1.3;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand strong {
    display: block;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.sidebar-logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 52px;
    object-fit: contain;
    object-position: left center;
}

.sidebar-nav {
    flex: 1;
    padding: 0.85rem 0.8rem;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sidebar-menu-item {
    margin: 0;
    padding: 0;
}

.sidebar .sidebar-nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.72rem 0.9rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.94);
    background: transparent;
    border: none;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.35;
    cursor: pointer;
    transition:
        background-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.sidebar .sidebar-nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    text-decoration: none;
    transform: translateX(2px);
}

.sidebar .sidebar-nav-link.active {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-weight: 700;
    transform: none;
    position: relative;
    padding-left: 1.35rem;
}

.sidebar .sidebar-nav-link.active::before {
    content: "";
    position: absolute;
    left: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 58%;
    min-height: 1.1rem;
    border-radius: 999px;
    background: #fff;
}

.sidebar-menu-group {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sidebar-group-heading {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    min-height: 44px;
    padding: 0.72rem 0.9rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: default;
    user-select: none;
    transition:
        background-color 0.18s ease,
        color 0.18s ease;
}

.sidebar-menu-group:hover > .sidebar-group-heading,
.sidebar-menu-group:focus-within > .sidebar-group-heading,
.sidebar-menu-group.is-current > .sidebar-group-heading {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

.sidebar-group-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 0.75rem;
    height: 0.75rem;
    flex-shrink: 0;
}

.sidebar-group-chevron::before {
    content: "";
    display: block;
    width: 0.38rem;
    height: 0.38rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
}

.sidebar-menu-group:hover > .sidebar-group-heading .sidebar-group-chevron::before,
.sidebar-menu-group:focus-within > .sidebar-group-heading .sidebar-group-chevron::before,
.sidebar-menu-group.is-current > .sidebar-group-heading .sidebar-group-chevron::before {
    transform: rotate(45deg);
}

.sidebar-group-label {
    flex: 1;
    min-width: 0;
}

.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition:
        max-height 0.22s ease,
        opacity 0.18s ease,
        padding 0.18s ease;
}

.sidebar-menu-group:hover > .sidebar-submenu,
.sidebar-menu-group:focus-within > .sidebar-submenu,
.sidebar-menu-group.is-current > .sidebar-submenu {
    max-height: 280px;
    opacity: 1;
    padding-bottom: 0.25rem;
    pointer-events: auto;
}

.sidebar-submenu .sidebar-nav-link {
    min-height: 40px;
    padding: 0.58rem 0.85rem 0.58rem 1rem;
    font-size: 0.92rem;
    font-weight: 500;
}

.sidebar-submenu .sidebar-nav-link.active {
    padding-left: 1.35rem;
}

@media (max-width: 900px) {
    .sidebar-menu-group > .sidebar-submenu {
        max-height: none;
        opacity: 1;
        padding-bottom: 0.25rem;
        pointer-events: auto;
    }

    .sidebar-menu-group > .sidebar-group-heading .sidebar-group-chevron::before {
        transform: rotate(45deg);
    }
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 1rem 0.8rem 1.15rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-user {
    margin: 0 0 0.75rem;
    padding: 0 0.15rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.4;
    word-break: break-word;
}

.sidebar-logout-form {
    margin: 0;
}

.sidebar .sidebar-logout-btn {
    min-height: 44px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.sidebar .sidebar-logout-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.32);
    transform: translateY(-1px);
}

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 1.5rem;
    width: calc(100% - var(--sidebar-width));
}

.page-header h1 { margin: 0 0 1rem; font-size: 1.75rem; }
.page-content { min-width: 0; }

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 55% at 12% 8%, rgba(30, 75, 122, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 92% 88%, rgba(22, 58, 95, 0.08) 0%, transparent 50%),
        linear-gradient(165deg, #eef2f6 0%, var(--color-bg) 42%, #e8eef5 100%);
    position: relative;
    overflow-x: hidden;
}

.auth-body::before,
.auth-body::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: 0;
    border: 1px solid rgba(30, 75, 122, 0.07);
    border-radius: 28px;
}

.auth-body::before {
    width: min(42vw, 340px);
    height: min(42vw, 340px);
    top: -8%;
    right: -6%;
    transform: rotate(18deg);
}

.auth-body::after {
    width: min(36vw, 280px);
    height: min(36vw, 280px);
    bottom: -10%;
    left: -5%;
    transform: rotate(-12deg);
    border-radius: 40% 60% 55% 45%;
}

.auth-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    margin-bottom: 0;
    padding: 2rem 1.85rem 1.35rem;
    border-radius: 14px;
    border-color: rgba(216, 222, 228, 0.95);
    box-shadow:
        0 1px 2px rgba(22, 58, 95, 0.04),
        0 12px 32px rgba(22, 58, 95, 0.10);
}

.auth-card-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-card-logo-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5.5rem;
    height: 5.5rem;
    margin: 0 auto 1.15rem;
    padding: 0.85rem;
    background: var(--color-primary);
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(22, 58, 95, 0.22);
}

.auth-card-logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    margin: 0;
    object-fit: contain;
    object-position: center;
}

.auth-card-title {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-primary-dark);
    letter-spacing: 0.01em;
}

.auth-card-tagline {
    margin: 0 auto;
    max-width: 28ch;
    font-size: 0.95rem;
    line-height: 1.4;
    color: var(--color-muted);
}

.auth-card-form {
    max-width: none;
}

.auth-card-form .form-group {
    margin-bottom: 1.15rem;
}

.auth-card-form .form-group > label {
    font-size: 0.95rem;
    color: var(--color-text);
}

.auth-card-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background-color var(--transition-fast);
}

.auth-card-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover {
    border-color: #c5d0db;
}

.auth-card-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 75, 122, 0.16);
    background: #fff;
}

.auth-card > .alert {
    margin-bottom: 1.15rem;
}

.auth-card-form .field-error {
    margin-top: 0.4rem;
}

.auth-card-submit {
    margin-top: 0.35rem;
    min-height: 48px;
    border-radius: 10px;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(30, 75, 122, 0.22);
    transition:
        background-color var(--transition-fast),
        box-shadow var(--transition-fast),
        transform var(--transition-fast);
}

.auth-card-submit:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 4px 14px rgba(22, 58, 95, 0.28);
    transform: translateY(-1px);
}

.auth-card-submit:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(22, 58, 95, 0.2);
}

.auth-card-submit:focus-visible {
    outline: 3px solid rgba(30, 75, 122, 0.35);
    outline-offset: 2px;
}

.auth-card-footer {
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--color-muted);
}

.auth-card-footer-name {
    font-weight: 600;
    color: var(--color-primary-dark);
}

.auth-card-footer-sep {
    opacity: 0.55;
}

@media (max-width: 600px) {
    .auth-container {
        padding: 1.25rem 0.85rem;
        align-items: flex-start;
        padding-top: 2.5rem;
    }

    .auth-card {
        padding: 1.65rem 1.25rem 1.2rem;
        border-radius: 12px;
    }

    .auth-card-logo-wrap {
        width: 5rem;
        height: 5rem;
        margin-bottom: 1rem;
        padding: 0.75rem;
        border-radius: 12px;
    }

    .auth-card-title {
        font-size: 1.35rem;
    }

    .auth-card-brand {
        margin-bottom: 1.45rem;
    }

    .auth-card-footer {
        flex-direction: column;
        gap: 0.15rem;
    }

    .auth-card-footer-sep {
        display: none;
    }

    .auth-body::before,
    .auth-body::after {
        opacity: 0.55;
    }
}

/* Formulários */
.form { max-width: 720px; }
.form.form-wide { max-width: 960px; }

.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

.form-label,
.form-group > label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    min-height: var(--control-height);
    font-family: inherit;
}

.form-group textarea {
    min-height: auto;
    resize: vertical;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 0.5rem 0;
    font-size: 1rem;
}

.settings-logo-row {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.settings-logo-upload {
    flex: 1 1 220px;
    min-width: 0;
}

.settings-logo-preview {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 140px;
    min-height: 88px;
    padding: 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #f8fafc;
}

.settings-logo-preview-img {
    display: block;
    max-width: 120px;
    max-height: 72px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.settings-logo-preview-empty {
    margin: 0;
    font-size: 0.875rem;
    color: var(--color-muted);
    text-align: center;
    line-height: 1.35;
}

.form-section-title {
    margin: 1.5rem 0 1rem;
    font-size: 1.15rem;
}
.form-section-title:first-child { margin-top: 0; }

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
    margin: 0;
}

.checkbox-label input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
}

.estado-group .form-label { margin-bottom: 0.5rem; }
.estado-group .checkbox-label { display: inline-flex; }

.checkbox-group .checkbox-label { display: inline-flex; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.form-group-full { grid-column: 1 / -1; }

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    min-height: var(--control-height);
    font-family: inherit;
    white-space: nowrap;
    box-sizing: border-box;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

a.btn:hover { text-decoration: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-secondary { background: #e9eef3; color: var(--color-text); }
.btn-secondary:hover { background: #dde4eb; color: var(--color-text); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #922018; color: #fff; }
.btn-block { width: 100%; }
.btn-small {
    padding: 0.45rem 0.75rem;
    font-size: 0.95rem;
    min-height: 36px;
}

.alert { padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: #e7f6ee; color: var(--color-success); border: 1px solid #b8e6cc; }
.alert-error { background: #fdecec; color: var(--color-error); border: 1px solid #f5c2c0; }

.field-error { display: block; color: var(--color-error); margin-top: 0.35rem; font-size: 0.95rem; }
.text-muted { color: var(--color-muted); }

/* Acções de página e listagens */
.page-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.crud-toolbar {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.crud-filters {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
    flex: 1 1 auto;
    min-width: 0;
}

.crud-filters .form-group {
    margin-bottom: 0;
    flex: 1 1 200px;
    min-width: 160px;
}

.crud-filters .btn { flex-shrink: 0; }

.crud-toolbar-actions {
    display: flex;
    gap: 0.75rem;
    flex-shrink: 0;
}

.filters {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filters .form-group { margin-bottom: 0; flex: 1 1 200px; min-width: 160px; }

.results-summary { margin: 0 0 1rem; }

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }

/* Tabelas */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-card);
}

.data-table { width: 100%; border-collapse: collapse; background: var(--color-card); }
.data-table th, .data-table td {
    padding: 0.85rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}
.data-table th { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }

.data-table td.actions {
    white-space: nowrap;
}
.data-table td.actions .btn { margin-right: 0.35rem; }
.data-table td.actions .btn:last-child { margin-right: 0; }

.pagination {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding: 0.25rem 0;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--control-height);
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    background: #e9eef3;
    color: var(--color-text);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}
.pagination-link:hover {
    background: #dde4eb;
    text-decoration: none;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form {
    display: inline;
    margin: 0;
}

.permissions-block { margin-top: 1.5rem; }
.permission-group {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    text-align: left;
}
.permission-group legend {
    font-weight: 600;
    padding: 0 0.35rem;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-right: 1rem;
    margin-bottom: 0.35rem;
    cursor: pointer;
    font-weight: 400;
}

.error-card { max-width: 640px; }
.debug-error {
    background: #f8fafc;
    padding: 1rem;
    overflow: auto;
    border-radius: 8px;
}

.auxiliary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
.auxiliary-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.2rem 1.15rem 1.1rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(22, 58, 95, 0.06);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.auxiliary-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 8px 20px rgba(22, 58, 95, 0.14);
    text-decoration: none;
    transform: translateY(-3px);
}
.auxiliary-card .dash-card-icon {
    margin-bottom: 0.45rem;
}
.auxiliary-card-title,
.auxiliary-card h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
}
.auxiliary-card-meta {
    margin: 0.15rem 0 0;
    font-size: 0.92rem;
    color: var(--color-muted);
}

.confirm-details {
    margin: 1rem 0;
    padding: 0;
}
.confirm-details dt {
    font-weight: 600;
    margin-top: 0.5rem;
}
.confirm-details dd {
    margin: 0.15rem 0 0;
}

/* Tablet */
@media (max-width: 900px) {
    .menu-toggle { display: block; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 1000;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-nav {
        padding: 0.85rem 0.75rem;
    }

    .sidebar .sidebar-nav-link {
        min-height: 48px;
        padding: 0.8rem 0.95rem;
    }

    .sidebar-logo {
        max-height: 48px;
    }

    .sidebar-brand {
        padding: 1.15rem 0.85rem 1rem;
    }

    .app-main {
        margin-left: 0;
        width: 100%;
        padding: 4rem 1rem 1.5rem;
    }
    .form-grid { grid-template-columns: 1fr; }

    .nascimento-label-spacer {
        display: none;
    }

    .crud-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .crud-toolbar-actions {
        width: 100%;
    }

    .crud-toolbar-actions .btn {
        width: 100%;
    }

    .crud-filters .form-group {
        flex: 1 1 100%;
        min-width: 0;
    }

    .crud-filters .btn {
        width: 100%;
    }

    .filters .form-group {
        flex: 1 1 100%;
        min-width: 0;
    }

    .filters .btn {
        width: 100%;
    }
}

/* Telemóvel */
@media (max-width: 600px) {
    .page-header h1 { font-size: 1.45rem; }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .btn {
        width: 100%;
    }

    .page-actions {
        flex-direction: column;
    }

    .page-actions .btn {
        width: 100%;
    }

    .data-table th, .data-table td {
        padding: 0.65rem;
        font-size: 0.95rem;
    }

    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-link {
        width: 100%;
        text-align: center;
    }

    .pagination span {
        text-align: center;
    }

    .col-hide-mobile {
        display: none;
    }

    .ficha-actions-top,
    .ficha-actions-top-right,
    .assinante-ficha-title-row {
        flex-direction: column;
        align-items: stretch;
    }

    .assinante-estado-badge {
        align-self: flex-start;
    }
}

.summary-bar {
    margin: 0 0 1rem;
    color: var(--color-muted);
    font-size: 1.05rem;
}

.clickable-row {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}
.clickable-row:hover {
    background: #f8fafc;
}

.radio-group {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.radio-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    font-weight: 400;
}

.radio-inline input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    margin: 0;
}

.nascimento-onomastico-row {
    align-items: start;
}

.nascimento-onomastico-row > .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.nascimento-label-spacer {
    display: block;
    height: calc(1rem * 1.35 + 0.35rem);
    margin: 0;
    flex-shrink: 0;
}

.form-group-onomastico > .form-label {
    margin-bottom: 0.35rem;
}

.onomastico-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.onomastico-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
}

.onomastico-field > label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.onomastico-field input {
    width: 100%;
}

.postal-autocomplete {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% - 0.35rem);
    z-index: 20;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(31, 41, 51, 0.08);
    overflow: hidden;
}

.autocomplete-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
    background: #f3f7fb;
}

.postal-selected {
    margin-top: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #f8fafc;
}

.postal-selected-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.postal-selected-label {
    display: block;
    font-size: 0.9rem;
    color: var(--color-muted);
    margin-bottom: 0.15rem;
}

.ficha-actions-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.ficha-actions-top-right {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.assinante-ficha-header {
    margin-bottom: 1rem;
}

.assinante-ficha-identity {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.assinante-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #e8f0f8;
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.assinante-avatar svg {
    width: 38px;
    height: 38px;
    fill: currentColor;
}

.assinante-ficha-main {
    flex: 1;
    min-width: 0;
}

.assinante-ficha-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.assinante-numero {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.15rem;
}

.assinante-numero-anterior {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-muted);
    margin: -0.05rem 0 0.25rem;
}

.assinante-nome {
    margin: 0;
    font-size: 1.75rem;
    line-height: 1.2;
}

.assinante-estado-badge .badge {
    font-size: 0.95rem;
    padding: 0.35rem 0.85rem;
}

.assinante-contact-line {
    margin: 0.5rem 0 0;
    color: var(--color-muted);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.assinante-contact-line span:not(:last-child)::after {
    content: "\00b7";
    margin-left: 0.75rem;
    color: #c3ccd6;
}

.ficha-tabs {
    margin-top: 1.35rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.65rem 1.75rem;
}

.ficha-tab {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.98rem;
    color: var(--color-muted);
    padding: 0.55rem 0.25rem 0.65rem;
    border-bottom: 3px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
}

a.ficha-tab {
    cursor: pointer;
    border-radius: 6px 6px 0 0;
}

a.ficha-tab:hover {
    color: var(--color-primary);
    background: var(--surface-hover);
    text-decoration: none;
}

.ficha-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

a.ficha-tab.active {
    background: var(--surface-hover);
}

a.ficha-tab.active:hover {
    color: var(--color-primary-dark);
    border-bottom-color: var(--color-primary-dark);
}

.ficha-tab-disabled {
    cursor: not-allowed;
    opacity: 0.55;
    padding: 0.55rem 0.25rem 0.65rem;
}

.assinante-ficha-resumo {
    margin: 0.5rem 0 0;
    color: var(--color-primary);
    font-weight: 600;
}

.badge-warning { background: #fff3cd; color: #856404; }
.badge-muted { background: #e9ecef; color: #495057; }

.form-advanced {
    margin: 1rem 0;
    padding: 0.75rem 0;
    border-top: 1px solid var(--color-border);
}

.form-advanced summary,
.assinaturas-historico summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--color-primary);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--surface-muted);
    transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.form-advanced summary::-webkit-details-marker,
.assinaturas-historico summary::-webkit-details-marker {
    display: none;
}

.form-advanced summary::before,
.assinaturas-historico summary::before {
    content: "▸";
    flex-shrink: 0;
    font-size: 0.9rem;
    line-height: 1;
    color: var(--color-primary);
    transition: transform var(--transition-medium);
}

.form-advanced[open] summary::before,
.assinaturas-historico[open] summary::before {
    transform: rotate(90deg);
}

.form-advanced summary:hover,
.assinaturas-historico summary:hover {
    color: var(--color-primary-dark);
    background: var(--surface-hover);
    border-color: #c5dff8;
}

.form-advanced[open] summary,
.assinaturas-historico[open] summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    margin-bottom: 0;
    border-bottom-color: transparent;
}

.form-advanced[open] .form-grid {
    padding: 0.85rem 0.95rem 0.15rem;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: var(--surface-muted);
}

.form-advanced .form-grid,
.assinaturas-historico .table-wrap {
    animation: expandableReveal var(--transition-medium);
}

@keyframes expandableReveal {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-info-card {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.form-info-card-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.ficha-details-compact {
    grid-template-columns: 140px 1fr;
}

.form-info-notice {
    background: #eef6ff;
    border: 1px solid #c5dff8;
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

.form-info-notice ul {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.form-context-line {
    margin: 0 0 1rem;
    color: var(--color-muted);
}

.field-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.form-group-wide {
    grid-column: 1 / -1;
}

.crud-toolbar-actions-inline {
    margin-bottom: 1rem;
}

.assinaturas-historico {
    margin-top: 1.5rem;
}

.assinaturas-historico .table-wrap {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
}

.assinatura-ficha-header {
    margin-bottom: 1rem;
}

.ficha-actions-inline {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.renewal-history-list {
    margin: 0;
    padding-left: 1.25rem;
}

.renewal-history-list li {
    margin-bottom: 0.35rem;
}

.renewal-history-list a {
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.renewal-history-list a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.page-content a:not(.btn):not(.ficha-tab):not(.pagination-link):not(.auxiliary-card):not(.sidebar-nav-link) {
    cursor: pointer;
    transition: color var(--transition-fast);
}

.page-content a:not(.btn):not(.ficha-tab):not(.pagination-link):not(.auxiliary-card):not(.sidebar-nav-link):hover {
    color: var(--color-primary-dark);
}

.confirm-warning {
    color: var(--color-error);
    font-weight: 600;
}

.confirm-title {
    margin-top: 0;
}

.ficha-section {
    margin-bottom: 1.5rem;
}

.ficha-section:last-child {
    margin-bottom: 0;
}

.ficha-section-title {
    margin: 0 0 0.75rem;
    font-size: 1.05rem;
}

.ficha-details {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.5rem 1rem;
    margin: 0;
}

.ficha-details dt {
    font-weight: 600;
    margin: 0;
}

.ficha-details dd {
    margin: 0;
}

.ficha-notes-placeholder {
    border: 1px dashed var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    background: #fafbfc;
}

.confirm-counts {
    margin: 0.75rem 0;
    padding-left: 1.25rem;
}

@media (max-width: 900px) {
    .col-hide-mobile {
        display: none;
    }

    .postal-selected-grid {
        grid-template-columns: 1fr;
    }

    .ficha-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .assinante-nome {
        font-size: 1.4rem;
    }

    .ficha-tabs {
        gap: 0.45rem 1.15rem;
    }

    .ficha-tab,
    a.ficha-tab,
    .ficha-tab-disabled {
        font-size: 0.95rem;
        padding: 0.5rem 0.15rem 0.55rem;
    }

    .ficha-actions-top-right {
        width: 100%;
    }

    .ficha-actions-top-right .btn {
        width: 100%;
    }
}

.crud-filters-wide {
    flex-wrap: wrap;
}

.form-note {
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface-muted, #f4f6f8);
    border-left: 3px solid var(--color-primary, #2f6fed);
    color: var(--color-text-muted, #5a6472);
    font-size: 0.95rem;
}

.field-hint {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    color: var(--color-muted);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.col-checkbox {
    width: 2.5rem;
    text-align: center;
}

.col-num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.conta-corrente-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    margin-bottom: 1rem;
    padding: 1.15rem 1.25rem;
}

.conta-corrente-saldo-block {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem 1rem;
}

.conta-corrente-saldo-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-muted);
}

.conta-corrente-saldo-value {
    font-size: 1.5rem;
    line-height: 1.2;
    color: var(--color-primary);
}

.conta-corrente-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    color: var(--color-muted);
    font-size: 0.95rem;
}

.conta-corrente-table .conta-corrente-saldo-cell {
    font-weight: 600;
}

@media (max-width: 900px) {
    .conta-corrente-top {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ---- Painel (Dashboard) ---- */
.dash-welcome {
    margin-bottom: 1.5rem;
    padding: 1.5rem 1.5rem 1.35rem;
    border-left: 4px solid var(--color-primary);
}

.dash-welcome-title {
    margin: 0 0 0.45rem;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.dash-welcome-date {
    margin: 0 0 0.55rem;
    color: var(--color-text);
    font-size: 1.05rem;
}

.dash-welcome-text {
    margin: 0;
    color: var(--color-muted);
}

.dash-section {
    margin-bottom: 1.5rem;
}

.dash-section-title {
    margin: 0 0 0.85rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.dash-panel-title {
    margin: 0 0 0.85rem;
    font-size: 1rem;
    font-weight: 700;
}

.dash-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.dash-card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.2rem 1.15rem 1.1rem;
    box-shadow: 0 1px 3px rgba(22, 58, 95, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 100%;
}

.dash-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.55rem;
    color: var(--color-primary);
    background: #e8f0f8;
}

.dash-card-icon-assinaturas { background: #eaf4ee; color: var(--color-success); }
.dash-card-icon-receber { background: #f7f0e6; color: #9a6700; }
.dash-card-icon-recebido { background: #e8f0f8; color: var(--color-primary); }

.dash-card-label {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.dash-card-value {
    margin: 0.15rem 0;
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--color-text);
}

.dash-card-value-sm {
    font-size: 1.35rem;
}

.dash-card-desc {
    margin: 0;
    font-size: 0.92rem;
    color: var(--color-muted);
}

.dash-card-meta {
    margin: 0.35rem 0 0;
    font-size: 0.86rem;
    color: var(--color-muted);
}

.dash-grid-2 {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dash-panel.card {
    margin-bottom: 0;
}

.dash-alert-ok {
    margin: 0;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    background: #eaf6ef;
    color: var(--color-success);
    font-weight: 600;
}

.dash-alert-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.dash-alert {
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    font-size: 0.95rem;
}

.dash-alert a {
    color: inherit;
    text-decoration: none;
    font-weight: 550;
}

.dash-alert a:hover {
    text-decoration: underline;
}

.dash-alert-aviso {
    background: #fff8eb;
    border-color: #f0d9a8;
    color: #7a5800;
}

.dash-alert-erro {
    background: #fdf2f1;
    border-color: #efc4c0;
    color: var(--color-error);
}

.dash-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.dash-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    background: var(--color-primary);
    color: #fff !important;
    font-weight: 600;
    text-align: center;
    text-decoration: none !important;
    border: 1px solid transparent;
    transition: background var(--transition-fast);
}

.dash-action-btn:hover {
    background: var(--color-primary-dark);
}

.dash-action-btn-secondary {
    background: #fff;
    color: var(--color-primary) !important;
    border-color: var(--color-border);
}

.dash-action-btn-secondary:hover {
    background: var(--surface-hover);
}

.dash-activity-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.dash-table {
    width: 100%;
    font-size: 0.92rem;
}

.dash-panel .table-wrap {
    border: none;
    border-radius: 0;
    background: transparent;
}

.dash-panel .data-table th,
.dash-panel .data-table td {
    padding: 0.55rem 0.4rem;
}

.dash-empty {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.95rem;
}

.dash-charts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.dash-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.3rem;
    height: 160px;
    padding-top: 0.5rem;
}

.dash-chart-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.dash-chart-bar-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.dash-chart-bar {
    width: 70%;
    max-width: 22px;
    min-height: 0;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, #3a6ea5 0%, var(--color-primary) 100%);
}

.dash-chart-label {
    margin-top: 0.35rem;
    font-size: 0.68rem;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

@media (max-width: 1100px) {
    .dash-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-activity-grid,
    .dash-charts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .dash-grid-2 {
        grid-template-columns: 1fr;
    }

    .dash-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .dash-cards {
        grid-template-columns: 1fr;
    }

    .dash-welcome-title {
        font-size: 1.25rem;
    }

    .dash-card-value {
        font-size: 1.55rem;
    }
}

/* ---- Modelo 25 ---- */
.modelo25-intro {
    margin-bottom: 1rem;
}

.modelo25-intro-text {
    margin: 0;
    line-height: 1.45;
}

.modelo25-filters {
    align-items: flex-end;
}

.modelo25-filters .radio-group {
    min-height: var(--control-height);
    align-items: center;
}

.data-table tfoot th {
    background: #f8fafc;
    font-weight: 700;
    border-top: 1px solid var(--color-border);
}
