/* Telas: cabeçalho, navegação, painel lateral, ficha do processo, sessões e conversas */

/* ---------- Cabeçalho ---------- */
.masthead {
  background: var(--ink-900);
  color: var(--text-inv);
  border-bottom: 1px solid var(--ink-950);
  position: relative;
}
.masthead::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -3px; height: 2px;
  background: linear-gradient(90deg, var(--brass-600), var(--brass-400) 50%, var(--brass-600));
  opacity: 0.85;
}
.masthead-inner { display: flex; align-items: center; gap: var(--s-8); min-height: 76px; }
.brand { display: flex; align-items: center; gap: var(--s-3); flex: none; }
.brand-seal {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--brass-400);
  color: var(--brass-400);
}
.brand-name { font-family: var(--font-doc); font-size: var(--fs-18); font-weight: var(--fw-semi); letter-spacing: 0.01em; line-height: 1.1; }
.brand-sub { font-size: var(--fs-12); color: rgba(244, 246, 248, 0.68); }
.metrics { display: flex; gap: var(--s-6); flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.metrics::-webkit-scrollbar { display: none; }
.metric { display: flex; flex-direction: column; gap: 2px; flex: none; }
.metric-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: rgba(244, 246, 248, 0.66); }
.metric-label .icon { width: 14px; height: 14px; }
.metric-value { font-size: var(--fs-16); font-weight: var(--fw-semi); font-variant-numeric: tabular-nums; transition: color var(--d-2) var(--ease); }
.metric-value.is-bad { color: #ff9d92; }
.metric-value.is-flash { animation: flash 900ms var(--ease-out); }
.masthead-actions { display: flex; gap: var(--s-2); align-items: center; flex: none; }
.masthead .btn-ghost { --btn-fg: rgba(244, 246, 248, 0.8); --btn-bg-hover: rgba(255, 255, 255, 0.08); }
.masthead .btn-ghost:hover:not(:disabled) { color: var(--text-inv); }
@keyframes flash { 0% { color: var(--brass-400); } 100% { color: inherit; } }

/* ---------- Navegação ---------- */
.navbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.navbar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.navbar .date-chip { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text-2); font-size: var(--fs-13); white-space: nowrap; }

/* ---------- Cabeçalho de tela ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.page-head p { margin-top: var(--s-2); color: var(--text-2); max-width: 64ch; }

/* ---------- Painel lateral de acontecimentos ---------- */
.aside { position: sticky; top: calc(var(--h-lg) + var(--s-6)); }
.feed { max-height: calc(100vh - 180px); overflow-y: auto; }
.feed-item { display: grid; grid-template-columns: 28px 1fr; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.feed-icon .icon { width: 14px; height: 14px; }
.feed-icon.k-court { background: var(--tint-strong); color: var(--ink-text); }
.feed-icon.k-crisis { background: var(--bad-bg); color: var(--bad); }
.feed-icon.k-congress { background: var(--brass-tint); color: var(--brass-text); }
.feed-icon.k-state { background: var(--ok-bg); color: var(--ok); }
.feed-text { font-size: var(--fs-13); line-height: 1.5; }
.feed-date { font-size: var(--fs-12); color: var(--text-3); margin-top: 2px; }
.feed-item.is-new { animation: msg-in var(--d-3) var(--ease-out) both; }

/* ---------- Orçamento ---------- */
.budget { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.budget .stat { padding: var(--s-5) var(--s-6); border-right: 1px solid var(--line); }
.budget .stat:last-child { border-right: 0; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-3); }
.action {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left; cursor: pointer;
  transition: border-color var(--d-1) var(--ease), background-color var(--d-1) var(--ease), transform var(--d-1) var(--ease);
}
.action:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.action:active:not(:disabled) { transform: translateY(1px); }
.action:disabled { opacity: 0.5; cursor: not-allowed; }
.action-icon { width: var(--h-md); height: var(--h-md); flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--tint); color: var(--ink-text); }
.action .grow { flex: 1; min-width: 0; }
.action-title { font-weight: var(--fw-medium); display: flex; justify-content: space-between; gap: var(--s-2); }
.action-cost { font-size: var(--fs-12); color: var(--text-3); font-weight: var(--fw-regular); white-space: nowrap; flex: none; padding-top: 1px; }
.action-text { margin-top: 2px; font-size: var(--fs-13); color: var(--text-2); }
.action.is-used .action-icon { background: var(--ok-bg); color: var(--ok); }

/* ---------- Estados ---------- */
.sector { display: inline-flex; align-items: center; gap: var(--s-2); }
.sector-icon { width: 28px; height: 28px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.sector-icon .icon { width: 15px; height: 15px; }

/* ---------- Congresso ---------- */
.bill-row { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) var(--s-6); border-bottom: 1px solid var(--line); }
.bill-row:last-child { border-bottom: 0; }
.bill-row .grow { flex: 1; min-width: 0; }
.bill-title { font-weight: var(--fw-medium); }
.bill-chips { display: flex; gap: var(--s-1); flex-wrap: wrap; margin-top: 6px; }
.tally { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-6); }
.tally-bar { display: flex; height: 10px; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-3); margin: var(--s-2) 0; }
.tally-bar .y { background: var(--ok); }
.tally-bar .n { background: var(--bad); }
.tally-bar span { transition: width var(--d-3) var(--ease-out); }
.party-chips { display: flex; flex-wrap: wrap; gap: var(--s-1); }

/* ---------- Ficha do processo (o dossiê) ---------- */
.dossier {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.dossier::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(var(--brass-500), var(--brass-600));
}
.dossier-head { display: grid; grid-template-columns: 1fr auto; gap: var(--s-6); padding: var(--s-8) var(--s-8) var(--s-6) calc(var(--s-8) + 4px); border-bottom: 1px solid var(--line); }
.dossier-kind { font-size: var(--fs-13); color: var(--text-3); display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; }
.dossier-title { margin-top: var(--s-2); font-family: var(--font-doc); font-size: var(--fs-28); line-height: 1.15; max-width: 30ch; }
.dossier-badges { margin-top: var(--s-4); display: flex; gap: var(--s-2); flex-wrap: wrap; }
.seal {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  border: 1.5px solid var(--brass-500);
  box-shadow: inset 0 0 0 5px var(--surface), inset 0 0 0 6px color-mix(in srgb, var(--brass-500) 55%, transparent);
  color: var(--brass-text);
  font-family: var(--font-doc);
  transform: rotate(-8deg);
}
.seal b { display: block; font-size: var(--fs-18); line-height: 1; }
.seal small { display: block; font-size: 11px; margin-top: 2px; }
.dossier-body { padding: var(--s-6) var(--s-8) var(--s-8) calc(var(--s-8) + 4px); display: flex; flex-direction: column; gap: var(--s-8); }
.dossier-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); }
.fact-label { font-size: var(--fs-12); color: var(--text-3); margin-bottom: var(--s-1); }
.fact-value { font-size: var(--fs-14); font-weight: var(--fw-medium); }
.doc-section h4 { font-family: var(--font-ui); font-size: var(--fs-13); font-weight: var(--fw-semi); color: var(--text-2); margin-bottom: var(--s-3); display: flex; align-items: center; gap: var(--s-2); }
.doc-section h4 .icon { width: 15px; height: 15px; color: var(--brass-600); }
.doc-text { font-family: var(--font-doc); font-size: var(--fs-16); line-height: var(--lh-doc); max-width: 72ch; }
.doc-lead { font-family: var(--font-doc); font-size: var(--fs-18); line-height: 1.5; max-width: 64ch; }
.sides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.side { border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; }
.side-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-4); font-size: var(--fs-13); font-weight: var(--fw-semi); border-bottom: 1px solid var(--line); }
.side-acc .side-head { color: var(--bad); background: color-mix(in srgb, var(--bad-bg) 60%, var(--surface-2)); }
.side-def .side-head { color: var(--ok); background: color-mix(in srgb, var(--ok-bg) 60%, var(--surface-2)); }
.arg { padding: var(--s-4); border-bottom: 1px solid var(--line); }
.arg:last-child { border-bottom: 0; }
.arg-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-2); }
.arg-title { font-weight: var(--fw-semi); font-size: var(--fs-14); }
.arg-text { font-family: var(--font-doc); font-size: var(--fs-15); line-height: 1.6; color: var(--text); }
.opinion { padding: var(--s-4) var(--s-5); border-radius: var(--r-md); background: var(--tint); border: 1px solid var(--tint-strong); }
.dossier-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-5) var(--s-8) var(--s-5) calc(var(--s-8) + 4px); border-top: 1px solid var(--line); background: var(--surface-2); }

/* Cartão de processo na lista */
.case-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--s-4); align-items: center;
  width: 100%;
  padding: var(--s-4) var(--s-6);
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; cursor: pointer;
  transition: background-color var(--d-1) var(--ease);
}
.case-card:last-child { border-bottom: 0; }
.case-card:hover { background: var(--surface-2); }
.case-card:hover .chev { transform: translateX(2px); color: var(--text-2); }
.case-card .chev { color: var(--text-3); transition: transform var(--d-2) var(--ease); }
.case-num { width: 52px; height: 52px; border-radius: var(--r-md); display: grid; place-items: center; text-align: center; background: var(--tint); color: var(--ink-text); font-family: var(--font-doc); line-height: 1.05; }
.case-num b { display: block; font-size: var(--fs-15); }
.case-num small { display: block; font-size: 10px; }
.case-title { font-weight: var(--fw-semi); font-size: var(--fs-15); }
.case-meta { margin-top: 4px; display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; font-size: var(--fs-13); color: var(--text-3); }

/* ---------- Colegiado ---------- */
.bench { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-3); }
.justice {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--d-1) var(--ease), background-color var(--d-1) var(--ease);
}
.justice:hover { border-color: var(--line-strong); }
.justice .grow { flex: 1; min-width: 0; }
.justice-name { font-weight: var(--fw-medium); font-size: var(--fs-14); line-height: 1.3; }
.justice-meta { margin-top: 2px; font-size: var(--fs-12); color: var(--text-3); }
.justice-tags { margin-top: var(--s-2); display: flex; gap: var(--s-1); flex-wrap: wrap; }
.justice.is-me { border-color: color-mix(in srgb, var(--brass-500) 55%, var(--line)); background: color-mix(in srgb, var(--brass-tint) 45%, var(--surface)); }
.justice.is-vacant { border-style: dashed; background: transparent; }
.venue-head { display: flex; align-items: center; gap: var(--s-4); }
.venue-icon { width: var(--h-lg); height: var(--h-lg); border-radius: var(--r-md); display: grid; place-items: center; background: var(--solid); color: var(--brass-400); flex: none; }

/* ---------- Sessão de julgamento e conversas ---------- */
.split-card { container-type: inline-size; overflow: hidden; }
.split {
  display: grid;
  grid-template-columns: var(--w-list) minmax(0, 1fr);
  height: clamp(560px, calc(100vh - 140px), 900px);
}
.split-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.split-list-head { padding: var(--s-4); border-bottom: 1px solid var(--line); }
.split-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.session { display: grid; grid-template-columns: minmax(0, 1fr) var(--w-panel); height: 100%; min-height: 0; }
.session-panel { border-left: 1px solid var(--line); padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-5); overflow-y: auto; background: var(--surface); }
.panel-block { display: flex; flex-direction: column; gap: var(--s-3); }
.panel-title { font-size: var(--fs-13); font-weight: var(--fw-semi); color: var(--text-2); }
.score { display: flex; align-items: baseline; gap: var(--s-2); font-family: var(--font-doc); }
.score b { font-size: var(--fs-36); line-height: 1; }
.score span { color: var(--text-3); font-size: var(--fs-13); font-family: var(--font-ui); }
.vote-list { display: flex; flex-direction: column; gap: 6px; }
.vote-row { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-13); }
.vote-row .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-empty { flex: 1; display: grid; place-items: center; }
.new-chat .seg { width: 100%; }
.new-chat .seg button { flex: 1; justify-content: center; }

/* O espaço disponível decide o arranjo, não a largura da janela */
@container (max-width: 1040px) {
  .split { height: auto; max-height: none; }
  .session { grid-template-columns: minmax(0, 1fr); }
  .session .chat-log { height: 460px; flex: none; }
  .session-panel { border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .session-panel > .notice { grid-column: 1 / -1; }
  .split-main > .chat .chat-log { height: 520px; flex: none; }
}
@container (max-width: 720px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 300px; }
  .session-panel { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Tela inicial ---------- */
.setup { min-height: 100vh; display: grid; place-items: center; padding: var(--s-8) var(--s-4); background: radial-gradient(1200px 600px at 50% -10%, var(--ink-700), var(--ink-950)); }
.chat-head .select { width: var(--w-select); }
.setup-card { width: min(var(--w-setup), 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; animation: modal-in 600ms var(--ease-out) both; }
.setup-top { padding: var(--s-10) var(--s-10) var(--s-6); display: flex; gap: var(--s-5); align-items: center; border-bottom: 1px solid var(--line); }
.setup-top .brand-seal { width: 64px; height: 64px; color: var(--brass-600); border-color: var(--brass-500); }
.setup-top h1 { font-size: var(--fs-36); }
.setup-top p { margin-top: var(--s-2); color: var(--text-2); }
.setup-body { padding: var(--s-8) var(--s-10); display: flex; flex-direction: column; gap: var(--s-6); }
.roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.role { display: flex; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.role .action-icon { background: var(--solid); color: var(--brass-400); }
.profiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.setup-foot { padding: var(--s-5) var(--s-10); border-top: 1px solid var(--line); background: var(--surface-2); display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); }

@media (max-width: 1080px) {
  .aside { position: static; }
  .feed { max-height: 420px; }
  .session { grid-template-columns: 1fr; }
  .session-panel { border-left: 0; border-top: 1px solid var(--line); }
  .split { height: auto; max-height: none; }
}
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .split-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 260px; }
  .budget { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget .stat { border-bottom: 1px solid var(--line); }
  .sides, .dossier-facts, .tally, .roles, .profiles { grid-template-columns: 1fr; }
  .dossier-head { grid-template-columns: 1fr; }
  .seal { width: 76px; height: 76px; }
  .masthead-inner { flex-wrap: wrap; gap: var(--s-4); padding: var(--s-4) 0; }
  .metrics { order: 3; width: 100%; flex: none; }
}
@media (max-width: 560px) {
  .setup-top, .setup-body, .setup-foot { padding-left: var(--s-5); padding-right: var(--s-5); }
  .dossier-head, .dossier-body, .dossier-actions { padding-left: calc(var(--s-5) + 4px); padding-right: var(--s-5); }
  .msg { max-width: 92%; }
}
