/* ==========================================================================
   LEGIMO — Design System
   Segurança jurídica patrimonial: sólido, institucional, legível.
   Tokens sobrescrevíveis por tenant (white label) via <style> inline.
   ========================================================================== */

:root {
  /* 1. Cor principal — navy profundo da marca (mesma paleta da landing) */
  --color-primary: #0F1E3D;
  --color-primary-hover: #1B3564;
  --color-primary-soft: #EEF1F7;

  /* 2. Suporte e legibilidade — neutros quentes */
  --color-bg: #F7F6F1;
  --color-surface: #FFFFFF;
  --color-text: #1E293B;
  --color-text-muted: #64748B;
  --color-border: #E5E3DB;

  /* 3. Ação / CTA — verde da marca */
  --color-accent: #1F9D6B;
  --color-accent-hover: #18815A;

  /* 3b. Dourado discreto — realces de destaque */
  --color-gold: #C9A227;
  --color-gold-soft: #FBF6E9;

  /* 4. Status do sistema */
  --status-success: #10B981;
  --status-progress: #3B82F6;
  --status-warning: #F59E0B;
  --status-error: #DC2626;

  /* Tipografia — display institucional + texto legível (fontes locais) */
  --font-display: Georgia, 'Times New Roman', 'Iowan Old Style', serif;
  --font-text: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(15, 30, 61, .06);
  --shadow: 0 10px 30px rgba(15, 30, 61, .10);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Garante que [hidden] vença regras com display explícito (ex.: painéis flex) */
[hidden] { display: none !important; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-text);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.015em; color: var(--color-primary); }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

:focus-visible { outline: 3px solid rgba(31, 157, 107, .55); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --------------------------------------------------------------- layout app */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, #13254A 0%, #0F1E3D 46%, #0B172F 100%);
  color: #fff;
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  transition: transform .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px; font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-brand img { height: 30px; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 0; }
/* Scroll discreto na paleta do próprio menu (navy) — some quando não usado */
.sidebar nav { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .16) transparent; }
.sidebar nav::-webkit-scrollbar { width: 5px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); border-radius: 999px; }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .32); }
.sidebar .nav-section { padding: 14px 20px 4px; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.45); }
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: rgba(255,255,255,.82); font-size: .9rem;
  border-right: 3px solid transparent;
  transition: background .14s ease, color .14s ease;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.sidebar a.nav-link.active {
  background: linear-gradient(90deg, rgba(31,157,107,.20), rgba(31,157,107,.06));
  color: #fff; border-right-color: var(--color-gold);
}
.sidebar .nav-link .ico { width: 20px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.12); font-size: .78rem; color: rgba(255,255,255,.55); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .18s ease; }
.sidebar { transition: transform .2s ease, width .18s ease; }
.sidebar-brand .brand-mini { display: none; }
.sidebar-tenant { padding: 8px 20px 0; font-size: .78rem; color: rgba(255,255,255,.6); border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: 10px; }

/* -------- modo mini (hamburger ≡ retrai a sidebar para só ícones, desktop) */
@media (min-width: 961px) {
  .app-shell.sidebar-mini .sidebar { width: 64px; }
  .app-shell.sidebar-mini .main { margin-left: 64px; }
  .app-shell.sidebar-mini .sidebar .lbl,
  .app-shell.sidebar-mini .sidebar .nav-section,
  .app-shell.sidebar-mini .sidebar-tenant,
  .app-shell.sidebar-mini .sidebar-foot,
  .app-shell.sidebar-mini .sidebar-brand .brand-logo { display: none; }
  .app-shell.sidebar-mini .sidebar-brand { justify-content: center; padding: 18px 8px 14px; }
  .app-shell.sidebar-mini .sidebar-brand .brand-mini { display: inline-block; }
  .app-shell.sidebar-mini .sidebar a.nav-link { justify-content: center; padding: 11px 8px; }
  .app-shell.sidebar-mini .sidebar a.nav-link.active { border-right-width: 3px; }
}

.topbar {
  height: 60px; background: rgba(255, 255, 255, .84); border-bottom: 1px solid var(--color-border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .burger { display: block; background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--color-primary); padding: 4px; border-radius: 6px; }
.topbar .burger:hover { background: var(--color-primary-soft); }
.topbar .spacer { flex: 1; }
.topbar .user-chip { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}

/* Conteúdo fluido: aproveita a largura disponível em qualquer dispositivo
   (notebook, desktop, ultrawide). Padding lateral escala com a viewport e há
   um teto generoso, centralizado, para telas muito largas manterem legibilidade. */
.content { padding: clamp(18px, 1.9vw, 40px) clamp(16px, 2vw, 52px) 64px; width: 100%; max-width: 2400px; margin-inline: auto; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { flex: 1; min-width: 200px; }
/* título com subtítulo embrulhado em <div> — ações continuam à direita */
.page-head > div:first-child { flex: 1; min-width: 200px; }
.page-head > div:first-child h1 { flex: initial; min-width: 0; }
.page-sub { color: var(--color-text-muted); font-size: .9rem; margin-top: 2px; }
/* Cabeçalho de grupo do catálogo (Jornadas × Serviços Técnicos) */
.catalog-group { display: flex; align-items: center; gap: 9px; margin: 30px 0 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border); font-size: 1.1rem; color: var(--color-primary); }
.catalog-group:first-of-type { margin-top: 10px; }
.catalog-group .ico-svg { color: var(--color-accent); }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px; margin-bottom: 20px;
  transition: box-shadow .18s ease;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .stat-label { font-size: .78rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .stat-value { font-size: 1.72rem; font-weight: 700; font-family: var(--font-display); color: var(--color-primary); letter-spacing: -.01em; }
.stat .stat-foot { font-size: .8rem; color: var(--color-text-muted); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 18px; font-size: .9rem; font-weight: 600; font-family: var(--font-text);
  cursor: pointer; white-space: nowrap;
  transition: background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 2px 8px rgba(15, 30, 61, .22); }
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: 0 4px 14px rgba(15, 30, 61, .28); }
.btn-accent { background: var(--color-accent); color: #fff; box-shadow: 0 2px 8px rgba(31, 157, 107, .26); }
.btn-accent:hover { background: var(--color-accent-hover); box-shadow: 0 4px 14px rgba(31, 157, 107, .32); }
.btn-outline { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--status-error); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ------------------------------------------------------------------- forms */
label.field-label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--color-text); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; font-size: .92rem; font-family: var(--font-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.input:focus { border-color: var(--color-accent); outline: none; box-shadow: 0 0 0 3px rgba(31, 157, 107, .14); }
textarea.input { min-height: 90px; resize: vertical; }
.form-row { display: grid; gap: 14px; margin-bottom: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) { .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; } }
/* Editor de itens da proposta (descrição · serviço · pacote · qtd · valor · remover) */
.pi-row { grid-template-columns: 2fr 1.4fr 1.4fr 70px 130px 40px; align-items: end; }
.pi-row [data-remove-item] { padding-left: 0; padding-right: 0; }
@media (max-width: 820px) {
  .pi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pi-row > input[name="description[]"],
  .pi-row > select[name="service_id[]"],
  .pi-row > select[name="package_id[]"] { grid-column: 1 / -1; }
  .pi-row > [data-remove-item] { grid-column: 1 / -1; justify-self: end; width: auto; }
}
.field-error { color: var(--status-error); font-size: .78rem; margin-top: 3px; }
/* Legenda de seção dentro de um formulário (agrupa campos afins) */
.form-caption { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); font-weight: 700; margin: 4px 0 12px; }
.field-hint { color: var(--color-text-muted); font-size: .78rem; margin-top: 3px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th {
  text-align: left; padding: 10px 12px; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-muted); border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tr:hover td { background: var(--color-primary-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Linha clicável (tr[data-href] — navegação via app.js) */
.table tr.row-link { cursor: pointer; }
.table tr.row-link:hover td { background: var(--color-primary-soft); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 11px; font-size: .74rem; font-weight: 700;
  white-space: nowrap;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-success  { background: #ECFDF5; color: #065F46; }
.badge-progress { background: #EFF6FF; color: #1D4ED8; }
.badge-warning  { background: #FFFBEB; color: #B45309; }
.badge-error    { background: #FEF2F2; color: #B91C1C; }
.badge-neutral  { background: var(--color-primary-soft); color: var(--color-primary); }

/* ------------------------------------------- linha do tempo (assinatura visual) */
.timeline { list-style: none; position: relative; padding-left: 6px; }
.timeline li { position: relative; padding: 0 0 22px 34px; }
.timeline li::before {
  content: ''; position: absolute; left: 10px; top: 22px; bottom: -2px;
  width: 2px; background: var(--color-border);
}
.timeline li:last-child::before { display: none; }
.timeline .dot {
  position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--color-border); background: var(--color-surface);
  display: flex; align-items: center; justify-content: center; font-size: .65rem; color: #fff;
}
.timeline li.done .dot     { border-color: var(--status-success); background: var(--status-success); }
.timeline li.progress .dot { border-color: var(--status-progress); background: var(--status-progress); animation: pulse 2s infinite; }
.timeline li.warning .dot  { border-color: var(--status-warning); background: var(--status-warning); }
.timeline li.error .dot    { border-color: var(--status-error); background: var(--status-error); }
.timeline li.done::before  { background: var(--status-success); }
.timeline .step-name { font-weight: 600; font-size: .92rem; }
.timeline .step-meta { font-size: .78rem; color: var(--color-text-muted); margin-top: 2px; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,.35); } 50% { box-shadow: 0 0 0 7px rgba(59,130,246,0); } }

/* ------------------------------------------------------------------ kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kanban-col {
  min-width: 262px; width: 262px; flex-shrink: 0;
  background: #F0EFE8; border-radius: var(--radius); padding: 12px;
}
.kanban-col h3 { font-size: .82rem; font-family: var(--font-text); color: var(--color-primary); text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; margin-bottom: 10px; }
.kanban-col .col-total { font-size: .75rem; color: var(--color-text-muted); }
.kanban-cards { min-height: 40px; display: flex; flex-direction: column; gap: 9px; }
.kanban-card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 11px 12px; cursor: grab; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .12s ease;
}
.kanban-card:hover { box-shadow: 0 6px 18px rgba(15, 30, 61, .12); transform: translateY(-1px); }
.kanban-card.dragging { opacity: .5; }
.kanban-card .kc-title { font-weight: 600; font-size: .86rem; }
.kanban-card .kc-meta { display: flex; justify-content: space-between; font-size: .76rem; color: var(--color-text-muted); margin-top: 6px; }
.kanban-cards.drag-over { outline: 2px dashed var(--color-accent); outline-offset: 3px; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ alerts */
.alert { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: .9rem; border: 1px solid; }
.alert-success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.alert-error   { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; }
.alert-info    { background: #EFF6FF; border-color: #BFDBFE; color: #1D4ED8; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #B45309; }

/* ----------------------------------------------------------- notifications */
.notif-bell { position: relative; background: none; border: 0; cursor: pointer; font-size: 1.15rem; color: var(--color-primary); }
.notif-bell .count {
  position: absolute; top: -6px; right: -8px; background: var(--status-error); color: #fff;
  border-radius: 999px; font-size: .62rem; font-weight: 700; padding: 1px 5px; min-width: 16px; text-align: center;
}
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 300px; max-width: 92vw; z-index: 60; overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu .dd-item { display: block; padding: 11px 14px; border-bottom: 1px solid var(--color-border); font-size: .84rem; }
.dropdown-menu .dd-item:last-child { border-bottom: 0; }
.dropdown-menu .dd-item:hover { background: var(--color-primary-soft); text-decoration: none; }
.dropdown-menu .dd-item .dd-time { font-size: .72rem; color: var(--color-text-muted); }
.dropdown-menu .dd-empty { padding: 20px; text-align: center; color: var(--color-text-muted); font-size: .85rem; }

/* --------------------------------------------------------------- messenger */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; background: var(--color-surface); min-height: 540px; }
.chat-list { border-right: 1px solid var(--color-border); overflow-y: auto; max-height: 70vh; }
.chat-list a { display: block; padding: 13px 15px; border-bottom: 1px solid var(--color-border); font-size: .86rem; }
.chat-list a:hover, .chat-list a.active { background: var(--color-primary-soft); text-decoration: none; }
.chat-list .cl-title { font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.chat-list .cl-unread { background: var(--color-accent); color: #fff; border-radius: 999px; font-size: .68rem; padding: 1px 7px; font-weight: 700; }
.chat-main { display: flex; flex-direction: column; max-height: 70vh; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--color-bg); }
.msg { max-width: 74%; padding: 9px 13px; border-radius: 12px; font-size: .88rem; box-shadow: var(--shadow-sm); }
.msg.mine { align-self: flex-end; background: var(--color-primary); color: #fff; border-bottom-right-radius: 3px; }
.msg.theirs { align-self: flex-start; background: var(--color-surface); border: 1px solid var(--color-border); border-bottom-left-radius: 3px; }
.msg .msg-author { font-size: .7rem; font-weight: 700; opacity: .75; margin-bottom: 2px; }
.msg .msg-time { display: block; font-size: .66rem; opacity: .65; margin-top: 3px; text-align: right; }
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--color-border); }
.chat-input textarea { flex: 1; min-height: 44px; max-height: 120px; }
@media (max-width: 860px) { .chat-layout { grid-template-columns: 1fr; } .chat-list { max-height: 200px; } }

/* ------------------------------------------------------------------- misc */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; }
.muted { color: var(--color-text-muted); }
.small { font-size: .8rem; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.text-right { text-align: right; }
.w-100 { width: 100%; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 44px 20px; color: var(--color-text-muted); }
.empty-state .es-icon { font-size: 2.2rem; margin-bottom: 8px; }
.empty-state p { margin-bottom: 14px; }
hr.sep { border: 0; border-top: 1px solid var(--color-border); margin: 18px 0; }
.tag { display: inline-block; background: var(--color-primary-soft); color: var(--color-primary); border-radius: 5px; padding: 2px 8px; font-size: .72rem; font-weight: 600; }
.progressbar { height: 8px; background: var(--color-border); border-radius: 999px; overflow: hidden; }
.progressbar > span { display: block; height: 100%; background: var(--status-success); border-radius: 999px; }

/* ----------------------------------------------- ícones SVG (outline) */
.ico-svg { flex-shrink: 0; vertical-align: -0.18em; }
.btn .ico-svg { vertical-align: -0.14em; }
.es-icon .ico-svg { width: 40px; height: 40px; stroke-width: 1.4; opacity: .55; }
.sidebar .nav-link .ico .ico-svg { display: block; }

/* ------------------------------------------- seletor de idioma (bandeiras) */
details.lang-dd { position: relative; display: inline-block; }
details.lang-dd > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 8px; border-radius: var(--radius-sm); opacity: .8; transition: opacity .15s, background .15s;
  user-select: none;
}
details.lang-dd > summary::-webkit-details-marker { display: none; }
details.lang-dd > summary:hover, details.lang-dd[open] > summary { opacity: 1; background: rgba(127,127,127,.16); }
details.lang-dd .lang-caret { font-size: .6rem; opacity: .7; }
details.lang-dd .lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 90;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); min-width: 152px; overflow: hidden;
}
details.lang-dd .lang-menu a {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  font-size: .85rem; color: var(--color-text); white-space: nowrap;
}
details.lang-dd .lang-menu a:hover { background: var(--color-primary-soft); text-decoration: none; }
details.lang-dd .lang-menu a.active { font-weight: 700; }
details.lang-dd .lang-menu .lang-check { margin-left: auto; color: var(--color-accent); font-weight: 700; }
.flag { width: 20px; height: 14px; border-radius: 2.5px; box-shadow: 0 0 0 1px rgba(15,23,42,.12); display: inline-block; }

/* -------------------------------------- seletor de território (ambiente logado) */
details.terr-dd { position: relative; display: inline-block; }
details.terr-dd > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px; user-select: none;
  font-size: .82rem; color: var(--color-primary); font-weight: 600;
  background: var(--color-primary-soft); border: 1px solid transparent;
  transition: border-color .15s ease, background .15s ease;
}
details.terr-dd > summary::-webkit-details-marker { display: none; }
details.terr-dd > summary:hover, details.terr-dd[open] > summary { border-color: var(--color-accent); }
details.terr-dd .terr-sum strong { font-family: var(--font-text); }
details.terr-dd .lang-caret { font-size: .6rem; opacity: .7; }
details.terr-dd .terr-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 90;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow); width: 260px; max-width: 92vw; padding: 14px;
}
details.terr-dd .terr-menu-head {
  display: flex; align-items: center; gap: 6px; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-muted); font-weight: 700; margin-bottom: 10px;
}
details.terr-dd .terr-label { display: block; font-size: .74rem; font-weight: 600; color: var(--color-text); margin: 8px 0 4px; }
details.terr-dd .terr-hint { font-size: .74rem; color: var(--color-text-muted); margin-top: 10px; line-height: 1.4; }
@media (max-width: 600px) { .topbar .terr-dd .hide-mobile { display: none; } }

/* -------------------------------------------- chat interno flutuante (FAB) */
#legimo-chat { position: fixed; right: 22px; bottom: 22px; z-index: 120; }
.chat-fab {
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .32); position: relative;
  transition: transform .15s ease, background .15s ease;
}
.chat-fab:hover { background: var(--color-primary-hover); transform: translateY(-2px); }
.chat-fab-badge {
  position: absolute; top: -4px; right: -4px; background: var(--status-error); color: #fff;
  border-radius: 999px; font-size: .66rem; font-weight: 700; padding: 2px 6px; min-width: 18px;
  border: 2px solid var(--color-bg);
}
.chat-panel {
  position: absolute; right: 0; bottom: 66px; width: 340px; max-width: calc(100vw - 32px);
  height: 480px; max-height: calc(100vh - 120px);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
}
.chat-panel-head {
  background: var(--color-primary); color: #fff; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.chat-panel-head .chat-panel-title { flex: 1; font-size: .95rem; }
.chat-panel-head button { background: none; border: 0; color: rgba(255,255,255,.85); cursor: pointer; font-size: 1rem; padding: 2px 6px; border-radius: 6px; }
.chat-panel-head button:hover { background: rgba(255,255,255,.15); color: #fff; }
.chat-panel-list { flex: 1; overflow-y: auto; padding: 10px 0; }
.chat-section-title { padding: 8px 14px 4px; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--color-text-muted); }
.chat-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 14px; border: 0; background: none; cursor: pointer; text-align: left;
  font-size: .88rem; color: var(--color-text); font-family: var(--font-text);
}
.chat-item:hover { background: var(--color-primary-soft); }
.chat-item .avatar { width: 30px; height: 30px; font-size: .78rem; flex-shrink: 0; }
.chat-item .ci-main { flex: 1; min-width: 0; }
.chat-item .ci-sub { display: block; font-size: .72rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-unread { background: var(--color-accent); color: #fff; border-radius: 999px; font-size: .66rem; font-weight: 700; padding: 2px 7px; }
.chat-empty { padding: 18px 14px; text-align: center; }
.chat-panel-conv { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-panel-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--color-bg); }
.chat-panel-msgs .msg { max-width: 86%; font-size: .84rem; padding: 7px 11px; }
.chat-panel-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--color-border); flex-shrink: 0; }
.chat-panel-input textarea { resize: none; min-height: 38px; max-height: 90px; font-size: .86rem; }
@media (max-width: 640px) { .chat-panel { width: calc(100vw - 32px); height: 70vh; } }

/* ------------------------------------------------------------- auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, #16294E 0%, #0F1E3D 55%, #0A1428 100%); }
.auth-card { background: var(--color-surface); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 420px; padding: 36px; }
.auth-card .auth-brand { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--color-primary); text-align: center; margin-bottom: 4px; }
.auth-card .auth-sub { text-align: center; color: var(--color-text-muted); font-size: .88rem; margin-bottom: 24px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: .84rem; }
.auth-state {
  display: flex; width: fit-content; align-items: center; gap: 6px; margin: 0 auto 12px; padding: 5px 12px;
  border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: rgba(31, 157, 107, .12); color: var(--color-accent); border: 1px solid rgba(31, 157, 107, .3);
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main { margin-left: 0; }
  .topbar .burger { display: block; }
  .content { padding: 18px 16px 60px; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; display: none; }
  .sidebar-backdrop.show { display: block; }
}

@media print {
  .sidebar, .topbar, .toolbar, .btn { display: none !important; }
  .main { margin: 0; }
}
