/* ==========================================================================
   BOSIA Discovery — Design System (fundação de frontend reutilizável)
   Layout: sidebar-editorial · Paleta: Ocean Light
   Escala de espaçamento em múltiplos de 8px · Contraste AA · Responsivo 360px
   ========================================================================== */

:root {
  /* Fallbacks do design system — a fonte de verdade da paleta é public/theme.css (Ocean Light). */
  --bg: #f1f7fb; --bg-2: #e4eef7; --panel: #ffffff; --ink: #0f2433; --muted: #567084;
  --line: #cfe0ee; --line-soft: #e4eef7; --line-strong: #b7cddf;
  --brand: #0e7bb8; --brand-deep: #0b5f8f; --brand-tint: #e7f3fa;
  --ok: #157f4b; --ok-tint: #e8f5ee; --warn: #8a5a00; --warn-tint: #fbf3e3;
  --danger: #b42318; --danger-tint: #fbeceb; --info: #0e7bb8; --info-tint: #e7f3fa;
  --c1: #0e7bb8; --c2: #6a8f4e; --c3: #157f4b; --c4: #a9843f; --c5: #567084; --c6: #b7cddf;
  --radius: 8px; --radius-sm: 6px; --radius-lg: 12px; --radius-xl: 16px;
  --sans: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--brand-tint); }
.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; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.serif { font-family: var(--serif); }
.divider { height: 1px; background: var(--line); border: 0; margin: 24px 0; }

/* ---- Shell --------------------------------------------------------------- */
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 16px 12px; gap: 8px; z-index: 40; }
.brand { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--radius); }
.brand:hover { text-decoration: none; background: var(--bg); }
.brand-mark { width: 32px; height: 32px; border-radius: 6px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; letter-spacing: .5px; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 650; font-size: 14px; color: var(--ink); letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }
.nav-group { margin-top: 8px; }
.nav-label { font-size: 10.5px; letter-spacing: .9px; text-transform: uppercase; color: var(--muted);
  font-weight: 650; padding: 8px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px;
  color: var(--ink); font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.active { background: var(--brand-tint); color: var(--brand-deep); font-weight: 650; }
.nav-item.active .nav-icon { color: var(--brand); }
.app-shell[data-screen="painel"] [data-nav="painel"],
.app-shell[data-screen="empresas"] [data-nav="empresas"],
.app-shell[data-screen="governanca"] [data-nav="governanca"],
.app-shell[data-screen="empresa"] [data-nav="empresa"],
.app-shell[data-screen="fontes"] [data-nav="fontes"],
.app-shell[data-screen="versoes"] [data-nav="versoes"],
.app-shell[data-screen="aprovacoes"] [data-nav="aprovacoes"] {
  background: var(--brand-tint); color: var(--brand-deep); font-weight: 650;
}
.app-shell[data-screen="painel"] [data-nav="painel"] .nav-icon,
.app-shell[data-screen="empresas"] [data-nav="empresas"] .nav-icon,
.app-shell[data-screen="governanca"] [data-nav="governanca"] .nav-icon,
.app-shell[data-screen="empresa"] [data-nav="empresa"] .nav-icon,
.app-shell[data-screen="fontes"] [data-nav="fontes"] .nav-icon,
.app-shell[data-screen="versoes"] [data-nav="versoes"] .nav-icon,
.app-shell[data-screen="aprovacoes"] [data-nav="aprovacoes"] .nav-icon { color: var(--brand); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); display: grid; place-items: center; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-icon svg, .btn svg, .icon-btn svg, .pend svg, .chat-title svg { fill: none; stroke: currentColor; }
.nav-item .badge-count { margin-left: auto; }
.nav-item.is-locked { color: var(--muted); }
.sidebar .journey { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.jstep { display: grid; grid-template-columns: 20px 1fr; gap: 8px; align-items: start; padding: 7px 8px;
  border-radius: 6px; color: var(--ink); }
.jstep:hover { background: var(--bg); text-decoration: none; }
.jstep.active { background: var(--brand-tint); }
.jstep .jdot { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); font-size: 10px; font-weight: 700; color: var(--muted);
  margin-top: 1px; background: var(--panel); }
.jstep.done .jdot { background: var(--ok); border-color: var(--ok); color: #fff; }
.jstep.current .jdot { background: var(--brand); border-color: var(--brand); color: #fff; }
.jstep.blocked { opacity: .72; }
.jstep .jmeta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.jstep .jname { font-size: 12.5px; font-weight: 600; }
.jstep .jstatus { font-size: 11px; color: var(--muted); }
.jstep.current .jstatus { color: var(--brand-deep); font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.user { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; }
.user:hover { background: var(--bg); text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-2); color: var(--brand-deep);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: 0 0 auto;
  border: 1px solid var(--line); }
.user-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--muted); }
.sidebar-scrim { display: none; }

/* Contexto persistente da jornada (empresa → processo → etapa) */
.side-context { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 8px; }
.side-context-label { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700;
  color: var(--muted); padding: 2px 4px 4px; }
.side-context-empresa, .side-context-processo, .side-context-etapa {
  display: flex; flex-direction: column; gap: 1px; padding: 5px 6px; border-radius: 6px;
  color: var(--ink); text-decoration: none; min-width: 0; }
.side-context-empresa:hover, .side-context-processo:hover { background: var(--panel); text-decoration: none; }
.side-context-empresa { border-left: 2px solid var(--brand); }
.side-context-processo { border-left: 2px solid color-mix(in srgb, var(--brand) 45%, var(--line)); }
.side-context-etapa { border-left: 2px solid var(--line-strong); }
.side-context-kicker { font-size: 9.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.side-context-name { font-size: 12px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-context-resume { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: var(--brand); color: #fff;
  font-size: 11.5px; font-weight: 650; }
.side-context-resume:hover { background: var(--brand-deep); text-decoration: none; }
.side-context-resume svg { fill: none; stroke: currentColor; }

/* ---- Topbar -------------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center;
  gap: 16px; padding: 0 24px; background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.icon-btn.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); min-width: 0; flex: 1 1 auto; overflow: hidden; }
.crumbs a { color: var(--muted); white-space: nowrap; }
.crumbs .sep { color: var(--line-strong); }
.crumbs strong { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 210px;
  max-width: 320px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.topbar-search > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-search kbd { margin-left: auto; font-family: var(--sans); font-size: 10px; border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 1px 4px; color: var(--muted); background: var(--panel); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.icon-btn { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; color: var(--muted); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.pend { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); font-size: 12px; font-weight: 600; color: var(--ink); }
.pend:hover { text-decoration: none; background: var(--bg); }
.pend .num { min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger-tint); color: var(--danger);
  display: grid; place-items: center; font-size: 11px; }
.content { width: 100%; max-width: 1480px; margin: 0 auto; padding: 32px; }
.content-wide { max-width: 1480px; }

/* ---- Page head ----------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; gap: 24px; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; }
.page-head > div { max-width: 100%; min-width: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--brand); font-weight: 700; margin-bottom: 8px; }
.display { font-family: var(--serif); font-weight: 600; font-size: 32px; line-height: 1.12; letter-spacing: -.4px; color: var(--ink); }
.display-sm { font-family: var(--serif); font-weight: 600; font-size: 24px; line-height: 1.2; letter-spacing: -.2px; }
.page-sub { margin-top: 8px; color: var(--muted); font-size: 14px; max-width: 72ch; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---- Buttons ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px;
  padding: 0 14px; border-radius: 6px; border: 1px solid transparent; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn svg { width: 15px; height: 15px; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-secondary { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--panel); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, #fff); }
.btn-danger:hover { background: var(--danger-tint); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---- Panels / cards ------------------------------------------------------ */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 36, 51, .04); min-width: 0; }
.panel-head { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 650; letter-spacing: -.1px; }
.panel-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel-body { padding: 20px; }
.panel-body.tight { padding: 0; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line-soft); display: flex;
  align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.panel-note { font-size: 12px; color: var(--muted); }

/* ---- KPI ----------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; justify-content: space-between; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  font-weight: 650; line-height: 1.3; }
.kpi-value { font-size: 26px; font-weight: 650; line-height: 1; letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.kpi-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--muted); }
.kpi-note { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ---- Forms --------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.field .req { color: var(--danger); }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--panel); padding: 9px 11px; font-size: 13.5px; color: var(--ink); min-height: 38px; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, #fff); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.textarea { min-height: 112px; resize: vertical; line-height: 1.55; }
.help { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.error-text { font-size: 11.5px; color: var(--danger); font-weight: 600; display: flex; gap: 4px; align-items: center; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--danger); }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 32px; }
.input-group { display: flex; }
.input-group .input { border-radius: 6px 0 0 6px; }
.input-group .btn { border-radius: 0 6px 6px 0; height: 38px; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 24px;
  text-align: center; background: var(--bg); color: var(--muted); font-size: 12.5px; }
.dropzone strong { color: var(--ink); display: block; margin-bottom: 4px; font-size: 13px; }
.unit-row { display: grid; grid-template-columns: 1.4fr .8fr 1fr auto; gap: 8px; align-items: end; }

/* ---- Filters / chips / segmented ---------------------------------------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filters .search { min-width: 240px; flex: 1 1 260px; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px;
  border-radius: 13px; border: 1px solid var(--line); background: var(--panel); font-size: 11.5px;
  color: var(--ink); font-weight: 500; white-space: nowrap; }
.chip .x { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 0; line-height: 1; font-size: 14px; }
.chip.is-on { background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 35%, #fff); color: var(--brand-deep); }
.chip-tab { cursor: pointer; }
.segmented { display: inline-flex; padding: 3px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 7px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 5px 10px; border-radius: 5px; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--muted); }
.segmented button.is-on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(15,36,51,.08); }
.segmented button:hover { color: var(--ink); }

/* ---- Tabs ---------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 12px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--brand-deep); border-bottom-color: var(--brand); }

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 700; padding: 10px 12px; background: var(--bg);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; white-space: nowrap; }
table.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.table tbody tr:hover { background: color-mix(in srgb, var(--bg) 65%, #fff); }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table .num { text-align: right; font-variant-numeric: tabular-nums; }
table.table .actions { text-align: right; white-space: nowrap; }
table.table .strong { font-weight: 600; color: var(--ink); }
table.table .sub { display: block; font-size: 11px; color: var(--muted); margin-top: 1px; }
.table-compact td, .table-compact th { padding: 8px 12px; }

/* ---- Badges / status ----------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .2px; text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent; }
.badge.ok { background: var(--ok-tint); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, #fff); }
.badge.warn { background: var(--warn-tint); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 24%, #fff); }
.badge.danger { background: var(--danger-tint); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, #fff); }
.badge.info { background: var(--info-tint); color: var(--brand-deep); border-color: color-mix(in srgb, var(--brand) 22%, #fff); }
.badge.neutral { background: var(--bg-2); color: var(--muted); border-color: var(--line); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.danger { color: var(--danger); }
.status.info { color: var(--brand-deep); }
.status.muted { color: var(--muted); }
.badge-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger-tint);
  color: var(--danger); font-size: 10.5px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---- Evidence markers ---------------------------------------------------- */
.evidence { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; vertical-align: 1px; }
.evidence.fact { background: var(--ok-tint); color: var(--ok); }
.evidence.user { background: var(--info-tint); color: var(--brand-deep); }
.evidence.hyp { background: var(--warn-tint); color: var(--warn); }
.evidence.sem-marcador { background: var(--bg-2); color: var(--muted); font-weight: 600; }

/* Proveniência, reuso e conversa da etapa 1 */
.prov-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.prov-count { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
  padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.prov-count strong { font-family: var(--serif); font-size: 20px; line-height: 1; color: var(--ink); }
.prov-count .evidence { align-self: flex-start; font-size: 9.5px; padding: 1px 5px; }
.prov-block { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.prov-block-title { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.prov-source-list { display: flex; flex-direction: column; gap: 6px; }
.prov-source-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; min-width: 0; }
.prov-source-row a { color: var(--brand-deep); font-weight: 600; text-decoration: none; word-break: break-word; }
.prov-source-row a:hover { text-decoration: underline; }
.prov-source-row .sub { flex-basis: 100%; padding-left: 2px; }
.prov-section-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.prov-section-label { font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); }
.prov-source { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line);
  background: var(--bg); border-radius: 999px; padding: 2px 8px; font-size: 10.5px; color: var(--ink); max-width: 100%; }
.prov-source a { color: var(--brand-deep); text-decoration: none; }
.prov-source a:hover { text-decoration: underline; }

/* ---- Grid helpers -------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr); gap: 24px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 8px 16px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); font-weight: 500; }

/* ---- Editorial document -------------------------------------------------- */
.doc { max-width: 860px; }
.doc-head { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 24px; }
.doc-kicker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.doc-title { font-family: var(--serif); font-size: 27px; font-weight: 600; line-height: 1.18; letter-spacing: -.3px; }
.doc-meta { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; color: var(--muted);
  font-size: 11.5px; margin-top: 12px; }
.doc-body { font-size: 13.5px; line-height: 1.7; color: var(--ink); }
.doc-section { padding: 20px 0; border-bottom: 1px solid var(--line-soft); scroll-margin-top: 88px; }
.doc-section.is-highlight { background: color-mix(in srgb, var(--brand) 8%, transparent); border-radius: 10px; box-shadow: inset 3px 0 0 var(--brand); padding-left: 14px; padding-right: 14px; transition: background .4s ease; }
.doc-section:last-child { border-bottom: 0; }
.doc-section h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; margin-bottom: 8px; letter-spacing: -.1px; }
.doc-section h3 .sec-num { color: var(--brand); font-size: 13px; font-family: var(--sans); font-weight: 700;
  display: inline-block; min-width: 24px; vertical-align: 2px; }
.doc-body p { margin: 8px 0; }
.doc-body ul, .doc-body ol { margin: 8px 0 8px 20px; padding: 0; }
.doc-body li { margin: 4px 0; }
.doc-body strong { font-weight: 650; }
.callout { border-left: 3px solid var(--brand); background: var(--brand-tint); padding: 12px 14px;
  border-radius: 0 6px 6px 0; font-size: 12.5px; line-height: 1.6; margin: 12px 0; }
.callout.warn { border-color: var(--warn); background: var(--warn-tint); }
.callout.danger { border-color: var(--danger); background: var(--danger-tint); }
.diagram { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  padding: 16px; margin: 12px 0; }
.flow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow-node { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 7px 10px; font-size: 11.5px; font-weight: 600; min-height: 34px; display: flex;
  flex-direction: column; justify-content: center; }
.flow-node small { font-weight: 500; color: var(--muted); font-size: 10px; }
.flow-node.decision { border-style: dashed; border-color: var(--warn); background: var(--warn-tint); }
.flow-node.start { border-color: var(--brand); background: var(--brand-tint); }
.flow-arrow { color: var(--muted); font-size: 14px; }
.diagram-fallback { margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.doc-actions > .btn-primary, .doc-actions > .btn-danger { margin-left: auto; }
.doc-actions { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border-top: 1px solid var(--line); padding: 12px 0; margin-top: 8px; z-index: 10;
  box-shadow: 0 -6px 12px color-mix(in srgb, var(--bg) 80%, transparent); }

/* ---- Workspace + chat ---------------------------------------------------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.doc-column { min-width: 0; }
.chat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; position: sticky; top: 80px; max-height: calc(100vh - 96px);
  overflow: hidden; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  gap: 8px; justify-content: space-between; }
.chat-title { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.chat-context { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 320px; }
.msg { display: flex; flex-direction: column; gap: 4px; max-width: 94%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg-role { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.msg-bubble { background: var(--bg); border: 1px solid var(--line-soft); border-radius: 8px; padding: 9px 11px;
  font-size: 12.5px; line-height: 1.55; }
.msg.user .msg-bubble { background: var(--brand); color: #fff; border-color: var(--brand); }
.msg.system .msg-bubble { background: transparent; border-style: dashed; color: var(--muted); font-size: 11.5px; }
.msg-meta { font-size: 10px; color: var(--muted); }
.revision { border: 1px solid color-mix(in srgb, var(--warn) 32%, #fff); background: var(--warn-tint);
  border-radius: 8px; padding: 10px; font-size: 12px; }
.revision-head { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--warn);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.diff { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; line-height: 1.5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 6px 8px; margin: 6px 0; }
.diff .add { color: var(--ok); }
.diff .rem { color: var(--danger); }
.revision-actions { display: flex; gap: 6px; }
.composer { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.composer textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; padding: 9px 10px;
  font-size: 12.5px; resize: none; min-height: 62px; background: var(--bg); line-height: 1.5; }
.composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.composer-actions .hint { font-size: 10.5px; color: var(--muted); margin-right: auto; }
.attach { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); cursor: pointer; }
.chat-note { padding: 8px 12px; font-size: 10.5px; color: var(--muted); background: var(--bg); border-top: 1px solid var(--line-soft); line-height: 1.45; }
.suggestions { display: flex; gap: 6px; flex-wrap: wrap; }
.suggestion { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 4px 8px;
  font-size: 10.5px; color: var(--brand-deep); cursor: pointer; }
.suggestion:hover { background: var(--brand-tint); }

/* ---- Journey trail (dashboard) ------------------------------------------ */
.journey-trail { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.trail-step { border: 1px solid var(--line); border-radius: 6px; padding: 10px; background: var(--bg);
  display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.trail-step .n { font-size: 10px; color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.trail-step .t { font-size: 11.5px; font-weight: 650; line-height: 1.25; }
.trail-step .s { font-size: 10px; color: var(--muted); margin-top: auto; }
.trail-step.done { border-color: color-mix(in srgb, var(--ok) 32%, #fff); background: var(--ok-tint); }
.trail-step.current { border-color: var(--brand); background: var(--brand-tint); }
.trail-step.blocked { opacity: .68; }

/* ---- Opportunities ------------------------------------------------------- */
.opp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.opp-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 16px;
  display: flex; flex-direction: column; gap: 10px; }
.opp-card.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.opp-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.opp-title { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.2; }
.opp-problem { font-size: 12px; color: var(--muted); line-height: 1.55; }
.opp-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.opp-meta b { color: var(--ink); font-weight: 600; }
.opp-check { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; }
.opp-check input { width: 16px; height: 16px; accent-color: var(--brand); }
.selection-bar { position: sticky; bottom: 16px; margin-top: 20px; background: var(--brand-deep); color: #fff;
  border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 16px;
  justify-content: space-between; flex-wrap: wrap; box-shadow: 0 8px 24px rgba(15,36,51,.18); z-index: 12; }
.selection-bar .btn-secondary { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.28); }
.selection-bar .btn-secondary:hover { background: rgba(255,255,255,.2); }

/* ---- Timeline ------------------------------------------------------------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 9px; top: 18px; bottom: 0;
  width: 1px; background: var(--line); }
.tl-dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  background: var(--panel); display: grid; place-items: center; font-size: 9px; color: var(--muted); z-index: 1; }
.tl-item.done .tl-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.tl-item.current .tl-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.tl-body { min-width: 0; }
.tl-title { font-size: 12.5px; font-weight: 600; }
.tl-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- Charts --------------------------------------------------------------- */
.chart { position: relative; width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart-grid line { stroke: var(--line-soft); stroke-width: 1; }
.chart-axis text { fill: var(--muted); font-size: 9.5px; font-family: var(--sans); }
.chart-empty { display: grid; place-items: center; min-height: 180px; color: var(--muted); font-size: 12px; }
.chart-note { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.charts-grid .span-2 { grid-column: span 2; }

/* ---- States --------------------------------------------------------------- */
.state-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.state-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 20px;
  display: flex; flex-direction: column; gap: 12px; min-height: 190px; }
.state-label { font-size: 10px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; padding: 32px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--bg); }
.empty-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-tint); color: var(--brand);
  display: grid; place-items: center; }
.empty-title { font-weight: 650; font-size: 13px; }
.empty-text { color: var(--muted); font-size: 12px; max-width: 42ch; }
.skeleton { background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg) 37%, var(--bg-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 4px; height: 12px; }
.skeleton.w-60 { width: 60%; } .skeleton.w-40 { width: 40%; } .skeleton.w-80 { width: 80%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); font-size: 12.5px; line-height: 1.5; }
.alert .alert-ico { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; }
.alert.info { border-color: color-mix(in srgb, var(--brand) 28%, #fff); background: var(--brand-tint); }
.alert.info .alert-ico { background: var(--brand); color: #fff; }
.alert.warn { border-color: color-mix(in srgb, var(--warn) 30%, #fff); background: var(--warn-tint); }
.alert.warn .alert-ico { background: var(--warn); color: #fff; }
.alert.danger { border-color: color-mix(in srgb, var(--danger) 28%, #fff); background: var(--danger-tint); }
.alert.danger .alert-ico { background: var(--danger); color: #fff; }
.alert.ok { border-color: color-mix(in srgb, var(--ok) 28%, #fff); background: var(--ok-tint); }
.alert.ok .alert-ico { background: var(--ok); color: #fff; }
.alert strong { display: block; margin-bottom: 2px; }
.progress { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.meter { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.meter .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.meter .bar span { display: block; height: 100%; background: var(--brand); }
.footer-note { margin-top: 24px; font-size: 11px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* ---- Auth (login) --------------------------------------------------------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr); }
.auth-brand { background: var(--brand-deep); color: #fff; padding: 48px; display: flex; flex-direction: column;
  justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand .brand-name, .auth-brand .brand-sub { color: #fff; }
.auth-brand .brand-mark { background: #fff; color: var(--brand-deep); }
.auth-graphic { position: absolute; inset: 0; opacity: .1; pointer-events: none; }
.auth-copy { position: relative; max-width: 520px; }
.auth-kicker { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: #b9d9ee; font-weight: 700; margin-bottom: 16px; }
.auth-title { font-family: var(--serif); font-size: 38px; line-height: 1.14; font-weight: 600; letter-spacing: -.5px; }
.auth-text { margin-top: 16px; color: #cfe3f1; font-size: 14px; line-height: 1.65; max-width: 44ch; }
.auth-points { display: flex; flex-direction: column; gap: 12px; margin-top: 32px; }
.auth-point { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; color: #dcebf5; }
.auth-point b { color: #fff; display: block; font-size: 13px; margin-bottom: 1px; }
.auth-point .pin { width: 22px; height: 22px; border-radius: 50%; background: color-mix(in srgb, #ffffff 16%, var(--brand-deep));
  display: grid; place-items: center; font-size: 11px; flex: 0 0 auto; }
.auth-form-wrap { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.auth-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.auth-form h1 { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.auth-form .page-sub { margin-top: -8px; }
.auth-alt { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.check input { accent-color: var(--brand); }
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 40px; }
.password-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0;
  background: transparent; color: var(--muted); cursor: pointer; padding: 4px;
  min-width: 28px; min-height: 28px; display: grid; place-items: center; border-radius: var(--radius-sm); }
.password-wrap button:hover { background: var(--bg); color: var(--ink); }

/* ---- Modal / toast -------------------------------------------------------- */
.overlay { position: fixed; inset: 0; background: rgba(9, 27, 40, .48); display: none; z-index: 90; }
.overlay.is-open { display: block; }
.modal { position: fixed; inset: 0; display: none; place-items: center; padding: 16px; z-index: 100; }
.modal.is-open { display: grid; }
.modal-card { width: 100%; max-width: 520px; background: var(--panel); border-radius: var(--radius-lg);
  border: 1px solid var(--line); box-shadow: 0 24px 64px rgba(9,27,40,.24); overflow: hidden; }
.modal-head { padding: 20px 24px 0; }
.modal-title { font-family: var(--serif); font-size: 21px; font-weight: 600; }
.modal-body { padding: 12px 24px 20px; display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.toast-wrap { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 120; }
.toast { background: var(--ink); color: #fff; border-radius: 6px; padding: 10px 14px; font-size: 12px;
  box-shadow: 0 8px 24px rgba(9,27,40,.22); max-width: 360px; display: flex; gap: 8px; align-items: center; }

/* ---- Snapshot (docs/preview-visual.html) --------------------------------- */
.snapshot { background: var(--bg-2); }
.snapshot-index { position: static; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 24px 32px; }
.snapshot-index-inner { max-width: 1480px; margin: 0 auto; }
.snapshot-index h1 { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.snapshot-index p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.snapshot-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.snapshot-nav a { font-size: 11.5px; border: 1px solid var(--line); border-radius: 12px; padding: 3px 9px;
  color: var(--ink); background: var(--bg); }
.snapshot-nav a:hover { background: var(--brand-tint); text-decoration: none; }
.preview-section { max-width: 1480px; margin: 0 auto; padding: 32px; scroll-margin-top: 24px; }
.preview-label { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-label .pid { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--brand); text-transform: uppercase; }
.preview-label h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.preview-label p { color: var(--muted); font-size: 12px; }
.preview-frame { border: 1px solid var(--line-strong); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: 0 8px 32px rgba(15,36,51,.08); background: var(--bg); }
.snapshot .preview-frame .app-shell { min-height: auto; }
.snapshot .preview-frame .sidebar { position: static; height: auto; min-height: 100%; align-self: stretch; }
.snapshot .preview-frame .topbar { position: static; }
.snapshot .preview-frame .chat { position: static; max-height: none; }
.snapshot .preview-frame .content { padding: 24px; }
.snapshot .preview-frame .doc-actions { position: static; }
.snapshot .preview-frame .selection-bar { position: static; }
.snapshot .menu-btn, .snapshot .sidebar-scrim { display: none !important; }
.snapshot .preview-frame .auth-shell { min-height: 680px; }
.preview-frame .chart { max-width: 100%; }

/* ---- Premium polish layer ------------------------------------------------ */
/* Refinamento visual: escala, ritmo, foco visível e acabamento dos estados.
   Mantém o Design Freeze (sidebar-editorial · Ocean Light) sem redesenho. */
:root {
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 40px;
  --shadow-1: 0 1px 2px rgba(15, 36, 51, .05);
  --shadow-2: 0 8px 24px rgba(15, 36, 51, .09);
  --shadow-3: 0 20px 48px rgba(9, 27, 40, .18);
  --ease: cubic-bezier(.2, .7, .3, 1);
}
html { scroll-behavior: smooth; }
body {
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
h1, h2, h3, .display, .display-sm, .doc-title, .auth-title { text-wrap: balance; }
.page-sub, .doc-body p, .empty-text, .panel-sub { text-wrap: pretty; }
.sidebar, .chat-log, .table-wrap, .tabs { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.sidebar::-webkit-scrollbar, .chat-log::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.sidebar::-webkit-scrollbar-thumb, .chat-log::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
  background: var(--line-strong); border: 3px solid var(--panel); border-radius: 999px;
}

/* Shell */
.sidebar { padding: 20px 12px 12px; gap: 4px; }
.brand { padding: 8px 8px 12px; margin-bottom: 4px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; font-size: 16px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .18); }
.nav-group { margin-top: 4px; }
.nav-label { padding: 12px 10px 4px; font-size: 10px; letter-spacing: 1px; }
.nav-item { min-height: 36px; padding: 8px 10px; border-radius: 7px;
  transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease); }
.nav-item.active,
.app-shell[data-screen="painel"] [data-nav="painel"],
.app-shell[data-screen="empresas"] [data-nav="empresas"],
.app-shell[data-screen="governanca"] [data-nav="governanca"],
.app-shell[data-screen="empresa"] [data-nav="empresa"],
.app-shell[data-screen="fontes"] [data-nav="fontes"],
.app-shell[data-screen="versoes"] [data-nav="versoes"],
.app-shell[data-screen="aprovacoes"] [data-nav="aprovacoes"] {
  box-shadow: inset 2px 0 0 var(--brand);
}
.jstep { min-height: 36px; padding: 7px 10px; transition: background .15s var(--ease); }
.jstep .jdot { width: 19px; height: 19px; }
.sidebar-foot { padding-top: 12px; }

/* Topbar */
.topbar { padding: 0 28px; box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 70%, transparent); }
.crumbs { gap: 6px; }
.crumbs a:hover { color: var(--ink); }
.topbar-search { height: 38px; border-radius: 7px; transition: border-color .15s var(--ease), background .15s var(--ease); }
.topbar-search:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); background: var(--panel); }
.icon-btn { transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.icon-btn:hover { border-color: var(--line-strong); }
.pend { transition: background .15s var(--ease), border-color .15s var(--ease); }
.pend:hover { border-color: color-mix(in srgb, var(--brand) 32%, var(--line)); }

/* Cabeçalho e ritmo editorial */
.display { font-size: 34px; }
.page-sub { font-size: 14.5px; line-height: 1.6; }
.page-head { margin-bottom: 28px; }
.panel-head { padding: 18px 22px; }
.panel-body { padding: 22px; }
.panel-foot { padding: 14px 22px; }

/* Botões */
.btn { height: 36px; border-radius: 7px; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease); }
.btn:active { transform: translateY(1px); }
.btn-primary { box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 30%, transparent); }
.btn-primary:hover { box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 28%, transparent); }
.btn-secondary:hover, .btn-ghost:hover { border-color: var(--line-strong); }
.btn[disabled], .btn.is-disabled { filter: saturate(.55); }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* KPIs e cartões */
.kpi { padding: 18px 18px 16px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.kpi:hover { border-color: color-mix(in srgb, var(--brand) 34%, var(--line)); box-shadow: var(--shadow-2); transform: translateY(-1px); }
.kpi-label { font-size: 10.5px; letter-spacing: .7px; }
.kpi-value { font-size: 30px; letter-spacing: -.8px; }
.kpi-value small { font-size: 12px; }
.kpi-note { font-size: 11.5px; }
.panel { box-shadow: var(--shadow-1); }
.opp-card, .state-card { transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.opp-card:hover, .state-card:hover { border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); box-shadow: var(--shadow-2); }
.opp-title { font-size: 19px; }

/* Formulários */
.input, .select, .textarea { border-radius: 7px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; }
.field label { letter-spacing: .1px; }
.help { font-size: 12px; }

/* Chips, tabs e segmented */
.chip { height: 28px; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.chip-tab { height: 32px; }
.chip-tab:hover, .chip.is-on:hover { background: var(--brand-tint); border-color: color-mix(in srgb, var(--brand) 40%, #fff); }
.chip .x { min-width: 20px; min-height: 20px; display: inline-grid; place-items: center; border-radius: 50%; }
.chip .x:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); color: var(--ink); }
.segmented button { min-height: 30px; transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease); }
.tab { min-height: 40px; border-radius: 7px 7px 0 0; transition: background .15s var(--ease), color .15s var(--ease); }
.tab:hover { background: color-mix(in srgb, var(--bg) 70%, transparent); }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

/* Tabelas como componente de primeira classe */
table.table th { padding: 11px 14px; background: color-mix(in srgb, var(--bg) 72%, var(--panel));
  box-shadow: inset 0 -1px 0 var(--line); }
table.table td { padding: 12px 14px; }
table.table tbody tr { transition: background .12s var(--ease); }
table.table tbody tr:focus-within { background: var(--brand-tint); }
table.table tbody tr:hover { background: color-mix(in srgb, var(--bg) 80%, #fff); }
.table-wrap { border-radius: 0 0 var(--radius) var(--radius); }

/* Badges e status */
.badge { padding: 3px 8px; border-radius: 999px; letter-spacing: .35px; }
.status .dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent); }

/* Chat / revisão */
.chat { border-radius: 10px; box-shadow: var(--shadow-1); }
.msg-bubble { border-radius: 4px 10px 10px 10px; }
.msg.user .msg-bubble { border-radius: 10px 4px 10px 10px; }
.msg-role { letter-spacing: .6px; }
.composer textarea { border-radius: 7px; }
.revision { border-radius: 10px; }
.diff { border-radius: 7px; }
.suggestion { min-height: 28px; transition: background .15s var(--ease), border-color .15s var(--ease); }
.suggestion:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }

/* Estados e feedback */
.alert { border-left-width: 3px; box-shadow: var(--shadow-1); }
.empty { border-radius: 10px; }
.state-card { border-radius: 10px; }
.progress, .meter .bar { height: 7px; }
.selection-bar { border: 1px solid color-mix(in srgb, var(--brand) 40%, #062033); }

/* Gráficos */
.chart rect { transition: opacity .12s var(--ease); }
.chart rect:hover { opacity: .82; }
.chart svg text { font-variant-numeric: tabular-nums; }
.chart-legend { gap: 14px; }
.chart-legend span { font-size: 11.5px; }

/* Snapshot */
.snapshot-index { box-shadow: var(--shadow-1); }
.snapshot-nav a { min-height: 28px; display: inline-flex; align-items: center; transition: background .15s var(--ease), border-color .15s var(--ease); }
.snapshot-nav a:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.preview-label h2 { letter-spacing: -.2px; }

/* Foco visível consistente em alvos interativos */
.nav-item:focus-visible, .jstep:focus-visible, .tab:focus-visible, .chip-tab:focus-visible,
.segmented button:focus-visible, .suggestion:focus-visible, .snapshot-nav a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

@media (min-width: 1440px) {
  .content { padding: 40px 40px 56px; }
}

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid.cols-5, .kpi-grid.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .journey-trail { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .chat { position: static; max-height: none; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .charts-grid { grid-template-columns: minmax(0, 1fr); }
  .charts-grid .span-2 { grid-column: auto; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { padding: 32px; min-height: 320px; }
  .auth-title { font-size: 30px; }
}
@media (max-width: 1024px) {
  .snapshot .preview-frame .sidebar { display: none; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; width: 272px;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 0 1px var(--line); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim.is-open { display: block; position: fixed; inset: 0; background: rgba(9,27,40,.4); z-index: 35; }
  .icon-btn.menu-btn { display: grid; }
  .content { padding: 24px; }
  .page-head { gap: 16px; }
  .state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  /* Alvos de toque confortáveis sem comprimir a hierarquia do desktop. */
  .snapshot-nav a, .segmented button, .suggestion, .chip-tab, .btn-sm { min-height: 32px; display: inline-flex; align-items: center; }
  .password-wrap button { width: 32px; height: 32px; }
  .chip .x { min-width: 24px; min-height: 24px; }
  .display { font-size: 27px; }
  .topbar { padding: 0 16px; gap: 8px; height: 56px; }
  .topbar-search { display: none; }
  .content { padding: 20px 16px 40px; }
  .kpi-grid, .kpi-grid.cols-5, .kpi-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .grid-2, .grid-3, .opp-grid { grid-template-columns: minmax(0, 1fr); }
  .journey-trail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .unit-row { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dt { font-size: 11px; }
  .kv dd { margin-bottom: 8px; }
  .preview-section { padding: 20px 12px; }
  .auth-brand { padding: 24px; }
  .doc-title { font-size: 23px; }
  .doc-actions { position: static; }
  .col-optional { display: none; }
  .toast-wrap { right: 12px; left: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
@media (max-width: 640px) {
  .crumbs a:not(:first-child), .crumbs .sep { display: none; }
  .crumbs strong::before { content: "·"; margin-right: 8px; color: var(--line-strong); }
}
@media (max-width: 480px) {
  .pend-label, .meta-sep { display: none; }
  .doc-meta { gap: 4px 12px; }
  .kpi-grid, .kpi-grid.cols-5, .kpi-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .state-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-direction: column; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
  .content { padding: 16px 12px 32px; }
  .chart-legend { font-size: 10px; }
  .journey-trail { grid-template-columns: minmax(0, 1fr); }
  .topbar-actions .btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Sprint 1 — acesso, sessão e conta
   ========================================================================== */
[hidden] { display: none !important; }

.logout-link {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: left;
}
.logout-link svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; }
.logout-link:hover { background: var(--danger-tint); color: var(--danger); }
.logout-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* T20 / T21 / T22 — foco total no estado, sem shell de navegação */
.state-focus-mode .app-shell { grid-template-columns: minmax(0, 1fr); }
.state-focus-mode .sidebar,
.state-focus-mode .sidebar-scrim,
.state-focus-mode .topbar { display: none !important; }
.state-focus-mode .main { min-height: 100vh; }
.state-focus-mode .content {
  max-width: none; min-height: 100vh; display: grid; place-items: center;
  padding: 48px 24px;
}
.state-focus { width: 100%; display: grid; place-items: center; }
.state-focus-card {
  width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: 0 1px 2px rgba(15, 36, 51, .04);
  padding: 40px; display: flex; flex-direction: column; gap: 16px;
}
.state-focus-card .display { font-size: 30px; }
.state-focus-icon {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; font-weight: 700; line-height: 1;
}
.state-focus-icon.warn { background: var(--warn-tint); color: var(--warn); }
.state-focus-icon.danger { background: var(--danger-tint); color: var(--danger); }
.state-focus-icon.neutral { background: var(--bg-2); color: var(--muted); }
.state-focus-card .alert { margin-top: 4px; }
.state-focus-card .row .btn { flex: 0 1 auto; }
.state-context {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--bg); font-size: 12px;
}
.state-context-label { font-size: 11px; letter-spacing: .6px; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.state-context code { font-size: 11.5px; color: var(--ink); word-break: break-all; }
.state-context .muted { font-size: 11.5px; }
.state-focus-card .status { font-size: 12px; }
.state-focus-card .status.ok { background: var(--ok-tint); border-radius: var(--radius); padding: 8px 10px; }
#conta-empresas .sub { display: block; margin-top: 2px; font-size: 10.5px; color: var(--muted); }
#conta-empresas code { font-size: 10.5px; word-break: break-all; }
#conta-id { word-break: break-all; }

@media (max-width: 640px) {
  .state-focus-mode .content { padding: 24px 16px; }
  .state-focus-card { padding: 24px; }
  .state-focus-card .display { font-size: 25px; }
  .state-focus-card .row .btn { flex: 1 1 100%; }
}

/* Pendências reais do usuário (contagem nunca simulada) */
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-width: min(360px, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(15, 36, 51, .16); z-index: 60; overflow: hidden;
}
.notif-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--bg); text-decoration: none; }
.notif-item .notif-title { font-size: 12.5px; font-weight: 650; }
.notif-item .notif-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.notif-item .notif-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 10.5px; color: var(--muted); }
.notif-empty { padding: 20px 16px; text-align: center; color: var(--muted); font-size: 12px; }
@media (max-width: 640px) {
  .notif-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}

@media (max-width: 480px) {
  .auth-form-wrap { padding: 24px 16px 32px; }
  .auth-title { font-size: 26px; }
  .auth-form { max-width: none; }
  .auth-alt { align-items: flex-start; }
}

/* ---- Sprint 4 · Empresas e processos (T02–T04) --------------------------- */
.unit-row-simple { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.unit-row-simple .field { gap: 0; }
.status[href] { text-decoration: none; }
.status[href]:hover { text-decoration: underline; }
#empresa-meta .chip { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#empresa-meta a.chip { display: inline-block; line-height: 26px; }
#empresa-processos-corpo .meter { min-width: 140px; }
@media (max-width: 640px) {
  .unit-row-simple { grid-template-columns: minmax(0, 1fr); }
  .unit-row-simple .btn { justify-self: start; }
}

/* ---- Sprint 7 · Fontes e evidências (T07) -------------------------------- */
#fontes-meta { row-gap: 6px; }
#fontes-meta .chip { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#fontes-meta a.chip { display: inline-block; line-height: 26px; }

.fontes-progresso { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
#fontes-progresso-passos .tl-item.done .tl-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
#fontes-progresso-passos .tl-item.current .tl-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
#fontes-progresso-bar { transition: width .5s var(--ease, ease); }

#fontes-tabela tbody tr.is-selected { background: var(--brand-tint); }
#fontes-tabela tbody tr.is-selected td { border-bottom-color: color-mix(in srgb, var(--brand) 22%, #fff); }
#fontes-tabela .fonte-cell { min-width: 220px; max-width: 360px; }
#fontes-tabela .fonte-url { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; word-break: break-all; }
#fontes-tabela .fonte-cell .strong { display: block; }
#fontes-tabela .actions .btn { margin-left: 4px; }
#fontes-tabela .actions .icon-btn { vertical-align: middle; }

.fontes-detail-head { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.fontes-detail-title { font-family: var(--serif); font-size: 20px; line-height: 1.2; color: var(--ink); }
.fontes-detail-url { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.fontes-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 0 0; }
.fontes-pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.fontes-section { padding-top: 16px; }
.fontes-section + .fontes-section { margin-top: 16px; border-top: 1px solid var(--line-soft); }
.fontes-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.fontes-list { display: flex; flex-direction: column; gap: 8px; }
.fontes-list-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: 10px 12px; min-width: 0; }
.fontes-list-item.is-failure { border-color: color-mix(in srgb, var(--danger) 24%, #fff); background: var(--danger-tint); }
.fontes-list-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.fontes-list-main { min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--ink); word-break: break-word; }
.fontes-list-meta { font-size: 11px; color: var(--muted); margin-top: 3px; word-break: break-word; }
.fontes-list-text { font-size: 12px; color: var(--ink); margin-top: 6px; line-height: 1.55; }
.fontes-list-text .fontes-list-meta { display: inline; margin-left: 6px; }
.fontes-empty-inline { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 14px; text-align: center; font-size: 12px; color: var(--muted); background: var(--bg); }
.fontes-kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px 12px; font-size: 12px; }
.fontes-kv dt { color: var(--muted); }
.fontes-kv dd { margin: 0; color: var(--ink); word-break: break-word; }
.fontes-bullets { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.55; }
.fontes-bullets li { margin: 2px 0; }
.fontes-evidence-link { color: var(--brand-deep); font-weight: 600; text-decoration: none; }
.fontes-evidence-link:hover { text-decoration: underline; }
.fontes-evidence-toolbar { margin-bottom: 12px; }
.fontes-evidence-toolbar .search { max-width: 420px; }
.fontes-evidence-toolbar .search .input { padding-left: 34px; }
#fontes-evidencia-conteudo { display: flex; flex-direction: column; gap: 12px; }
.fontes-coverage { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: 12px 14px; }
.fontes-coverage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.fontes-coverage-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fontes-coverage-num { font-family: var(--serif); font-size: 19px; line-height: 1.1; color: var(--ink); }
.fontes-coverage-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 650; }
.fontes-coverage-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; margin: 10px 0 8px; }
.fontes-coverage-bar > span { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.fontes-coverage .panel-note { margin: 0; }
.fontes-evidence-count { margin: 0; }
.fontes-evidence-doc { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; }
.fontes-evidence-doc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.fontes-evidence-doc-title { min-width: 0; font-size: 12px; font-weight: 700; color: var(--ink); word-break: break-word; }
.fontes-evidence-section { padding: 10px 12px; }
.fontes-evidence-section + .fontes-evidence-section { border-top: 1px solid var(--line-soft); }
.fontes-evidence-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.fontes-evidence-section-head .strong { font-size: 11.5px; color: var(--ink); }
.fontes-evidence-item { background: var(--panel); }
.fontes-evidence-item + .fontes-evidence-item { margin-top: 8px; }
.fontes-evidence-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.fontes-evidence-actions .btn { text-decoration: none; }
.fontes-evidence-extra[hidden] { display: none; }
.fontes-evidence-extra .fontes-evidence-item:first-child { margin-top: 8px; }
.fontes-evidence-more { margin-top: 8px; }

@media (max-width: 640px) {
  #fontes-tabela .fonte-cell { min-width: 180px; }
  .fontes-kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .fontes-kv dt { font-size: 10.5px; }
  .fontes-kv dd { margin-bottom: 6px; }
  .fontes-detail-actions .btn { flex: 1 1 auto; }
  .fontes-coverage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fontes-evidence-toolbar .search { max-width: none; }
  .fontes-evidence-doc-head { flex-direction: column; align-items: flex-start; }
  #fontes-form .row.between > .row { width: 100%; }
  #fontes-form .row.between > .row .btn { flex: 1 1 auto; }
  .fontes-list-top { flex-direction: column; }
}

/* ---- Sprint 9 · Arquivos privados e extração com OCR (T08) --------------- */
#arquivos-meta { row-gap: 6px; }
#arquivos-meta .chip { max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#arquivos-meta a.chip { display: inline-block; line-height: 26px; }

.arq-dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 24px; transition: border-color .15s var(--ease), background .15s var(--ease); }
.arq-dropzone:hover, .arq-dropzone:focus-visible { border-color: var(--brand); background: var(--brand-tint); outline: none; }
.arq-dropzone.is-drag { border-color: var(--brand); background: var(--brand-tint); }
.arq-drop-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); display: grid; place-items: center; margin-bottom: 2px; }
.arq-drop-icon svg { width: 22px; height: 22px; }
.arq-dropzone .btn { margin-top: 10px; }

.arq-fila { border-top: 1px solid var(--line-soft); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.arq-fila-head .panel-title { font-size: 13px; }
.arq-fila-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: 10px 12px; }
.arq-fila-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.arq-fila-icon { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); color: var(--brand); display: grid; place-items: center; }
.arq-fila-icon svg { width: 15px; height: 15px; }
.arq-fila-main .strong { display: block; font-size: 12.5px; word-break: break-word; }
.arq-fila-progress { grid-column: 1 / -1; height: 5px; }
.arq-fila-erro { grid-column: 1 / -1; font-size: 11px; color: var(--danger); font-weight: 600; }
.arq-fila-aviso { grid-column: 1 / -1; font-size: 11px; color: var(--warn); font-weight: 600; line-height: 1.45; }

.arq-conteudo {
  margin: 0; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; line-height: 1.6; color: var(--ink);
}

.arq-tabela .arq-file-cell { min-width: 220px; max-width: 360px; }
.arq-tabela .arq-file-cell .strong { display: block; word-break: break-word; }
.arq-tabela .arq-file-meta { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.arq-tabela .arq-row-error { display: block; color: var(--danger); font-size: 10.5px; margin-top: 3px; line-height: 1.4; }
.arq-tabela tbody tr { cursor: pointer; }
.arq-tabela tbody tr.is-selected { background: var(--brand-tint); }
.arq-tabela tbody tr.is-selected td { border-bottom-color: color-mix(in srgb, var(--brand) 22%, #fff); }
.arq-tabela .actions { white-space: nowrap; }
.arq-tabela .actions .btn, .arq-tabela .actions .icon-btn { margin-left: 4px; }
.arq-tabela .actions .icon-btn { vertical-align: middle; }
.arq-poll-dot { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--brand); animation: arq-pulse 1.4s ease-in-out infinite; }
@keyframes arq-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.arq-uso-grupos { display: flex; flex-direction: column; gap: 10px; }
.arq-uso-grupo { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: 12px; }
.arq-uso-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.arq-uso-titulo { font-size: 12.5px; font-weight: 700; color: var(--ink); word-break: break-word; }
.arq-uso-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: 10.5px; color: var(--muted); }
.arq-uso-meta code { font-size: 10px; color: var(--muted); word-break: break-all; }
.arq-uso-arquivos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.arq-uso-arquivo { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); padding: 4px 8px 4px 7px; font-size: 10.5px; color: var(--ink); min-width: 0; }
.arq-uso-arquivo > svg { flex: 0 0 auto; color: var(--brand); }
.arq-uso-arquivo.is-removido { opacity: .72; }
.arq-uso-arquivo .badge { font-size: 9.5px; padding: 1px 6px; }
.arq-tipos { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.arq-tipo-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 28px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.arq-tipo-nome { font-weight: 700; color: var(--ink); }
.arq-tipo-bar { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.arq-tipo-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.arq-tipo-num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .arq-tabela .arq-file-cell { min-width: 160px; max-width: none; }
  .arq-tabela .col-optional { display: none; }
  .arq-fila-item { grid-template-columns: minmax(0, 1fr); }
  .arq-fila-item > .badge { justify-self: start; }
  .fontes-detail-actions .btn { flex: 1 1 auto; }
  .arq-uso-head { flex-direction: column; }
  .arq-uso-head .btn { align-self: flex-start; }
}

@media (max-width: 520px) {
  .prov-counts { grid-template-columns: minmax(0, 1fr); }
  .prov-source-row { align-items: flex-start; }
  #ws-chat-panel .panel-body.tight { padding: 0; }
}

/* ---- Versionamento e aprovação (T09/T10/T11) ----------------------------- */
.diagram-code { margin: 0; padding: 12px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10.5px; line-height: 1.55;
  color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.diff-list { display: flex; flex-direction: column; gap: 12px; }
.diff-item { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: 12px; }
.diff-item .diff { margin: 6px 0 0; }
.version-summary { max-width: 340px; font-size: 12px; line-height: 1.5; color: var(--ink); }
.actions { text-align: right; white-space: nowrap; }
.actions > * + * { margin-left: 6px; }
#aprovacoes-etapas .status { width: 100%; text-decoration: none; }
#aprovacoes-etapas .status:hover { text-decoration: none; background: var(--bg); border-radius: 6px; }
#aprovacoes-etapas .status .sub { font-size: 11px; color: var(--muted); }
#aprovacoes-timeline .callout { width: 100%; }
.table .actions { vertical-align: middle; }

@media (max-width: 760px) {
  .version-summary { max-width: none; }
  .actions { white-space: normal; }
  #aprovacoes-etapas .status { flex-wrap: wrap; row-gap: 4px; }
  #aprovacoes-etapas .status .sub { margin-left: 0 !important; }
}
.chat-context-banner { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); font-size: 11px; line-height: 1.5; color: var(--ink); }
.chat-context-banner strong { color: var(--brand-deep); }
.chat-context-banner span { color: var(--muted); }

/* ---- Guarda responsiva (smartphone 360px) -------------------------------- */
/* Chips e etiquetas nunca podem empurrar a página além da viewport; textos
   longos de contexto (empresa, processo, versão) quebram dentro do cartão. */
.chip { max-width: 100%; }
.doc-body, .doc-section, .doc-meta, .kv dd, .status, .msg-bubble,
.prov-source-row, .prov-source, .chat-context-banner, .panel-sub { overflow-wrap: anywhere; }
.grid-main > *, .workspace > *, .stack > *, .row > *, .between > * { min-width: 0; }
.panel, .doc, .doc-body, .chat, .msg, .msg-bubble { max-width: 100%; }

@media (max-width: 480px) {
  .chip { white-space: normal; height: auto; min-height: 28px; }
  .chip .x { flex: 0 0 auto; }
  .badge { white-space: normal; }
  .row > .btn, .head-actions > .btn { max-width: 100%; }
}
