/* ==========================================================================
   Componentes padronizados
   Regra: todo controle interativo tem altura --h-sm, --h-md ou --h-lg.
   ========================================================================== */

/* ---------- Ícone ---------- */
.icon { width: var(--icon-md); height: var(--icon-md); stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon-lg { width: var(--icon-lg); height: var(--icon-lg); }

/* ---------- Botão ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--line-strong);
  --btn-bg-hover: var(--surface-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: var(--h-md);
  padding: 0 var(--s-4);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--bevel);
  font-family: var(--font-title);
  font-size: var(--fs-16);
  font-weight: var(--fw-semi);
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--d-1) var(--ease), border-color var(--d-1) var(--ease), color var(--d-1) var(--ease), box-shadow var(--d-2) var(--ease), transform var(--d-1) var(--ease), filter var(--d-1) var(--ease);
}
a.btn { text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--btn-bg-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn-primary {
  --btn-fg: var(--ink-950);
  --btn-bd: var(--brass-700);
  background: linear-gradient(180deg, var(--brass-400), var(--brass-500) 55%, var(--brass-600));
  box-shadow: inset 0 1px 0 rgba(255, 250, 225, 0.6), inset 0 -2px 0 rgba(90, 58, 6, 0.35), 0 2px 8px color-mix(in srgb, var(--brass-500) 25%, transparent);
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, var(--brass-200), var(--brass-400) 55%, var(--brass-500)); }
.btn-ink { --btn-bg: var(--solid); --btn-fg: var(--text-inv); --btn-bd: var(--solid); --btn-bg-hover: var(--solid-hover); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-bg-hover: var(--surface-3); --btn-fg: var(--text-2); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-danger { --btn-bg: transparent; --btn-fg: var(--bad); --btn-bd: color-mix(in srgb, var(--bad) 40%, var(--line)); --btn-bg-hover: var(--bad-bg); }
.btn-ok { --btn-bg: transparent; --btn-fg: var(--ok); --btn-bd: color-mix(in srgb, var(--ok) 40%, var(--line)); --btn-bg-hover: var(--ok-bg); }
.btn-sm { height: var(--h-sm); padding: 0 var(--s-3); font-size: var(--fs-15); gap: 6px; }
.btn-lg { height: var(--h-lg); padding: 0 var(--s-6); font-size: var(--fs-18); }
.btn-icon { width: var(--h-md); padding: 0; }
.btn-icon.btn-sm { width: var(--h-sm); }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
}

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-14); font-weight: var(--fw-semi); color: var(--text-2); }
.field-hint { font-size: var(--fs-12); color: var(--text-3); }
.input,
.select,
.textarea {
  width: 100%;
  height: var(--h-md);
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--paper) 55%, var(--surface));
  color: var(--text);
  font-size: var(--fs-15);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: border-color var(--d-1) var(--ease), box-shadow var(--d-2) var(--ease), background-color var(--d-1) var(--ease);
}
.input:hover,
.select:hover,
.textarea:hover { border-color: var(--text-3); }
.input:focus,
.select:focus,
.textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input::placeholder,
.textarea::placeholder { color: var(--text-3); }
.input[type='number'] { font-variant-numeric: tabular-nums; }
.select {
  appearance: none;
  padding-right: var(--s-10);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2375818d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  text-overflow: ellipsis;
}
.textarea { height: auto; min-height: 88px; padding: 10px var(--s-3); line-height: var(--lh-ui); resize: vertical; }
.input-sm, .select-sm { height: var(--h-sm); font-size: var(--fs-13); }
.check { display: inline-flex; align-items: center; gap: var(--s-2); height: var(--h-md); cursor: pointer; font-size: var(--fs-14); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brass-500); cursor: pointer; }

/* ---------- Controle segmentado ---------- */
.seg {
  display: inline-flex;
  height: var(--h-md);
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--paper) 60%, var(--surface-3));
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.18);
}
.seg button {
  height: 100%;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: calc(var(--r-sm) - 2px);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-15);
  font-weight: var(--fw-semi);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--s-2);
  transition: background-color var(--d-2) var(--ease), color var(--d-1) var(--ease), box-shadow var(--d-2) var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--surface-3); color: var(--brass-text); box-shadow: var(--bevel), 0 1px 3px rgba(0, 0, 0, 0.2); }
.seg-sm { height: var(--h-sm); }
.seg-sm button { font-size: var(--fs-13); padding: 0 var(--s-3); }

/* ---------- Abas principais ---------- */
.tabs {
  display: flex;
  gap: var(--s-1);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: var(--h-lg);
  padding: 0 var(--s-4);
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-title);
  font-size: var(--fs-18);
  font-weight: var(--fw-semi);
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--d-1) var(--ease);
}
.tab::after {
  content: '';
  position: absolute;
  left: var(--s-4); right: var(--s-4); bottom: -1px;
  height: 3px;
  border-radius: 0;
  background: var(--brass-500);
  box-shadow: 0 0 10px color-mix(in srgb, var(--brass-500) 60%, transparent);
  transform: scaleX(0);
  transition: transform var(--d-3) var(--ease-out);
}
.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { color: var(--text); }
.tab[aria-selected='true']::after { transform: scaleX(1); }
.tab .count { margin-left: 2px; }

/* Abas secundárias (dentro de uma tela) */
.subtabs { display: flex; gap: var(--s-1); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  display: inline-flex; align-items: center; gap: var(--s-2);
  flex: none;
  height: var(--h-md);
  padding: 0 var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-15);
  font-weight: var(--fw-semi);
  cursor: pointer;
  transition: background-color var(--d-2) var(--ease), color var(--d-1) var(--ease), border-color var(--d-2) var(--ease);
}
.subtab:hover { background: var(--surface); color: var(--text); }
.subtab[aria-selected='true'] { background: var(--surface); color: var(--brass-text); border-color: color-mix(in srgb, var(--brass-500) 45%, var(--line)); box-shadow: var(--bevel), var(--sh-1); }

/* ---------- Cartão ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--bevel), var(--sh-1);
}
/* Cantoneiras douradas: a assinatura dos painéis de Valdória */
.card::before,
.card::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  pointer-events: none;
  z-index: 1;
}
.card::before, .card::after { content: none; display: none; }
.card-pad { padding: var(--s-6); }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.card-head h3 { display: flex; align-items: center; gap: var(--s-2); }
.card-head h3 > .icon { color: var(--brass-text); }
.card-head p { margin-top: var(--s-1); color: var(--text-2); font-size: var(--fs-14); }
.card-body { padding: var(--s-6); }
.card-foot { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-flush .card-body { padding: 0; }
.card-accent { border-color: color-mix(in srgb, var(--brass-500) 55%, var(--line)); box-shadow: var(--glow), var(--sh-1); }

/* ---------- Indicadores ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: var(--fs-13); color: var(--text-3); }
.stat-value { font-family: var(--font-title); font-size: clamp(var(--fs-18), 1.5vw, var(--fs-22)); font-weight: var(--fw-title); font-variant-numeric: tabular-nums; letter-spacing: 0.01em; line-height: 1.1; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.stat-big .stat-value { font-family: var(--font-title); font-size: var(--fs-36); font-weight: 900; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px;
  padding: 0 var(--s-2);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-13);
  font-weight: var(--fw-semi);
  white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-brass { background: var(--brass-tint); color: var(--brass-text); }
.badge-ink { background: var(--solid); color: var(--text-inv); }
.dot-count {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--brass-500); color: var(--ink-950);
  font-size: 12px; font-weight: var(--fw-semi);
  box-shadow: 0 0 8px color-mix(in srgb, var(--brass-500) 55%, transparent);
}

/* ---------- Avatar ---------- */
.avatar {
  --av: 36px;
  font-family: var(--font-title);
  width: var(--av); height: var(--av);
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--tint-strong);
  color: var(--ink-text);
  font-size: var(--fs-13);
  font-weight: var(--fw-semi);
  letter-spacing: 0.02em;
  position: relative;
}
.avatar-sm { --av: 28px; font-size: 11px; }
.avatar-lg { --av: 48px; font-size: var(--fs-15); }
.avatar-me { background: linear-gradient(180deg, var(--brass-400), var(--brass-600)); color: var(--ink-950); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--brass-600); }
.avatar-doc { background: var(--solid); color: var(--brass-400); }
.avatar-vacant { background: transparent; border: 1px dashed var(--line-strong); color: var(--text-3); }
.avatar .crown {
  position: absolute; right: -4px; bottom: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--solid); color: var(--brass-400);
  border: 2px solid var(--surface);
}
.avatar .crown .icon { width: 10px; height: 10px; }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
.table th {
  height: var(--h-md);
  padding: 0 var(--s-4);
  text-align: right;
  font-weight: var(--fw-semi);
  color: var(--text-3);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel-head);
  position: sticky; top: 0;
}
.table td {
  height: 52px;
  padding: 0 var(--s-4);
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.table th:first-child, .table td:first-child, .table .tl { text-align: left; }
.table td .subtle { font-size: var(--fs-12); }
.table tbody tr { transition: background-color var(--d-1) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Lista de itens ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--line);
  transition: background-color var(--d-1) var(--ease);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item-title { font-weight: var(--fw-medium); }
.list-item-meta { margin-top: 2px; font-size: var(--fs-13); color: var(--text-3); }
button.list-item { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }

/* ---------- Medidor (relação, nível) ---------- */
.meter { position: relative; height: 8px; border-radius: 1px; background: color-mix(in srgb, var(--paper) 50%, var(--surface-3)); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25); }
.meter::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), color-mix(in srgb, var(--surface) 80%, transparent) calc(10% - 1px) 10%); pointer-events: none; }
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--ink-text); transition: width var(--d-3) var(--ease-out); }
.meter.ok > span { background: var(--ok); }
.meter.bad > span { background: var(--bad); }
.meter.brass > span { background: var(--brass-500); }

/* ---------- Estado vazio ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-3);
  padding: var(--s-12) var(--s-6);
  color: var(--text-2);
}
.empty .empty-icon {
  width: var(--h-lg); height: var(--h-lg);
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brass-tint);
  color: var(--brass-text);
  border: 1px dashed color-mix(in srgb, var(--brass-500) 50%, transparent);
}
.empty h4 { font-size: var(--fs-22); color: var(--text); }
.empty p { max-width: 42ch; font-size: var(--fs-14); }

/* ---------- Aviso em linha ---------- */
.notice {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  border-left: 3px solid currentColor;
  background: var(--info-bg); color: var(--info);
  font-size: var(--fs-14);
}
.notice .icon { margin-top: 1px; }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-bad { background: var(--bad-bg); color: var(--bad); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--line);
}
.chat-head .grow { flex: 1; min-width: 0; }
.chat-title { font-family: var(--font-title); font-weight: var(--fw-semi); font-size: var(--fs-22); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: var(--fs-13); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-log {
  flex: 1;
  min-height: 280px;
  overflow-y: auto;
  padding: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-4);
  background: color-mix(in srgb, var(--paper) 45%, var(--surface-2));
  scroll-behavior: auto;
  overscroll-behavior: contain;
}
.msg { display: flex; gap: var(--s-3); max-width: 78%; align-items: flex-start; }
.msg > .avatar { margin-top: 18px; }
.msg-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.msg-name { font-size: var(--fs-12); color: var(--text-3); display: flex; gap: var(--s-2); align-items: center; }
.msg-bubble {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 1px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: var(--fs-15);
  line-height: var(--lh-ui);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg-me { align-self: flex-end; flex-direction: row-reverse; }
.msg-me .msg-body { align-items: flex-end; }
.msg-me .msg-bubble { background: var(--solid); border-color: color-mix(in srgb, var(--brass-500) 35%, var(--solid)); color: var(--text-inv); border-radius: var(--r-lg) var(--r-lg) 1px var(--r-lg); }
.msg-sys {
  align-self: center; max-width: 90%;
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 6px var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-13);
  text-align: center;
}
.msg-sys.tone-ok { background: var(--ok-bg); color: var(--ok); }
.msg-sys.tone-bad { background: var(--bad-bg); color: var(--bad); }
.msg-sys.tone-brass { background: var(--brass-tint); color: var(--brass-text); }
.msg-vote { font-size: var(--fs-12); }
.msg.is-new { animation: msg-in var(--d-3) var(--ease-out) both; }
.msg-sys.is-new { animation: msg-in var(--d-3) var(--ease-out) both; }
.typing { display: inline-flex; gap: 4px; padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: typing 1.2s var(--ease) infinite; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.composer {
  display: flex; gap: var(--s-3); align-items: flex-end;
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--line);
  background: var(--surface);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.composer .textarea { min-height: var(--h-md); height: var(--h-md); max-height: 160px; padding-top: 9px; resize: none; }
.composer-hint { padding: 0 var(--s-6) var(--s-3); font-size: var(--fs-12); color: var(--text-3); background: var(--surface); }

/* Lista de conversas */
.threads { display: flex; flex-direction: column; overflow-y: auto; }
.thread {
  display: flex; gap: var(--s-3); align-items: center;
  width: 100%;
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-left: 2px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--d-1) var(--ease), border-color var(--d-2) var(--ease);
}
.thread:hover { background: var(--surface-2); }
.thread[aria-selected='true'] { background: linear-gradient(90deg, var(--brass-tint), transparent 85%); border-left: 3px solid var(--brass-500); }
.thread .grow { flex: 1; min-width: 0; }
.thread-title { font-size: var(--fs-15); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-sub { font-size: var(--fs-12); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-title.wrap, .thread-sub.wrap { white-space: normal; overflow: visible; }
.invite { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.invite .grow { flex: 1; min-width: 0; }
.thread-group { padding: var(--s-4) var(--s-4) var(--s-2); font-family: var(--font-title); font-size: var(--fs-16); color: var(--brass-text); font-weight: var(--fw-semi); letter-spacing: 0.02em; }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s-4); }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(4px) saturate(0.8); animation: fade-in var(--d-2) var(--ease) both; }
.modal {
  position: relative;
  width: min(var(--w-modal), 100%);
  max-height: calc(100vh - var(--s-8));
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--brass-500);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  animation: modal-in var(--d-3) var(--ease-out) both;
}
.modal-wide { width: min(var(--w-modal-wide), 100%); }
.modal-head { padding: var(--s-6) var(--s-6) var(--s-4); display: flex; gap: var(--s-4); align-items: flex-start; }
.modal-head .grow { flex: 1; }
.modal-head h2, .modal-head h3 { font-size: var(--fs-28); }
.modal-head p { margin-top: var(--s-2); color: var(--text-2); }
.modal-body { padding: 0 var(--s-6) var(--s-6); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal-mark {
  width: var(--h-lg); height: var(--h-lg); flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--brass-tint); color: var(--brass-text);
  border: 1.5px solid var(--brass-500);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--brass-500) 45%, transparent);
}
.modal-mark.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px color-mix(in srgb, var(--bad) 45%, transparent); }

/* Opção grande clicável (crises, perfis) */
.option {
  display: flex; gap: var(--s-4); align-items: flex-start;
  width: 100%;
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: var(--bevel);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--d-1) var(--ease), background-color var(--d-1) var(--ease), box-shadow var(--d-2) var(--ease), transform var(--d-1) var(--ease);
}
.option:hover { border-color: var(--line-strong); background: var(--surface-3); }
.option:active { transform: translateY(1px); }
.option[aria-pressed='true'] { border-color: var(--brass-500); background: linear-gradient(180deg, var(--brass-tint), color-mix(in srgb, var(--brass-tint) 40%, var(--surface-2))); box-shadow: var(--glow); }
.option[aria-pressed='true'] > .icon { color: var(--brass-text); }
.option .grow { flex: 1; min-width: 0; }
.option-title { font-family: var(--font-title); font-size: var(--fs-18); font-weight: var(--fw-semi); letter-spacing: 0.02em; line-height: 1.15; }
.option-text { margin-top: 2px; font-size: var(--fs-14); color: var(--text-2); }
.option .chev { color: var(--text-3); align-self: center; transition: transform var(--d-2) var(--ease); }
.option:hover .chev { transform: translateX(2px); color: var(--text-2); }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: var(--s-6); transform: translateX(-50%); display: flex; flex-direction: column; gap: var(--s-2); align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: var(--h-md);
  padding: 0 var(--s-4);
  border-radius: var(--r-sm);
  background: var(--hud-bg); color: var(--hud-text);
  border: 1px solid var(--hud-line);
  border-left: 3px solid var(--brass-500);
  box-shadow: var(--sh-2);
  font-size: var(--fs-15);
  animation: toast-in var(--d-3) var(--ease-out) both;
}
.toast.out { animation: toast-out var(--d-2) var(--ease) both; }
.toast .icon { color: var(--brass-400); }

/* ---------- Menu suspenso ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + var(--s-2)); z-index: 40;
  width: var(--w-menu);
  padding: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  animation: pop-in var(--d-2) var(--ease-out) both;
  transform-origin: top right;
}
.menu-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; height: var(--h-md);
  padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text);
  font-size: var(--fs-14); text-align: left;
  cursor: pointer;
  transition: background-color var(--d-1) var(--ease);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .icon { color: var(--text-3); }
.menu-sep { height: 1px; margin: var(--s-2) 0; background: var(--line); }

/* ---------- Linha do tempo ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 20px 1fr; gap: var(--s-3); padding-bottom: var(--s-4); position: relative; }
.tl-item::before { content: ''; position: absolute; left: 9px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.tl-item:last-child { padding-bottom: 0; }
.tl-item:last-child::before { display: none; }
.tl-mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.tl-mark .icon { width: 12px; height: 12px; }
.tl-item.is-done .tl-mark { background: var(--solid); color: var(--brass-400); }
.tl-text { font-size: var(--fs-14); }
.tl-date { font-size: var(--fs-12); color: var(--text-3); }

/* ---------- Animações ---------- */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity var(--d-3) var(--ease-out), transform var(--d-3) var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }
.view-enter { animation: view-in var(--d-3) var(--ease-out) both; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brass-500) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}


/* ==========================================================================
   Estrutura de aplicativo: barra lateral fixa + área de conteúdo
   (usada pelo jogo e pelo painel)
   ========================================================================== */
.frame { display: grid; grid-template-columns: var(--w-sidebar) minmax(0, 1fr); min-height: 100vh; }
.frame-main { min-width: 0; display: flex; flex-direction: column; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--hud-bg-2), var(--hud-bg));
  border-right: 1px solid var(--hud-line);
  color: var(--hud-text);
  z-index: 30;
  --text: var(--hud-text);
  --text-2: var(--hud-text-2);
  --text-3: #8b8672;
  --line: var(--hud-line);
  --surface: var(--hud-bg-2);
  --surface-2: #17291f;
  --surface-3: #1e3a32;
  --brass-text: var(--brass-400);
  --brass-tint: #3a2e12;
}
.side-brand { display: flex; align-items: center; gap: var(--s-3); min-height: var(--h-topbar); padding: var(--s-3) var(--s-5); border-bottom: 1px solid var(--line); flex: none; }
.side-brand .brand-seal { width: 36px; height: 36px; color: var(--brass-text); border-color: var(--brass-500); }
.side-brand-name { font-family: var(--font-title); font-size: var(--fs-16); font-weight: var(--fw-semi); line-height: 1.15; }
.side-brand-sub { font-size: var(--fs-13); color: var(--text-2); line-height: 1.3; }
.side-scroll { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-3); display: flex; flex-direction: column; gap: var(--s-5); }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-title { padding: 0 var(--s-3) var(--s-2); font-family: var(--font-title); font-size: var(--fs-15); font-weight: var(--fw-semi); letter-spacing: 0.04em; color: var(--brass-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-link {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; height: var(--h-md);
  padding: 0 var(--s-3);
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2);
  font-size: var(--fs-15); font-weight: var(--fw-medium);
  text-align: left; text-decoration: none;
  cursor: pointer;
  transition: background-color var(--d-1) var(--ease), color var(--d-1) var(--ease);
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link .grow { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-link[aria-current='page'] { background: linear-gradient(90deg, color-mix(in srgb, var(--brass-500) 18%, transparent), transparent 90%); color: var(--text); font-weight: var(--fw-semi); }
.side-link[aria-current='page']::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0; background: var(--brass-500); box-shadow: 0 0 10px var(--brass-500); }
.side-link[aria-current='page'] .icon { color: var(--brass-text); }
.side-sub { height: var(--h-sm); padding-left: calc(var(--s-3) + var(--icon-md) + var(--s-3)); font-size: var(--fs-14); }
.side-sub[aria-current='page']::before { top: 6px; bottom: 6px; }
.side-highlight { background: var(--brass-500); color: var(--ink-950); }
.side-highlight:hover { background: var(--brass-400); color: var(--ink-950); }
.side-highlight .icon { color: var(--ink-950); }
.side-foot { flex: none; border-top: 1px solid var(--line); padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.side-user { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2); }
.side-user .grow { flex: 1; min-width: 0; }
.side-user-name { font-family: var(--font-title); font-size: var(--fs-18); font-weight: var(--fw-semi); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: var(--fs-13); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Barra superior da área de conteúdo */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-4);
  min-height: var(--h-topbar); padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--hud-bg) 94%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hud-line);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--brass-500) 22%, transparent), 0 6px 18px rgba(0, 0, 0, 0.18);
  color: var(--hud-text);
  --text: var(--hud-text);
  --text-2: var(--hud-text-2);
  --text-3: #8b8672;
  --line: var(--hud-line);
  --line-strong: #3d5e52;
  --surface: var(--hud-bg-2);
  --surface-2: #17291f;
  --surface-3: #1e3a32;
  --bad: #ec6a55;
  --bad-bg: #3a1a15;
  --brass-text: var(--brass-400);
}
.topbar .grow { flex: 1; min-width: 0; }
.topbar-title { font-family: var(--font-title); font-size: var(--fs-28); font-weight: var(--fw-title); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-toggle { display: none; }

/* Trilha de navegação (voltar sempre no topo) */
.crumbs { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; font-size: var(--fs-14); color: var(--text-3); }
.crumbs a, .crumbs button { display: inline-flex; align-items: center; gap: 6px; height: var(--h-sm); padding: 0 var(--s-2); margin-left: calc(var(--s-2) * -1); border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font: inherit; font-weight: var(--fw-medium); cursor: pointer; text-decoration: none; transition: background-color var(--d-1) var(--ease), color var(--d-1) var(--ease); }
.crumbs a:hover, .crumbs button:hover { background: var(--surface-2); color: var(--text); }
.crumbs .sep { color: var(--line-strong); }
.crumbs .here { color: var(--text); font-weight: var(--fw-medium); }

.side-overlay { display: none; }

@media (max-width: 1080px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(var(--w-sidebar), 86vw); transform: translateX(-102%); visibility: hidden; box-shadow: none; transition: transform var(--d-3) var(--ease-out), visibility 0s linear var(--d-3), box-shadow var(--d-3) var(--ease); }
  .frame.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--sh-3); transition: transform var(--d-3) var(--ease-out), visibility 0s, box-shadow var(--d-3) var(--ease); }
  .frame.nav-open .side-overlay { display: block; position: fixed; inset: 0; z-index: 25; background: var(--backdrop); animation: fade-in var(--d-2) var(--ease) both; }
  .menu-toggle { display: inline-flex; }
}

/* ---------- Tabela com rolagem lateral ---------- */
.table-scroll { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line-strong, var(--line)) transparent; outline: none; }
.table-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--focus, var(--brass-500)); }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll.is-overflowing:not(.at-end) { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }

.scroll-hint { display: none; align-items: center; gap: var(--s-2); height: var(--h-sm, 32px); padding: 0 var(--s-3); border-radius: 999px; border: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-12); white-space: nowrap; user-select: none; }
.scroll-hint .icon { width: 14px; height: 14px; }
.scroll-hint .sh-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .scroll-hint .sh-mouse { display: none; } .scroll-hint .sh-touch { display: inline; } }
.card-scroll.has-overflow .scroll-hint { display: inline-flex; animation: view-in var(--d-3) var(--ease-out) both; }
.card-scroll .card-head { align-items: center; flex-wrap: wrap; row-gap: var(--s-3); }

/* Estados: colunas com largura fixa e o nome do estado preso à esquerda */
.table-states { table-layout: fixed; min-width: 1120px; }
.table-states .c-estado { width: 220px; }
.table-states .c-setor { width: 200px; }
.table-states .c-num { width: 104px; }
.table-states .c-saldo { width: 136px; }
.table-states .c-acoes { width: 248px; }
.table-states th, .table-states td { overflow: hidden; text-overflow: ellipsis; }
.table-states td:first-child, .table-states th:first-child { overflow: visible; }
.table-states td:first-child > div { overflow: hidden; text-overflow: ellipsis; }
.table-states td:first-child, .table-states th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); padding-left: var(--s-6); }
.table-states th:first-child { background: var(--surface-2); z-index: 2; }
.table-states tbody tr:hover td:first-child { background: var(--surface-2); }
.table-states td:first-child::after, .table-states th:first-child::after { content: ""; position: absolute; top: 0; right: -12px; bottom: 0; width: 12px; pointer-events: none; opacity: 0; background: linear-gradient(to right, rgba(0,0,0,.18), transparent); transition: opacity var(--d-2) var(--ease); }
.table-scroll.is-scrolled .table-states td:first-child::after, .table-scroll.is-scrolled .table-states th:first-child::after { opacity: 1; }
.table-scroll.is-scrolled .table-states td:first-child, .table-scroll.is-scrolled .table-states th:first-child { box-shadow: inset -1px 0 0 var(--line-strong); }
.table-states td:last-child, .table-states th:last-child { padding-right: var(--s-6); }
.table-actions { justify-content: flex-end; flex-wrap: nowrap; gap: var(--s-2); }
@media (max-width: 720px) {
  .table-states .c-estado { width: 168px; }
  .table-states td:first-child, .table-states th:first-child { padding-left: var(--s-4); }
}

/* ---------- Ditado (microfone ao lado do Enviar) ---------- */
.btn-mic { flex: none; height: var(--h-md); }
.btn-mic.is-recording { --btn-bg: var(--bad); --btn-fg: #fff; --btn-bd: var(--bad); --btn-bg-hover: var(--bad); position: relative; }
.btn-mic.is-recording::after { content: ""; position: absolute; inset: -4px; border-radius: inherit; border: 2px solid var(--bad); opacity: 0; animation: mic-pulse 1.4s var(--ease-out) infinite; pointer-events: none; }
@keyframes mic-pulse { 0% { opacity: .6; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.18); } }
@media (prefers-reduced-motion: reduce) { .btn-mic.is-recording::after { animation: none; opacity: .5; } }

/* Unidades ao lado dos números (moeda, escala, índice, porcentagem) */
.unit { font-size: 0.62em; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.unit:first-child { margin-right: 0.22em; }
.unit:last-child { margin-left: 0.18em; }
.metric-value.is-bad .unit { color: inherit; opacity: .75; }
.metric[title] { cursor: help; }

/* ---------- Pendências do mês ---------- */
.pend-btn b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; }
.pend-btn.has-pend { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.pend-players { display: flex; flex-direction: column; gap: var(--s-4); }
.pend-player { border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-4); background: var(--surface-2); }
.pend-head { display: flex; align-items: center; gap: var(--s-3); }
.pend-list { list-style: none; margin: var(--s-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.pend-item { display: flex; align-items: center; gap: var(--s-2); padding: 6px 0; font-size: var(--fs-13); color: var(--text); }
.pend-item .icon { color: var(--warn, var(--brass-500)); }
.pend-item.is-done { color: var(--text-3); }
.pend-item.is-done .icon { color: var(--ok); }
.pend-actions { margin-top: var(--s-3); display: flex; justify-content: flex-end; }
@media (max-width: 1280px) { .pend-btn span { display: none; } .pend-btn { width: var(--h-md); padding: 0; } }
.crisis-cat { color: var(--bad) !important; font-weight: 700; }

/* Retrato circular sem cortar o selo de presidência. */
.avatar.is-portrait > svg { width: 100%; height: 100%; display: block; border-radius: inherit; }
