:root {
    color-scheme: light;

    /* Superfícies */
    --app-bg: #f8fafc;                 /* fundo geral das páginas internas */
    --app-bg-alt: #eef2f7;             /* fundo das páginas de login/guest */
    --app-bg-muted: #f5f7fa;           /* app-shell / cabeçalhos de tabela */
    --app-surface: #ffffff;            /* cards, painéis, sidebar, tabela */
    --app-surface-subtle: #f6f9fc;     /* painéis internos sutis */
    --app-surface-hover: #f1f5f9;      /* hover neutro / chips cinza */
    --app-surface-hover-brand: #f6faff;/* hover azulado de linhas */
    --app-surface-brand: #eaf3fb;      /* tinta de marca (nav ativa, ícones) */
    --app-surface-brand-2: #eef6ff;    /* tinta de marca alternativa */

    /* Bordas */
    --app-border: #d8dee6;
    --app-border-soft: #e6ebf1;
    --app-border-faint: #f1f4f8;       /* linhas internas de tabela */
    --app-border-brand: #c8dff8;

    /* Texto */
    --app-text: #1f2937;
    --app-text-strong: #0f172a;
    --app-text-body: #334155;
    --app-text-muted: #475569;
    --app-text-soft: #64748b;
    --app-text-faint: #94a3b8;
    --app-text-disabled: #cbd5e1;
    --app-on-brand: #ffffff;           /* texto/ícone sobre cor de marca */

    /* Marca (azul Voxel Dasti) e acento (laranja) */
    --app-brand: #2E7BC4;
    --app-brand-strong: #256aa8;
    --app-brand-active: #215f97;
    --app-brand-text: #1c6bb0;
    --app-accent: #EA5B2A;

    /* Detalhe */
    --app-spinner-track: #dbe6f2;

    /* Status (alertas, tags, KPIs) */
    --app-success-bg: #e8f6ee;
    --app-success-text: #1a7f43;
    --app-accent-bg: #fdede4;
    --app-warning-bg: #fdf0dc;
    --app-warning-text: #9a6413;
    --app-danger-bg: #fdecec;
    --app-danger-text: #b3352f;
    --app-danger-strong: #d64545;
    --app-highlight-bg: #fff2c2;

    /* Aliases legados (compatibilidade) */
    --surface-border: var(--app-border);
    --surface-muted: var(--app-bg-muted);
    --text-muted: var(--app-text-soft);
}

body {
    background: var(--app-bg);
    color: var(--app-text);
}

.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--app-bg-alt);
}

.login-panel {
    width: min(100%, 420px);
    background: var(--app-surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 12px 36px rgb(15 23 42 / 8%);
}

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

.page-header h1 {
    font-size: 1.5rem;
    line-height: 1.2;
    margin: 0;
}

.toolbar,
.form-surface,
.module-card,
.metric-card {
    background: var(--app-surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.metric-card {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    min-height: 112px;
}

.metric-card strong {
    font-size: 2rem;
    line-height: 1;
}

.module-card {
    height: 100%;
}

.module-card h2 {
    font-size: 1rem;
    margin: 0 0 .35rem;
}

.module-card p {
    color: var(--text-muted);
    margin: 0;
}

.module-icon {
    align-items: center;
    background: var(--app-surface-brand-2);
    border: 1px solid var(--app-border-brand);
    border-radius: 8px;
    color: var(--app-brand-text);
    display: inline-flex;
    flex: 0 0 42px;
    font-size: 1.25rem;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.permission-item {
    align-items: center;
    background: var(--app-surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    display: flex;
    gap: .65rem;
    min-height: 44px;
    padding: .65rem .8rem;
}

.metric-label,
.detail-grid span {
    color: var(--text-muted);
    font-size: .875rem;
}

.table {
    background: var(--app-surface);
    border: 1px solid var(--surface-border);
}

.table thead th {
    background: var(--surface-muted);
    color: var(--app-text-muted);
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.detail-grid > div {
    background: var(--app-surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 1rem;
}

.detail-grid strong {
    display: block;
    margin-top: .25rem;
    font-weight: 600;
    word-break: break-word;
}

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

.empty-state {
    background: var(--app-surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
}

@media (max-width: 767.98px) {
    .page-header {
        flex-direction: column;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

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

/* ==== Login (autenticação) ==== */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--app-bg-alt);
    padding: 2.5rem 1rem;
}

.auth-alerts { width: min(100%, 940px); }

.auth-card {
    position: relative;
    width: min(100%, 940px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--app-surface);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgb(15 23 42 / 12%);
    border: 1px solid var(--app-border-soft);
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: linear-gradient(90deg, var(--app-brand) 0%, var(--app-brand) 55%, var(--app-accent) 100%);
}

.auth-brand {
    background: var(--app-surface-subtle);
    border-right: 1px solid var(--app-border-soft);
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-brand img { max-width: 250px; height: auto; margin-bottom: 1.5rem; }

.auth-brand-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--app-text-strong);
    margin: 0 0 1.25rem;
    line-height: 1.45;
}

.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: .65rem; }
.auth-points li { font-size: .92rem; color: var(--app-text-muted); display: flex; gap: .55rem; align-items: center; }
.auth-points i { color: var(--app-brand); font-size: 1.05rem; }

.auth-form {
    padding: 3rem 2.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-title { font-size: 1.55rem; font-weight: 600; margin: 0 0 .3rem; color: var(--app-text-strong); }
.auth-subtitle { color: var(--app-text-soft); margin: 0 0 1.7rem; }
.auth-form .form-label { font-weight: 500; font-size: .9rem; color: var(--app-text-body); margin-bottom: .35rem; }

.auth-input { position: relative; margin-bottom: 1rem; }
.auth-input > i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--app-text-faint); }
.auth-input .form-control { height: 48px; padding-left: 2.55rem; border-radius: 11px; }
.auth-input .form-control:focus { border-color: var(--app-brand); box-shadow: 0 0 0 .2rem rgb(46 123 196 / 18%); }

.auth-eye {
    position: absolute;
    right: .45rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 0;
    color: var(--app-text-faint);
    padding: .35rem .55rem;
}

/* Campo de senha com botão mostrar/ocultar (fora do login) */
.pw-field { position: relative; }
.pw-field .form-control { padding-right: 2.6rem; }

/* Aviso LGPD */
.lgpd-note { display: flex; align-items: flex-start; gap: .6rem; background: var(--app-surface-brand-2); border: 1px solid var(--app-border-brand); color: var(--app-brand-text); border-radius: 10px; padding: .7rem 1rem; margin-bottom: 1rem; font-size: .86rem; line-height: 1.45; }
.lgpd-note i { color: var(--app-brand); font-size: 1.05rem; margin-top: .1rem; }

/* Autocomplete (cidade, bairro, indicação) */
.ac { position: relative; }
.ac-list { position: absolute; z-index: 40; top: 100%; left: 0; right: 0; margin-top: 3px; background: var(--app-surface); border: 1px solid var(--app-border-soft); border-radius: 10px; box-shadow: 0 12px 30px rgb(15 23 42 / 12%); list-style: none; padding: .25rem; max-height: 240px; overflow: auto; display: none; }
.ac-list.is-open { display: block; }
.ac-item { padding: .5rem .7rem; border-radius: 7px; cursor: pointer; font-size: .92rem; color: var(--app-text-body); }
.ac-item:hover, .ac-item.is-active { background: var(--app-surface-brand); color: var(--app-brand-text); }
.ac-empty { padding: .55rem .7rem; color: var(--app-text-faint); font-size: .88rem; }

/* Overlay de carregamento */
.app-loading { position: fixed; inset: 0; background: rgb(15 23 42 / 35%); display: none; align-items: center; justify-content: center; z-index: 1080; }
.app-loading.is-active { display: flex; }
.app-loading-box { background: var(--app-surface); border-radius: 12px; padding: 1.15rem 1.6rem; display: flex; align-items: center; gap: .9rem; box-shadow: 0 12px 36px rgb(15 23 42 / 18%); color: var(--app-text-body); font-size: .95rem; }
.app-spinner { width: 26px; height: 26px; border: 3px solid var(--app-spinner-track); border-top-color: var(--app-brand); border-radius: 50%; animation: app-spin .7s linear infinite; }
.app-spinner--sm { width: 18px; height: 18px; border-width: 3px; border-color: var(--app-spinner-track); border-top-color: var(--app-brand); display: inline-block; vertical-align: -4px; margin-right: .4rem; }
.form-text .app-spinner--sm { color: inherit; }
.cep-loading-text { color: var(--app-brand); font-weight: 600; }
.form-control.is-loading { border-color: var(--app-brand); box-shadow: 0 0 0 .18rem rgb(46 123 196 / 20%); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 16 16'%3E%3Cg fill='none' stroke='%232E7BC4' stroke-width='2.4'%3E%3Ccircle cx='8' cy='8' r='6' stroke='%23bcd6ef'/%3E%3Cpath d='M8 2a6 6 0 0 1 6 6'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 8 8' to='360 8 8' dur='0.7s' repeatCount='indefinite'/%3E%3C/path%3E%3C/g%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 22px 22px; padding-right: 2.4rem; }
@keyframes app-spin { to { transform: rotate(360deg); } }

.auth-submit {
    height: 48px;
    border-radius: 11px;
    font-weight: 500;
    margin-top: .4rem;
    background: var(--app-brand);
    border-color: var(--app-brand);
}
.auth-submit:hover, .auth-submit:focus { background: var(--app-brand-strong); border-color: var(--app-brand-strong); }

.auth-options { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: .1rem 0 1.1rem; }
.auth-check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--app-text-muted); cursor: pointer; margin: 0; }
.auth-check input { width: 16px; height: 16px; accent-color: var(--app-brand); }
.auth-link { font-size: .9rem; color: var(--app-brand); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

.auth-card--single { grid-template-columns: 1fr; width: min(100%, 460px); }
.auth-card--single .auth-form { text-align: center; padding: 3rem 2.5rem; }
.auth-recover-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--app-surface-brand);
    color: var(--app-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin: 0 auto 1.1rem;
}
.auth-recover-text { color: var(--app-text-soft); font-size: .92rem; line-height: 1.6; margin: 0 0 1.6rem; }

/* ==== App shell (sidebar) ==== */
.app-shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; background: var(--app-bg-muted); position: relative; }
/* Faixa de acento contínua no topo (atravessa a logo e o cabeçalho) */
.app-shell::before {
    content: "";
    position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 30;
    background: linear-gradient(90deg, var(--app-brand) 0%, var(--app-brand) 60%, var(--app-accent) 100%);
}
.app-side { background: var(--app-surface); border-right: 1px solid var(--app-border-soft); display: flex; flex-direction: column; }
.app-side-brand { height: 60px; display: flex; align-items: center; padding: 0 1.1rem; border-bottom: 1px solid var(--app-border-soft); }
.app-side-brand a { display: inline-flex; align-items: center; }
.app-side-brand img { max-width: 190px; max-height: 40px; width: auto; height: auto; display: block; }
.app-nav { padding: .75rem .6rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.app-nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 9px; color: var(--app-text-muted); text-decoration: none; font-size: .94rem; position: relative; }
.app-nav a i { font-size: 1.1rem; width: 1.3rem; text-align: center; color: var(--app-text-faint); }
.app-nav a:hover { background: var(--app-surface-hover); color: var(--app-text-strong); }
.app-nav a.active { background: var(--app-surface-brand); color: var(--app-brand-text); font-weight: 500; }
.app-nav a.active i { color: var(--app-brand); }
.app-nav a.active::before { content: ""; position: absolute; left: 0; top: .4rem; bottom: .4rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--app-brand); }
.app-nav a.is-disabled { color: var(--app-text-disabled); pointer-events: none; }
.app-nav-badge { margin-left: auto; font-size: .66rem; background: var(--app-surface-hover); color: var(--app-text-faint); padding: .1rem .45rem; border-radius: 20px; }
.app-side-foot { border-top: 1px solid var(--app-border-soft); padding: .85rem 1rem; }
.app-user { display: flex; align-items: center; gap: .6rem; width: 100%; text-align: left; background: none; border: 0; padding: .45rem .5rem; border-radius: 10px; cursor: pointer; }
.app-user:hover { background: var(--app-surface-hover); }
.app-user-info { min-width: 0; flex: 1; }
.app-user-caret { color: var(--app-text-disabled); font-size: .95rem; }
.app-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--app-brand); color: var(--app-on-brand); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .82rem; flex: 0 0 38px; }
.app-user-name { font-size: .88rem; font-weight: 500; color: var(--app-text-strong); line-height: 1.15; }
.app-user-role { font-size: .75rem; color: var(--app-text-faint); }
.app-credit { display: flex; align-items: center; justify-content: center; gap: .35rem; margin-top: .85rem; color: var(--app-text-faint); font-size: .7rem; }
.app-credit img { height: 16px; opacity: .85; }
.app-main { display: flex; flex-direction: column; min-width: 0; }
/* Acento agora é a faixa contínua em .app-shell::before */
.app-accent { display: none; }
.app-content { padding: 1.5rem; }
.app-top { height: 60px; background: var(--app-surface); border-bottom: 1px solid var(--app-border-soft); display: flex; align-items: center; gap: 1rem; padding: 0 1rem; }
.app-toggle { background: none; border: 0; color: var(--app-text-muted); font-size: 1.3rem; line-height: 1; padding: .3rem .5rem; border-radius: 8px; cursor: pointer; }
.app-toggle:hover { background: var(--app-surface-hover); color: var(--app-text-strong); }
.app-shell.is-collapsed { grid-template-columns: 1fr; }
.app-shell.is-collapsed .app-side { display: none; }

/* Botão primário padronizado (azul Voxel Dasti) */
.btn-primary {
    --bs-btn-bg: var(--app-brand);
    --bs-btn-border-color: var(--app-brand);
    --bs-btn-hover-bg: var(--app-brand-strong);
    --bs-btn-hover-border-color: var(--app-brand-strong);
    --bs-btn-active-bg: var(--app-brand-active);
    --bs-btn-active-border-color: var(--app-brand-active);
    --bs-btn-disabled-bg: var(--app-brand);
    --bs-btn-disabled-border-color: var(--app-brand);
}

/* KPIs e painéis */
.kpi { background: var(--app-surface); border: 1px solid var(--app-border-soft); border-radius: 12px; padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; height: 100%; }
.kpi-icon { width: 46px; height: 46px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex: 0 0 46px; }
.kpi-blue { background: var(--app-surface-brand); color: var(--app-brand); }
.kpi-orange { background: var(--app-accent-bg); color: var(--app-accent); }
.kpi-green { background: var(--app-success-bg); color: var(--app-success-text); }
.kpi-label { font-size: .85rem; color: var(--app-text-soft); }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: var(--app-text-strong); }
.panel { background: var(--app-surface); border: 1px solid var(--app-border-soft); border-radius: 12px; padding: 1.2rem 1.3rem; height: 100%; }
.panel h3 { font-size: 1rem; font-weight: 600; margin: 0 0 1rem; }
.panel-empty { color: var(--app-text-faint); font-size: .9rem; text-align: center; padding: 1.5rem 0; }

/* Tags (badges) e avatar de listas */
.tag { display: inline-block; font-size: .75rem; font-weight: 500; padding: .2rem .6rem; border-radius: 20px; line-height: 1.5; }
.tag-blue { background: var(--app-surface-brand); color: var(--app-brand-text); }
.tag-green { background: var(--app-success-bg); color: var(--app-success-text); }
.tag-amber { background: var(--app-warning-bg); color: var(--app-warning-text); }
.tag-gray { background: var(--app-surface-hover); color: var(--app-text-soft); }
.tag-red { background: var(--app-danger-bg); color: var(--app-danger-text); }
.list-name-cell { display: flex; align-items: center; gap: .6rem; }
.list-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--app-surface-brand); color: var(--app-brand-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .78rem; flex: 0 0 34px; }
.row-inactive td { color: var(--app-text-faint); }
.row-inactive .list-avatar { background: var(--app-surface-hover); color: var(--app-text-faint); }

/* Paginação */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.pager-info { color: var(--app-text-soft); font-size: .88rem; }
.pagination .page-link { color: var(--app-brand-text); }
.pagination .page-item.active .page-link { background: var(--app-brand); border-color: var(--app-brand); color: var(--app-on-brand); }
.pagination .page-item.disabled .page-link { color: var(--app-text-disabled); }

/* Painel de dados (tabela padrão dos módulos) */
.data-panel { background: var(--app-surface); border: 1px solid var(--app-border-soft); border-radius: 14px; overflow: hidden; box-shadow: 0 1px 2px rgb(15 23 42 / 4%); }
.data-panel__head { padding: 1rem 1.15rem; border-bottom: 1px solid var(--app-border-soft); }
.data-panel__foot { padding: .65rem 1.15rem; border-top: 1px solid var(--app-border-soft); background: var(--app-surface-subtle); }
.data-panel__foot .pager { margin-top: 0; }
.data-panel .table-responsive { margin: 0; }
.data-panel .table { margin: 0; border: 0; background: transparent; }
.data-panel .table thead th {
    background: var(--app-bg);
    color: var(--app-text-soft);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--app-border-soft);
    padding: .7rem 1.15rem;
    white-space: nowrap;
}
.data-panel .table tbody td { padding: .8rem 1.15rem; border-color: var(--app-border-faint); vertical-align: middle; }
.data-panel .table tbody tr:last-child td { border-bottom: 0; }
.data-panel .table.table-hover tbody tr:hover { background: var(--app-surface-hover-brand); }

/* Cabeçalho ordenável */
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.th-sort:hover { color: var(--app-brand); }
.th-sort .sort-caret { font-size: .75rem; opacity: .35; }
.th-sort.is-active { color: var(--app-brand); }
.th-sort.is-active .sort-caret { opacity: 1; }

/* Destaque de termo buscado */
mark.hl { background: var(--app-highlight-bg); color: inherit; padding: 0 .12em; border-radius: 3px; }

@media (max-width: 991.98px) {
    .app-shell { grid-template-columns: 1fr; min-height: 0; }
    .app-side { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--app-border-soft); }
    .app-side-brand { border-bottom: 0; flex: 0 0 auto; }
    .app-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
    .app-nav a.active::before { display: none; }
    .app-side-foot { border-top: 0; display: flex; align-items: center; gap: 1rem; }
    .app-side-foot .app-credit { margin-top: 0; }
    .app-side-foot form { margin-top: 0 !important; }
}

.auth-foot { display: flex; align-items: center; justify-content: center; gap: .5rem; color: var(--app-text-faint); font-size: .82rem; margin: 1.7rem 0 0; }
.auth-foot img { height: 22px; width: auto; }

@media (max-width: 767.98px) {
    .auth-card { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}

/* ===== Padrão de modais do sistema ===== */
.modal-content {
    border: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgb(15 23 42 / 22%);
}
.modal-accent { height: 4px; background: linear-gradient(90deg, var(--app-brand) 0%, var(--app-brand) 58%, var(--app-accent) 100%); }
.modal-header { padding: 1.15rem 1.35rem .5rem; border-bottom: 0; align-items: flex-start; }
.modal-head { display: flex; align-items: center; gap: .8rem; }
.modal-icon {
    width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
    display: flex; align-items: center; justify-content: center;
    background: var(--app-surface-brand); color: var(--app-brand); font-size: 1.25rem;
}
.modal-icon--danger { background: var(--app-danger-bg); color: var(--app-danger-strong); }
.modal-title { font-size: 1.15rem; font-weight: 600; }
.modal-sub { font-size: .82rem; color: var(--text-muted); font-weight: 400; }
.modal-body { padding: .75rem 1.35rem 1.1rem; }
.modal-footer { padding: .35rem 1.35rem 1.2rem; border-top: 0; gap: .35rem; }
.modal-footer > * { margin: 0; }
.modal-footer .btn { border-radius: 9px; font-weight: 600; }

/* ===== Modal de pré-cadastro (específicos) ===== */
.precad-search { background: var(--app-surface-subtle); border: 1px solid var(--app-border-soft); border-radius: 12px; padding: 1rem 1rem .85rem; }
.precad-search .form-label { font-size: .78rem; font-weight: 600; color: var(--app-text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .3rem; }
.precad-search .form-control { border-radius: 9px; }
.precad-search .form-control:focus { border-color: var(--app-brand); box-shadow: 0 0 0 .2rem rgb(46 123 196 / 15%); }
.precad-date { text-align: center; letter-spacing: .08em; }
.precad-search .btn-primary { border-radius: 9px; font-weight: 600; }
.precad-hint { display: flex; align-items: center; gap: .4rem; margin-top: .7rem; font-size: .8rem; color: var(--app-text-soft); }
.precad-hint i { color: var(--app-brand); }

.precad-result { margin-top: 1rem; }
.precad-result:empty { margin-top: 0; }
.precad-result .alert { border: 0; border-radius: 11px; display: flex; align-items: center; gap: .55rem; font-size: .9rem; }
.precad-result .alert-success { background: var(--app-success-bg); color: var(--app-success-text); }
.precad-result .alert-warning { background: var(--app-warning-bg); color: var(--app-warning-text); }
.precad-result .alert i { font-size: 1.05rem; }
.precad-status { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-muted); padding: .3rem .1rem; }
.precad-status--error { color: var(--app-danger-text); }

.precad-list { border: 1px solid var(--app-border-soft); border-radius: 11px; overflow: hidden; max-height: 264px; overflow-y: auto; }
.precad-list .precad-item {
    display: block; padding: .7rem .9rem; border: 0; border-top: 1px solid var(--app-border-faint);
    text-decoration: none; color: inherit; transition: background .12s ease;
}
.precad-list .precad-item:first-child { border-top: 0; }
.precad-list .precad-item:hover { background: var(--app-surface-hover-brand); }
.precad-item__name { font-weight: 600; color: var(--app-text); display: flex; align-items: center; gap: .4rem; }
.precad-item__name .bi { color: var(--app-text-disabled); font-size: .85rem; margin-left: auto; }
.precad-item:hover .precad-item__name .bi { color: var(--app-brand); }
.precad-item__meta { font-size: .8rem; color: var(--text-muted); margin-top: .12rem; }

/* ===== Etiquetas ===== */
.etq-card { background: var(--app-surface); border: 1px solid var(--surface-border); border-radius: 14px; padding: 1.2rem 1.35rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgb(15 23 42 / 4%); }
.etq-card__head { display: flex; align-items: flex-start; gap: .8rem; margin-bottom: 1.1rem; }
.etq-step { flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; background: var(--app-surface-brand); color: var(--app-brand); font-weight: 700; font-size: .9rem; display: flex; align-items: center; justify-content: center; }
.etq-card__title { font-size: 1.02rem; font-weight: 600; margin: 0; }
.etq-card__sub { font-size: .82rem; color: var(--text-muted); margin: .12rem 0 0; }

.etq-switch { padding-left: 2.6em; }
.etq-switch .form-check-input { width: 2em; height: 1em; cursor: pointer; margin-left: -2.6em; }
.etq-switch .form-check-input:checked { background-color: var(--app-brand); border-color: var(--app-brand); }
.etq-switch .form-check-label { cursor: pointer; }

.etq-birthday { background: var(--app-surface-subtle); border: 1px solid var(--app-border-soft); border-radius: 11px; padding: .95rem 1rem; }

.etq-group { border: 1px solid var(--surface-border); border-radius: 12px; padding: 1rem; height: 100%; display: flex; flex-direction: column; }
.etq-group__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.etq-group__title { font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--app-text-muted); margin: 0; display: flex; align-items: center; gap: .4rem; }
.etq-group__title i { color: var(--app-brand); }
.etq-count { font-size: .7rem; font-weight: 700; color: var(--app-brand); background: var(--app-surface-brand); border-radius: 999px; padding: .08rem .5rem; }
.etq-count:empty { display: none; }

.etq-search { position: relative; margin-bottom: .55rem; }
.etq-search i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--app-text-faint); font-size: .9rem; }
.etq-search .form-control { padding-left: 2rem; border-radius: 9px; }
.etq-search .form-control:focus { border-color: var(--app-brand); box-shadow: 0 0 0 .18rem rgb(46 123 196 / 15%); }

.etq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .1rem .9rem; max-height: 288px; overflow-y: auto; overflow-x: hidden; padding: .1rem .35rem .1rem 0; flex: 1; }
.etq-grid--single { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.etq-grid .form-check { margin: 0; min-height: auto; padding: .2rem 0 .2rem 1.7rem; }
.etq-grid .form-check-input { cursor: pointer; }
.etq-grid .form-check-label { font-size: .8rem; font-weight: 600; cursor: pointer; }
.etq-grid .form-check-label .text-secondary { font-size: .72rem; font-weight: 500; }
.etq-grid .form-check.is-hidden { display: none; }

.etq-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--app-text-faint); padding: 1.8rem 1rem; font-size: .88rem; }
.etq-empty i { font-size: 1.7rem; margin-bottom: .45rem; color: var(--app-text-disabled); }

.etq-actionbar { position: sticky; bottom: 0; z-index: 5; background: rgb(255 255 255 / 92%); backdrop-filter: blur(4px); border: 1px solid var(--surface-border); border-radius: 12px; padding: .7rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; box-shadow: 0 -2px 14px rgb(15 23 42 / 5%); }

/* ===== Agenda de compromissos ===== */
.agenda-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 1rem; font-size: .85rem; border-bottom: 1px solid var(--surface-border); }
.agenda-info i { color: var(--app-brand); }

.agenda-list { padding: .25rem 0; }
.agenda-day { display: grid; grid-template-columns: 150px 1fr; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--app-bg-alt); }
.agenda-day.is-empty { padding-top: .45rem; padding-bottom: .45rem; }
.agenda-day__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .4rem; }
.agenda-day__date { display: block; font-weight: 700; color: var(--app-text-strong); }
.agenda-day__dow { display: block; font-size: .8rem; color: var(--app-text-faint); text-transform: capitalize; }
.list-add { flex: none; width: 36px; height: 36px; border: 1.5px dashed var(--app-border-brand); background: var(--app-surface-brand); border-radius: 8px; color: var(--app-brand); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1.1rem; line-height: 1; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s; }
.list-add:hover, .list-add:focus-visible { background: var(--app-brand); border-style: solid; border-color: var(--app-brand); color: var(--app-on-brand); box-shadow: 0 2px 8px rgba(46, 123, 196, .3); }
.list-add:active { transform: translateY(1px); }
.agenda-day__events { display: flex; flex-direction: column; gap: .55rem; }
.agenda-day__empty { color: var(--app-text-disabled); font-size: .82rem; font-style: italic; align-self: center; }

.agenda-evt { display: grid; grid-template-columns: 120px 1fr auto; gap: .8rem; background: var(--app-bg); border: 1px solid var(--surface-border); border-radius: 10px; padding: .6rem .8rem; }
.agenda-evt.is-done { opacity: .65; }
.agenda-evt__time { font-size: .82rem; color: var(--app-text-muted); font-weight: 600; display: flex; flex-direction: column; gap: .1rem; align-items: flex-start; }
.agenda-evt__time i { color: var(--app-brand); }
.agenda-evt__top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .2rem; }
.agenda-evt__desc { font-size: .9rem; color: var(--app-text-strong); }
.agenda-evt__conc { font-size: .85rem; color: var(--app-text-muted); margin-top: .25rem; }
.agenda-evt__meta { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .3rem; font-size: .8rem; color: var(--app-text-soft); }
.agenda-evt__meta i { color: var(--app-text-faint); }
.agenda-evt__foot { margin-top: .35rem; font-size: .74rem; color: var(--app-text-faint); }
.agenda-evt__actions { display: flex; flex-wrap: wrap; gap: .35rem; align-content: flex-start; }
.list-act { width: 34px; height: 34px; flex: none; border: 1px solid var(--app-border); background: var(--app-surface); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--app-text-body); font-size: 1rem; transition: background .15s, border-color .15s, color .15s, transform .05s; }
.list-act:hover { background: var(--app-surface-hover); border-color: var(--app-text-faint); color: var(--app-text-strong); }
.list-act:active { transform: translateY(1px); }

/* Cor semântica por função (estado normal, mais legível que o cinza anterior) */
.list-act--view,
.list-act--edit    { color: var(--app-brand-text); }
.list-act--confirm { color: var(--app-warning-text); }
.list-act--finalize{ color: var(--app-success-text); }
.list-act--delete  { color: var(--app-danger-text); }

/* Hover/foco com tinta da própria função */
.list-act--view:hover, .list-act--edit:hover,
.list-act--view:focus-visible, .list-act--edit:focus-visible { background: var(--app-surface-brand); border-color: var(--app-border-brand); color: var(--app-brand-text); }
.list-act--confirm:hover, .list-act--confirm:focus-visible { background: var(--app-warning-bg); border-color: var(--app-warning-text); color: var(--app-warning-text); }
.list-act--finalize:hover, .list-act--finalize:focus-visible { background: var(--app-success-bg); border-color: var(--app-success-text); color: var(--app-success-text); }
.list-act--delete:hover, .list-act--delete:focus-visible { background: var(--app-danger-bg); border-color: var(--app-danger-text); color: var(--app-danger-text); }

/* ===== Modal de detalhes do compromisso ===== */
.det-badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.det-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem 1.4rem; margin: 0; }
.det-row { margin: 0; }
.det-row--full { grid-column: 1 / -1; }
.det-row[hidden] { display: none; }
.det-row dt { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--app-text-faint); margin-bottom: .15rem; }
.det-row dd { margin: 0; font-size: .92rem; color: var(--app-text-strong); white-space: pre-line; word-break: break-word; }
.det-footer { justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.det-actions { display: flex; flex-wrap: wrap; gap: .4rem; }

/* Criação rápida em select ("+"): input de descrição confortável; os botões
   quebram para a linha de baixo quando falta largura (colunas estreitas). */
.inline-create { display: flex; flex-direction: column; gap: .45rem; }
.inline-create__row { display: flex; gap: .4rem; }
@media (max-width: 575.98px) {
    .det-grid { grid-template-columns: 1fr; }
    .det-footer, .det-actions { width: 100%; }
}

.agenda-nodate { padding: 1rem; border-top: 2px solid var(--surface-border); }
.agenda-nodate__title { font-size: .95rem; font-weight: 700; color: var(--app-text-muted); margin-bottom: .6rem; display: flex; align-items: center; gap: .4rem; }
.agenda-nodate__title i { color: var(--app-warning-text); }

@media (max-width: 640px) {
    .agenda-day { grid-template-columns: 1fr; gap: .4rem; }
    .agenda-evt { grid-template-columns: 1fr; gap: .35rem; }
}

/* ===== Tema escuro ===== */
[data-bs-theme="dark"] {
    color-scheme: dark;

    --app-bg: #0f172a;
    --app-bg-alt: #0b1220;
    --app-bg-muted: #131c2e;
    --app-surface: #1e293b;
    --app-surface-subtle: #172032;
    --app-surface-hover: #24314a;
    --app-surface-hover-brand: #1b2942;
    --app-surface-brand: #14304d;
    --app-surface-brand-2: #14304d;

    --app-border: #334155;
    --app-border-soft: #2b3a52;
    --app-border-faint: #263248;
    --app-border-brand: #2b4d70;

    --app-text: #e2e8f0;
    --app-text-strong: #f1f5f9;
    --app-text-body: #cbd5e1;
    --app-text-muted: #a3b0c2;
    --app-text-soft: #94a3b8;
    --app-text-faint: #7688a0;
    --app-text-disabled: #55647a;
    --app-on-brand: #ffffff;

    --app-brand: #4a95d6;
    --app-brand-strong: #3d84c4;
    --app-brand-active: #367ab6;
    --app-brand-text: #7bb4e3;
    --app-accent: #f2764a;

    --app-spinner-track: #334155;

    /* Status no escuro (fundos escurecidos, texto claro) */
    --app-success-bg: #14321f;
    --app-success-text: #5cc98a;
    --app-accent-bg: #3a2114;
    --app-warning-bg: #33270f;
    --app-warning-text: #e0b361;
    --app-danger-bg: #3a1c1c;
    --app-danger-text: #f08b84;
    --app-danger-strong: #f06a6a;
    --app-highlight-bg: #4d431a;
}

/* ===== Acessibilidade ===== */
/* Pular para o conteúdo (visível apenas ao receber foco via teclado) */
.skip-link {
    position: absolute;
    left: .75rem;
    top: -3rem;
    z-index: 1090;
    background: var(--app-brand);
    color: var(--app-on-brand);
    padding: .5rem .9rem;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    transition: top .15s ease;
}
.skip-link:focus { top: 0; }

/* Foco visível consistente em todos os elementos interativos */
:focus-visible {
    outline: 2px solid var(--app-brand);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Botão de alternância de tema (topo) */
.app-theme-toggle { margin-left: auto; }

/* Respeita a preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Mensagem de validação inserida via JS (fora do fluxo de irmãos do Bootstrap) */
.invalid-feedback[data-auto] { display: block; }
