/* Identidade visual Zini (zeta2.com.br). Claro/escuro. Será substituído pelo build do Tailwind. */
:root {
  --font-head: "Montserrat", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;

  --bg: #faf9f9;
  --surface: #ffffff;
  --surface-low: #f5f3f3;
  --fg: #1b1c1c;
  --muted: #3d4946;
  --border: #bcc9c5;
  --primary: #006b5e;
  --primary-fg: #ffffff;
  --primary-soft: #bee8e0;
  --link: #006b5e;
  --ok: #006b5e;
  --warn: #8a5a00;
  --danger: #c0001f;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --glow: 0 0 20px rgba(0, 107, 94, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1f1c;
    --surface: #132a26;
    --surface-low: #17332e;
    --fg: #e8efed;
    --muted: #bcc9c5;
    --border: #3d5a54;
    --primary: #51c1af;
    --primary-fg: #0d1f1c;
    --primary-soft: #1f4a43;
    --link: #7fdccd;
    --ok: #51c1af;
    --warn: #f0b85a;
    --danger: #ff8a98;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.35);
    --glow: 0 0 20px rgba(81, 193, 175, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.25; margin: 0 0 12px; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; margin-top: 32px; }
p { margin: 0 0 12px; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* Cabeçalho */
.header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header .container { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; }
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; height: 40px; width: auto; }
.header nav { display: flex; gap: 20px; flex: 1; }
.header nav a {
  font-family: var(--font-head); font-weight: 600; text-decoration: none; color: var(--fg);
  padding: 8px 0; border-bottom: 2px solid transparent;
}
.header nav a:hover { border-bottom-color: var(--primary); }
.header .logout { margin-left: auto; }

/* Cartões e listas */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 16px; box-shadow: var(--shadow-card);
}
.list { list-style: none; padding: 0; margin: 0; }
.list .card { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin-bottom: 12px; }
.list .card a { font-weight: 600; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 10px 24px; border: 0; border-radius: 9999px; background: var(--primary);
  color: var(--primary-fg); font-family: var(--font-head); font-weight: 700; font-size: 0.95rem;
  text-decoration: none; cursor: pointer; transition: box-shadow 0.2s, transform 0.2s;
}
.btn:hover { box-shadow: var(--glow); transform: translateY(-1px); }

/* Formulários */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg);
}
.field textarea { min-height: 120px; }
/* Campo de senha com o botão Mostrar/Ocultar */
.password-field { position: relative; }
.password-field input { padding-right: 92px; }
.password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  min-height: 36px; padding: 0 12px; font: inherit; font-size: 0.875rem; font-weight: 600;
  color: var(--primary); background: transparent; border: 0; border-radius: var(--radius-sm); cursor: pointer;
}
.password-toggle:hover { background: var(--primary-soft); }
.password-toggle[hidden] { display: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.error { color: var(--danger); font-weight: 600; }

/* Selos de status: cor + ícone + texto */
.badge {
  display: inline-flex; gap: 6px; align-items: center; padding: 2px 12px;
  border-radius: 9999px; border: 1px solid currentColor; font-size: 0.85rem; font-weight: 700;
}
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--warn); }
.badge--danger { color: var(--danger); }

/* Mensagens e estado vazio */
.messages {
  list-style: none; margin: 0 0 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--fg); border-left: 4px solid var(--primary);
}
.messages li + li { margin-top: 4px; }
.empty { text-align: center; padding: 48px 24px; }
.empty .btn { margin-top: 8px; }

/* Entrar */
.auth { max-width: 420px; margin: 48px auto; }
.auth .brand { justify-content: center; margin-bottom: 24px; }
.auth .brand img { height: 56px; }
.auth .btn { width: 100%; }

@media (max-width: 600px) {
  .container { padding: 16px; }
  .card { padding: 16px; }
  h1 { font-size: 1.5rem; }
}

.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;
}

/* Barra de busca */
.filters {
  display: flex; flex-wrap: wrap; gap: 0 16px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 16px 0; margin-bottom: 16px; box-shadow: var(--shadow-card);
}
.filters__search { flex: 1 1 280px; }
.filters__status { flex: 0 1 200px; }
.filters__actions { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.actions form { margin: 0; }

/* Meios de contato */
.channels { list-style: none; margin: 0 0 12px; padding: 0; }
.channels li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.channels li:last-child { border-bottom: 0; }
.channels__kind { min-width: 110px; font-weight: 600; }
.muted { color: var(--muted); }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }
.channel-form { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; margin-top: 12px; }
.channel-form .field { flex: 1 1 160px; }
.channel-form .field--check { flex: 0 0 auto; }
.channel-form .field--check label { font-weight: 500; }
.channel-form .field--check input { width: auto; min-height: 0; margin-right: 6px; }
.channel-form .btn { margin-bottom: 16px; }
details { margin-top: 12px; }
summary { cursor: pointer; font-weight: 600; }

/* Consumo contratado */
.usage progress { width: 100%; height: 14px; accent-color: var(--primary); }
.usage--warn progress { accent-color: var(--warn); }
.usage--danger progress { accent-color: var(--danger); }
.usage table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.usage th, .usage td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }

/* ===== Página de detalhe ===== */
.page-head { display: flex; flex-wrap: wrap; gap: 16px 24px; justify-content: space-between; align-items: flex-start; margin: 8px 0 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.9rem; }
.page-head .crumb { margin: 0 0 4px; font-size: 0.9rem; }
.page-head .sub { margin: 0; color: var(--muted); }
.page-head__side { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.page-head__side .actions { margin-top: 0; justify-content: flex-end; }

.section-head { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; margin: 28px 0 12px; }
.card .section-head { margin-top: 0; }
.section-title { font-size: 1.15rem; margin: 28px 0 12px; }
.section-head .section-title { margin: 0; }
.card .section-title:first-child { margin-top: 0; }
.card h3 { font-size: 1rem; margin: 0 0 8px; color: var(--primary); }

/* Botões secundários */
.btn--ghost { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.btn--ghost:hover { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); transform: none; }
.btn--danger { color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); }
.btn--danger:hover { background: transparent; box-shadow: inset 0 0 0 2px var(--danger), 0 0 14px rgba(192, 0, 31, 0.25); }
.btn--sm { min-height: 36px; padding: 6px 16px; font-size: 0.85rem; }
summary.btn { list-style: none; display: inline-flex; }
summary.btn::-webkit-details-marker { display: none; }

/* Dados em grade */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px 24px; margin: 0; }
.facts dt { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.facts > div { min-width: 0; }
.facts dd { margin: 0; font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }

/* Consumo */
.usage__lead { margin: 0 0 8px; }
.meter { appearance: none; -webkit-appearance: none; width: 100%; height: 16px; border: 0; border-radius: 9999px; background: var(--surface-low); overflow: hidden; display: block; }
.meter::-webkit-progress-bar { background: var(--surface-low); border-radius: 9999px; }
.meter::-webkit-progress-value { background: var(--ok); border-radius: 9999px; }
.meter::-moz-progress-bar { background: var(--ok); border-radius: 9999px; }
.usage--warn .meter::-webkit-progress-value { background: var(--warn); }
.usage--warn .meter::-moz-progress-bar { background: var(--warn); }
.usage--danger .meter::-webkit-progress-value { background: var(--danger); }
.usage--danger .meter::-moz-progress-bar { background: var(--danger); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stats > div { background: var(--surface-low); border-radius: var(--radius-sm); padding: 12px 16px; }
.stats dt { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; }
.stats dd.muted { font-family: var(--font-body); font-size: 0.8rem; font-weight: 500; }
.stats__alert { background: transparent !important; box-shadow: inset 0 0 0 2px var(--danger); }
.stats__alert dd { color: var(--danger); }
.table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.table th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 8px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.table .num { text-align: right; }
.table tbody tr:hover { background: var(--surface-low); }
details.add > summary { cursor: pointer; }
details.add form { margin-top: 16px; }
details.add.card { padding: 16px 24px; }

/* Contatos, documentos e histórico */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.contact-grid .card { margin: 0; }
.contact + .contact { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; margin-top: 16px; }
.docs { list-style: none; padding: 0; margin: 0; }
.card--row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 14px 20px; margin-bottom: 8px; }
.docs__name { flex: 1 1 200px; font-weight: 600; }
.timeline { list-style: none; margin: 0 0 32px; padding: 0 0 0 20px; border-left: 2px solid var(--border); }
.timeline li { position: relative; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 6px 0 6px 16px; }
.timeline li::before { content: ""; position: absolute; left: -27px; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg); }
.timeline time { min-width: 130px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 700px) {
  .page-head__side { align-items: flex-start; }
  .page-head__side .actions { justify-content: flex-start; }
}
.stats__alert { grid-column: span 2; }
.facts + .section-title { margin-top: 24px; }
@media (max-width: 700px) { .stats__alert { grid-column: auto; } }
.table-wrap { overflow-x: auto; }
.table td .small, .table td .muted { overflow-wrap: anywhere; }
.timeline li { display: grid; grid-template-columns: 140px 1fr; gap: 4px 16px; }
@media (max-width: 600px) { .timeline li { grid-template-columns: 1fr; } }

/* ===== Assistente (chat) ===== */
.chat { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.chat > * { min-width: 0; }
.chat__side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat__list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.chat__list ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.chat__list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); }
.chat__list li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; color: var(--fg); }
.chat__list li.is-active { background: var(--primary-soft); font-weight: 600; }
.chat__main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); display: flex; flex-direction: column; min-height: 70vh; }
.chat__head { padding: 20px 24px 8px; border-bottom: 1px solid var(--border); }
.chat__head h1 { margin: 0 0 4px; font-size: 1.4rem; }
.chat__head p { margin: 0 0 8px; }
.chat__messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; max-height: 62vh; }
.chat__empty { text-align: center; box-shadow: none; }
.chat__form { display: flex; gap: 12px; align-items: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-low); border-radius: 0 0 var(--radius) var(--radius); }
.chat__form textarea { flex: 1; min-height: 52px; max-height: 160px; padding: 12px; font: inherit; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); resize: vertical; }
.chat__form textarea:focus { border-color: var(--primary); }

.msg { display: flex; gap: 12px; max-width: 85%; }
.msg--user { align-self: flex-end; flex-direction: row-reverse; }
.msg__avatar { flex: 0 0 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 700; font-family: var(--font-head); background: var(--primary-soft); color: var(--fg); }
.msg--assistant .msg__avatar { background: var(--primary); color: var(--primary-fg); }
.msg__body { min-width: 0; }
.msg__text { padding: 12px 16px; border-radius: var(--radius); background: var(--surface-low); overflow-wrap: anywhere; }
.msg--user .msg__text { background: var(--primary); color: var(--primary-fg); border-top-right-radius: 4px; }
.msg--assistant .msg__text { border-top-left-radius: 4px; }
.msg__text p { margin: 0 0 8px; }
.msg__text p:last-child, .msg__text ul:last-child { margin-bottom: 0; }
.msg__text ul { margin: 0 0 8px; padding-left: 20px; }
.msg--error .msg__text { box-shadow: inset 0 0 0 2px var(--danger); }
.msg--typing .msg__text { color: var(--muted); font-style: italic; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .msg--typing .msg__text { animation: none; } }
.msg__sources { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; }
.msg__sources a { display: inline-block; padding: 4px 12px; border: 1px solid var(--primary); border-radius: 9999px; font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.msg__sources a:hover { background: var(--primary-soft); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 0; margin: 0; }
.chip { font: inherit; padding: 8px 16px; border: 1px solid var(--primary); border-radius: 9999px; background: transparent; color: var(--primary); cursor: pointer; }
.chip:hover { background: var(--primary-soft); }
.chat__focus { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

@media (max-width: 800px) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat__side { position: static; }
  .msg { max-width: 100%; }
  .chat__messages { max-height: 55vh; }
}

/* ===== Solicitações ===== */
.ticket { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; align-items: center; }
.ticket__main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 320px; }
.ticket__title { font-weight: 700; font-size: 1.05rem; }
.ticket__meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.small { font-size: 0.85rem; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.radio-row { border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 24px; }
.radio { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.radio input { width: auto; min-height: 0; }

/* Caixas de seleção e opções nunca herdam a largura total dos campos de texto */
.field input[type="checkbox"], .field input[type="radio"] { width: auto; min-height: 0; margin-right: 6px; }
.field--check { align-self: flex-end; padding-bottom: 8px; }
.field--check label { display: inline-flex; align-items: center; font-weight: 500; }

/* Anexos no formulário */
.file-list { list-style: none; margin: 8px 0 0; padding: 0; }
.file-list li { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 6px; background: var(--surface-low); }
.dropzone input[type="file"] { padding: 14px; border: 2px dashed var(--primary); background: var(--surface-low); cursor: pointer; }
kbd { font-family: var(--font-body); font-size: 0.85em; padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-low); }

/* Selos neutro e informativo (status das solicitações) */
.badge--neutral { color: var(--muted); }
.badge--info { color: var(--primary); }
.badge { white-space: nowrap; }

/* Tabela de solicitações */
.card--flush { padding: 0; overflow: hidden; }
.table--tickets { margin: 0; }
.table--tickets th, .table--tickets td { padding: 12px 16px; vertical-align: top; }
.table--tickets td:first-child { white-space: nowrap; }
.table--tickets td:first-child .badge { margin-right: 6px; }

/* Cadastro de usuários */
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 0 0 12px; padding: 8px 16px 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 4px 16px; }
.perm-group legend { font-family: var(--font-head); font-weight: 700; padding: 0 8px; color: var(--primary); }
.perm { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.perm input { width: 18px; height: 18px; }
.perm:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }
.auth__help { margin: 16px 0 0; text-align: center; }

/* Ações na última coluna da tabela */
.table td.num { white-space: nowrap; }
.table td.num > a, .table td.num > form { margin-left: 14px; }

/* Quem está logado e quem está online */
.whoami { margin: 0 0 0 auto; display: flex; flex-direction: column; line-height: 1.25; text-align: right; }
.whoami small { color: var(--muted); }
.header .whoami + .logout { margin-left: 0; }
.online-count { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
@media (max-width: 700px) { .whoami { margin-left: 0; text-align: left; } }

/* Cabeçalho: nome de quem está logado e botão Sair juntos, sempre à direita */
.header__user { margin-left: auto; display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }
.header__user .whoami, .header__user .logout { margin: 0; }
.header nav { flex-wrap: wrap; gap: 8px 18px; }
.table th { white-space: nowrap; }
.table td:nth-child(2), .table td:nth-child(3) { min-width: 0; }

/* Texto só para leitor de tela dentro de tabelas não pode empurrar a largura da página */
.table-wrap { position: relative; }

/* Solicitações filhas e relógio parado */
.origin { margin: 4px 0 0; }
.card--pause { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.card--pause .section-title { color: var(--warn); }
.card--accent { border-color: var(--primary); }
.children-summary { margin: 0 0 12px; }

/* Painel */
.period { flex-direction: row; align-items: center; gap: 8px; }
.period select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font: inherit; }
.stats dd .meter { margin-top: 8px; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 90px 1fr 40px; gap: 12px; align-items: center; }
.bars__label { font-weight: 600; }
.bars__value { text-align: right; font-weight: 700; font-family: var(--font-head); }
.stats dd.small { font-family: var(--font-body); font-weight: 500; font-size: 0.8rem; }

/* Paginação */
.pager { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin: 16px 0 32px; }
.pager__info { margin: 0; color: var(--muted); }
.pager__nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pager__btn { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); text-decoration: none; font-weight: 600; }
a.pager__btn:hover { border-color: var(--primary); background: var(--primary-soft); }
.pager__btn.is-current { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.pager__btn.is-disabled { opacity: 0.45; cursor: not-allowed; }
.pager__gap { padding: 0 4px; color: var(--muted); }
.pager__size { display: flex; align-items: center; gap: 8px; margin: 0; }
.pager__size select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font: inherit; }

/* Menu "Cadastro" (lista suspensa sem JavaScript para abrir; o JS só fecha ao clicar fora) */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; font-family: var(--font-head); font-weight: 600;
  padding: 8px 0; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: "▾"; font-size: 0.8em; transition: transform 0.15s; }
.menu[open] > summary::after { transform: rotate(180deg); }
.menu > summary:hover, .menu[open] > summary, .menu.is-active > summary { border-bottom-color: var(--primary); }
.menu__panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 220px;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.header .menu__panel a { padding: 10px 14px; border-radius: 6px; border-bottom: 0; white-space: nowrap; }
.header .menu__panel a:hover, .header .menu__panel a[aria-current="page"] { background: var(--primary-soft); }
.header nav a[aria-current="page"] { border-bottom-color: var(--primary); }
@media (max-width: 700px) {
  .menu { flex-basis: 100%; }
  .menu__panel { position: static; box-shadow: none; margin-top: 4px; }
}

/* Itens do menu principal com a mesma altura e alinhamento (links e "Cadastro") */
.header nav { align-items: center; }
.header nav > a, .header nav > .menu > summary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0; line-height: 1.4;
  border-bottom: 2px solid transparent;
}
.header nav > a:hover, .header nav > a[aria-current="page"] { border-bottom-color: var(--primary); }
.header nav > .menu { display: flex; align-items: center; }
.menu__panel { top: calc(100% + 2px); }
/* A margem de 12 px dos <details> de formulário não vale para o menu */
details.menu { margin: 0; }

/* Sublinhado do "Cadastro" (aberto, com o mouse em cima ou numa página dele) e seta desenhada */
.header nav > .menu > summary:hover,
.header nav > .menu[open] > summary,
.header nav > .menu.is-active > summary { border-bottom-color: var(--primary); }
.menu > summary::after {
  content: ""; width: 7px; height: 7px; margin-left: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform 0.15s;
}
.menu[open] > summary::after { transform: rotate(225deg) translate(-1px, -1px); }

/* Campos que o JS esconde (o atributo hidden perde para display:grid) */
[data-restricted][hidden] { display: none; }

/* Lista de caixas de marcar com rolagem (escolher pessoas ou departamentos) */
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field > legend { font-family: var(--font-head); font-weight: 600; padding: 0; margin-bottom: 4px; }
.checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; margin-top: 8px; }
.checklist .perm[hidden] { display: none; }
.checklist-hint { margin: 0 0 8px; }
/* Lado a lado, os dois blocos começam e terminam nas mesmas linhas, qualquer que seja o texto */
@media (min-width: 701px) {
  [data-restricted] > fieldset.field { display: flex; flex-direction: column; }
  .checklist-hint { min-height: 3em; } /* até 2 linhas de texto */
  [data-restricted] .checklist { height: 220px; max-height: none; margin-top: 8px; }
}
@media (min-width: 1000px) {
  .checklist-hint { min-height: 1.6em; } /* cabe em 1 linha */
}

/* Fases do projeto */
.phases { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.phase__head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.phase__number { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-family: var(--font-head); font-weight: 700; flex: none; }
.phase__title { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.phase__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; }

/* Barra de progresso (fase e projeto) */
.progress { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.progress__bar { flex: 1 1 160px; height: 10px; border: 0; border-radius: 999px; background: var(--border); overflow: hidden; appearance: none; -webkit-appearance: none; }
.progress__bar::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
.progress__bar::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
.progress__bar::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.progress__text { font-size: 0.875rem; white-space: nowrap; }
.phase__progress { margin: 12px 0; }
.facts__wide { grid-column: 1 / -1; }
.table--tasks td, .table--tasks th { vertical-align: middle; }
tr.is-muted { opacity: 0.6; }

/* Período personalizado do painel */
.period { flex-wrap: wrap; }
.period__custom { display: inline-flex; align-items: center; gap: 6px; }
.period__custom[hidden] { display: none; }
.period__custom input { min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); font: inherit; }

/* Editor de fases */
.phase-rows { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.phase-row { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: start; }
.phase-row__fields { display: grid; grid-template-columns: minmax(180px, 2fr) 1fr 1fr; gap: 8px 12px; }
.phase-row__info, .phase-row__actions { grid-column: 2; }
.phase-row__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.phase-row__actions[hidden], .phase-rows__add[hidden] { display: none; }
.phase-row.is-removed { opacity: 0.55; }
.phase-row.is-removed input[name="row_name"] { text-decoration: line-through; }
.phase-rows__save { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
@media (max-width: 700px) { .phase-row__fields { grid-template-columns: 1fr; } }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kanban__col { background: var(--primary-soft); border-radius: var(--radius-sm); padding: 10px; min-height: 160px; }
.kanban__col.is-over { outline: 2px dashed var(--primary); }
.kanban__title { font-family: var(--font-head); font-size: 1rem; margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; }
.kanban__count { font-weight: 600; color: var(--primary); }
.kanban__cards { display: grid; gap: 8px; min-height: 60px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: grid; gap: 6px; }
.kcard[draggable="true"] { cursor: grab; }
.kcard.is-dragging { opacity: 0.45; }
.kcard.is-blocked { border-left: 4px solid var(--warn, #b7791f); }
.kcard__title { font-weight: 600; }
.kcard__meta { display: flex; flex-wrap: wrap; gap: 6px; }
.kcard__line { margin: 0; }
.kcard__move summary { cursor: pointer; font-size: 0.875rem; color: var(--primary); }
.kcard__move form { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.kcard__move select { min-height: 36px; }
.kanban__empty[hidden], #kanban-error[hidden] { display: none; }
@media (max-width: 900px) { .kanban { grid-auto-flow: row; grid-auto-columns: auto; } }

/* Execução e ondas */
.waves { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.waves__title { font-family: var(--font-head); font-size: 1rem; margin: 0 0 6px; }
.waves__list { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.section-head__links { display: inline-flex; gap: 8px; }

.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

/* Linha do tempo (SVG) */
.timeline-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.timeline-svg { display: block; font-family: var(--font-body, inherit); }
.tl-row-line { stroke: var(--border); stroke-width: 1; }
.tl-week { stroke: var(--border); stroke-width: 1; opacity: 0.5; }
.tl-month-line { stroke: var(--border); stroke-width: 1; }
.tl-month-text { fill: var(--muted, #5b6b66); font-size: 12px; font-weight: 600; }
.tl-label { fill: var(--fg); font-size: 13px; }
.tl-label--phase { font-weight: 700; }
.tl-today { stroke: #c0392b; stroke-width: 2; stroke-dasharray: 4 3; }
.tl-today-text { fill: #c0392b; font-size: 11px; font-weight: 700; }
.tl-arrow { fill: none; stroke: #7a8a85; stroke-width: 1.4; }
.tl-arrow--critical { stroke: #c0392b; stroke-width: 2; }
.tl-arrow-head { fill: #7a8a85; }
.tl-arrow-head--critical { fill: #c0392b; }
.bar-phase-bg { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 1; }
.bar-phase-done { fill: var(--primary); opacity: 0.55; }
.phase--done .bar-phase-bg { fill: var(--primary); opacity: 0.4; }
.bar-task { stroke-width: 1.5; }
.task--todo .bar-task { fill: #dfe6e3; stroke: #8a9b95; }
.task--in_progress .bar-task { fill: #bcd8f5; stroke: #2e6fb5; }
.task--review .bar-task { fill: #f7e3a8; stroke: #b7791f; }
.task--done .bar-task { fill: #a9dcc3; stroke: #1c7c54; }
.task--overdue .bar-task { stroke: #c0392b; stroke-width: 2.5; }
.task--critical .bar-task { stroke: #c0392b; stroke-width: 3; }
.timeline-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0; padding: 0; list-style: none; font-size: 0.875rem; }
.timeline-legend__swatch { display: inline-block; width: 22px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: middle; border: 2px solid transparent; }
.sw-todo { background: #dfe6e3; border-color: #8a9b95; }
.sw-progress { background: #bcd8f5; border-color: #2e6fb5; }
.sw-review { background: #f7e3a8; border-color: #b7791f; }
.sw-done { background: #a9dcc3; border-color: #1c7c54; }
.sw-critical { background: #fff; border-color: #c0392b; }
.sw-phase { background: var(--primary-soft); border-color: var(--primary); }

/* Controle do projeto (marcos, orçamento, riscos) */
.control-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 16px; padding: 0 0 8px; border-bottom: 1px solid var(--border); }
.control-nav a { padding: 6px 2px; font-weight: 600; border-bottom: 2px solid transparent; text-decoration: none; }
.control-nav a[aria-current="page"], .control-nav a:hover { border-bottom-color: var(--primary); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form select { min-height: 36px; }
.tl-milestone { stroke-width: 2; }
.milestone--pending .tl-milestone { fill: #fff; stroke: #2e6fb5; }
.milestone--reached .tl-milestone { fill: #1c7c54; stroke: #1c7c54; }
.milestone--late .tl-milestone { fill: #fff; stroke: #c0392b; }

/* Base de conhecimento */
.knowledge { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 0.8125rem; font-weight: 600; text-decoration: none; }
a.tag:hover { text-decoration: underline; }

/* Avisos da entrada do sistema */
.pending { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 1.0625rem; }
.pending li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

/* Quadro por raias: uma raia por fase */
.kanban-lanes { display: grid; gap: 20px; }
.kanban-lane { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--surface); }
.kanban-lane__title { font-family: var(--font-head); font-size: 1.125rem; margin: 0 0 10px; }
.kanban-lane .kanban__title { font-size: 0.9375rem; }

.menu__label { display: block; padding: 8px 14px 2px; font-size: 0.75rem; color: var(--muted, #667); text-transform: uppercase; letter-spacing: 0.04em; }

.solution { margin-top: 16px; padding: 12px 16px; border-radius: 8px; background: var(--ok-soft, #e6f4ea); box-shadow: inset 4px 0 0 var(--ok, #1b7f4b); }
.solution .section-title { margin-top: 0; color: var(--ok, #1b7f4b); }

/* Entrar */
.auth__lead { margin: 0 0 16px; }
.auth__messages { margin-bottom: 12px; }
.auth__divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 12px; color: var(--muted, #667); }
.auth__divider::before, .auth__divider::after { content: ""; flex: 1; border-top: 1px solid var(--border, #d0d7de); }
.btn--google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.field--check label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.field--check input { width: auto; }

/* Tela inicial: o que está com você e o que você pediu */
.alerts { display: grid; gap: 8px; margin-bottom: 16px; }
.alert { margin: 0; padding: 12px 16px; border-radius: 8px; border: 1px solid; }
.alert--danger { background: var(--danger-soft, #fdecea); border-color: var(--danger, #b3261e); }
.alert--warn { background: var(--warn-soft, #fff4e0); border-color: var(--warn, #b26a00); }
.overview { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.overview__item { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 10px 12px; border-radius: 8px; border-left: 4px solid transparent; }
.overview__item--overdue { border-left-color: var(--danger, #b3261e); background: var(--danger-soft, #fdecea); }
.overview__item--paused { border-left-color: var(--warn, #b26a00); }
.overview__main { display: grid; gap: 2px; min-width: 0; }
.overview__due { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
@media (max-width: 640px) { .overview__item { flex-direction: column; align-items: flex-start; } .overview__due { justify-content: flex-start; text-align: left; } }

/* Lembretes por e-mail */
.reminder { margin: 12px 0; }
.reminder__list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.reminder__add form { margin-top: 12px; max-width: 520px; }

/* Desempenho individual (gráfico de linhas em SVG) */
.perf-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.perf-svg { display: block; min-width: 560px; width: 100%; height: auto; font-family: var(--font-body, inherit); }
.perf-grid { stroke: var(--border); stroke-width: 1; opacity: 0.6; }
.perf-axis { fill: var(--muted); font-size: 12px; }
.perf-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.perf--subject { stroke: var(--primary); fill: var(--primary); }
.perf--global { stroke: #2e6fb5; fill: #2e6fb5; stroke-dasharray: 8 5; }
.perf--department { stroke: #b7791f; fill: #b7791f; stroke-dasharray: 2 5; }
.perf-line.perf--global, .perf-line.perf--department, .perf-line.perf--subject { fill: none; }
.perf-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 0.875rem; }
.perf-legend svg { vertical-align: middle; margin-right: 6px; }
.perf-verdict { font-weight: 700; }

.legend { display: grid; gap: 12px; margin: 0; }
.legend dt { font-weight: 700; }
.legend dd { margin: 2px 0 0; color: var(--muted); }

/* Procedimentos */
.steps { margin: 0; padding-left: 22px; display: grid; gap: 14px; }
.steps li p { margin: 2px 0 0; }
.step-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.step-row legend { font-weight: 700; padding: 0 6px; }
.skills { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
