/* ═══════════════════════════════════════════════════════
   TITAN CORE — Design System CSS
   The Analytical Atelier · v1.0
   ═══════════════════════════════════════════════════════ */

/* ── Google Fonts fallback (já carregado no header.php) ── */

/* ──────────────────────────────────────────────────────────
   1. DESIGN TOKENS — CSS Variables
   ────────────────────────────────────────────────────────── */
:root {
    /* Primárias */
    --tc-primary:       #000613;
    --tc-primary-c:     #001f3f;
    --tc-accent:        #4586e2;
    --tc-accent-dim:    #6f88ad;

    /* Superfícies */
    --tc-bg:            #f7f9fb;
    --tc-surface:       #ffffff;
    --tc-surface-low:   #f2f4f6;
    --tc-surface-c:     #eceef0;
    --tc-surface-high:  #e6e8ea;

    /* Texto */
    --tc-on-surface:    #191c1e;
    --tc-muted:         #74777f;
    --tc-on-accent:     #ffffff;

    /* Bordas */
    --tc-outline:       #dfe2e8;   /* hairline mais suave (era #c4c6cf) */

    /* Semânticas */
    --tc-success:       #10b981;
    --tc-warning:       #f59e0b;
    --tc-danger:        #ba1a1a;
    --tc-info:          #4586e2;

    /* Sidebar */
    --tc-sidebar-bg:    #ffffff;
    --tc-sidebar-text:  #191c1e;
    --tc-sidebar-muted: #74777f;
    --tc-sidebar-hover: #eceef0;
    --tc-sidebar-active:#f2f4f6;

    /* Header */
    --tc-topbar-bg:     rgba(255,255,255,0.88);

    /* Footer */
    --tc-footer-bg:     #f2f4f6;
    --tc-footer-text:   #74777f;

    /* Sombras */
    /* Sombras ambientes em camadas — mais difusas e suaves */
    --tc-shadow:        0 1px 2px rgba(16,24,40,0.04), 0 10px 28px rgba(16,24,40,0.07);
    --tc-shadow-sm:     0 1px 2px rgba(16,24,40,0.05), 0 1px 3px rgba(16,24,40,0.06);
    --tc-shadow-primary:0 8px 24px rgba(69,134,226,0.28);

    /* Dimensões */
    --tc-sidebar-w:     260px;
    --tc-sidebar-cw:    64px;
    --tc-header-h:      64px;
    --tc-footer-h:      52px;

    /* Forma */
    --tc-radius:        8px;    /* cantos um pouco mais suaves (era 6px) */
    --tc-radius-md:     12px;   /* (era 10px) */
    --tc-radius-lg:     16px;   /* (era 14px) */
    --tc-radius-xl:     20px;
    --tc-radius-full:   999px;

    /* Tipografia */
    --tc-font:          'DM Sans', system-ui, sans-serif;

    /* Transição */
    --tc-ease:          cubic-bezier(0.4, 0, 0.2, 1);
    --tc-transition:    all 0.28s var(--tc-ease);
}

/* Dark Mode */
html.dark {
    --tc-bg:            #0e1420;
    --tc-surface:       #131a28;
    --tc-surface-low:   #1a2333;
    --tc-surface-c:     #20293b;
    --tc-surface-high:  #283246;

    --tc-on-surface:    #eceef2;
    --tc-muted:         #8b95a8;
    --tc-outline:       #2f3648;

    --tc-sidebar-bg:    #0d121e;
    --tc-sidebar-text:  #eceef2;
    --tc-sidebar-muted: #8b95a8;
    --tc-sidebar-hover: rgba(255,255,255,0.05);
    --tc-sidebar-active:rgba(175,200,240,0.12);

    --tc-topbar-bg:     rgba(14,20,32,0.92);
    --tc-footer-bg:     #0d121e;
    --tc-footer-text:   #6b7488;
}

/* ──────────────────────────────────────────────────────────
   2. RESET & BASE
   ────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--tc-font);
    background: var(--tc-bg);
    color: var(--tc-on-surface);
    font-size: 14px;
    line-height: 1.5;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--tc-font); border: none; background: none; }
input, select, textarea { font-family: var(--tc-font); }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--tc-outline); border-radius: 99px; }

/* Material Symbols */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    flex-shrink: 0;
}
.tc-icon-filled {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Utilitários */
.tc-truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ──────────────────────────────────────────────────────────
   3. LAYOUT — App Shell
   ────────────────────────────────────────────────────────── */

/* Shell raiz */
.tc-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Wrapper sidebar + conteúdo */
.tc-main-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    margin-left: var(--tc-sidebar-w);
    transition: margin-left 0.28s var(--tc-ease);
    height: 100vh;
    overflow: hidden;
}

/* Quando sidebar está colapsada */
html.tc-sidebar-collapsed .tc-main-wrapper {
    margin-left: var(--tc-sidebar-cw);
}

/* Main content area */
.tc-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px;
    background: var(--tc-bg);
}

/* ──────────────────────────────────────────────────────────
   4. SIDEBAR
   ────────────────────────────────────────────────────────── */
.tc-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--tc-sidebar-w);
    background: var(--tc-sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--tc-transition);
    box-shadow: var(--tc-shadow);
    overflow: visible;
}

/* Estado colapsado */
html.tc-sidebar-collapsed .tc-sidebar {
    width: var(--tc-sidebar-cw);
}

/* Brand */
.tc-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    height: var(--tc-header-h);
    border-bottom: 1px solid var(--tc-outline);
    flex-shrink: 0;
    overflow: hidden;
}

.tc-sidebar__logo {
    width: 34px;
    height: 34px;
    border-radius: var(--tc-radius-md);
    background: linear-gradient(135deg, var(--tc-primary-c) 0%, var(--tc-accent) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(69,134,226,0.35);
}

.tc-sidebar__brand-text {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.18s, width 0.28s var(--tc-ease);
}

.tc-sidebar__site-name {
    display: block;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--tc-sidebar-text);
    line-height: 1.1;
    text-transform: uppercase;
}

.tc-sidebar__site-slogan {
    display: block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--tc-sidebar-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

html.tc-sidebar-collapsed .tc-sidebar__brand-text {
    opacity: 0;
    width: 0;
}

/* Botão toggle desktop */
.tc-sidebar__toggle-btn {
    position: absolute;
    top: 70px;
    right: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--tc-surface);
    border: 1.5px solid var(--tc-outline);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tc-muted);
    box-shadow: var(--tc-shadow-sm);
    z-index: 101;
    transition: var(--tc-transition);
}
.tc-sidebar__toggle-btn:hover {
    background: var(--tc-surface-c);
    color: var(--tc-on-surface);
}
.tc-sidebar__toggle-btn .material-symbols-outlined { font-size: 14px; }

/* Rótulo de seção */
.tc-sidebar__section-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--tc-sidebar-muted);
    padding: 12px 18px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.18s;
}
html.tc-sidebar-collapsed .tc-sidebar__section-label { opacity: 0; }

/* Nav */
.tc-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 10px;
}

/* Item de nav */
.tc-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--tc-radius-md);
    color: var(--tc-sidebar-muted);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: -0.01em;
    transition: var(--tc-transition);
    position: relative;
    white-space: nowrap;
    margin-bottom: 2px;
    cursor: pointer;
}
.tc-nav-item:hover {
    background: var(--tc-sidebar-hover);
    color: var(--tc-sidebar-text);
}
.tc-nav-item--active {
    background: var(--tc-sidebar-active);
    color: var(--tc-sidebar-text);
    font-weight: 600;
}
.tc-nav-item--active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--tc-accent), var(--tc-primary-c));
}
.tc-nav-item--active .material-symbols-outlined { color: var(--tc-accent); }

.tc-nav-item__label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.18s, width 0.28s var(--tc-ease);
}
html.tc-sidebar-collapsed .tc-nav-item__label { opacity: 0; width: 0; }
html.tc-sidebar-collapsed .tc-nav-item { justify-content: center; padding: 10px 0; }

.tc-nav-item__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tc-accent);
    flex-shrink: 0;
    margin-left: auto;
}
html.tc-sidebar-collapsed .tc-nav-item__dot { display: none; }

/* Bottom nav */
.tc-sidebar__bottom {
    padding: 10px 10px;
    border-top: 1px solid var(--tc-outline);
    flex-shrink: 0;
}
.tc-nav-item--bottom { margin-bottom: 2px; }

/* Overlay mobile */
.tc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.28s var(--tc-ease);
}

/* Tooltip */
.tc-tooltip {
    position: fixed;
    padding: 5px 10px;
    background: var(--tc-on-surface);
    color: var(--tc-bg);
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--tc-radius);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 200;
    transition: opacity 0.15s;
    box-shadow: var(--tc-shadow);
}
.tc-tooltip.tc-tooltip--visible { opacity: 1; }

/* ──────────────────────────────────────────────────────────
   5. TOPBAR
   ────────────────────────────────────────────────────────── */
.tc-topbar {
    height: var(--tc-header-h);
    background: var(--tc-topbar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--tc-outline);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
}

.tc-topbar__hamburger {
    width: 36px;
    height: 36px;
    border-radius: var(--tc-radius-md);
    background: var(--tc-surface-low);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tc-muted);
    flex-shrink: 0;
    transition: background 0.15s;
}
.tc-topbar__hamburger:hover { background: var(--tc-surface-c); color: var(--tc-on-surface); }

.tc-topbar__search {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 180px;     /* nao deixa a busca encolher demais quando filial cresce */
}
.tc-topbar__search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--tc-muted);
    pointer-events: none;
}
.tc-topbar__search-input {
    width: 100%;
    height: 36px;
    background: var(--tc-surface-low);
    border: 1.5px solid transparent;
    border-radius: var(--tc-radius-full);
    padding: 0 14px 0 38px;
    font-size: 13px;
    color: var(--tc-on-surface);
    outline: none;
    transition: border-color 0.2s;
}
.tc-topbar__search-input::placeholder { color: var(--tc-muted); }
.tc-topbar__search-input:focus { border-color: var(--tc-accent); }

.tc-topbar__spacer { flex: 1; }

.tc-topbar__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tc-topbar__divider {
    width: 1px;
    height: 24px;
    background: var(--tc-outline);
    margin: 0 4px;
}

/* Icon button */
.tc-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--tc-radius-md);
    background: var(--tc-surface-low);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tc-muted);
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.tc-icon-btn:hover { background: var(--tc-surface-c); color: var(--tc-on-surface); }
.tc-icon-btn--relative { position: relative; }

/* Badge de notificação */
.tc-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tc-danger);
    border: 1.5px solid var(--tc-topbar-bg);
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.tc-badge--pulse {
    animation: tc-pulse 2s ease infinite;
}
@keyframes tc-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: 0.75; }
}

/* User button */
.tc-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--tc-radius-full);
    background: var(--tc-surface-low);
    transition: background 0.15s;
}
.tc-user-btn:hover { background: var(--tc-surface-c); }

.tc-user-btn__info {
    display: none;
    flex-direction: column;
    text-align: left;
}
@media (min-width: 1280px) {
    .tc-user-btn__info { display: flex; }
}

/* ─── Desktop: nome da filial maior para caber completo ────
   A busca tem min-width: 180px e o spacer (flex:1) absorve o resto.
   Se a janela apertar, o truncate continua respeitando o max-width. */
@media (min-width: 1280px) {
    #tc-filial-btn .tc-truncate { max-width: 320px !important; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
    #tc-filial-btn .tc-truncate { max-width: 220px !important; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    #tc-filial-btn .tc-truncate { max-width: 160px !important; }
}
.tc-user-btn__name { font-size: 12px; font-weight: 700; color: var(--tc-on-surface); line-height: 1.2; }
.tc-user-btn__role { font-size: 10px; color: var(--tc-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.tc-user-btn__chevron { font-size: 14px !important; color: var(--tc-muted); }

/* Avatar */
.tc-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tc-primary-c), var(--tc-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}
.tc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tc-avatar--lg { width: 44px; height: 44px; font-size: 16px; }

/* ──────────────────────────────────────────────────────────
   6. DROPDOWNS
   ────────────────────────────────────────────────────────── */
.tc-dropdown-wrap { position: relative; }

.tc-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 340px;
    background: var(--tc-surface);
    border: 1px solid var(--tc-outline);
    border-radius: var(--tc-radius-lg);
    box-shadow: var(--tc-shadow);
    z-index: 200;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s, transform 0.2s var(--tc-ease);
}
.tc-dropdown--right { width: 220px; }
.tc-dropdown.tc-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.tc-dropdown__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--tc-outline);
}
.tc-dropdown__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--tc-on-surface);
}
.tc-dropdown__link {
    font-size: 11px;
    font-weight: 600;
    color: var(--tc-accent);
    background: none;
    border: none;
    cursor: pointer;
}
.tc-dropdown__list { max-height: 300px; overflow-y: auto; }
.tc-dropdown__footer {
    padding: 10px 16px;
    border-top: 1px solid var(--tc-outline);
    text-align: center;
}

/* Item de dropdown */
.tc-dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13px;
    color: var(--tc-muted);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.tc-dropdown__item:hover { background: var(--tc-surface-low); color: var(--tc-on-surface); }
.tc-dropdown__item--danger { color: var(--tc-danger); }
.tc-dropdown__item--danger:hover { background: rgba(186,26,26,0.06); }
.tc-dropdown__item .material-symbols-outlined { font-size: 16px !important; color: var(--tc-outline); }
.tc-dropdown__item--danger .material-symbols-outlined { color: var(--tc-danger); }

/* Perfil no dropdown */
.tc-dropdown__profile {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 16px;
    border-bottom: 1px solid var(--tc-outline);
}
.tc-dropdown__profile-name { font-size: 13px; font-weight: 700; color: var(--tc-on-surface); }
.tc-dropdown__profile-email { font-size: 11px; color: var(--tc-muted); margin-top: 2px; }

/* Item de notificação */
.tc-notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--tc-outline);
    cursor: pointer;
    transition: background 0.15s;
}
.tc-notif-item:hover { background: var(--tc-surface-low); }
.tc-notif-item--unread { background: rgba(69,134,226,0.04); }

.tc-notif-item__icon {
    width: 34px;
    height: 34px;
    border-radius: var(--tc-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tc-notif-item__body { flex: 1; min-width: 0; }
.tc-notif-item__title { font-size: 12px; font-weight: 500; color: var(--tc-on-surface); line-height: 1.4; }
.tc-notif-item--unread .tc-notif-item__title { font-weight: 600; }
.tc-notif-item__time { font-size: 11px; color: var(--tc-muted); margin-top: 2px; }
.tc-notif-item__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tc-accent);
    flex-shrink: 0;
    margin-top: 4px;
    animation: tc-pulse 2s ease infinite;
}

/* ──────────────────────────────────────────────────────────
   7. FOOTER
   ────────────────────────────────────────────────────────── */
.tc-footer {
    height: var(--tc-footer-h);
    background: var(--tc-footer-bg);
    border-top: 1px solid var(--tc-outline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    gap: 16px;
}

.tc-footer__brand {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tc-footer__logo {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--tc-primary-c), var(--tc-accent));
    display: flex;
    align-items: center;
    justify-content: center;
}
.tc-footer__name { font-size: 11px; font-weight: 700; color: var(--tc-footer-text); }
.tc-footer__sep  { font-size: 11px; color: var(--tc-outline); }
.tc-footer__version { font-size: 11px; color: var(--tc-footer-text); }

.tc-footer__links {
    display: flex;
    gap: 20px;
}
.tc-footer__link {
    font-size: 11px;
    color: var(--tc-footer-text);
    transition: color 0.15s;
}
.tc-footer__link:hover { color: var(--tc-on-surface); }

.tc-footer__copy {
    font-size: 11px;
    color: var(--tc-footer-text);
    white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────
   8. COMPONENTES DE CONTEÚDO
   ────────────────────────────────────────────────────────── */

/* Page Header */
.tc-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}
.tc-page-title {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--tc-on-surface);
    line-height: 1.1;
}
.tc-page-subtitle {
    font-size: 13px;
    color: var(--tc-muted);
    margin-top: 6px;
    font-weight: 400;
}
.tc-page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons */
.tc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--tc-radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tc-transition);
    border: none;
    white-space: nowrap;
    text-decoration: none;
    font-family: var(--tc-font);
}
.tc-btn:active { transform: scale(0.98); }
.tc-btn--primary {
    background: linear-gradient(135deg, var(--tc-primary-c), var(--tc-accent));
    color: #fff;
    box-shadow: var(--tc-shadow-primary);
}
.tc-btn--primary:hover { filter: brightness(1.1); }
.tc-btn--secondary {
    background: var(--tc-surface-c);
    color: var(--tc-on-surface);
    border: 1px solid var(--tc-outline);
}
.tc-btn--secondary:hover { background: var(--tc-surface-high); }
.tc-btn--danger {
    background: rgba(186,26,26,0.1);
    color: var(--tc-danger);
}
.tc-btn--danger:hover { background: rgba(186,26,26,0.18); }
.tc-btn .material-symbols-outlined { font-size: 16px !important; }

/* Grid padrão */
.tc-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.tc-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tc-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 1024px) {
    .tc-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .tc-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .tc-grid-4, .tc-grid-3, .tc-grid-2 { grid-template-columns: 1fr; }
}

/* KPI Card */
.tc-kpi-card {
    background: var(--tc-surface);
    border: 1px solid rgba(69,134,226,0.1);
    border-radius: var(--tc-radius-lg);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
}
.tc-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--tc-shadow);
}
.tc-kpi-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 14px;
}
.tc-kpi-card__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--tc-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tc-kpi-card__icon .material-symbols-outlined { font-size: 17px !important; }
.tc-kpi-card__label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tc-muted);
}
.tc-kpi-card__value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--tc-on-surface);
    line-height: 1;
}
.tc-kpi-card__glow {
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    opacity: 0.12;
    filter: blur(20px);
    pointer-events: none;
}

/* Delta (variação) */
.tc-delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
}
.tc-delta .material-symbols-outlined { font-size: 12px !important; }
.tc-delta--up   { background: rgba(16,185,129,0.1);  color: var(--tc-success); }
.tc-delta--down { background: rgba(186,26,26,0.1);   color: var(--tc-danger); }

/* Card genérico */
.tc-card {
    background: var(--tc-surface);
    border: 1px solid rgba(69,134,226,0.1);
    border-radius: var(--tc-radius-lg);
    overflow: hidden;
}
.tc-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--tc-outline);
}
.tc-card__title { font-size: 14px; font-weight: 700; color: var(--tc-on-surface); letter-spacing: -0.02em; }
.tc-card__subtitle { font-size: 11px; color: var(--tc-muted); margin-top: 2px; }
.tc-card__body { padding: 20px 22px; }

/* Status Chips */
.tc-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}
.tc-chip--success { background: rgba(16,185,129,0.1);  color: var(--tc-success); }
.tc-chip--warning { background: rgba(245,158,11,0.1);  color: var(--tc-warning); }
.tc-chip--danger  { background: rgba(186,26,26,0.1);   color: var(--tc-danger);  }
.tc-chip--neutral { background: var(--tc-surface-c);   color: var(--tc-muted);   }
.tc-chip--accent  { background: rgba(69,134,226,0.12); color: var(--tc-accent);  }

/* Tabela */
.tc-table-wrap { overflow-x: auto; }
.tc-table {
    width: 100%;
    border-collapse: collapse;
}
.tc-table thead tr {
    background: var(--tc-surface-low);
}
.tc-table th {
    padding: 10px 20px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--tc-muted);
    white-space: nowrap;
}
.tc-table td {
    padding: 13px 20px;
    font-size: 13px;
    color: var(--tc-on-surface);
    vertical-align: middle;
}
.tc-table tbody tr:nth-child(even) { background: var(--tc-surface-low); }
.tc-table tbody tr { transition: background 0.15s; cursor: pointer; }
.tc-table tbody tr:hover { background: var(--tc-surface-c); }

/* Ação rápida na tabela */
.tc-table-actions { display: flex; gap: 4px; justify-content: flex-end; }
.tc-table-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--tc-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tc-surface-low);
    color: var(--tc-muted);
    transition: background 0.15s, color 0.15s;
    border: none;
    cursor: pointer;
}
.tc-table-btn:hover { background: var(--tc-surface-c); color: var(--tc-on-surface); }
.tc-table-btn--danger:hover { background: rgba(186,26,26,0.1); color: var(--tc-danger); }
.tc-table-btn .material-symbols-outlined { font-size: 16px !important; }

/* Paginação */
.tc-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 16px 20px;
    border-top: 1px solid var(--tc-outline);
}
.tc-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--tc-radius);
    border: 1px solid var(--tc-outline);
    background: var(--tc-surface);
    color: var(--tc-on-surface);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.tc-page-btn:hover { background: var(--tc-surface-low); }
.tc-page-btn--active {
    background: var(--tc-accent);
    border-color: var(--tc-accent);
    color: #fff;
}
.tc-page-btn--active:hover { filter: brightness(1.1); }
.tc-page-btn .material-symbols-outlined { font-size: 16px !important; }

/* Formulários */
.tc-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .tc-form-grid { grid-template-columns: 1fr; } }
.tc-form-grid--full { grid-column: 1 / -1; }

.tc-field { display: flex; flex-direction: column; gap: 4px; }
.tc-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tc-muted);
}
.tc-input,
.tc-select,
.tc-textarea {
    width: 100%;
    background: var(--tc-surface-low);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--tc-radius) var(--tc-radius) 0 0;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--tc-on-surface);
    font-family: var(--tc-font);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}
.tc-input:focus,
.tc-select:focus,
.tc-textarea:focus {
    border-bottom-color: var(--tc-accent);
    background: var(--tc-surface-c);
}
.tc-input.tc-input--error { border-bottom-color: var(--tc-danger); }
.tc-textarea { resize: vertical; min-height: 100px; }
.tc-select { appearance: none; cursor: pointer; }

/* Breadcrumb */
.tc-breadcrumb { margin-bottom: 16px; }
.tc-breadcrumb ol {
    display: flex;
    align-items: center;
    list-style: none;
    flex-wrap: wrap;
    gap: 2px;
}
.tc-breadcrumb__item a, .tc-breadcrumb__item {
    font-size: 12px;
    color: var(--tc-muted);
    font-weight: 500;
    transition: color 0.15s;
}
.tc-breadcrumb__item a:hover { color: var(--tc-on-surface); }
.tc-breadcrumb__item--active { color: var(--tc-on-surface); font-weight: 600; }
.tc-breadcrumb__sep .material-symbols-outlined { font-size: 14px !important; color: var(--tc-outline); }

/* Filtros */
.tc-filters {
    background: var(--tc-surface);
    border: 1px solid rgba(69,134,226,0.1);
    border-radius: var(--tc-radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.tc-filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; flex: 1; }

/* Seção de detalhe */
.tc-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px 32px;
    padding: 20px;
}
@media (max-width: 768px) { .tc-detail-grid { grid-template-columns: repeat(2, 1fr); } }
.tc-detail-field__label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--tc-muted); margin-bottom: 4px; }
.tc-detail-field__value { font-size: 14px; color: var(--tc-on-surface); font-weight: 500; }

/* ──────────────────────────────────────────────────────────
   9. RESPONSIVIDADE — Mobile
   ────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    /* Sidebar como drawer */
    .tc-sidebar {
        transform: translateX(-100%);
        width: var(--tc-sidebar-w) !important; /* sempre largo no mobile */
        box-shadow: var(--tc-shadow);
    }
    html.tc-drawer-open .tc-sidebar {
        transform: translateX(0);
    }
    html.tc-drawer-open .tc-overlay {
        display: block;
        opacity: 1;
    }

    /* Main sem margem no mobile */
    .tc-main-wrapper { margin-left: 0 !important; }

    /* Ocultar toggle btn no mobile */
    .tc-sidebar__toggle-btn { display: none; }

    /* Main padding menor */
    .tc-main { padding: 16px; }

    /* Footer simplificado */
    .tc-footer__links, .tc-footer__copy { display: none; }

    /* Topbar search oculto no mobile (libera espaco para filial+acoes) */
    .tc-topbar__search { display: none; }

    /* Botao de filial mais compacto no mobile */
    #tc-filial-btn {
        padding: 0 6px !important;
        gap: 4px !important;
        font-size: 11px !important;
    }
    #tc-filial-btn .tc-truncate { max-width: 90px !important; }
    #tc-filial-btn .material-symbols-outlined { font-size: 14px !important; }

    /* Reduzir nome do usuario para caber */
    .tc-user-btn__info { display: none; }

    /* Dividers menos invasivos */
    .tc-topbar__divider { display: none; }

    /* Topbar gap menor entre acoes */
    .tc-topbar__actions { gap: 4px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    /* Tablet: sidebar inicia colapsada */
    .tc-sidebar { width: var(--tc-sidebar-cw); }
    html.tc-sidebar-collapsed .tc-sidebar { width: var(--tc-sidebar-cw); }
    .tc-main-wrapper { margin-left: var(--tc-sidebar-cw); }
}

/* ──────────────────────────────────────────────────────────
   10. ANIMAÇÕES
   ────────────────────────────────────────────────────────── */
@keyframes tc-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes tc-slide-in {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.tc-fade-in  { animation: tc-fade-in 0.22s var(--tc-ease) both; }
.tc-slide-in { animation: tc-slide-in 0.22s var(--tc-ease) both; }

/* ──────────────────────────────────────────────────────────
   11. PRE-LOADER (substitui style.css)
   ────────────────────────────────────────────────────────── */
#preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--tc-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
#preloader.tc-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.waviy {
    display: flex;
    gap: 2px;
}
.waviy span {
    font-size: 32px;
    font-weight: 800;
    color: var(--tc-accent);
    animation: waviy 1s infinite;
    animation-delay: calc(var(--i) * 0.1s);
}
@keyframes waviy {
    0%, 40%, 100% { transform: translateY(0); }
    20%           { transform: translateY(-18px); }
}

/* ──────────────────────────────────────────────────────────
   12. AJUSTES SHELL / INTEGRAÇÕES
   ────────────────────────────────────────────────────────── */

/* Override Bootstrap body background em dark mode */
html.dark body { background-color: var(--tc-bg); color: var(--tc-on-surface); }

/* Remove underline que Bootstrap adiciona em todos os links do shell */
.tc-shell a,
.tc-topbar a,
.tc-dropdown a,
.tc-sidebar a,
.tc-footer a { text-decoration: none !important; }

/* Ícones FontAwesome dentro de tc-nav-item */
.tc-nav-item i {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    color: inherit;
}
html.tc-sidebar-collapsed .tc-nav-item i { font-size: 16px; }

/* Sub-label de grupo de menu */
.tc-nav-group-label {
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--tc-sidebar-muted);
    padding: 8px 10px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.18s;
}
/* Collapsible sidebar groups */
.tc-nav-group { margin-bottom: 2px; }
.tc-nav-group-label.tc-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-radius: var(--tc-radius-md);
}
.tc-nav-group-label.tc-group-toggle:hover {
    background: var(--tc-sidebar-hover);
    color: var(--tc-sidebar-text);
}
/* Inner: icon + text side by side */
.tc-grp-label-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
.tc-grp-label-inner i,
.tc-grp-label-inner .material-symbols-outlined {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 14px;
    color: inherit;
}
.tc-grp-chevron {
    font-size: 14px !important;
    flex-shrink: 0;
    transition: transform 0.25s ease;
    color: var(--tc-sidebar-muted);
}
.tc-group-toggle[aria-expanded="true"] .tc-grp-chevron {
    transform: rotate(90deg);
}
.tc-grp-items:not(.show) { display: none; }

/* Indenta os itens filhos em relação ao label do grupo */
.tc-grp-items > .tc-nav-item {
    padding-left: 38px;
}

/* ── Sidebar colapsada: grupo vira ícone clicável, itens ficam ocultos ── */
html.tc-sidebar-collapsed .tc-nav-group-label {
    opacity: 1;
    justify-content: center;
    padding: 9px 0;
}
html.tc-sidebar-collapsed .tc-grp-label-text { display: none; }
html.tc-sidebar-collapsed .tc-grp-chevron    { display: none; }
html.tc-sidebar-collapsed .tc-grp-items      { display: none !important; }

/* ── Flyout panel (aparece ao hover do grupo colapsado) ── */
.tc-grp-flyout {
    display: none;
    position: fixed;
    min-width: 190px;
    background: var(--tc-surface);
    border: 1px solid var(--tc-outline);
    border-radius: var(--tc-radius-md);
    box-shadow: var(--tc-shadow);
    padding: 6px;
    z-index: 9999;
}
.tc-grp-flyout.tc-grp-flyout--visible { display: block; }
.tc-grp-flyout-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--tc-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 10px 6px;
    border-bottom: 1px solid var(--tc-outline);
    margin-bottom: 4px;
    white-space: nowrap;
}
.tc-grp-flyout-item {
    display: block;
    padding: 7px 10px;
    border-radius: var(--tc-radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--tc-sidebar-text);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s;
}
.tc-grp-flyout-item:hover {
    background: var(--tc-sidebar-hover);
    color: var(--tc-on-surface);
}
.tc-grp-flyout-item--active {
    color: var(--tc-accent);
    font-weight: 700;
}

/* Active dot para menu items com rota */
.tc-nav-item--active .tc-nav-item__dot { display: flex; }

/* ──────────────────────────────────────────────────────────
   13. DARK MODE — Bootstrap component overrides
   ────────────────────────────────────────────────────────── */

/* Cards */
html.dark .card {
    background-color: var(--tc-surface);
    border-color: var(--tc-outline);
    color: var(--tc-on-surface);
}
html.dark .card-header {
    background-color: var(--tc-surface-low);
    border-color: var(--tc-outline);
    color: var(--tc-on-surface);
}
html.dark .card-footer {
    background-color: var(--tc-surface-low);
    border-color: var(--tc-outline);
}

/* Tabelas — alinhamento vertical centralizado em todas as células */
.table tbody td,
.table tbody th,
.verticle-middle td,
.verticle-middle th { vertical-align: middle; }

/* Tabelas */
html.dark .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--tc-on-surface);
    --bs-table-striped-bg: rgba(255,255,255,0.04);
    --bs-table-striped-color: var(--tc-on-surface);
    --bs-table-hover-bg: rgba(255,255,255,0.06);
    --bs-table-hover-color: var(--tc-on-surface);
    --bs-table-active-color: var(--tc-on-surface);
    color: var(--tc-on-surface);
    border-color: var(--tc-outline);
}
html.dark .table > :not(caption) > * > * { border-color: var(--tc-outline); }
html.dark thead { color: var(--tc-muted); }
/* Garante cor de texto em todas as células, independente do Bootstrap calcular */
html.dark .table tbody td,
html.dark .table tbody th { color: var(--tc-on-surface) !important; }

/* Remove a faixa inferior do card de filtro (margin do .collapse dentro do .card) */
.card > .collapse { margin-bottom: 0 !important; }

/* Formulários */
html.dark .form-control,
html.dark .form-select {
    background-color: var(--tc-surface-low);
    color: var(--tc-on-surface);
    border-color: var(--tc-outline);
}
html.dark .form-control::placeholder { color: var(--tc-muted); }
html.dark .form-control:focus,
html.dark .form-select:focus {
    background-color: var(--tc-surface-c);
    color: var(--tc-on-surface);
    border-color: var(--tc-accent);
    box-shadow: 0 0 0 3px rgba(69,134,226,0.18);
}
html.dark .form-label { color: var(--tc-muted); }

/* Botões */
html.dark .btn-secondary {
    background-color: var(--tc-surface-c);
    color: var(--tc-on-surface);
    border-color: var(--tc-outline);
}
html.dark .btn-light {
    background-color: var(--tc-surface-c);
    color: var(--tc-on-surface);
    border-color: var(--tc-outline);
}

/* Breadcrumb */
html.dark .breadcrumb-item a { color: var(--tc-accent); text-decoration: none; }
html.dark .breadcrumb-item.active,
html.dark .breadcrumb-item + .breadcrumb-item::before { color: var(--tc-muted); }

/* Popover dark mode */
html.dark .popover {
    background-color: var(--tc-surface);
    border-color: var(--tc-outline);
    box-shadow: var(--tc-shadow);
}
html.dark .popover-header {
    background-color: var(--tc-surface-c);
    border-bottom-color: var(--tc-outline);
    color: var(--tc-on-surface);
}
html.dark .popover-body {
    color: var(--tc-on-surface);
}
html.dark .popover .popover-arrow::before { border-bottom-color: var(--tc-outline); }
html.dark .popover .popover-arrow::after  { border-bottom-color: var(--tc-surface-c); }
html.dark .bs-popover-start .popover-arrow::before  { border-left-color: var(--tc-outline); }
html.dark .bs-popover-start .popover-arrow::after   { border-left-color: var(--tc-surface); }
html.dark .bs-popover-end .popover-arrow::before    { border-right-color: var(--tc-outline); }
html.dark .bs-popover-end .popover-arrow::after     { border-right-color: var(--tc-surface); }

/* Alerts */
html.dark .alert-light {
    background-color: var(--tc-surface-low);
    color: var(--tc-muted);
    border-color: var(--tc-outline);
}

/* Modais */
html.dark .modal-content {
    background-color: var(--tc-surface);
    color: var(--tc-on-surface);
    border-color: var(--tc-outline);
}
html.dark .modal-header,
html.dark .modal-footer { border-color: var(--tc-outline); }
html.dark .modal-title { color: var(--tc-on-surface); }

/* Dropdown Bootstrap */
html.dark .dropdown-menu {
    background-color: var(--tc-surface);
    border-color: var(--tc-outline);
}
html.dark .dropdown-item { color: var(--tc-on-surface); }
html.dark .dropdown-item:hover,
html.dark .dropdown-item:focus { background-color: var(--tc-surface-c); }

/* Collapse / accordion */
html.dark .accordion-button {
    background-color: var(--tc-surface-low);
    color: var(--tc-on-surface);
}
html.dark .accordion-body { background-color: var(--tc-surface); color: var(--tc-on-surface); }
html.dark .rounded.p-3 { background-color: var(--tc-surface-low); }

/* Badges */
html.dark .badge.bg-light { background-color: var(--tc-surface-c) !important; color: var(--tc-on-surface) !important; }

/* Charts ApexCharts — fundo transparente */
.mbi-apex { background: transparent !important; }
html.dark .mbi-chart-wrap,
html.dark .card .mbi-apex { background: transparent !important; }

/* ===== Select2 alinhado ao tema Titan (claro/escuro pelas vars) =====
   ⚠️ ESPECIFICIDADE: em config/dz.php o `vendor/select2/css/select2.min.css` e
   carregado DEPOIS do titan.css. Como o CSS do Select2 usa exatamente os mesmos
   seletores (`.select2-container--default .select2-selection--single ...`), no
   empate vence o ultimo carregado — e as regras abaixo eram ignoradas (o texto
   herdava `padding-left:8px` e `line-height:28px` do plugin, ficando recuado e
   fora do centro vertical). O prefixo `html` sobe a especificidade e resolve
   sem precisar de !important nem reordenar o carregamento global. */

/* Altura do Select2 = altura do .form-control do tema (mesma formula do Bootstrap),
   senao o campo fica visivelmente mais baixo que os inputs vizinhos na mesma linha. */
html .select2-container--default .select2-selection--single{
    background-color: var(--tc-surface);
    border: 1px solid var(--tc-outline);
    border-radius: 8px;
    height: auto;
    min-height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    display: flex; align-items: center;
}
/* O recuo do texto vem SO do padding do .select2-selection--single (que espelha o
   .form-control). O __rendered zera padding/margin proprios do Select2 e usa
   line-height relativo, para o texto centralizar na altura do campo. */
html .select2-container--default .select2-selection--single .select2-selection__rendered{
    color: var(--tc-on-surface);
    line-height: 1.5;
    padding: 0 16px 0 0;
    margin: 0;
    width: 100%;
    display: block;
}
html .select2-container--default .select2-selection--single .select2-selection__arrow{
    height: 100%; top: 0; right: 4px;
}
/* Variante -sm: espelha a ALTURA do input pequeno (o select original fica
   escondido logo antes do container do Select2). A FONTE fica em 0.875rem de
   proposito — a fonte -sm do Bootstrap (0.76563rem) deixa o campo com texto
   visivelmente menor que o dropdown e que os campos vizinhos. */
html select.form-control-sm.select2-hidden-accessible + .select2-container--default .select2-selection--single{
    min-height: calc(1.5em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;   /* IDENTICO ao .form-control-sm: alinha o texto com os campos vizinhos */
}
/* Campo e dropdown com a MESMA tipografia. */
html .select2-container--default .select2-selection--single,
html .select2-container--default .select2-results__option,
html .select2-container--default .select2-search--dropdown .select2-search__field{
    font-size: 0.875rem;
}
/* Dropdown: mesmo prefixo `html` -- sem ele o select2.min.css (carregado depois)
   vencia e a lista ficava BRANCA com o texto claro do tema escuro (ilegivel). */
html .select2-container--default .select2-selection--single .select2-selection__placeholder{ color: var(--tc-muted); }
html .select2-dropdown{
    background-color: var(--tc-surface);
    border: 1px solid var(--tc-outline);
    color: var(--tc-on-surface);
    z-index: 1080;                      /* acima do modal do Bootstrap (1055) */
}
html .select2-container--default .select2-search--dropdown .select2-search__field{
    background-color: var(--tc-surface-low);
    border: 1px solid var(--tc-outline);
    color: var(--tc-on-surface);
    border-radius: 6px; padding: 6px 8px;
}
html .select2-container--default .select2-results__option{ color: var(--tc-on-surface); }
html .select2-container--default .select2-results__option--highlighted[aria-selected]{
    background-color: var(--tc-accent); color: var(--tc-on-accent);
}
html .select2-container--default .select2-results__option[aria-selected=true]{
    background-color: var(--tc-surface-c); color: var(--tc-on-surface);
}
html .select2-container--default .select2-results__option[aria-disabled=true]{ color: var(--tc-muted); }
html .select2-container--open .select2-dropdown{ box-shadow: 0 8px 24px rgba(0,0,0,.18); }

/* Select2 MULTIPLO (22/10/2026). So o simples tinha tema: o multiplo ficava com o
   fundo BRANCO do plugin e as etiquetas com o texto claro do tema escuro (ilegivel).
   Altura maxima com rolagem: "Marcar todas" com dezenas de lojas empurrava os
   botoes do modal para fora da tela. */
html .select2-container--default .select2-selection--multiple{
    background-color: var(--tc-surface);
    border: 1px solid var(--tc-outline);
    border-radius: 8px;
    min-height: calc(1.5em + 0.5rem + 2px);
    max-height: 110px;
    overflow-y: auto;
    font-size: 0.875rem;
}
html .select2-container--default.select2-container--focus .select2-selection--multiple{ border-color: var(--tc-accent); }
html .select2-container--default .select2-selection--multiple .select2-selection__rendered{ padding: 2px 6px; }
html .select2-container--default .select2-selection--multiple .select2-selection__choice{
    background-color: var(--tc-surface-c);
    border: 1px solid var(--tc-outline);
    color: var(--tc-on-surface);
    border-radius: 6px;
    font-size: 0.8125rem;
    margin-top: 4px;
}
html .select2-container--default .select2-selection--multiple .select2-selection__choice__remove{
    color: var(--tc-muted); border-right-color: var(--tc-outline);
}
html .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{
    color: var(--tc-danger, #ef4444); background-color: transparent;
}
html .select2-container--default .select2-search--inline .select2-search__field{
    color: var(--tc-on-surface); font-size: 0.875rem;
}
html .select2-container--default .select2-selection--multiple .select2-selection__placeholder{ color: var(--tc-muted); }

/* =========================================================
   KPI CARDS (tc-kpi) — cartões de indicador do dashboard e das
   consultas. Um único componente para toda a aplicação: a cor de
   destaque vem da variável --kpi definida inline no card.
   Dark mode sai de graça (usa var(--tc-*)).
   ========================================================= */
.tc-kpi{
    position: relative;
    display: flex; align-items: center; gap: 14px;
    padding: 18px 18px 18px 20px;
    height: 100%;
    background: var(--tc-surface);
    border: 1px solid var(--tc-border);
    border-radius: 16px;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
/* faixa de destaque à esquerda */
.tc-kpi::before{
    content:''; position:absolute; left:0; top:0; bottom:0; width:4px;
    background: linear-gradient(180deg, var(--kpi, var(--tc-accent)) 0%, transparent 140%);
}
/* brilho sutil no canto superior direito */
.tc-kpi::after{
    content:''; position:absolute; right:-40px; top:-40px; width:120px; height:120px;
    border-radius:50%; opacity:.07; background: var(--kpi, var(--tc-accent));
    pointer-events:none;
}
.tc-kpi:hover{
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,.10);
    border-color: color-mix(in srgb, var(--kpi, var(--tc-accent)) 40%, var(--tc-border));
}
.tc-kpi__icon{
    flex: 0 0 auto;
    width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    color: var(--kpi, var(--tc-accent));
    background: color-mix(in srgb, var(--kpi, var(--tc-accent)) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--kpi, var(--tc-accent)) 22%, transparent);
}
.tc-kpi__body{ min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tc-kpi__label{
    font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
    color: var(--tc-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-kpi__value{
    font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em;
    color: var(--tc-on-surface);
    font-variant-numeric: tabular-nums;   /* números não "dançam" ao atualizar */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tc-kpi__hint{ font-size: 11px; color: var(--tc-muted); }
/* estado de carregamento */
.tc-kpi__value.is-loading{ opacity:.35; }
@media (max-width: 575.98px){
    .tc-kpi{ padding: 14px; gap: 10px; }
    .tc-kpi__icon{ width: 40px; height: 40px; font-size: 17px; border-radius: 12px; }
    .tc-kpi__value{ font-size: 21px; }
}

/* =====================================================================
   COR POR MODULO  (27/08/2026)
   Cada modulo raiz do menu tem uma cor. Ela aparece em 3 lugares:
     1. pastilha do icone na sidebar  -> tira o branco do menu em repouso
     2. faixa de 3px sob a topbar     -> leva o sinal para dentro da tela
     3. etiqueta acima do titulo      -> diz o nome do modulo por extenso
   A cor entra pelo atributo data-mod (sidebar) e data-mod-ativo (.tc-shell),
   escritos pelo PHP em elements/funcoes.php e elements/nav-header.php.
   Todas as cores tem luminosidade parecida, para nenhuma pular na frente
   das outras, e modulos vizinhos no menu receberam matizes distantes.
   ===================================================================== */

:root {
    --m01: #5a7391;  /* Dashboard              */
    --m02: #c05a7d;  /* CRM & Campanhas        */
    --m03: #4586e2;  /* Operacao               */
    --m04: #7a68cf;  /* Importacao de Arquivos */
    --m05: #cf8f3e;  /* Documentos             */
    --m06: #2e9c93;  /* Consultas & BI         */
    --m07: #cf5f52;  /* Metas                  */
    --m08: #3f9a67;  /* Financeiro             */
    --m09: #7f9a3f;  /* Comissoes              */
    --m10: #3b8fa8;  /* Qualidade & Compliance */
    --m11: #9c5fae;  /* Suporte (Tickets)      */
    --m12: #b8703f;  /* Cadastros              */
    --m13: #6373c9;  /* Empresa & Pessoas      */
    --m14: #8c5566;  /* Seguranca & Sistema    */
}

/* No tema escuro as mesmas cores sobem de luminosidade: as versoes claras
   ficam ilegiveis sobre o fundo #0e1420. */
html.dark {
    --m01: #8ba3bd;  --m02: #e08aa8;  --m03: #79aaf0;  --m04: #a596e8;
    --m05: #e5b269;  --m06: #5cc4bb;  --m07: #e8887c;  --m08: #6cc194;
    --m09: #a8c46b;  --m10: #6cb8ce;  --m11: #c48ed4;  --m12: #d99a6e;
    --m13: #94a2e8;  --m14: #bd8394;
}

/* --- data-mod -> --tc-mod (CSS nao mapeia atributo em variavel sozinho) --- */
.tc-nav-group[data-mod="m01"], .tc-nav-item[data-mod="m01"] { --tc-mod: var(--m01); }
.tc-nav-group[data-mod="m02"], .tc-nav-item[data-mod="m02"] { --tc-mod: var(--m02); }
.tc-nav-group[data-mod="m03"], .tc-nav-item[data-mod="m03"] { --tc-mod: var(--m03); }
.tc-nav-group[data-mod="m04"], .tc-nav-item[data-mod="m04"] { --tc-mod: var(--m04); }
.tc-nav-group[data-mod="m05"], .tc-nav-item[data-mod="m05"] { --tc-mod: var(--m05); }
.tc-nav-group[data-mod="m06"], .tc-nav-item[data-mod="m06"] { --tc-mod: var(--m06); }
.tc-nav-group[data-mod="m07"], .tc-nav-item[data-mod="m07"] { --tc-mod: var(--m07); }
.tc-nav-group[data-mod="m08"], .tc-nav-item[data-mod="m08"] { --tc-mod: var(--m08); }
.tc-nav-group[data-mod="m09"], .tc-nav-item[data-mod="m09"] { --tc-mod: var(--m09); }
.tc-nav-group[data-mod="m10"], .tc-nav-item[data-mod="m10"] { --tc-mod: var(--m10); }
.tc-nav-group[data-mod="m11"], .tc-nav-item[data-mod="m11"] { --tc-mod: var(--m11); }
.tc-nav-group[data-mod="m12"], .tc-nav-item[data-mod="m12"] { --tc-mod: var(--m12); }
.tc-nav-group[data-mod="m13"], .tc-nav-item[data-mod="m13"] { --tc-mod: var(--m13); }
.tc-nav-group[data-mod="m14"], .tc-nav-item[data-mod="m14"] { --tc-mod: var(--m14); }

/* Mesma tabela para o modulo ATIVO, lida no .tc-shell (faixa + etiqueta). */
.tc-shell[data-mod-ativo="m01"] { --tc-mod-ativo: var(--m01); }
.tc-shell[data-mod-ativo="m02"] { --tc-mod-ativo: var(--m02); }
.tc-shell[data-mod-ativo="m03"] { --tc-mod-ativo: var(--m03); }
.tc-shell[data-mod-ativo="m04"] { --tc-mod-ativo: var(--m04); }
.tc-shell[data-mod-ativo="m05"] { --tc-mod-ativo: var(--m05); }
.tc-shell[data-mod-ativo="m06"] { --tc-mod-ativo: var(--m06); }
.tc-shell[data-mod-ativo="m07"] { --tc-mod-ativo: var(--m07); }
.tc-shell[data-mod-ativo="m08"] { --tc-mod-ativo: var(--m08); }
.tc-shell[data-mod-ativo="m09"] { --tc-mod-ativo: var(--m09); }
.tc-shell[data-mod-ativo="m10"] { --tc-mod-ativo: var(--m10); }
.tc-shell[data-mod-ativo="m11"] { --tc-mod-ativo: var(--m11); }
.tc-shell[data-mod-ativo="m12"] { --tc-mod-ativo: var(--m12); }
.tc-shell[data-mod-ativo="m13"] { --tc-mod-ativo: var(--m13); }
.tc-shell[data-mod-ativo="m14"] { --tc-mod-ativo: var(--m14); }

/* ---------------------------------------------------------------------
   1. PASTILHA DO ICONE NA SIDEBAR
   Vale para o cabecalho do grupo e para a raiz-folha (Dashboard).
   --------------------------------------------------------------------- */
.tc-nav-group[data-mod] .tc-grp-label-inner > i,
.tc-nav-group[data-mod] .tc-grp-label-inner > .material-symbols-outlined,
.tc-nav-item[data-mod] > i,
.tc-nav-item[data-mod] > .material-symbols-outlined {
    color: var(--tc-mod);
    background: color-mix(in srgb, var(--tc-mod) 13%, transparent);
    border-radius: 7px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-size: 17px;
    transition: background .16s var(--tc-ease), color .16s var(--tc-ease);
}

/* Grupo aberto / item ativo: pastilha solida. */
.tc-nav-group--on[data-mod] .tc-grp-label-inner > i,
.tc-nav-group--on[data-mod] .tc-grp-label-inner > .material-symbols-outlined,
.tc-nav-item--active[data-mod] > i,
.tc-nav-item--active[data-mod] > .material-symbols-outlined {
    background: var(--tc-mod);
    color: #fff;
}
.tc-nav-group--on[data-mod] .tc-grp-label-text { color: var(--tc-mod); font-weight: 600; }

/* Sidebar colapsada (a classe fica no <html>): sobra so a pastilha, entao ela
   centraliza e nao encolhe junto com o rotulo. */
html.tc-sidebar-collapsed .tc-nav-group[data-mod] .tc-grp-label-inner > i,
html.tc-sidebar-collapsed .tc-nav-group[data-mod] .tc-grp-label-inner > .material-symbols-outlined,
html.tc-sidebar-collapsed .tc-nav-item[data-mod] > i,
html.tc-sidebar-collapsed .tc-nav-item[data-mod] > .material-symbols-outlined {
    margin: 0 auto;
    width: 28px;
    height: 28px;
    font-size: 17px;
}

/* ---------------------------------------------------------------------
   2. FAIXA SOB A TOPBAR
   --------------------------------------------------------------------- */
.tc-mod-band {
    height: 3px;
    flex: none;
    background: var(--tc-mod-ativo, transparent);
    position: relative;
    z-index: 41;   /* acima da topbar (z-index 40), senao o blur come a faixa */
}

/* ---------------------------------------------------------------------
   3. ETIQUETA DO MODULO ACIMA DO TITULO DA PAGINA
   Puro CSS, via ::before no proprio <h2 class="tc-page-header-title">.
   Nao entra como filho do .tc-page-header (que e flex com
   justify-content:space-between) para nao virar uma coluna ao lado do
   botao de acao -- dentro do h2 o pseudo e block e empilha por cima.
   As 115 telas com cabecalho ganham isso sem nenhuma edicao de view.
   --------------------------------------------------------------------- */
.tc-shell[data-mod-ativo] .tc-page-header-title {
    border-left: 3px solid var(--tc-mod-ativo);
    padding-left: 12px;
}
.tc-shell[data-mod-ativo] .tc-page-header-title::before {
    content: var(--tc-mod-nome, "");
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;   /* MAIUSCULA aqui: strtoupper do PHP quebra acento */
    line-height: 1.4;
    color: var(--tc-mod-ativo);
    margin-bottom: 1px;
}

@media (prefers-reduced-motion: reduce) {
    .tc-nav-group[data-mod] .tc-grp-label-inner > i,
    .tc-nav-group[data-mod] .tc-grp-label-inner > .material-symbols-outlined,
    .tc-nav-item[data-mod] > i,
    .tc-nav-item[data-mod] > .material-symbols-outlined { transition: none; }
}
