:root {
    --blue: #3157b7;
    --blue-dark: #263f89;
    --blue-light: #eaf0ff;
    --bg: #f6f8fc;
    --text: #101828;
    --muted: #667085;
    --border: #e3e7ef;
    --white: #ffffff;
    --green: #159455;
    --orange: #f05a00;
    --red: #d92d20;
    --shadow: 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.login-body { min-height: 100vh; background: #fff; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 42%) 1fr; }
.login-brand { background: linear-gradient(145deg, var(--blue), var(--blue-dark)); color: #fff; padding: 58px 72px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; position: relative; }
.login-brand::before, .login-brand::after { content: ""; position: absolute; border: 2px solid rgba(255,255,255,.08); border-radius: 50%; width: 360px; height: 360px; }
.login-brand::before { top: -180px; right: -120px; }
.login-brand::after { bottom: -230px; left: -110px; }
.brand-logo { font-size: 34px; font-weight: 800; letter-spacing: 1px; position: relative; z-index: 1; }
.login-brand h1 { font-size: clamp(38px, 5vw, 64px); line-height: 1.05; margin: 0 0 24px; max-width: 560px; position: relative; z-index: 1; }
.login-brand p { max-width: 480px; line-height: 1.7; color: #e8edff; position: relative; z-index: 1; }
.brand-modules { display: flex; gap: 12px; flex-wrap: wrap; position: relative; z-index: 1; }
.brand-modules span { background: rgba(255,255,255,.13); padding: 10px 16px; border-radius: 999px; font-weight: 700; }
.login-panel { display: grid; place-items: center; padding: 50px; }
.login-card { width: min(520px, 100%); }
.login-card h2 { font-size: 38px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.login-help { color: var(--muted); text-align: center; font-size: 14px; margin-top: 24px; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin: 22px 0; }
.form-group label { font-weight: 650; font-size: 14px; }
.form-control { min-height: 48px; border: 1px solid var(--border); border-radius: 9px; padding: 0 14px; background: #fff; outline: none; width: 100%; }
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49,87,183,.12); }
.check-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin: 8px 0 24px; }
.field-error, .errorlist { color: var(--red); font-size: 13px; margin: 0; padding: 0; list-style: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; min-height: 46px; padding: 0 20px; font-weight: 700; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #26499f; }
.btn-light { background: #fff; color: var(--blue); border-color: var(--border); }
.btn-block { width: 100%; }

.app-body { min-height: 100vh; display: flex; }
.sidebar { width: 248px; background: #fff; border-right: 1px solid var(--border); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; padding: 26px 16px; z-index: 5; }
.sidebar-brand { padding: 5px 18px 26px; display: flex; flex-direction: column; }
.sidebar-brand strong { font-size: 31px; color: var(--blue); }
.sidebar-brand span { color: var(--muted); font-size: 13px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar-nav a, .sidebar-modules a { padding: 13px 16px; border-radius: 9px; font-weight: 600; color: #344054; }
.sidebar-nav a:hover, .sidebar-nav a.active { color: var(--blue); background: var(--blue-light); }
.sidebar-modules { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 16px; display: flex; flex-direction: column; gap: 5px; }
.sidebar-modules p { margin: 0 16px 6px; font-size: 11px; letter-spacing: 1px; color: #98a2b3; font-weight: 800; }
.sidebar-modules a { font-size: 14px; padding-block: 9px; }
.sidebar-modules a:hover { background: #f2f4f7; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 20px 16px 4px; color: var(--red); font-weight: 650; }

.app-main { margin-left: 248px; min-height: 100vh; width: calc(100% - 248px); }
.topbar { height: 78px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 36px; position: sticky; top: 0; z-index: 4; }
.search-box { border: 1px solid var(--border); border-radius: 9px; width: min(440px, 50%); color: #98a2b3; padding: 13px 16px; }
.user-box { display: flex; align-items: center; gap: 12px; }
.user-box > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.user-box span { font-size: 12px; color: var(--muted); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--blue-light); color: var(--blue); display: grid; place-items: center; font-weight: 800; }
.content { padding: 36px; max-width: 1500px; margin: auto; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.page-heading h1 { margin: 0 0 8px; font-size: 34px; }
.page-heading p { margin: 0; color: var(--muted); }
.module-heading { border-left: 5px solid var(--module-color); padding-left: 20px; }
.module-badge { display: inline-flex; color: var(--module-color); font-weight: 800; margin-bottom: 8px; }

.stats-grid { display: grid; gap: 18px; margin-bottom: 24px; }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; min-height: 122px; padding: 24px; display: flex; align-items: center; gap: 18px; box-shadow: var(--shadow); }
.stat-card small { display: block; color: var(--muted); margin-bottom: 8px; }
.stat-card strong { font-size: 30px; }
.stat-icon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 23px; font-weight: 800; }
.stat-icon.blue { background: var(--blue-light); color: var(--blue); }
.stat-icon.green { background: #e8f8ef; color: var(--green); }
.stat-icon.orange { background: #fff0e6; color: var(--orange); }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.section-title h2 { margin: 0 0 5px; font-size: 21px; }
.section-title p { margin: 0; color: var(--muted); font-size: 14px; }
.text-link { color: var(--blue); font-weight: 700; }

.module-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.large-gap { gap: 24px; }
.module-card { --module-color: var(--blue); border: 1px solid color-mix(in srgb, var(--module-color) 25%, #e3e7ef); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; min-height: 285px; background: color-mix(in srgb, var(--module-color) 3%, white); }
.module-card-large { min-height: 355px; padding: 28px; }
.module-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 13px; background: color-mix(in srgb, var(--module-color) 12%, white); color: var(--module-color); font-size: 25px; font-weight: 800; }
.module-card h3 { margin: 20px 0 10px; color: var(--module-color); font-size: 21px; }
.module-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.55; flex: 1; }
.module-button { margin-top: 18px; background: var(--module-color); color: #fff; border-radius: 9px; padding: 13px; text-align: center; font-weight: 750; }

.status { display: inline-flex; width: fit-content; padding: 7px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status.active { background: #eaf8f0; color: #138a4e; }
.status.inactive { background: #feeceb; color: var(--red); }
.activity-list { display: flex; flex-direction: column; }
.activity-row { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: 0; }
.activity-row div { display: flex; flex-direction: column; gap: 4px; }
.activity-row small, .activity-row time { color: var(--muted); font-size: 12px; }
.activity-dot { width: 9px; height: 9px; background: var(--blue); border-radius: 50%; }

.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.feature-card { background: #f9fafb; border: 1px solid var(--border); padding: 22px; border-radius: 13px; display: flex; flex-direction: column; gap: 9px; }
.feature-card span { color: var(--green); font-size: 22px; }
.feature-card small { color: var(--muted); }

.table-panel { padding: 0; overflow: hidden; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th, td { padding: 17px 20px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; background: #fcfcfd; }
tr:last-child td { border-bottom: 0; }
.user-form { max-width: 980px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.full-width { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
#id_modules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; border: 1px solid var(--border); border-radius: 9px; padding: 16px; }
#id_modules label { font-weight: 500; display: flex; gap: 8px; }
.access-denied { text-align: center; padding: 80px 30px; }
.denied-icon { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 20px; background: #feeceb; color: var(--red); font-size: 45px; font-weight: 800; }
.empty-state { color: var(--muted); text-align: center; padding: 30px; }
.alert { padding: 13px 16px; border-radius: 9px; margin-bottom: 18px; font-size: 14px; }
.alert.success { background: #eaf8f0; color: #127b46; }
.alert.error { background: #feeceb; color: var(--red); }
.alert.warning { background: #fff4e5; color: #b54708; }

@media (max-width: 1100px) {
    .module-grid { grid-template-columns: repeat(2, 1fr); }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
    .login-shell { grid-template-columns: 1fr; }
    .login-brand { min-height: 380px; padding: 38px; }
    .content { padding: 24px 16px; }
    .topbar { padding: 0 16px; }
    .stats-grid-3, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .module-grid, .feature-grid { grid-template-columns: 1fr; }
    .search-box { display: none; }
    .page-heading { flex-direction: column; }
}

/* Gestão administrativa da FILA Base */
.stats-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-shortcuts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.shortcut-card { border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; background: #fcfcfd; }
.shortcut-card:hover { border-color: #c8d2ea; box-shadow: var(--shadow); }
.shortcut-card div { display: flex; flex-direction: column; gap: 5px; }
.shortcut-card small { color: var(--muted); line-height: 1.5; }
.shortcut-card b { color: var(--blue); font-size: 22px; }
.filter-panel { padding-block: 18px; }
.filter-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; gap: 16px; align-items: end; }
.compact-field { margin: 0; }
.filter-actions { display: flex; gap: 8px; padding-bottom: 1px; }
.row-actions { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: transparent; padding: 0; color: var(--blue); font-weight: 700; cursor: pointer; }
.danger-link { color: var(--red); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 22px 0; color: var(--muted); font-size: 14px; }
.pagination a { color: var(--blue); font-weight: 700; }
.back-link { display: inline-block; color: var(--blue); font-weight: 700; margin-bottom: 12px; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.info-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.info-card small { color: var(--muted); }
.info-card strong { font-size: 22px; }
.panel-heading-pad { padding: 24px 24px 0; }
.code-badge { display: inline-flex; padding: 5px 9px; border-radius: 7px; background: var(--blue-light); color: var(--blue-dark); font-weight: 800; font-size: 12px; letter-spacing: .4px; }
.state-panel { display: flex; justify-content: space-between; gap: 24px; align-items: center; }
.state-panel h2 { margin: 0 0 8px; font-size: 20px; }
.state-panel p { margin: 0; max-width: 800px; line-height: 1.55; }
.btn-danger-soft { background: #fff; color: var(--red); border-color: #f3b9b5; }
.btn-danger-soft:hover { background: #fff3f2; }
.admin-check { margin: 12px 0 0; color: var(--text); font-weight: 650; }
textarea.form-control { min-height: 100px; padding-top: 12px; resize: vertical; }

@media (max-width: 1200px) {
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-actions { align-self: end; }
}
@media (max-width: 820px) {
    .detail-grid, .admin-shortcuts { grid-template-columns: 1fr; }
    .state-panel { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
    .stats-grid-4, .filter-grid { grid-template-columns: 1fr; }
    .heading-actions, .filter-actions { width: 100%; }
    .heading-actions .btn, .filter-actions .btn { flex: 1; }
}

/* Logótipo */
.brand-logo {
    display: flex;
    align-items: center;
    min-height: 55px;
}

.brand-logo img {
    display: block;
    width: 145px;
    height: auto;
    object-fit: contain;


}

/* Campo da palavra-passe */
.password-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.password-wrapper > input {
    display: block;
    width: 100% !important;
    padding-right: 55px !important;
}

.password-toggle {
    position: absolute !important;
    top: 50% !important;
    right: 12px !important;
    transform: translateY(-50%) !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    width: 36px !important;
    height: 36px !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;

    border: none !important;
    background: transparent !important;
    color: #526b9a;
    cursor: pointer;
    z-index: 10;
    line-height: 0;
}

.password-toggle:hover {
    color: #3157b7;
}

.eye-icon {
    display: block;
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.eye-closed {
    display: none;
}

/* Checkbox pequeno */
.check-line {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: fit-content !important;
    margin: 14px 0 18px !important;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.check-line input[type="checkbox"] {
    appearance: auto !important;
    display: inline-block !important;

    width: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;

    height: 18px !important;
    min-height: 18px !important;
    max-height: 18px !important;

    padding: 0 !important;
    margin: 0 !important;
    flex: 0 0 18px !important;

    cursor: pointer;
}

.sidebar-logo {
    display: block;
    width: 130px;
    height: auto;
    margin-bottom: 6px;
    object-fit: contain;
}

.sidebar-nav a,
.sidebar-modules a,
.sidebar-footer a {
    display: flex;
    align-items: center;
}

.nav-icon {
    width: 22px;
    min-width: 22px;
    margin-right: 10px;
    font-size: 18px;
    line-height: 1;
    text-align: center;
}

.nav-count {
    margin-left: auto;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box i {
    color: var(--blue);
    font-size: 16px;
}

.notification-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.notification-button > i {
    color: var(--blue);
    font-size: 21px;
}

.module-icon i {
    font-size: 24px;
    line-height: 1;
}

.sidebar-logo {
    display: block;
    width: 130px;
    height: auto;
    margin-bottom: 6px;
    object-fit: contain;
}

.sidebar-nav a,
.sidebar-modules a,
.sidebar-footer a {
    display: flex;
    align-items: center;
}

.nav-icon {
    width: 22px;
    min-width: 22px;
    margin-right: 10px;
    font-size: 18px;
    line-height: 1;
    text-align: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box i {
    color: var(--blue);
    font-size: 16px;
}

.quick-icon,
.process-symbol,
.empty-mini-state,
.user-white-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.quick-icon i {
    font-size: 22px;
    line-height: 1;
}

.process-symbol i {
    font-size: 18px;
}

.empty-mini-state i {
    color: var(--green);
    font-size: 32px;
    margin-bottom: 12px;
}

.user-white-btn {
    gap: 8px;
}

.brand-logo-img {
    display: block;
    width: 145px;
    height: auto;
    object-fit: contain;
    filter: none;
}

.institution-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.institution-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.institution-letter-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 28px;
    font-weight: 800;
    color: var(--blue);
}

.institution-letter-fallback[hidden] {
    display: none;
}

.institution-card p i {
    color: var(--blue);
    margin-right: 4px;
}

.institution-card .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.institution-logo-preview {
    width: 100px;
    height: 100px;
    margin: 10px 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--blue-light);
}

.institution-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}


/* =========================================================
   CORREÇÃO — MENU LATERAL ADMINISTRATIVO COM ROLAGEM
   O menu permanece fixo, mas pode subir/descer de forma
   independente quando o conteúdo ultrapassa a altura da tela.
   ========================================================= */
.sidebar {
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.sidebar::-webkit-scrollbar {
    width: 7px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #98a2b3;
}

/* Evita que os blocos do menu sejam comprimidos pelo flexbox. */
.sidebar-brand,
.sidebar-nav,
.sidebar-modules,
.sidebar-footer {
    flex-shrink: 0;
}

/* Mantém a saída no fim do conteúdo, mas acessível pela rolagem. */
.sidebar-footer {
    margin-top: 24px;
}

/* Os Bootstrap Icons do Dashboard seguem a mesma linguagem visual
   utilizada no menu lateral. */
.stat-icon i,
.module-icon i {
    font-size: inherit;
    line-height: 1;
}

