/* ============================================================
   ELOS — Electrosol Operações Sincronizadas
   CSS global com suporte a dark/light mode via data-theme
   ============================================================ */

:root {
    /* Cor principal Electrosol */
    --color-primary:        #113357;
    --color-primary-dark:   #0c2440;
    --color-primary-light:  #1a4a7a;

    /* Superfícies */
    --bg-page:      #f4f6f8;
    --bg-card:      #ffffff;
    --bg-sidebar:   #113357;
    --bg-header:    #113357;
    --bg-input:     #ffffff;
    --bg-table-row: #ffffff;
    --bg-table-alt: #f8fafc;
    --bg-table-head:#f0f4f8;

    /* Texto */
    --text-primary:   #111827;
    --text-secondary: #4b5563;
    --text-muted:     #888888;
    --text-on-primary:#ffffff;

    /* Bordas */
    --border-color:  #e5e7eb;
    --border-input:  #d1d5db;

    /* Status badges */
    --badge-pedido-bg:      #fef3c7;
    --badge-pedido-text:    #92400e;
    --badge-comprado-bg:    #dbeafe;
    --badge-comprado-text:  #1e40af;
    --badge-parcial-bg:     #cffafe;
    --badge-parcial-text:   #155e75;
    --badge-recebido-bg:    #d1fae5;
    --badge-recebido-text:  #065f46;
    --badge-enviado-bg:     #ede9fe;
    --badge-enviado-text:   #5b21b6;
    --badge-obsoleto-bg:    #f3f4f6;
    --badge-obsoleto-text:  #6b7280;

    /* Outros */
    --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
    --shadow-md:   0 4px 12px rgba(0,0,0,.1);
    --radius-sm:   4px;
    --radius-md:   6px;
    --sidebar-width: 220px;
    --sidebar-collapsed: 52px;
    --header-height: 52px;
}

[data-theme="dark"] {
    /* Cinza carvão — estilo VSCode / Chrome dark */
    --bg-page:      #1e1e1e;
    --bg-card:      #252526;
    --bg-sidebar:   #252526;
    --bg-header:    #2d2d2d;
    --bg-input:     #3c3c3c;
    --bg-table-row: #252526;
    --bg-table-alt: #2a2a2a;
    --bg-table-head:#2d2d2d;

    --text-primary:   #d4d4d4;
    --text-secondary: #a0a0a0;
    --text-muted:     #888888;

    --border-color:  #3c3c3c;
    --border-input:  #505050;

    /* Cor primária mais suave no escuro — mantém identidade sem dominar */
    --color-primary:       #5b9bd5;
    --color-primary-dark:  #4a88c2;
    --color-primary-light: #6eaee0;
}

/* ── Reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
}

/* Transição suave só ao trocar tema (não em navegação) */
body.theme-transitioning,
body.theme-transitioning .header,
body.theme-transitioning .sidebar,
body.theme-transitioning .card,
body.theme-transitioning .main,
body.theme-transitioning table,
body.theme-transitioning input,
body.theme-transitioning select {
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

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

/* ── Layout principal ─────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Header ───────────────────────────────────────── */
.header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    color: var(--text-on-primary);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.header-logo img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}
.header-logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: .5px;
    color: #fff;
}

.header-logo-text span {
    font-weight: 300;
    opacity: .7;
    font-size: .85rem;
    display: block;
    line-height: 1;
}

.header-spacer { flex: 1; }
/* Nome da seção centralizado no header — link pra raiz da seção. */
.header-section {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-on-primary);
    text-decoration: none;
    opacity: .85;
    white-space: nowrap;
    transition: opacity .12s;
}
.header-section:hover { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 900px) { .header-section { display: none; } }

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user {
    font-size: .8rem;
    opacity: .85;
    white-space: nowrap;
}

.btn-sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    opacity: .8;
    transition: opacity .15s;
    font-size: 1.1rem;
    line-height: 1;
}
.btn-sidebar-toggle:hover { opacity: 1; }

/* ── Theme toggle ─────────────────────────────────── */
.theme-toggle {
    background: none;
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: 20px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: .75rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: border-color .15s, background .15s;
}
.theme-toggle:hover { background: rgba(255,255,255,.1); }

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width .2s ease;
    z-index: 90;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-nav { padding: 8px 0; }

.sidebar-section-title {
    color: rgba(255,255,255,.4);
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 12px 14px 4px;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .15s;
}
.sidebar.collapsed .sidebar-section-title { opacity: 0; height: 0; padding: 0; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .85rem;
    white-space: nowrap;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    text-decoration: none;
    border-left-color: #fff;
}
.sidebar-link .icon {
    font-size: 1rem;
    min-width: 20px;
    text-align: center;
}
/* Fluent Emoji 3D (self-hosted) — alinha com o texto ao redor. */
.femoji { display: inline-block; vertical-align: -.22em; object-fit: contain; }
.sidebar-link .icon .femoji { vertical-align: middle; }
.sidebar-link .label { transition: opacity .15s; }
.sidebar.collapsed .sidebar-link .label { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-link { padding: 10px 14px; }

/* Tooltip da sidebar colapsada — via JS (position:fixed), pois o
   overflow da sidebar cortaria um ::after posicionado fora dela */
/* sidebar usa tooltip JS próprio (.sidebar-tooltip) — o ::after genérico fica
   desligado inclusive no hover (especificidade maior que [data-tip]:hover::after) */
.sidebar-link[data-tip]::after,
.sidebar-link[data-tip]:hover::after { display: none; }
.sidebar-tooltip {
    position: fixed;
    transform: translateY(-50%);
    background: rgba(0,0,0,.82);
    color: #fff;
    font-size: 1rem;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10000;
}

/* ── Main content ─────────────────────────────────── */
.main {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 20px;
    flex: 1;
    min-width: 0;
    transition: margin-left .2s ease;
}
.sidebar.collapsed ~ .layout .main { margin-left: var(--sidebar-collapsed); }

/* ── Page header (STICKY: título + ações da página sempre visíveis) ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    position: sticky;
    top: var(--header-height);
    z-index: 80;                       /* abaixo do header (100) e da sidebar (90) */
    background: var(--bg-page);        /* fundo SÓLIDO — era --bg-body (inexistente) e vazava conteúdo */
    /* full-bleed: cobre o conteúdo que rola por baixo (o .main tem padding 20px) */
    margin: -20px -20px 12px;
    padding: 6px 20px;
    border-bottom: 1px solid var(--border-color);
}
.page-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.page-subtitle {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Breadcrumb (navegação padrão — substitui botões "← Voltar") ── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .74rem;
    color: var(--text-muted);
    margin-bottom: 3px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--color-primary); text-decoration: none; }
.breadcrumb .bc-sep { opacity: .45; }
.breadcrumb .bc-current { color: var(--text-secondary); font-weight: 500; }

/* ── Cards ────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
.card-body { padding: 16px; }
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: .9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Stat cards ───────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    border-left: 3px solid var(--color-primary);
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}
.stat-card .stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}
thead th {
    background: var(--bg-table-head);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tbody tr { background: var(--bg-table-row); border-bottom: 1px solid var(--border-color); }
tbody tr:nth-child(even) { background: var(--bg-table-alt); }
tbody tr:hover { background: rgba(17,51,87,.05); }
[data-theme="dark"] tbody tr:hover { background: rgba(255,255,255,.06); }
tbody td { padding: 7px 10px; vertical-align: middle; }

/* ── Botões ───────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    text-decoration: none;
    white-space: nowrap;
}

/* Primary — borda azul + fundo translúcido */
.btn-primary {
    background: color-mix(in srgb, var(--color-primary) 20%, transparent);
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.btn-primary:hover {
    background: color-mix(in srgb, var(--color-primary) 32%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--color-primary) 45%, transparent);
    text-decoration: none;
    color: var(--color-primary);
}
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary:hover { color: #fff; }

/* Secondary — neutro translúcido */
.btn-secondary {
    background: color-mix(in srgb, var(--text-primary) 7%, transparent);
    border-color: var(--border-input);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: color-mix(in srgb, var(--text-primary) 14%, transparent);
    text-decoration: none;
    color: var(--text-primary);
}

/* Danger — borda vermelha + fundo translúcido */
.btn-danger {
    background: color-mix(in srgb, #dc2626 13%, transparent);
    border-color: #dc2626;
    color: #dc2626;
}
.btn-danger:hover {
    background: color-mix(in srgb, #dc2626 25%, transparent);
    box-shadow: 0 0 0 1px color-mix(in srgb, #dc2626 45%, transparent);
    text-decoration: none;
    color: #dc2626;
}
[data-theme="dark"] .btn-danger,
[data-theme="dark"] .btn-danger:hover { border-color: #f87171; color: #f87171; }

.btn-sm { padding: 4px 10px; font-size: .75rem; }
.btn-icon { padding: 4px 7px; }

/* ── Badges de status ─────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-pedido   { background: var(--badge-pedido-bg);   color: var(--badge-pedido-text); }
.badge-comprado { background: var(--badge-comprado-bg); color: var(--badge-comprado-text); }
.badge-parcial  { background: var(--badge-parcial-bg);  color: var(--badge-parcial-text); }
.badge-recebido { background: var(--badge-recebido-bg); color: var(--badge-recebido-text); }
.badge-enviado  { background: var(--badge-enviado-bg);  color: var(--badge-enviado-text); }
.badge-obsoleto { background: var(--badge-obsoleto-bg); color: var(--badge-obsoleto-text); }
.badge-rascunho { background: #f3f4f6; color: #374151; }
.badge-em_revisao { background: #fef3c7; color: #92400e; }
.badge-aprovado { background: #d1fae5; color: #065f46; }
.badge-cancelado { background: #fee2e2; color: #991b1b; }
.badge-ativo    { background: #dbeafe; color: #1e40af; }
/* Status de documento (GRD) — esquema próprio: pendente→andamento→concluído→aprovado */
.badge-doc-pendente  { background: #fee2e2; color: #991b1b; }
.badge-doc-priorizar { background: #ffedd5; color: #9a3412; }
.badge-doc-andamento { background: #fef3c7; color: #92400e; }
.badge-doc-enviado   { background: #cffafe; color: #155e75; }
.badge-doc-concluido { background: #dbeafe; color: #1e40af; }
.badge-doc-aprovado  { background: #d1fae5; color: #065f46; }
.badge-doc-na        { background: #f3f4f6; color: #6b7280; }

/* ── Formulários ──────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-control {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: .85rem;
    transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--color-primary); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Setas do input numérico — sempre visíveis e dimensionadas corretamente */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
    height: 28px;
    cursor: pointer;
}
/* color-scheme faz o Chrome renderizar as setas na cor certa para cada tema */
input[type="number"] { color-scheme: light; }
[data-theme="dark"] input[type="number"] { color-scheme: dark; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.form-error { font-size: .75rem; color: #dc2626; margin-top: 3px; }
.form-hint  { font-size: .75rem; color: var(--text-muted); margin-top: 3px; }

/* ── Alerts ───────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    margin-bottom: 14px;
    border: 1px solid;
    border-left-width: 3px;
}
.alert-error   { background: color-mix(in srgb, #dc2626 13%, transparent); color: #991b1b; border-color: #dc2626; }
.alert-success { background: color-mix(in srgb, #10b981 13%, transparent); color: #065f46; border-color: #10b981; }
.alert-info    { background: color-mix(in srgb, #3b82f6 13%, transparent); color: #1e40af; border-color: #3b82f6; }
.alert-warning { background: color-mix(in srgb, #f59e0b 13%, transparent); color: #92400e; border-color: #f59e0b; }

[data-theme="dark"] .alert-error   { color: #f87171; }
[data-theme="dark"] .alert-success { color: #34d399; }
[data-theme="dark"] .alert-info    { color: #60a5fa; }
[data-theme="dark"] .alert-warning { color: #fbbf24; }

/* ── Barra de destaque (ex: seletor de projeto) ───── */
.info-bar {
    background: color-mix(in srgb, var(--color-primary) 20%, transparent);
    border: 1px solid var(--color-primary);
    color: #fff;
    padding: 7px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* ── Export bar ───────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Paginação / empty state ──────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: .85rem;
}

/* ── Responsive ───────────────────────────────────── */
/* ── Tooltip instantâneo ──────────────────────────────── */
[data-tip] {
    position: relative;
}
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.85);
    color: #fff;
    font-size: .8rem;
    line-height: 1.3;
    white-space: nowrap;
    padding: 5px 9px;
    border-radius: 4px;
    pointer-events: none;
    /* display (não opacity): escondido não pode ocupar layout — tooltip largo
       perto da borda direita criava scroll horizontal na página */
    display: none;
    z-index: 9999;
}
[data-tip]:hover::after {
    display: block;
}
/* Dentro de wrapper com scroll horizontal, tooltip centralizado em coluna da
   direita vaza pro lado e cria scrollbar no hover — ancora pela direita do
   título (cresce pra dentro da tabela; vazar pra esquerda não gera scroll) */
.table-wrapper th[data-tip]::after {
    left: auto;
    right: 0;
    transform: none;
}
/* Regra de borda genérica p/ QUALQUER tabela: tooltip da última coluna (ações
   à direita) ancora à direita e cresce pra dentro; o da primeira coluna (colada
   na sidebar, ex. estrela de prioridade) ancora à esquerda. Evita vazamento e
   scroll horizontal sem precisar de .tip-left/.tip-right em cada botão. */
.table-wrapper td:last-child [data-tip]::after,
.table-wrapper td:last-child[data-tip]::after {
    left: auto; right: 0; transform: none;
}
.table-wrapper td:first-child [data-tip]::after,
.table-wrapper td:first-child[data-tip]::after,
.table-wrapper th:first-child[data-tip]::after {
    left: 0; right: auto; transform: none;
}

/* ── Wizard de orçamento (indicador de etapas) ────── */
.wizard-step { opacity: .55; }
.wizard-step.active { opacity: 1; font-weight: 700; color: var(--color-primary); }

/* ── Toast notification ───────────────────────────── */
#toast-container {
    position: fixed;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: min(480px, 92vw);
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,.35);
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.4;
    min-width: 260px;
    border-left: 4px solid;
    animation: toast-in .2s cubic-bezier(.22,1,.36,1);
    cursor: pointer;
    word-break: break-word;
}
.toast.toast-out {
    animation: toast-out .18s ease forwards;
}
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; }
.toast-close {
    flex-shrink: 0;
    background: none; border: none; cursor: pointer;
    font-size: .9rem; opacity: .5; padding: 0; line-height: 1;
    color: inherit;
}
.toast-close:hover { opacity: 1; }

.toast-success { background: #d1fae5; color: #065f46; border-color: #10b981; }
.toast-error   { background: #fee2e2; color: #7f1d1d; border-color: #ef4444; }
.toast-warning { background: #fef3c7; color: #78350f; border-color: #f59e0b; }
.toast-info    { background: #dbeafe; color: #1e3a8a; border-color: #3b82f6; }

[data-theme="dark"] .toast-success { background: #064e3b; color: #a7f3d0; }
[data-theme="dark"] .toast-error   { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .toast-warning { background: #451a03; color: #fde68a; }
[data-theme="dark"] .toast-info    { background: #1e3a8a; color: #bfdbfe; }

@keyframes toast-in  { from { opacity:0; transform:translateY(-12px) scale(.95) } to { opacity:1; transform:none } }
@keyframes toast-out { to   { opacity:0; transform:translateY(-8px) scale(.95) } }

@media (max-width: 768px) {
    /* Sidebar vira off-canvas: escondida por padrão, hambúrguer abre por cima */
    .sidebar,
    .sidebar.collapsed { width: var(--sidebar-width); transform: translateX(-105%); transition: transform .22s ease; }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: 6px 0 28px rgba(0,0,0,.45); }
    .sidebar.collapsed .sidebar-link .label { opacity: 1; width: auto; overflow: visible; }
    .sidebar.collapsed .sidebar-section-title { opacity: 1; height: auto; padding: 12px 14px 4px; }
    .main,
    .sidebar.collapsed ~ .layout .main { margin-left: 0; padding: 12px; }
    .header-logo-text span { display: none; }
    .page-header { margin: -12px -12px 12px; padding: 10px 12px 8px; }
}
#sidebarBackdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0,0,0,.5);
    z-index: 89;
}
#sidebarBackdrop.show { display: block; }

/* Selects sobre fundo escuro (ex: barra de montagem de RC):
   o <select> precisa de texto branco, mas a lista nativa de opções
   abre com fundo claro — sem isso o texto branco fica ilegível. */
#cartProjectSelect option {
    color: var(--text-primary);
    background: var(--bg-input);
}

/* ── Linha separadora de grupo no carrinho / RC ───────── */
.cart-group-row td {
    padding: 5px 12px 4px;
    background: var(--bg-table-head);
    border-top: 2px solid var(--border-color);
}
.cart-group-row:first-child td {
    border-top: none;
}
.cart-group-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.cart-group-count {
    margin-left: 8px;
    color: var(--text-muted);
    font-size: .75rem;
}

/* Espaço entre número e setas nos inputs de quantidade */
.qty-input::-webkit-inner-spin-button {
    margin-left: 5px;
}

/* Tabela com layout fixo: células quebram palavra em vez de expandir a tabela */
table[style*="table-layout:fixed"] td {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ── Cart table ───────────────────────────────────── */
.cart-table {
    table-layout: fixed;
    width: 100%;
}
.cart-table thead th {
    position: static;
    white-space: normal;
}
.cart-table td {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ── "Ver como" (admin simula outro perfil) ───────── */
.view-as-form {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 20px;
    padding: 2px 8px;
}
.view-as-form.view-as-active {
    border-color: #f59e0b;
    background: rgba(245,158,11,.15);
}
.view-as-label { font-size: .8rem; opacity: .8; }
.view-as-select {
    background: transparent;
    border: none;
    color: #fff;
    font-size: .75rem;
    cursor: pointer;
    outline: none;
    padding: 2px;
}
.view-as-select option { color: #111; background: #fff; }

/* ── Notificações (sino no header) ────────────────── */
.notif-wrap { position: relative; }
.notif-bell {
    background: none; border: 1px solid rgba(255,255,255,.3); color: #fff;
    border-radius: 20px; padding: 3px 10px; cursor: pointer; font-size: .85rem;
    position: relative; transition: background .15s;
}
.notif-bell:hover { background: rgba(255,255,255,.1); }
.notif-badge {
    position: absolute; top: -5px; right: -5px;
    background: #ef4444; color: #fff; font-size: .62rem; font-weight: 700;
    min-width: 16px; height: 16px; line-height: 16px; text-align: center;
    border-radius: 8px; padding: 0 4px;
}
.notif-panel {
    position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 92vw;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px;
    box-shadow: 0 10px 34px rgba(0,0,0,.4); z-index: 300; color: var(--text-primary);
}
.notif-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 12px; border-bottom: 1px solid var(--border-color); font-weight: 600; font-size: .82rem;
}
.notif-link { background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: .72rem; padding: 0; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
    display: block; padding: 9px 12px; border-bottom: 1px solid var(--border-color);
    text-decoration: none; color: var(--text-primary); cursor: pointer;
}
.notif-item:hover { background: var(--bg-table-alt); text-decoration: none; }
.notif-item.unread { border-left: 3px solid var(--color-primary); background: color-mix(in srgb, var(--color-primary) 6%, transparent); }
.notif-item .nt { font-weight: 600; font-size: .8rem; }
.notif-item .nb { font-size: .75rem; color: var(--text-secondary); margin-top: 1px; }
.notif-item .nd { font-size: .68rem; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: .8rem; }
.notif-foot { padding: 7px 12px; border-top: 1px solid var(--border-color); text-align: center; }

/* ── Página de requisição ─────────────────────────── */
.btn-icon-plain {
    background: none; border: none; cursor: pointer;
    font-size: .9rem; opacity: .5; transition: opacity .12s;
    padding: 2px 4px;
}
.btn-icon-plain:hover { opacity: 1; }
/* Resultado da busca de material: 1 linha por item (unidade à direita)
   pra caberem mais resultados na tela */
.ai-row {
    display: flex; align-items: baseline; gap: 8px;
    padding: 7px 12px; cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: .82rem;
}
.ai-row:hover { background: var(--bg-table-alt); }
.ai-row .ai-desc { flex: 1; min-width: 0; }
.ai-row .ai-meta {
    margin-left: auto; white-space: nowrap;
    color: var(--text-muted); font-size: .72rem;
}

/* Tooltip ancorado pela direita — para botões perto da borda direita da
   página (tooltip centralizado vazava e criava scroll horizontal no body) */
.tip-left[data-tip]::after { left: auto; right: 0; transform: none; }
/* Tooltip ancorado pela esquerda — para botões perto da borda esquerda (1ª
   coluna colada na sidebar) onde o padrão centralizado vazaria e seria cortado. */
.tip-right[data-tip]::after { left: 0; right: auto; transform: none; }
/* Tooltip crescendo pra baixo — para elementos no topo (header) onde o padrão
   (acima) seria cortado pela borda superior da janela. */
.tip-down[data-tip]::after { bottom: auto; top: calc(100% + 5px); }
/* Tooltip de texto longo (ex: valores do log) — quebra linha em vez de virar
   uma faixa gigante. Usar junto de data-tip quando o conteúdo é livre. */
.tip-wrap[data-tip]::after { white-space: normal; width: max-content; max-width: 320px; }
/* Célula/cabeçalho de código de item — NUNCA quebra linha (padrão do projeto).
   Usar em toda <td>/<th> que exibe código de material/documento/RC. */
.cell-code { white-space: nowrap; font-family: monospace; }
/* Alça de redimensionar coluna (borda direita do th). */
.col-resizer {
    position: absolute; top: 0; right: 0; width: 6px; height: 100%;
    cursor: col-resize; user-select: none; z-index: 2;
}
.col-resizer:hover { background: color-mix(in srgb, var(--color-primary) 50%, transparent); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing a, body.col-resizing button { pointer-events: none; }

/* ── Personalizador de colunas (⚙ em tabelas) ────────── */
.col-picker { position: relative; display: inline-block; }
.col-picker button.has-hidden { color: var(--color-primary); font-weight: 700; }
.col-picker-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 900;
    min-width: 210px; max-height: 340px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.25); padding: 8px;
}
.col-picker-menu[hidden] { display: none; }
.col-picker-title {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-muted); padding: 2px 6px 6px;
}
.col-picker-item {
    display: flex; align-items: center; gap: 7px; font-weight: 400;
    font-size: .84rem; padding: 5px 6px; border-radius: 4px; cursor: pointer; margin: 0;
}
.col-picker-item:hover { background: color-mix(in srgb, var(--color-primary) 8%, transparent); }
.col-picker-reset {
    width: 100%; margin-top: 6px; padding: 5px; font-size: .78rem; cursor: pointer;
    background: none; border: 1px solid var(--border-color); border-radius: 4px;
    color: var(--text-muted);
}
.col-picker-reset:hover { color: var(--color-primary); border-color: var(--color-primary); }

/* ── Painel de status do projeto (stat tiles + gráficos) ── */
.stat-tiles { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.stat-tile {
    flex: 1; min-width: 92px; text-align: center;
    background: var(--bg-table-alt); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 10px 12px;
}
.st-num { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.st-lbl { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }
.dash-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.dash-title { font-weight: 600; font-size: .9rem; margin-bottom: 10px; }
.dash-canvas { position: relative; height: 260px; min-width: 0; }
.dash-empty { color: var(--text-muted); font-size: .85rem; padding: 40px 24px; text-align: center; }
/* Rótulo de campo em modais de detalhe (documento etc.) */
.dv-lbl { color: var(--text-muted); font-size: .72rem; }
@media (max-width: 1100px) { .dash-charts { grid-template-columns: 1fr; } }

/* Botão X de fechar modal (canto superior esquerdo do header). */
.modal-x {
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; line-height: 1; color: var(--text-muted);
    padding: 0 6px; border-radius: 4px; flex: 0 0 auto;
}
.modal-x:hover { color: var(--text); background: color-mix(in srgb, var(--text-muted) 20%, transparent); }
/* Linhas clicáveis que abrem modal de detalhe (pendência, material...). */
.pend-row, .mat-row { cursor: pointer; }
.pend-row:hover, .mat-row:hover { background: color-mix(in srgb, var(--color-primary) 7%, transparent); }
/* rede de segurança: a página nunca rola horizontal (tabelas rolam no wrapper) */
body { overflow-x: hidden; }

/* ── Tabela de documentos (GRD) — edição inline estilo Excel ── */
.doc-table .mini-select, .doc-table .mini-date {
    font-size: .78rem; padding: 3px 5px; border: 1px solid var(--border-input);
    border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-primary);
    max-width: 100%;
}
.doc-table .mini-select:hover, .doc-table .mini-date:hover { border-color: var(--color-primary); }
.doc-table .mini-select.saving, .doc-table .star-btn.saving { opacity: .5; }
/* status colorido no próprio select (feedback rápido do estado) */
.doc-table .status-select { font-weight: 600; }
.doc-table .st-pendente  { border-left: 3px solid #ef4444; }
.doc-table .st-priorizar { border-left: 3px solid #f97316; }
.doc-table .st-andamento { border-left: 3px solid #f59e0b; }
.doc-table .st-enviado   { border-left: 3px solid #06b6d4; }
.doc-table .st-concluido { border-left: 3px solid #3b82f6; }
.doc-table .st-aprovado  { border-left: 3px solid #22c55e; }
.doc-table .st-nao_se_aplica { border-left: 3px solid var(--border-color); color: var(--text-muted); }
.star-btn {
    background: none; border: none; cursor: pointer; font-size: 1.05rem;
    color: #f59e0b; line-height: 1; padding: 0;
}
.doc-table tr.doc-mine { background: rgba(17,51,87,.045); }
[data-theme="dark"] .doc-table tr.doc-mine { background: rgba(74,144,196,.10); }
.mine-tag {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .03em;
    background: var(--color-primary); color: #fff; padding: 1px 5px; border-radius: 8px; margin-left: 4px;
}
.btn-icon-plain { color: var(--text-primary); }
a.wizard-step { color: inherit; text-decoration: none; }
a.wizard-step:hover { opacity: 1; color: var(--color-primary); text-decoration: none; }
.rs-row { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border-color); font-size: .82rem; }
.rs-row:hover { background: var(--bg-table-alt); }
