/*
 * Atividades — identidade SIMPLE
 * Paleta do manual de marca: laranja assinatura #F15A24, grafite #333333,
 * cinza claro #D1D3D4, branco. Tipografia: Lato (a mesma do site simple.com.br).
 * O laranja puro é usado em destaques; em fundos de botão com texto branco usa-se
 * um tom mais escuro para manter o contraste acessível (4.8:1).
 */
:root {
    --orange: #F15A24;          /* assinatura: marcas, barras, foco */
    --orange-action: #C94616;   /* fundo de botões (texto branco legível) */
    --orange-deep: #B93F12;     /* links e hover */
    --orange-wash: #FEF0EA;     /* fundo suave de destaque */
    --graphite: #333333;
    --ash: #5F6264;             /* texto secundário */
    --mist: #D1D3D4;            /* linhas e bordas */
    --mist-soft: #E8E9EA;
    --canvas: #F4F5F5;          /* fundo da aplicação */
    --paper: #FFFFFF;
    --success: #1E7F55;
    --success-wash: #E8F5EE;
    --danger: #B3261E;
    --danger-wash: #FDECEA;
    --radius: 3px;
    --sidebar: 248px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--graphite);
    background: var(--canvas);
    font-variant-numeric: tabular-nums;
}
a { color: var(--orange-deep); text-underline-offset: 2px; }
a:hover { color: var(--graphite); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
img { max-width: 100%; height: auto; }

/* Separador da marca: a barra laranja do slogan "Estratégia | Gestão | Operação" */
.sep { display: inline-block; width: 1.5px; height: .95em; background: var(--orange); margin: 0 .6em; vertical-align: -.12em; }

/* ---------- Estrutura ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    background: var(--paper);
    border-right: 1px solid var(--mist);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-logo { display: block; padding: 28px 24px 20px; }
.sidebar-logo img { display: block; width: 188px; }

.tenant-switcher { margin: 0 24px 8px; }
.tenant-switcher-label { display: block; margin: 0 0 4px; font-size: 13px; font-weight: 400; color: var(--ash); }
.tenant-switcher-row { display: flex; gap: 6px; align-items: flex-start; position: relative; }

/* Seletor de empreendimento/rede (partials/tenant-switcher) */
.switcher { flex: 1; min-width: 0; }
.switcher-current {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    border: 1px solid #cbd2d9; border-radius: 6px; padding: 7px 10px; font-weight: 700; background: var(--paper);
    white-space: nowrap; overflow: hidden;
}
.switcher-current::-webkit-details-marker { display: none; }
.switcher-current > span { overflow: hidden; text-overflow: ellipsis; }
.switcher-current::after { content: ""; flex: none; width: 7px; height: 7px; border-right: 1.5px solid var(--graphite); border-bottom: 1.5px solid var(--graphite); transform: rotate(45deg) translate(-2px, -2px); }
.switcher[open] .switcher-current { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(241, 90, 36, .18); }
.switcher-panel {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 60vh; overflow-y: auto;
    background: var(--paper); border: 1px solid var(--mist); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); padding: 6px;
}
.switcher-search { width: 100%; max-width: none; margin: 0 0 6px; padding: 7px 10px; }
.switcher-item { display: block; padding: 7px 10px; border-radius: 6px; color: var(--graphite); text-decoration: none; }
.switcher-item:hover { background: var(--canvas); color: var(--graphite); }
.switcher-item[aria-current="page"] { background: var(--orange-wash); font-weight: 700; }
.switcher-network > summary { list-style: none; display: flex; align-items: center; gap: 2px; cursor: pointer; border-radius: 6px; }
.switcher-network > summary::-webkit-details-marker { display: none; }
.switcher-network > summary:hover { background: var(--canvas); }
.switcher-toggle { flex: none; width: 22px; height: 30px; display: grid; place-items: center; }
.switcher-toggle::before { content: ""; border-left: 6px solid var(--ash); border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; transition: transform .15s; }
.switcher-network[open] > summary .switcher-toggle::before { transform: rotate(90deg); }
.switcher-network-link { flex: 1; padding-left: 2px; font-weight: 700; }
.switcher-group { flex: 1; padding: 7px 2px; font-weight: 700; color: var(--ash); }
.switcher-count { flex: none; font-size: 12px; color: var(--ash); padding: 0 8px; }
.switcher-child { padding-left: 34px; }
.switcher-empty { padding: 7px 10px; margin: 0; }
.btn-icon { padding: 6px 9px; display: inline-flex; align-items: center; }

.nav { flex: 1; padding: 8px 0 16px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 24px 9px 21px;
    border-left: 3px solid transparent;
    color: var(--graphite);
    text-decoration: none;
}
.nav a:hover { background: var(--canvas); color: var(--graphite); }
.nav a.active { border-left-color: var(--orange); background: var(--orange-wash); font-weight: 700; }
.nav-icon { flex: none; width: 18px; height: 18px; color: var(--graphite); }
.nav a.active .nav-icon { color: var(--orange); }
.inline-icon { width: 15px; height: 15px; vertical-align: -2px; }
.form-mark { color: var(--ash); margin-left: 4px; }
.nav-group { margin: 20px 24px 6px; font-size: 13px; color: var(--ash); }
/* Grupos recolhíveis (public/js/nav.js) */
.nav-section > summary.nav-group {
    display: flex; align-items: center; justify-content: space-between;
    margin: 14px 0 2px; padding: 6px 24px; cursor: pointer; list-style: none;
}
.nav-section > summary.nav-group::-webkit-details-marker { display: none; }
.nav-section > summary.nav-group::after {
    content: ""; border-left: 5px solid var(--ash); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
    transform: rotate(90deg); transition: transform .15s;
}
.nav-section:not([open]) > summary.nav-group::after { transform: none; }
.nav-section > summary.nav-group:hover { color: var(--graphite); }

/* Caminho no topo da tela */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 4px 0; list-style: none; margin: -12px 0 16px; padding: 0; font-size: 13px; color: var(--ash); }
.breadcrumb li + li::before { content: "›"; margin: 0 8px; color: var(--ash); }
.breadcrumb a { color: var(--ash); text-decoration: none; }
.breadcrumb a:hover { color: var(--orange-deep); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--graphite); }

.sidebar-user { border-top: 1px solid var(--mist); padding: 16px 24px 20px; font-size: 14px; }
.sidebar-user-name { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--graphite); text-decoration: none; }
.sidebar-user-name:hover { color: var(--orange-deep); }
.sidebar-user-meta { display: block; color: var(--ash); margin: 2px 0 10px; }
.sidebar-user-meta, .sidebar-user form { padding-left: 30px; } /* alinha com o nome, depois do ícone */
.link-button { background: none; border: 0; padding: 0; color: var(--orange-deep); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-button:hover { background: none; color: var(--graphite); }

.content { flex: 1; min-width: 0; padding: 32px 40px 48px; max-width: 1280px; }

.mobile-bar { display: none; }

@media (max-width: 860px) {
    .mobile-bar {
        display: flex; align-items: center; justify-content: space-between;
        position: sticky; top: 0; z-index: 20;
        background: var(--paper); border-bottom: 1px solid var(--mist); padding: 10px 16px;
    }
    .mobile-brand { display: flex; align-items: center; gap: 10px; color: var(--graphite); text-decoration: none; font-weight: 700; }
    .menu-toggle { background: var(--paper); color: var(--graphite); border: 1px solid var(--mist); }
    .menu-toggle:hover, .menu-toggle:focus { background: var(--canvas); color: var(--graphite); border-color: #B7BABB; }
    .shell { display: block; }
    .sidebar { display: none; position: static; width: auto; height: auto; border-right: 0; border-bottom: 1px solid var(--mist); }
    .menu-open .sidebar { display: flex; }
    .sidebar-logo { display: none; }
    .content { padding: 20px 16px 40px; }
}

/* ---------- Tipografia ---------- */
h1, h2, h3 { color: var(--graphite); line-height: 1.2; }
h1 { font-size: 30px; font-weight: 900; letter-spacing: -0.015em; margin: 0; }
h2 { font-size: 19px; font-weight: 700; margin: 0 0 12px; }
.muted { color: var(--ash); }
.hint { color: var(--ash); font-size: 13px; margin: 6px 0 0; }
.text-danger { color: var(--danger); }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header p { margin: 6px 0 0; }

/* ---------- Superfícies ---------- */
.card { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 16px; }
.empty { color: var(--ash); padding: 32px 8px; text-align: center; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; border-left: 3px solid; }
.alert-success { background: var(--success-wash); color: var(--success); border-color: var(--success); }
.alert-error { background: var(--danger-wash); color: var(--danger); border-color: var(--danger); }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--mist-soft); vertical-align: middle; }
thead th { font-size: 13px; font-weight: 700; color: var(--ash); border-bottom: 1px solid var(--mist); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFAFA; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
/* Ordenação e busca (public/js/tables.js) */
.table-tools { position: sticky; left: 0; display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.table-tools input[type=search] {
    width: 100%; max-width: 320px; padding: 8px 12px;
    border: 1px solid var(--mist); border-radius: var(--radius); font: inherit; font-size: 14px; color: var(--graphite); background: var(--paper);
}
.table-tools .table-count { font-size: 13px; white-space: nowrap; }
th.sortable { padding-top: 0; padding-bottom: 0; }
button.sort-button {
    min-height: 40px; padding: 0; gap: 6px; justify-content: flex-start;
    background: none; border: 0; border-radius: 0;
    color: inherit; font: inherit; text-align: left; white-space: nowrap;
}
button.sort-button:hover { background: none; color: var(--graphite); }
.sort-indicator { display: inline-block; width: 8px; font-size: 10px; line-height: 1; color: var(--mist); }
.sort-indicator::after { content: "\2195"; } /* ↕ */
th.sortable:hover .sort-indicator { color: var(--ash); }
th[aria-sort] { color: var(--graphite); }
th[aria-sort] .sort-indicator, th[aria-sort]:hover .sort-indicator { color: var(--orange); }
th[aria-sort=ascending] .sort-indicator::after { content: "\25B2"; }  /* ▲ */
th[aria-sort=descending] .sort-indicator::after { content: "\25BC"; } /* ▼ */
/* Linhas aninhadas (redes e empreendimentos, #35) */
.table-tools .tree-all { display: flex; gap: 6px; margin-left: auto; }
.table-tools .tree-all .btn { white-space: nowrap; }
.tree-cell { display: flex; align-items: flex-start; gap: 6px; }
button.tree-toggle, .tree-toggle-space {
    flex: none; width: 24px; height: 24px; min-height: 0; padding: 0; display: grid; place-items: center;
    background: none; border: 0; border-radius: 4px; cursor: pointer;
}
button.tree-toggle::before { content: ""; border-left: 7px solid var(--ash); border-top: 5px solid transparent; border-bottom: 5px solid transparent; transition: transform .15s; }
button.tree-toggle[aria-expanded="true"]::before { transform: rotate(90deg); }
button.tree-toggle:hover { background: var(--canvas); }
button.tree-toggle:hover::before { border-left-color: var(--graphite); }
tr.tree-child td:first-child { padding-left: 30px; }
@media (max-width: 700px) {
    .table-tools { flex-wrap: wrap; }
    .table-tools .tree-all { margin-left: 0; }
}

.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
/* Executar / Não se aplica (Minhas tarefas): botões de mesma largura, sempre alinhados */
.run-actions { display: flex; gap: 8px; justify-content: flex-end; }
.run-actions form { margin: 0; }
.run-actions button { width: 120px; white-space: nowrap; }
@media (max-width: 700px) { .run-actions { flex-direction: column; align-items: stretch; } }
.actions form { margin: 0; }

/* Ações dentro de tabelas: links compactos numa linha, separados pela barra da marca */
td .actions { flex-wrap: nowrap; gap: 0; align-items: center; }
td .actions > * + * { border-left: 1.5px solid var(--orange); margin-left: 10px; padding-left: 10px; }
td .actions .btn-sm, td .actions button.btn-sm {
    min-height: 0; padding: 2px 0; background: none; border: 0; border-radius: 0;
    color: var(--orange-deep); font-weight: 700; white-space: nowrap;
}
td .actions .btn-sm:hover, td .actions button.btn-sm:hover { background: none; color: var(--graphite); text-decoration: underline; text-underline-offset: 3px; }
td .actions .btn-danger, td .actions button.btn-danger { color: var(--danger); }
td .actions .btn-danger:hover, td .actions button.btn-danger:hover { color: var(--danger); background: none; }
td .actions .badge { margin: 0; }
/* Ação principal da linha (ex.: Executar) continua sendo botão */
td .actions button.btn-solid { min-height: 34px; padding: 4px 14px; background: var(--orange-action); color: #fff; border: 1px solid var(--orange-action); border-radius: 2px; }
td .actions button.btn-solid:hover { background: var(--orange-deep); color: #fff; text-decoration: none; }
td .actions > .muted { font-size: 13px; }

/* ---------- Formulários ---------- */
label { display: block; margin: 16px 0 6px; font-weight: 700; font-size: 14px; }
label.check, label[style*="font-weight:normal"] { font-weight: 400; display: flex; align-items: center; gap: 8px; }
label.check[hidden] { display: none; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=month], input[type=file], select, textarea {
    width: 100%; max-width: 520px;
    padding: 10px 12px;
    border: 1px solid var(--mist);
    border-radius: var(--radius);
    font: inherit;
    color: var(--graphite);
    background: var(--paper);
}
input:hover, select:hover, textarea:hover { border-color: #B7BABB; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(241, 90, 36, .18); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--orange-action); }
/* Campos de uma linha com a mesma altura; seleção sem o visual nativo do navegador
   (no Mac ela fica mais baixa e com o texto em outra posição). */
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=month], input[type=file], select:not([multiple]) { height: 44px; }
select:not([multiple]) {
    -webkit-appearance: none; appearance: none;
    padding-right: 36px;
    background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235F6264' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
select[multiple] { min-height: 150px; }
.template-summary { background: var(--canvas); border-radius: 6px; padding: 12px 16px; margin-bottom: 8px; }
.template-summary p { margin: 0 0 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 4px 0; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain:disabled input { background: var(--canvas); color: var(--ash); }
.form-section { font-size: 18px; margin: 28px 0 4px; padding-top: 20px; border-top: 1px solid var(--mist); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.form-actions { margin-top: 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.filter-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-inline label { margin: 0; }
.filter-inline select { width: auto; max-width: 100%; }
.access-table select { margin: 0; min-width: 140px; }
.access-table td { vertical-align: middle; }
.access-table .check { margin: 0; justify-content: center; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 16px; }
/* Grade logo abaixo de um campo: mesmo respiro que os rótulos soltos têm */
input + .filter-grid, select + .filter-grid, .field-error + .filter-grid { margin-top: 16px; }
.filter-grid label { margin-top: 0; }
.filter-grid select, .filter-grid input { max-width: none; }

/* ---------- Botões ---------- */
button, .btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 8px 18px;
    background: var(--orange-action); color: #fff;
    border: 1px solid var(--orange-action); border-radius: 2px;
    font: inherit; font-weight: 700; font-size: 14px;
    text-decoration: none; cursor: pointer;
}
button:hover, .btn:hover { background: var(--orange-deep); border-color: var(--orange-deep); color: #fff; }
.btn-secondary, button.btn-secondary { background: var(--paper); color: var(--graphite); border-color: var(--mist); }
.btn-secondary:hover, button.btn-secondary:hover { background: var(--canvas); color: var(--graphite); border-color: #B7BABB; }
.btn-danger, button.btn-danger { background: var(--paper); color: var(--danger); border-color: #E7B7B3; }
.btn-danger:hover, button.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm, button.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
button:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; }
button:disabled:hover { background: var(--orange-action); border-color: var(--orange-action); }
button.btn-secondary:disabled:hover { background: var(--paper); border-color: var(--mist); }

/* ---------- Selos ---------- */
.task-number { display: inline-block; min-width: 26px; padding: 1px 6px; margin-right: 6px; border-radius: 4px; background: var(--mist-soft); color: var(--graphite); font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; vertical-align: 1px; }
/* Coluna "Nº" das tabelas de atividades (#36): estreita, centralizada */
th.col-number, td.col-number { width: 1%; white-space: nowrap; text-align: center; }
th.col-number button.sort-button { justify-content: center; width: 100%; }
td.col-number .task-number { margin-right: 0; }
td.col-number .task-number + .task-number { margin-left: 2px; }
tr.is-deactivated td { color: var(--ash); }
.btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--mist-soft); color: var(--graphite); white-space: nowrap; }
.badge-success { background: var(--success-wash); color: var(--success); }
.badge-muted { background: var(--mist-soft); color: var(--ash); }
.badge-danger { background: var(--danger-wash); color: var(--danger); }
.badge-warning { background: var(--orange-wash); color: var(--orange-deep); }

/* ---------- Página inicial ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat {
    display: flex; flex-direction: column; gap: 2px;
    background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius);
    padding: 20px 24px; text-decoration: none; color: var(--graphite);
}
.stat:hover { border-color: var(--orange); color: var(--graphite); }
.stat strong { font-size: 40px; font-weight: 900; line-height: 1.1; }
.stat strong.money { font-size: 22px; white-space: nowrap; }
/* Valores em reais (Financeiro, #38): sem quebrar "R$" do número */
td.money, th.money { white-space: nowrap; }
/* Financeiro (#38): caixas preenchem a linha e os números ficam alinhados no pé */
.stats.stats-bottom { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stats-bottom .stat strong { margin-top: auto; }
/* Linha seguinte com poucos quadros: mesma largura dos de cima, sem esticar */
.stats.stats-follow { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stats.stats-money { grid-template-columns: repeat(2, minmax(0, 300px)); }
.stat.is-late strong { color: var(--orange-action); }
.home-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; }
.home-grid .card + .card { margin-top: 0; }
@media (max-width: 1000px) { .home-grid { grid-template-columns: 1fr; } }
/* Página inicial mais baixa: gráfico, mural, painel e cartões na primeira tela */
.stats-compact { grid-template-columns: repeat(2, minmax(0, 220px)); gap: 12px; margin-bottom: 12px; }
.stats-compact .stat { flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 18px; }
.stats-compact .stat strong { font-size: 28px; }
.home-grid .card { padding-top: 16px; padding-bottom: 16px; }
.home-grid .card h2 { margin-top: 0; }
.home-donut .donut { width: 136px; height: 136px; }
.home-donut .donut-hole { width: 92px; height: 92px; }
.home-donut .donut-hole strong { font-size: 20px; }
.home-donut .legend { gap: 3px; font-size: 13px; }
.home-grid .mural-list { min-height: 120px; }
.mural-card { display: flex; flex-direction: column; }
/* Quadro baixo (≈3 avisos) com rolagem; no computador acompanha a altura do gráfico ao lado */
.mural-list { list-style: none; margin: 0; padding: 0 8px 0 0; height: 210px; overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 1001px) { .mural-list { flex: 1 1 0; height: auto; min-height: 180px; } }
.pin-icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; color: var(--orange); }
.pin-badge .pin-icon { width: 12px; height: 12px; color: currentColor; }
.mural-item { padding: 12px 0; border-bottom: 1px solid var(--mist-soft); }
.mural-item:first-child { padding-top: 0; }
.mural-item:last-child { border-bottom: 0; }
.mural-item .muted { font-size: 13px; margin-bottom: 2px; }
.mural-heading { display: block; font-weight: 700; overflow-wrap: anywhere; }
.mural-item .link-button { font-size: 14px; margin-top: 2px; }
/* Lista da tela Mural: título + até 2 linhas do texto; o completo abre na janela */
.mural-excerpt { white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.mural-more { font-size: 14px; margin-top: 2px; }
.mural-more[hidden] { display: none; }

/* ---------- Janela (modal) ---------- */
.modal {
    width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
    padding: 0; border: 1px solid var(--mist); border-top: 3px solid var(--orange);
    border-radius: var(--radius); color: var(--graphite); background: var(--paper);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
}
.modal::backdrop { background: rgba(51, 51, 51, .55); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 12px; border-bottom: 1px solid var(--mist-soft); }
.modal-head h2 { margin: 2px 0 0; overflow-wrap: anywhere; }
.modal-head .muted { font-size: 13px; }
.modal-body { padding: 16px 24px 24px; white-space: pre-line; overflow-wrap: anywhere; }
/* Janela com uma página dentro (execução aberta pelo diário) */
.modal-frame { width: min(860px, calc(100vw - 32px)); height: min(820px, calc(100vh - 48px)); }
.modal-frame[open] { display: flex; flex-direction: column; }
.modal-frame .modal-head { align-items: center; padding: 12px 16px 12px 24px; }
.modal-frame .modal-head h2 { font-size: 16px; margin: 0; }
.modal-frame iframe { flex: 1; width: 100%; border: 0; background: var(--paper); }
@media (max-width: 700px) {
    .modal-frame { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-top: 3px solid var(--orange); border-radius: 0; }
}
.in-window { max-width: none; padding: 20px 24px 32px; }
.in-window .page-header .btn-secondary { display: none; } /* "Voltar": a janela tem o próprio Fechar */
@media (max-width: 700px) { .in-window { padding: 16px; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.field-help { margin: 4px 0 0; font-size: 13px; }

/* ---------- Gráfico de rosca ---------- */
.donut-wrap { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.donut-hole { width: 112px; height: 112px; border-radius: 50%; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-hole strong { font-size: 24px; font-weight: 900; }
.donut-hole span { font-size: 12px; color: var(--ash); }
/* Gráfico de linhas (partials/line-chart) */
.line-chart { position: relative; margin: 0 0 12px; }
.line-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.line-chart svg:focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }
.lc-grid { stroke: #e9ebed; stroke-width: 1; }
.lc-axis { font-size: 11px; fill: var(--ash); }
.lc-axis-title { font-weight: 700; }
.lc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lc-dot { stroke: var(--paper); stroke-width: 2; }
.lc-label { font-size: 12px; fill: var(--graphite); }
.lc-cross { stroke: var(--graphite); stroke-width: 1; opacity: .5; }
.lc-hit { fill: transparent; cursor: crosshair; }
.lc-hit.lc-link { cursor: pointer; }
.lc-tooltip { position: absolute; pointer-events: none; background: var(--paper); border: 1px solid var(--mist); border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 8px 10px; font-size: 13px; min-width: 150px; z-index: 5; }
.lc-tip-title { color: var(--ash); margin-bottom: 4px; }
.lc-tip-row { display: flex; align-items: center; gap: 8px; }
.lc-tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.lc-tip-name { color: var(--ash); }
.lc-legend { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--graphite); }
.lc-legend li { display: flex; align-items: center; gap: 6px; }
.lc-key { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

/* Visão da rede */
.network-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.network-grid .card + .card { margin-top: 0; }
.network-card h2 { margin: 0; }
.network-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.network-card > .muted { margin: 0 0 10px; font-size: 13px; text-align: right; }
.network-rate { font-size: 32px; font-weight: 900; line-height: 1; }
.stacked-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #e4e7eb; margin-bottom: 14px; }
.stacked-bar span { display: block; height: 100%; }
.network-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0 0 16px; }
.network-numbers dt { font-size: 13px; color: var(--ash); }
.network-numbers dd { margin: 0; font-size: 20px; font-weight: 700; }
.network-numbers .is-late dd { color: var(--orange-action); }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend li strong { margin-left: auto; padding-left: 16px; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

/* ---------- Diário ---------- */
.diary-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.diary-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.diary-nav .btn { gap: 4px; }
.segmented { display: inline-flex; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child { border-radius: 2px 0 0 2px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 2px 2px 0; }
/* Atalhos em links (ex.: período do Comparar formulários, #25) */
.segmented .btn { border-radius: 0; margin-left: -1px; }
.segmented .btn:first-child { border-radius: 2px 0 0 2px; margin-left: 0; }
.segmented .btn:last-child { border-radius: 0 2px 2px 0; }
.segmented .btn[aria-current=true] { background: var(--graphite); border-color: var(--graphite); color: #fff; position: relative; }
.period-filter .filter-inline { margin-bottom: 0; }
.period-filter .filter-label { font-weight: 700; }
.period-dates { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-dates label { margin: 0; font-weight: 400; }
.period-dates input[type=date] { width: auto; }
.compare-fields fieldset { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 20px; }
.compare-fields legend { padding: 0; margin-bottom: 6px; font-weight: 700; font-size: 14px; }
.compare-fields .check { margin: 0; }
/* Filtro de hotéis das comparações da SIMPLE (#41) */
.tenant-picker .filter-inline { margin-bottom: 0; }
.tenant-picker .filter-label { font-weight: 700; }
.tenant-picker select { width: auto; max-width: 100%; }
.tenant-picker details { margin-top: 12px; }
.tenant-picker summary { cursor: pointer; font-size: 14px; }
.tenant-picker-group { border: 0; padding: 0; margin: 10px 0 0; }
.tenant-picker-group legend { padding: 0; font-weight: 700; font-size: 13px; color: var(--ash); }
/* No celular o gráfico mantém uma largura legível e rola para o lado */
.chart-scroll { overflow-x: auto; }
@media (max-width: 700px) { .chart-scroll .line-chart { min-width: 560px; } }
@media (max-width: 700px) {
    .period-filter .segmented { display: flex; width: 100%; }
    .period-filter .segmented .btn { flex: 1; padding-left: 4px; padding-right: 4px; }
}
.segmented button[aria-pressed=true] { background: var(--graphite); border-color: var(--graphite); color: #fff; position: relative; }
.diary-legend { font-size: 12px; gap: 4px 14px; margin-bottom: 10px; color: var(--ash); }
.diary-legend .swatch { width: 10px; height: 10px; }

.diary-scroll { overscroll-behavior-x: contain; }
table.diary { --day-w: 24px; --task-w: 220px; width: max-content; border-collapse: separate; border-spacing: 3px; }
table.diary th, table.diary td { padding: 0; border: 0; text-align: center; font-size: 12px; }
table.diary thead th { color: var(--ash); font-weight: 400; }
table.diary th.day, table.diary td.cell { width: var(--day-w); min-width: var(--day-w); max-width: var(--day-w); }
table.diary th.day { line-height: 1.2; padding: 2px 0 4px; }
table.diary th.day .dow { display: block; font-size: 10px; color: #8A8D8F; }
table.diary th.weekend { background: var(--canvas); border-radius: 2px; }
/* Hoje: coluna contínua em laranja suave (a sombra preenche o espaçamento entre células) */
table.diary { --today-wash: #FBDDCF; }
table.diary th.day.today, table.diary td.cell.today { box-shadow: 0 0 0 3px var(--today-wash); }
table.diary th.day.today { background: var(--today-wash); color: var(--orange-deep); font-weight: 900; }
table.diary th.today .dow { color: var(--orange-deep); }
table.diary th.today .dom { display: inline-block; min-width: 16px; background: var(--orange); color: #fff; border-radius: 2px; padding: 0 2px; }
table.diary.is-dense th.day.today, table.diary.is-dense td.cell.today { box-shadow: 0 0 0 2px var(--today-wash); }
table.diary.is-dense { border-spacing: 2px; }
table.diary.is-dense th.day { font-size: 10px; }
table.diary.is-dense th.day .dow { display: none; }
table.diary.is-tiny th.day:not(.mark):not(.today) .dom { visibility: hidden; }
table.diary.is-tiny th.day .dom { display: block; width: var(--day-w); overflow: visible; white-space: nowrap; }
table.diary .diary-months th { text-align: left; font-weight: 700; color: var(--graphite); font-size: 12px; text-transform: capitalize; border-left: 1px solid var(--mist); padding: 0 0 2px 6px; white-space: nowrap; }
table.diary .diary-months th.diary-task { border-left: 0; padding: 0; vertical-align: bottom; }
table.diary .diary-months th span { position: sticky; left: calc(var(--task-w) + 12px); }
/* Sem o destaque genérico de linha (que apagava as células); só o nome da tarefa realça */
table.diary tbody tr:hover td.diary-section { background: none; }
table.diary tbody tr:hover .diary-task { color: var(--orange-deep); }
table.diary .diary-task {
    width: var(--task-w); min-width: var(--task-w); max-width: var(--task-w);
    text-align: left; padding: 4px 12px 4px 0; font-size: 14px; font-weight: 400; color: var(--graphite);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    position: sticky; left: 0; z-index: 2; background: var(--paper);
    box-shadow: -4px 0 0 var(--paper), 4px 0 0 var(--paper), 6px 0 6px -4px rgba(0,0,0,.12);
}
table.diary thead .diary-task { color: var(--ash); font-size: 13px; }
/* Nº em faixa de largura fixa: os nomes ficam alinhados, como uma coluna (#36) */
table.diary .diary-number { display: inline-block; width: 40px; text-align: center; margin-right: 4px; }
table.diary .diary-number .task-number { margin-right: 0; }
table.diary .diary-months th .diary-number { position: static; }
/* Faixa de cada frequência: rótulo com marcador laranja e linha fina em toda a largura */
table.diary .diary-section { text-align: left; font-weight: 700; padding: 18px 0 6px; border-bottom: 1px solid var(--mist); }
table.diary .diary-section span {
    position: sticky; left: 0; display: inline-flex; align-items: center; gap: 8px;
    font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--graphite);
}
table.diary .diary-section span::before { content: ""; width: 10px; height: 10px; border-radius: 2px; background: var(--orange); }
/* Zebra muito leve nos nomes, para seguir a linha até as células */
table.diary tbody tr.zebra .diary-task { background: #F8F8F8; box-shadow: -4px 0 0 #F8F8F8, 4px 0 0 #F8F8F8, 6px 0 6px -4px rgba(0,0,0,.12); }
table.diary .cell { height: 26px; background: var(--mist-soft); border-radius: 2px; }
table.diary .cell.weekend { background: #DCDEDF; }
table.diary .cell a { display: block; width: 100%; height: 26px; border-radius: 2px; }
table.diary .cell a:hover, table.diary .cell a:focus-visible { box-shadow: inset 0 0 0 2px var(--graphite); outline: none; }
@media (max-width: 700px) {
    table.diary { --task-w: 120px; }
    table.diary .diary-task { font-size: 13px; white-space: normal; line-height: 1.25; overflow-wrap: anywhere; }
    .diary-toolbar { justify-content: flex-start; }
    .diary-toolbar .segmented { width: 100%; }
    .diary-toolbar .segmented button { flex: 1; }
    .diary-nav .wide-only { display: none; }
}

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--paper); }
.login-brand {
    position: relative; overflow: hidden;
    background: var(--graphite);
    display: flex; align-items: flex-end;
    padding: 48px;
}
.login-symbol {
    position: absolute; width: 118%; max-width: none;
    right: -38%; top: -12%;
    opacity: .92;
}
.login-tagline {
    position: relative; margin: 0;
    color: #fff; font-weight: 300; font-size: clamp(13px, 1.45vw, 19px); letter-spacing: .22em;
    white-space: nowrap;
}
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(24px, 6vw, 88px); max-width: 560px; }
.login-logo { width: 220px; margin-bottom: 36px; }
.login-panel h1 { font-size: 26px; margin-bottom: 8px; }
.login-panel input { max-width: none; }
.login-single { grid-template-columns: 1fr; place-items: center; background: var(--canvas); }
.login-single .login-panel { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius); margin: 24px 16px; }
@media (max-width: 860px) {
    .login { grid-template-columns: 1fr; }
    .login-brand { min-height: 180px; padding: 24px; }
    .login-symbol { width: 70%; right: -18%; top: -40%; }
    .login-tagline { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Páginas de erro ---------- */
.error-page { max-width: 520px; margin: 14vh auto 0; padding: 0 16px; text-align: center; }
.error-page h1 { margin: 4px 0 12px; }
.error-code { color: var(--orange-deep); font-weight: 700; margin: 20px 0 0; }

/* ---------- Campos numéricos (#33) ---------- */
.field-list { display: grid; gap: 12px; margin-top: 12px; }
.field-card { border: 1px solid var(--mist); border-radius: 6px; padding: 16px; background: var(--paper); }
.field-card label { margin: 0 0 6px; font-size: 13px; }
.field-card label .muted { font-weight: 400; }
.field-card input, .field-card select { max-width: none; height: 42px; padding: 0 12px; }
.fc-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.fc-main > [hidden] { display: block; visibility: hidden; }
.fc-main .btn { height: 42px; min-height: 42px; }
.fc-number { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 16px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--mist); }
.fc-number[hidden] { display: none; }
.fc-number > div { grid-column: span 2; }
.fc-number > .fc-wide { grid-column: span 3; }
.fc-range { display: flex; align-items: center; gap: 8px; }
.fc-range input { flex: 1; min-width: 0; }
.fc-range span { color: var(--ash); }
@media (max-width: 720px) {
    .fc-main { grid-template-columns: 1fr; }
    .fc-main > [hidden] { display: none; }
    .fc-number { grid-template-columns: 1fr; }
    .fc-number > div, .fc-number > .fc-wide { grid-column: auto; }
}
.input-unit { display: flex; align-items: center; gap: 8px; max-width: 520px; }
.input-unit input { flex: 1; }
.input-unit .unit { color: var(--graphite); font-weight: 700; white-space: nowrap; }
.confirm-value { margin: 8px 0 0; padding: 8px 12px; background: #FFF4E5; border-radius: var(--radius); font-weight: 400; display: flex; gap: 8px; align-items: center; }

/* ---------- Mini dashboard (#9) ---------- */
/* Gráficos à esquerda (na largura de "Este mês"), cartões à direita, embaixo do mural */
.dashboard { margin-top: 16px; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dashboard-header h2 { margin: 0; }
.dashboard-grid { display: grid; gap: 16px; align-items: start; }
/* Gráficos e cartões lado a lado: ao lado de cada gráfico, 4 cartões (2 × 2),
   cada um com meia altura do gráfico; topo e base alinhados com ele. As linhas
   vêm do HTML (2 por gráfico); se houver mais cartões, os gráficos esticam. */
.dashboard-grid.has-charts.has-cards { align-items: stretch; }
.dashboard-grid.has-charts.has-cards .dashboard-charts { display: flex; flex-direction: column; gap: 16px; }
.dashboard-grid.has-charts.has-cards .dashboard-charts > .card { margin: 0; flex: 1 1 auto; }
.dashboard-grid.has-charts.has-cards .indicator-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-grid.has-charts.has-cards .indicator-card { padding: 10px 14px; gap: 2px; }
.dashboard-grid.has-charts.has-cards .indicator-card-main { padding: 0; gap: 2px; }
.dashboard-grid.has-charts.has-cards .indicator-card-main strong { font-size: 24px; }
.dashboard-charts > * + * { margin-top: 16px; }
/* Com gráficos, sempre as colunas do quadro de cima (3:2): gráficos um embaixo do
   outro na largura de "Este mês"; cartões na largura do mural (vazia se não houver) */
.dashboard-grid.has-charts { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.chart-card { padding: 14px 16px; }
.chart-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.chart-card-head h3 { margin: 0; font-size: 15px; }
.chart-card-head .muted { font-size: 12px; }
.chart-card .hint { margin-top: 2px; font-size: 12px; }
.chart-card .lc-legend { font-size: 12px; }
.chart-zoom { cursor: zoom-in; }
.modal-chart { width: min(1000px, calc(100vw - 32px)); }
.modal-chart-body { padding: 12px 24px 20px; }
.indicator-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.indicator-card { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.indicator-card-main { display: flex; flex-direction: column; gap: 4px; margin: auto 0; padding: 4px 0; }
.indicator-card .indicator-card-foot { font-size: 12px; }
.indicator-card-main strong { font-size: 28px; font-weight: 900; line-height: 1.15; white-space: nowrap; }
/* Nome sempre com a altura de 2 linhas: números alinhados entre cartões vizinhos */
.indicator-card-name { font-weight: 700; line-height: 1.3; min-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.indicator-card > .muted:first-child { line-height: 1.3; min-height: 1.3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1000px) {
    .dashboard-grid.has-charts { grid-template-columns: 1fr; }
    .dashboard-grid.has-charts.has-cards .indicator-cards { order: -1; grid-template-rows: none !important; }
}

/* ---------- Relatórios comparativos (#11) ---------- */
.report-pickers { display: grid; gap: 8px; margin-top: 16px; }
.report-pickers summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; margin: 8px 0; }
.check-list .check { margin: 0; }

/* Impressão / PDF: só o conteúdo, sem menu nem filtros */
@media print {
    .sidebar, .mobile-bar, .no-print, .table-tools, .breadcrumb { display: none !important; }
    .shell, .content { display: block; margin: 0; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    body { background: #fff; }
}

/* ---------- Abas dentro de uma tela (ex.: Atividades | Formulários) ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--mist); margin: -4px 0 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-bottom: 3px solid transparent; margin-bottom: -1px; color: var(--ash); text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--graphite); }
.tabs a[aria-current] { border-bottom-color: var(--orange); color: var(--graphite); font-weight: 700; }

/* Personalizar dashboard: campos lado a lado, com rótulos e caixas na mesma linha */
.dashboard-add .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.dashboard-add .filter-grid label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dashboard-add .filter-grid > [hidden] { display: block; visibility: hidden; }
@media (max-width: 900px) {
    .dashboard-add .filter-grid { grid-template-columns: 1fr; }
    .dashboard-add .filter-grid > [hidden] { display: none; }
}

/* Ficha do usuário: acessos agrupados por rede (#40) */
.access-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.access-head h2 { margin: 0; }
.access-head [data-show-all][hidden] { display: none; }
.access-table { margin-top: 12px; }
.access-table td select { width: 100%; }
.access-table select:disabled { opacity: .55; cursor: not-allowed; }
.access-table tbody[hidden], .access-table tr[hidden] { display: none; }
.access-table tr.access-group th, .access-table tr.access-group td { background: var(--mist-soft); border-bottom: 0; padding-top: 12px; padding-bottom: 12px; vertical-align: bottom; }
.access-table tr.access-group th { padding-left: 12px; font-size: 15px; white-space: nowrap; vertical-align: middle; }
.access-table tr.access-group td:last-child { padding-right: 12px; }
.access-table tr.access-group-note td { padding: 0 12px 12px; text-align: left; }
.access-table tr.access-group-note .hint { margin: 0; }
.access-group-field { display: block; margin: 0; font-size: 12px; font-weight: 700; color: var(--ash); white-space: nowrap; }
.access-group-field select { display: block; margin-top: 4px; }
.access-table tbody + tbody tr.access-group:first-child th, .access-table tbody + tbody tr.access-group:first-child td { border-top: 16px solid var(--paper); }
.access-table tr.access-columns th { font-size: 13px; font-weight: 700; color: var(--ash); border-bottom: 1px solid var(--mist); white-space: nowrap; padding-top: 8px; padding-bottom: 8px; }
.access-table tr.access-columns th:last-child, .access-table td:last-child { text-align: center; }
