/* Portal de Demandas – Trova Consult */
:root {
  --primary: #0073ea; --primary-hover: #0060c2; --primary-soft: #e6f0fd;
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f8f9fc;
  --text: #323338; --muted: #676879; --border: #d0d4e4; --border-soft: #e6e9ef;
  --danger: #e2445c; --success: #00c875; --warning: #fdab3d;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 32px rgba(16, 24, 40, .18);
  --font: "Figtree", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 16px; font-weight: 500; cursor: pointer; background: var(--surface); color: var(--text); white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); border-color: #f3c3cb; }
.btn-danger:hover { background: #fdecef; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; border-radius: 6px; background: transparent; }
.btn-icon:hover { background: var(--border-soft); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: 13px; }
.field .req { color: var(--danger); }
.field .hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 115, 234, .15); }
textarea.input { resize: vertical; min-height: 120px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Topo ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: 1600px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #0073ea, #00a9ff); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.spacer { flex: 1; }

/* ---------- Página pública ---------- */
.public-hero { background: linear-gradient(180deg, #e8f1fd 0%, var(--bg) 100%); padding: 40px 16px 8px; text-align: center; }
.public-hero h1 { font-size: 28px; margin-bottom: 8px; }
.public-hero p { color: var(--muted); margin: 0 auto; max-width: 560px; }
.public-wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 28px; }
@media (max-width: 640px) { .card-pad { padding: 20px 16px; } .public-hero h1 { font-size: 22px; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin: 0 0 20px; }
.tab { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.dropzone strong { color: var(--primary); }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); background: var(--surface); }
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .fsize { color: var(--muted); font-size: 12px; }
.ficon { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; background: #8b8fa3; flex-shrink: 0; text-transform: uppercase; }
.ficon.pdf { background: #e2445c; } .ficon.img { background: #a25ddc; } .ficon.xls { background: #00a16a; } .ficon.doc { background: #2b6cd4; } .ficon.zip { background: #fdab3d; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fdecef; color: #a3162f; border: 1px solid #f6c5ce; }
.alert-info { background: var(--primary-soft); color: #0b4c94; border: 1px solid #c4dcfa; }

.success { text-align: center; padding: 12px 0; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: #dff8ec; color: #00a35b; display: grid; place-items: center; margin: 0 auto 16px; font-size: 32px; }
.protocol-box { display: inline-flex; flex-direction: column; gap: 4px; padding: 16px 28px; border-radius: var(--radius); background: var(--primary-soft); margin: 16px 0; }
.protocol-box .num { font-size: 26px; font-weight: 800; letter-spacing: .5px; color: var(--primary); }
.protocol-box .code { font-size: 14px; color: var(--muted); }
.protocol-box .code b { color: var(--text); letter-spacing: 2px; }
.muted { color: var(--muted); }
.footer-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--primary)); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0; width: 2px; background: var(--border-soft); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: 12px; }

/* ---------- Pílulas de status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; background: var(--c, #c4c4c4); white-space: nowrap; }
.pill.dark-text { color: #323338; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #e8f1fd, #f5f6f8 60%); }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 20px; margin: 18px 0 4px; }

/* ---------- Painel ---------- */
.app-main { max-width: 1600px; margin: 0 auto; padding: 20px 24px 60px; }
@media (max-width: 640px) { .app-main { padding: 16px 16px 48px; } .topbar-inner { padding: 10px 16px; } }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; text-align: left; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--primary)); }
.kpi:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16, 24, 40, .1); }
.kpi.active { outline: 2px solid var(--c, var(--primary)); outline-offset: -2px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart-card { padding: 16px 18px; }
.chart-card h3 { font-size: 14px; margin-bottom: 12px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 110px 1fr 30px; font-size: 12px; } }
.bar-row .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-track { display: block; height: 18px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--c, var(--primary)); min-width: 2px; transition: width .4s ease; }
.bar-row .bn { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty-chart { color: var(--muted); font-size: 13px; padding: 12px 0; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { width: auto; padding: 7px 10px; font-size: 13px; }
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 320px; }
.toolbar .search .input { width: 100%; padding-left: 32px; }
.toolbar .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; }
.chip.on { background: #fdecef; border-color: #f3c3cb; color: #a3162f; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* ---------- Quadro (tabela estilo Monday) ---------- */
.group { margin-bottom: 22px; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; color: var(--c); font-weight: 700; font-size: 15px; cursor: pointer; user-select: none; background: none; border: 0; padding: 4px 0; }
.group-head .count { color: var(--muted); font-weight: 500; font-size: 13px; }
.group-head .chev { transition: transform .15s; }
.group.collapsed .chev { transform: rotate(-90deg); }
.group.collapsed .table-wrap { display: none; }
.table-wrap { background: var(--surface); border: 1px solid var(--border-soft); border-left: 6px solid var(--c, var(--primary)); border-radius: var(--radius-sm); overflow-x: auto; box-shadow: var(--shadow); }
table.board { width: 100%; border-collapse: collapse; min-width: 1340px; table-layout: fixed; }
.board td { overflow: hidden; text-overflow: ellipsis; }
.board th, .board td { border-bottom: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft); padding: 0 10px; height: 40px; text-align: left; font-size: 13px; white-space: nowrap; }
.board th:last-child, .board td:last-child { border-right: 0; }
.board th { background: var(--surface); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; cursor: pointer; }
.board th.nosort { cursor: default; }
.board tbody tr:hover td { background: #f5f8ff; }
.board tbody tr:last-child td { border-bottom: 0; }
.board .c-id a { font-weight: 600; }
.board .c-desc { color: var(--muted); }
.board td.cell-color { padding: 0; }
.color-cell { width: 100%; height: 40px; border: 0; background: var(--c, #c4c4c4); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; padding: 0 8px; position: relative; transition: filter .15s; }
.color-cell:hover { filter: brightness(.94); }
.color-cell.dark-text { color: #323338; }
.color-cell::after { content: ""; position: absolute; right: 0; top: 0; border-style: solid; border-width: 0 10px 10px 0; border-color: transparent rgba(0,0,0,.18) transparent transparent; opacity: 0; transition: opacity .15s; }
.color-cell:hover::after { opacity: 1; }
.inline-input { border: 1px solid transparent; background: transparent; padding: 5px 6px; border-radius: 4px; width: 100%; font-size: 13px; }
.inline-input:hover { border-color: var(--border); background: var(--surface); }
.inline-input:focus { border-color: var(--primary); background: var(--surface); outline: none; }
.inline-input.late { color: var(--danger); font-weight: 600; }
.late-flag { color: var(--danger); font-size: 11px; font-weight: 700; margin-left: 4px; }
.clip { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.clip:hover { background: var(--border-soft); color: var(--primary); }
.board-empty { text-align: center; padding: 48px 16px; color: var(--muted); background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }

/* Mobile: linhas viram cartões */
@media (max-width: 760px) {
  table.board { min-width: 0; }
  .board thead, .board colgroup { display: none; }
  table.board { table-layout: auto; }
  .board, .board tbody, .board tr, .board td { display: block; width: 100%; }
  .board tr { border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .board td { border: 0; height: auto; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; white-space: normal; max-width: none !important; }
  .board td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; flex-shrink: 0; }
  .board td.cell-color { width: 100%; min-width: 0; }
  .color-cell { height: 30px; border-radius: 6px; max-width: 60%; }
  .inline-input { max-width: 60%; text-align: right; }
  .board .c-desc { overflow: visible; text-overflow: clip; }
  .board td .td-val { text-align: right; overflow: hidden; text-overflow: ellipsis; }
  .table-wrap { overflow-x: visible; }
}

/* ---------- Popover de seleção ---------- */
.popover { position: fixed; z-index: 60; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; width: 210px; display: flex; flex-direction: column; gap: 4px; }
.popover button { border: 0; border-radius: 4px; padding: 8px; color: #fff; font-weight: 600; cursor: pointer; font-size: 13px; background: var(--c); text-align: center; }
.popover button.dark-text { color: #323338; }
.popover button:hover { filter: brightness(.92); }
.popover button.current { outline: 2px solid #323338; outline-offset: 1px; }

/* ---------- Gaveta de detalhes ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 50; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: flex-start; gap: 10px; }
.drawer-head h2 { font-size: 18px; }
.drawer-head .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 32px; }
.drawer .tabs { margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .detail-grid { grid-template-columns: 1fr; } .drawer-body { padding: 16px; } .drawer-head { padding: 14px 16px; } }
.status-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.status-picker button { border: 2px solid transparent; border-radius: 999px; padding: 5px 12px; color: #fff; font-weight: 600; font-size: 12px; background: var(--c); cursor: pointer; opacity: .55; }
.status-picker button.dark-text { color: #323338; }
.status-picker button.current { opacity: 1; border-color: #323338; }
.status-picker button:hover { opacity: 1; }
.info-box { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.info-box b { font-weight: 600; }
.attach-grid { display: flex; flex-direction: column; gap: 8px; }
.attach { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 8px 10px; }
.attach .ainfo { flex: 1; min-width: 0; }
.attach .aname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach .ameta { color: var(--muted); font-size: 12px; }
.attach .thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border-soft); cursor: zoom-in; }
.save-state { font-size: 12px; color: var(--muted); }
.section-title { font-size: 13px; font-weight: 700; margin: 8px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .5); }
.modal-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal-card.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 18px; }
.modal-body img { max-width: 100%; display: block; margin: 0 auto; border-radius: 6px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.user-row:last-child { border-bottom: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }

/* ---------- Menu e toast ---------- */
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; z-index: 35; }
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; font-size: 13px; }
.menu-list .who small { display: block; color: var(--muted); }
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #323338; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13px; animation: toast-in .2s ease; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hide-sm { }
@media (max-width: 640px) { .hide-sm { display: none !important; } }
