:root {
    color-scheme: light;
    --ink: #182b3c;
    --muted: #637486;
    --line: #dfe6ec;
    --surface: #ffffff;
    --canvas: #f3f6f8;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --danger: #9c3030;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

a { color: inherit; }

.topbar {
    min-height: 68px;
    padding: 0 max(24px, calc((100vw - 1280px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { color: var(--brand); font-size: 1.15rem; font-weight: 750; text-decoration: none; }
.brand-block { display: flex; flex: none; flex-direction: column; margin-right: 16px; line-height: 1.2; white-space: nowrap; }
.organization-name { max-width: 190px; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: .78rem; font-weight: 600; text-decoration: none; text-overflow: ellipsis; }
.organization-name:hover, .organization-name.active { color: var(--brand); text-decoration: underline; }
.topbar-actions, .heading-actions { display: flex; align-items: center; gap: 20px; }
.topbar-actions { flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
.topbar-actions a, .link-button { color: var(--muted); text-decoration: none; }
.topbar-actions a { padding: 6px 8px; border-radius: 6px; white-space: nowrap; }
.topbar-actions a.active { background: #eff6ff; color: var(--brand); font-weight: 650; box-shadow: inset 0 -2px 0 var(--brand); }
.topbar-actions .user-name, .topbar-actions .link-button { padding: 6px 8px; }
.topbar-actions a:hover, .link-button:hover, .clear-link:hover { color: var(--brand); }
.user-name { color: var(--muted); font-size: .92rem; }
/* Faixa da empresa em trabalho, logo abaixo do menu. */
.work-bar { padding: 8px max(24px, calc((100vw - 1280px) / 2)); border-bottom: 1px solid var(--line); background: #f8fafc; }
.work-bar.active { border-bottom-color: #bfdbfe; background: #eff6ff; }
.work-bar-form { display: flex; align-items: center; gap: 10px; }
.work-bar-form label { color: var(--muted); font-size: .82rem; font-weight: 650; white-space: nowrap; }
.work-bar-form select { width: auto; min-width: 280px; max-width: 100%; min-height: 34px; padding: 5px 9px; font-size: .9rem; }
.work-bar.active .work-bar-form label { color: var(--brand); }
.work-bar.active .work-bar-form select { border-color: var(--brand); color: var(--brand); font-weight: 650; }
.topbar form { margin: 0; }
.link-button { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }

.page-shell { width: min(1160px, calc(100% - 40px)); flex: 1 0 auto; margin: 38px auto 72px; }
/* Rodapé: fica no fim da página mesmo quando o conteúdo é curto. */
.site-footer { display: flex; justify-content: space-between; gap: 12px; padding: 16px max(24px, calc((100vw - 1280px) / 2)); border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .82rem; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1, .login-card h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.15rem); letter-spacing: -.035em; }
.page-heading p { margin: 6px 0 0; }
.eyebrow { margin: 0 0 5px !important; color: var(--brand); font-size: .76rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.muted, small { color: var(--muted); }

.panel, .login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 5px 18px rgb(24 43 60 / 4%); }
.panel { padding: 24px; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 9px 16px; border: 1px solid transparent; border-radius: 7px; font: inherit; font-weight: 650; text-decoration: none; cursor: pointer; }
.button.primary { background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { background: white; color: var(--ink); border-color: var(--line); }
.button.secondary:hover { border-color: #9aaab7; }

.search-form { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.search-form input { flex: 1; }
.search-form select { width: auto; min-width: 130px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.board-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; gap: 12px; margin-bottom: 20px; }
.board-filters > .button { justify-self: start; }
.board-filters label { white-space: nowrap; }
/* Painel: abas do modo de exibição. */
.view-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 14px; }
.view-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.generation-list { white-space: normal; color: var(--muted); font-size: .85rem; }
.view-tabs-label { margin-right: 6px; color: var(--muted); font-size: .82rem; font-weight: 650; }
.view-tab { padding: 7px 14px; border: 1px solid #cbd5de; border-radius: 999px; background: white; color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none; }
.view-tab:hover { border-color: var(--brand); color: var(--brand); }
.view-tab.active { border-color: var(--brand); background: var(--brand); color: white; }
/* Painel: tabelas "Por empresa" e "Por tarefa". */
.summary-table td:first-child { min-width: 220px; white-space: normal; }
.summary-table .number { width: 1%; text-align: right; white-space: nowrap; }
.summary-table tfoot th { border-top: 2px solid var(--line); }
.late-number { color: #992f28; font-weight: 750; }
.summary-note { margin: 10px 0 0; font-size: .8rem; }
.progress { position: relative; min-width: 110px; height: 20px; overflow: hidden; border-radius: 999px; background: #eef2f5; }
.progress-bar { position: absolute; inset: 0 auto 0 0; background: #8fd1ad; }
.progress-text { position: relative; display: block; color: #17633e; font-size: .74rem; font-weight: 700; line-height: 20px; text-align: center; }
.catalog-filters { grid-template-columns: 1.5fr repeat(4, minmax(130px, 1fr)) auto; }
.task-kind { display: block; max-width: 300px; margin-top: 2px; white-space: normal; overflow-wrap: anywhere; }
.company-tree-list { display: grid; gap: 10px; }
.company-tree { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.company-tree[open] { border-color: #bfdbfe; box-shadow: 0 3px 12px rgb(37 99 235 / 7%); }
.company-tree-summary { display: grid; grid-template-columns: 32px minmax(180px, 1fr) repeat(5, minmax(85px, auto)); align-items: center; gap: 12px; min-height: 58px; padding: 10px 14px; cursor: pointer; list-style: none; }
.company-tree-summary::-webkit-details-marker { display: none; }
.company-tree-summary:hover { background: #f5f8ff; }
.company-tree-name { color: var(--ink); font-weight: 700; }
.company-tree-count, .company-tree-metric { color: var(--muted); font-size: .84rem; }
.company-tree-metric.overdue { color: #992f28; }
.company-tree-metric.completed { color: #17633e; }
.tree-disclosure { display: inline-grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; border: 1px solid #bfdbfe; border-radius: 5px; background: #eff6ff; color: var(--brand); font: inherit; font-weight: 750; line-height: 1; }
.company-disclosure-icon::before { content: '+'; }
.company-tree[open] .company-disclosure-icon::before { content: '−'; }
.task-tree-table { min-width: 850px; border-top: 1px solid var(--line); }
.task-tree-table th { background: #f8faff; }
.task-tree-table td { padding-top: 11px; padding-bottom: 11px; vertical-align: middle; }
.task-tree-row[hidden] { display: none; }
.task-tree-name { display: flex; align-items: flex-start; gap: 9px; white-space: normal; }
.task-disclosure { margin-top: 1px; cursor: pointer; }
.task-disclosure[aria-expanded="true"] { background: #dbeafe; }
.task-leaf, .tree-leaf { display: inline-grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center; color: #94a3b8; }
.step-row { background: #f8faff; }
.step-name { padding-left: 50px !important; }
.tree-branch { width: 12px; height: 17px; flex: 0 0 12px; margin-top: 2px; border-bottom: 1px solid #93c5fd; border-left: 1px solid #93c5fd; }
.link-action { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: .9rem; font-weight: 650; cursor: pointer; }
.link-action:hover { text-decoration: underline; }
.link-action.danger { color: var(--danger); }
.status { display: inline-block; padding: 4px 9px; border-radius: 999px; background: #eef2f5; color: var(--muted); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.status.pending { background: #fff3d9; color: #835c00; }
.status.late { background: #fde9e7; color: #992f28; }
.status.concluida { background: #e2f3eb; color: #17633e; }
.status.cancelada { background: #eef0f2; color: #596875; }
.status.paused { background: #ede9fe; color: #5b21b6; }
.icon { display: block; flex: none; }
.acoes { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; }
.acoes form { display: contents; }
.acao-painel { display: grid; gap: 6px; width: 230px; margin-top: 8px; padding: 10px; border: 1px solid #dbe3ea; border-radius: 8px; background: white; box-shadow: 0 4px 14px rgb(15 23 42 / 8%); }
.acao-painel[hidden] { display: none; }
.acao-painel label { color: var(--muted); font-size: .78rem; font-weight: 650; }
.acao-painel textarea, .acao-painel input[type="date"] { min-height: 0; padding: 6px 8px; font-size: .85rem; }
.button.small { min-height: 0; padding: 6px 12px; font-size: .85rem; }
.icon-button[aria-expanded="true"] { background: var(--brand); color: white; }
.icon-button { display: inline-grid; width: 32px; height: 32px; place-items: center; padding: 0; border: 1px solid #bfdbfe; border-radius: 6px; background: #eff6ff; color: var(--brand); cursor: pointer; }
.icon-button:hover { background: #dbeafe; }
.icon-button.danger { border-color: #f3c9c4; background: #fdf1ef; color: var(--danger); }
.icon-button.danger:hover { background: #fbe1dd; }
.icon-button:focus-visible, .status-icon:focus-visible { outline: 3px solid rgb(37 99 235 / 30%); outline-offset: 2px; }
.status-icon { display: inline-grid; width: 28px; height: 28px; margin-right: 6px; place-items: center; border-radius: 999px; vertical-align: middle; }
.status-icon.running { background: #dbeafe; color: var(--brand); }
.status-icon.waiting { background: #fff3d9; color: #835c00; }
.status-icon.late { background: #fde9e7; color: #992f28; }
.status-icon.paused { background: #ede9fe; color: #5b21b6; }
.icon-spin { animation: icone-girando 1.2s linear infinite; }
@keyframes icone-girando { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-spin { animation: none; } }
/* Dica que aparece ao passar o mouse (ou focar com Tab) sobre um ícone. */
.icon-tip { position: relative; }
.icon-tip::after { content: attr(data-dica); position: absolute; bottom: calc(100% + 6px); left: 50%; z-index: 20; padding: 4px 8px; border-radius: 5px; background: #1e293b; color: white; font-size: .75rem; font-weight: 600; line-height: 1.3; white-space: nowrap; opacity: 0; pointer-events: none; transform: translateX(-50%); transition: opacity .12s; }
.icon-tip:hover::after, .icon-tip:focus-visible::after { opacity: 1; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd5de; border-radius: 6px; background: white; color: var(--ink); font: inherit; }
input[type="checkbox"] { width: 18px; min-height: 18px; padding: 0; accent-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgb(37 99 235 / 15%); border-color: var(--brand); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 12px 14px; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: 15px 14px; border-bottom: 1px solid #edf1f4; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.table-link { color: var(--brand); font-weight: 650; text-decoration: none; }
.table-link:hover { text-decoration: underline; }
.table-scroll { overflow-x: auto; }
.table-panel td a { color: var(--brand); font-weight: 650; text-decoration: none; }
.table-panel td a:hover { text-decoration: underline; }
.table-panel td small { display: block; font-weight: 400; }
.help-text { display: block; margin-top: 5px; }
.section-panel { margin-top: 22px; }
.section-panel .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 0; }
.simple-list { margin: 0; padding-left: 20px; }
.adjustment-form { display: grid; gap: 18px; }
.adjustment-form .form-grid { align-items: start; }
.adjustment-form > .button { justify-self: start; }
.calendar-scroll { overflow-x: auto; }
.calendar-title { margin: 22px 0 10px; font-size: 1.05rem; }
.calendar-grid { min-width: 880px; table-layout: fixed; }
.calendar-grid td { height: 132px; padding: 8px; vertical-align: top; white-space: normal; border: 1px solid var(--line); }
.calendar-day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-bottom: 5px; }
.calendar-day time { font-size: .85rem; font-weight: 750; }
.calendar-total { color: var(--muted); font-size: .7rem; font-weight: 650; white-space: nowrap; }
/* Executadas e canceladas: só a contagem; clicando, abre a lista. */
.calendar-count { margin: 5px 0; border-radius: 4px; font-size: .72rem; }
.calendar-count summary { display: flex; align-items: center; gap: 5px; padding: 4px 7px; border-left: 3px solid; border-radius: 4px; font-weight: 650; cursor: pointer; list-style: none; }
.calendar-count summary::-webkit-details-marker { display: none; }
.calendar-count summary .icon { width: 13px; height: 13px; }
.calendar-count a { display: block; padding: 2px 7px 2px 10px; color: inherit; overflow-wrap: anywhere; text-decoration: none; }
.calendar-count a:hover { text-decoration: underline; }
.calendar-count.done summary { border-color: #398663; background: #e2f3eb; color: #17633e; }
.calendar-count.cancelled summary { border-color: #8a969e; background: #edf0f2; color: #596875; }
/* Calendário em "Mostrar: Empresas": uma linha por empresa, colorida pela situação do dia. */
.calendar-company { display: block; margin: 5px 0; padding: 5px 7px; border-left: 3px solid; border-radius: 4px; color: inherit; font-size: .72rem; line-height: 1.3; text-decoration: none; }
.calendar-company span { display: block; overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.calendar-company small { display: block; }
.calendar-company:hover, .calendar-company:focus-visible { box-shadow: 0 0 0 2px rgb(37 99 235 / 35%); }
.calendar-company.aberta { border-color: #d09b27; background: #fff7e5; }
.calendar-company.atrasada { border-color: #b74840; background: #fbecea; }
.calendar-company.concluida { border-color: #398663; background: #e2f3eb; color: #17633e; }
.calendar-company.cancelada { border-color: #8a969e; background: #edf0f2; color: #596875; }
.calendar-day.outside-month { background: #f7f9fa; color: #97a4ae; }
.calendar-event { display: block; margin: 5px 0; padding: 6px 7px; border-left: 3px solid #d09b27; border-radius: 4px; background: #fff7e5; color: inherit; font-size: .72rem; line-height: 1.3; text-decoration: none; }
.calendar-event:hover, .calendar-event:focus-visible { box-shadow: 0 0 0 2px rgb(37 99 235 / 35%); }
.calendar-event span, .calendar-event small { display: block; overflow-wrap: anywhere; }
.calendar-event span { font-weight: 650; }
.calendar-more summary { margin: 4px 0; color: var(--brand); font-size: .74rem; font-weight: 650; cursor: pointer; }
/* Linha aberta pelo calendário (âncora #ocorrencia-N). */
.task-tree-row { scroll-margin-top: 90px; }
.task-tree-row:target > td { background: #fef9c3; }
.calendar-event.event-atrasada { border-color: #b74840; background: #fbecea; }
.clear-link { color: var(--muted); font-size: .9rem; }
.empty-state { padding: 45px 20px; text-align: center; }
.empty-state h2 { margin: 0 0 6px; font-size: 1.15rem; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }

.form-grid, .details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.narrow-form { max-width: 720px; }
.form-field { margin-bottom: 18px; }
.section-heading { margin: 30px 0 14px; padding-top: 22px; border-top: 1px solid var(--line); }
.section-heading h2 { margin: 0; font-size: 1.2rem; }
.section-heading p { margin: 4px 0 0; }
.plan-items { display: grid; gap: 14px; }
.plan-item { min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.plan-item legend { padding: 0 6px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.plan-item .form-grid { align-items: start; }
.plan-item-add { margin-top: 12px; }
.field { min-width: 0; }
.task-form-section + .task-form-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.task-form-section h2 { margin: 0; font-size: 1.08rem; }
.task-form-section-description { margin: 4px 0 14px; color: var(--muted); font-size: .92rem; }
.task-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.field label { display: block; margin-bottom: 6px; font-size: .9rem; font-weight: 650; }
.field ul { margin: 6px 0 0; padding-left: 18px; color: var(--danger); font-size: .86rem; }
.field small { display: block; margin-top: 5px; }
.wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.details-grid > div { padding-bottom: 16px; border-bottom: 1px solid #edf1f4; }
.details-grid span, .details-grid strong { display: block; }
.details-grid span { margin-bottom: 5px; color: var(--muted); font-size: .82rem; }
.details-grid strong { font-weight: 600; }

.login-card { width: min(440px, 100%); margin: 56px auto; padding: 32px; }
.error-panel { max-width: 640px; margin: 56px auto; }
.login-card h1 { margin-bottom: 24px; font-size: 1.65rem; }
.login-card .form-fields { display: grid; gap: 18px; margin-bottom: 22px; }
.full-width { width: 100%; }
.form-error, .errorlist { color: var(--danger); }
.messages { margin-bottom: 18px; }
.message { padding: 12px 16px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.message.success { border-color: #a6d6c0; color: #17633e; }
.message.error { border-color: #e0b4b0; background: #fff2f0; color: #8a2824; }
.message.warning { border-color: #ead7a6; background: #fff8e7; color: #6c4c00; }
.message.info { border-color: #b8d5e7; background: #eef7fc; color: #285872; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 680px) {
    .topbar { padding: 12px 18px; flex-wrap: wrap; }
    .topbar-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 4px; }
    .page-shell { width: min(100% - 28px, 1160px); margin-top: 25px; }
    .user-name { display: none; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .heading-actions { width: 100%; }
    .form-grid, .details-grid, .task-form-grid { grid-template-columns: 1fr; }
    .wide { grid-column: auto; }
    .panel { padding: 18px; }
    .search-form { flex-wrap: wrap; }
    .search-form input { flex-basis: 100%; }
    .board-filters { grid-template-columns: 1fr; }
    td, th { padding-right: 20px; }
    .company-tree-summary { grid-template-columns: 30px 1fr; gap: 5px 10px; }
    .company-tree-name { grid-column: 2; }
    .company-tree-count, .company-tree-metric { grid-column: 2; }
    .company-tree-summary .company-disclosure-icon { grid-column: 1; grid-row: 1 / span 6; }
}
