/* =========================================================================
   CHAT2LAW — CODEX visual system
   Editorial legal × AI assistant
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Instrument+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root{
  /* Ink + parchment */
  --ink:#1C1F26;
  --ink-2:#262A33;
  --ink-3:#3A4151;
  --paper:#F4F4F1;
  --paper-2:#FBFBF8;
  --paper-3:#E2E2DC;
  --rule:rgba(28,31,38,.14);
  --rule-soft:rgba(28,31,38,.08);

  /* Accents */
  --brass:#1E3A8A;
  --brass-2:#162B6B;
  --brass-soft:rgba(30,58,138,.12);
  --ai:oklch(62% 0.14 235);
  --ai-soft:oklch(92% 0.04 235);

  /* States */
  --ok:#1E6A4A;
  --ok-soft:#E0EFE5;
  --danger:#8E2A1F;
  --danger-soft:#F5E3E0;
  --warn:#7A5A12;
  --warn-soft:#F4ECD2;

  /* Effects */
  --shadow-sm:0 1px 0 rgba(28,31,38,.04), 0 1px 2px rgba(28,31,38,.06);
  --shadow:0 1px 0 rgba(28,31,38,.05), 0 14px 30px rgba(28,31,38,.07);
  --shadow-lg:0 1px 0 rgba(28,31,38,.05), 0 30px 60px rgba(28,31,38,.10);
  --radius:14px;
  --radius-sm:10px;
  --radius-lg:20px;

  /* Compatibility shims (do not remove — referenced by inherited markup) */
  --bg:var(--paper);
  --panel:var(--paper-2);
  --panel-soft:#EFEFEA;
  --primary:var(--ink);
  --primary-dark:var(--ink);
  --text:var(--ink);
  --muted:#646A77;
  --line:1px solid var(--rule);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
html{ -webkit-text-size-adjust:100% }

body{
  font-family:'Instrument Sans', ui-sans-serif, system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  color:var(--ink);
  background:var(--paper);
  background-image:
    radial-gradient(rgba(28,31,38,.06) 1px, transparent 1px),
    radial-gradient(rgba(28,31,38,.04) 1px, transparent 1px);
  background-size:28px 28px, 28px 28px;
  background-position:0 0, 14px 14px;
  font-feature-settings:"ss01","cv11";
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

a{ color:var(--ink); text-underline-offset:3px }
a:hover{ color:var(--brass-2) }

::selection{ background:var(--ink); color:var(--paper-2) }

/* =========================== Buttons =================================== */
button,input,textarea,select{ font:inherit; color:inherit }

button{
  appearance:none;
  border:1px solid var(--ink);
  background:var(--ink);
  color:var(--paper-2);
  border-radius:999px;
  padding:11px 18px;
  font-weight:600;
  font-size:14px;
  letter-spacing:.01em;
  cursor:pointer;
  transition:transform .12s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:40px;
}
button:hover{ transform:translateY(-1px); box-shadow:0 8px 22px rgba(28,31,38,.18) }
button:active{ transform:translateY(0) }
button:disabled{ opacity:.42; cursor:not-allowed; transform:none; box-shadow:none }

.btn-ghost{
  background:transparent;
  color:var(--ink);
  border:1px solid var(--rule);
}
.btn-ghost:hover{ background:rgba(28,31,38,.04); border-color:var(--ink) }

.btn-danger{ background:var(--danger); border-color:var(--danger); color:#fff }
.btn-danger:hover{ background:#6F1F17; border-color:#6F1F17 }

.btn-mini{ padding:6px 12px; font-size:12px; min-height:30px }

/* =========================== Form fields =============================== */
.input, select, textarea{
  width:100%;
  border:1px solid var(--rule);
  border-radius:var(--radius-sm);
  padding:11px 13px;
  background:var(--paper-2);
  color:var(--ink);
  transition:border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:var(--ink);
  background:#fff;
  box-shadow:0 0 0 4px rgba(28,31,38,.06);
}
textarea{ resize:vertical; min-height:120px; font-family:'Instrument Sans', system-ui, sans-serif }
label{
  display:block;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.14em;
  color:#646A77;
  margin-bottom:7px;
  font-weight:600;
}

.code, .codex-mono{
  font-family:'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:.92em;
}

/* =========================== App header ================================ */
header.app-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:18px 28px;
  background:rgba(251,247,236,.86);
  border-bottom:1px solid var(--rule);
  position:sticky;
  top:0;
  z-index:20;
  backdrop-filter:saturate(140%) blur(14px);
}
.brandwrap{ display:flex; align-items:center; gap:16px; min-width:0 }
.c2l-brand-mark{
  width:46px; height:46px;
  border-radius:11px;
  background:var(--ink);
  padding:6px;
  border:2px solid #fff;
  box-shadow:0 6px 18px rgba(28,31,38,.20);
  position:relative;
  flex:0 0 auto;
  display:inline-flex; align-items:center; justify-content:center;
}
.c2l-brand-mark img{
  width:100%; height:100%;
  object-fit:contain; display:block;
  filter:brightness(1.05) saturate(.9);
}
.c2l-ai-dot{
  position:absolute;
  top:5px; right:4px;
  width:6px; height:6px; border-radius:50%;
  background:var(--ai);
  box-shadow:0 0 0 3px rgba(30,58,138,.18);
  animation:ai-pulse 2.6s ease-in-out infinite;
}
@keyframes ai-pulse{ 0%,100%{ opacity:.95 } 50%{ opacity:.4 } }

.brand-text{ min-width:0 }
.brand{
  font-family:'Instrument Serif', serif;
  font-weight:400;
  color:var(--ink);
  font-size:28px;
  letter-spacing:-0.015em;
  line-height:1;
  display:inline-flex;
  flex-direction:column;
  align-items:flex-start;
  gap:5px;
}
.brand-sub{
  font-family:'JetBrains Mono', ui-monospace, monospace;
  font-size:10.5px;
  font-weight:500;
  letter-spacing:.16em;
  text-transform:uppercase;
  color:var(--muted);
}
.sub{
  color:#646A77;
  font-size:13px;
  margin-top:8px;
  letter-spacing:.005em;
}

.nav{ display:flex; gap:4px; flex-wrap:wrap; margin-top:10px }
.nav a{
  text-decoration:none;
  padding:7px 12px;
  border-radius:999px;
  color:#3C424E;
  font-weight:500;
  font-size:13px;
  letter-spacing:.01em;
  background:transparent;
  border:1px solid transparent;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
}
.nav a:hover{ background:rgba(28,31,38,.05); color:var(--ink) }
.nav a.active{
  background:var(--ink);
  color:var(--paper-2);
  border-color:var(--ink);
}

.header-actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap }

/* =========================== Main + layout ============================= */
main.app-main{
  width:100%;
  margin:24px 0 64px;
  padding:0 28px;
}
.grid-main{
  display:grid;
  grid-template-columns:420px minmax(0,1fr);
  gap:22px;
  align-items:start;
}
.grid-main.equal{ grid-template-columns:minmax(360px,1fr) minmax(420px,1.25fr) }
@media(max-width:1160px){ .grid-main, .grid-main.equal{ grid-template-columns:1fr } }

/* =========================== Card ===================================== */
.card{
  background:var(--paper-2);
  border:1px solid var(--rule);
  border-radius:var(--radius-lg);
  padding:24px 26px;
  box-shadow:var(--shadow);
  min-width:0;
  position:relative;
}
.card::before{
  content:"";
  position:absolute;
  top:14px; left:14px; right:14px;
  height:1px;
  background:linear-gradient(90deg, transparent, var(--rule-soft) 20%, var(--rule-soft) 80%, transparent);
  pointer-events:none;
}
.card h2{
  margin:0 0 6px;
  font-family:'Instrument Serif', serif;
  font-weight:400;
  font-size:30px;
  letter-spacing:-0.015em;
  line-height:1.05;
}
.card h3{
  margin:0 0 8px;
  font-family:'Instrument Sans', sans-serif;
  font-weight:600;
  font-size:15px;
  letter-spacing:.01em;
}

.muted{ color:#646A77 }
.small{ font-size:12px }
.right-muted{ margin-left:auto; color:#646A77; font-size:13px }

/* =========================== Pills + meta ============================== */
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 11px;
  border-radius:999px;
  border:1px solid var(--rule);
  background:var(--paper-2);
  color:#3C424E;
  font-size:12px;
  font-weight:500;
  letter-spacing:.01em;
}
.pill .code, .pill code{
  font-family:'JetBrains Mono', ui-monospace, monospace;
  font-size:11.5px;
}

.pill.status-ready{ background:var(--ok-soft); color:var(--ok); border-color:rgba(30,106,74,.22) }
.pill.status-ready::before{
  content:""; width:6px; height:6px; border-radius:50%;
  background:var(--ok); box-shadow:0 0 0 3px rgba(30,106,74,.18);
}
.pill.status-pending{
  background:var(--warn-soft); color:var(--warn);
  border-color:rgba(122,90,18,.22);
}
.pill.status-pending::before{
  content:""; width:6px; height:6px; border-radius:50%;
  background:var(--warn); animation:pulse-ai 1.6s ease-in-out infinite;
}
.pill.status-error{ background:var(--danger-soft); color:var(--danger); border-color:rgba(142,42,31,.22) }
.pill.status-cancelled{ background:#E2E2DC; color:#646A77 }

.kpis{ display:flex; gap:8px; flex-wrap:wrap }

@keyframes pulse-ai{
  0%,100%{ box-shadow:0 0 0 0 rgba(122,90,18,.4) }
  50%{ box-shadow:0 0 0 6px rgba(122,90,18,0) }
}

/* =========================== Rows ===================================== */
.row{ display:flex; gap:14px; flex-wrap:wrap; align-items:flex-end }
.row > .grow{ flex:1 1 240px }
.actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center }
.top-space{ margin-top:14px }

.section-line{
  height:1px;
  background:linear-gradient(90deg, transparent, var(--rule), transparent);
  margin:18px 0;
}
.section-line.editorial{
  height:5px;
  background:none;
  border-top:1px solid var(--ink);
  border-bottom:1px solid var(--ink);
  position:relative;
}

/* =========================== Lists (docs, templates) =================== */
.list{
  border:1px solid var(--rule);
  border-radius:var(--radius);
  overflow:hidden;
  background:var(--paper-2);
}
.list-head, .list-item{
  display:grid;
  grid-template-columns:28px minmax(0,1fr);
  gap:12px;
  align-items:flex-start;
  padding:12px 14px;
}
.list-head{
  background:var(--paper-3);
  color:#646A77;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.18em;
  font-weight:600;
  border-bottom:1px solid var(--rule);
}
.list-item{
  border-top:1px solid var(--rule);
  cursor:pointer;
  transition:background .15s ease;
  position:relative;
}
.list-item:first-of-type{ border-top:none }
.list-item:hover{ background:rgba(28,31,38,.03) }
.list-item.active{
  background:#fff;
  box-shadow:inset 3px 0 0 var(--brass);
}
.filename{
  font-weight:600;
  color:var(--ink);
  overflow-wrap:anywhere;
  word-break:break-word;
  font-size:14px;
}
.filemeta{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; margin-top:8px }

/* =========================== Result box (AI output) ==================== */
.result-box{
  background:var(--ink);
  color:#E5DDC9;
  border-radius:var(--radius);
  padding:18px 20px;
  min-height:280px;
  white-space:pre-wrap;
  word-break:break-word;
  overflow:auto;
  max-height:65vh;
  font-size:14.5px;
  line-height:1.65;
  position:relative;
  border:1px solid var(--ink);
}
.result-box::before{
  content:"§ RESPOSTA";
  position:absolute;
  top:14px; right:18px;
  font-family:'JetBrains Mono', monospace;
  font-size:10px;
  letter-spacing:.18em;
  color:rgba(229,221,201,.4);
}

.citations{ display:flex; gap:8px; flex-wrap:wrap }
.citation{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 12px;
  border-radius:6px;
  background:var(--paper-2);
  color:var(--ink);
  border:1px solid var(--rule);
  font-family:'JetBrains Mono', ui-monospace, monospace;
  font-weight:500;
  font-size:12px;
}
.citation::before{
  content:"¶";
  color:var(--brass);
  font-family:'Instrument Serif', serif;
  font-size:14px;
  margin-right:2px;
}

/* =========================== Banners / notes =========================== */
.banner, .note, .inline-note, .empty-state{
  border:1px solid var(--rule);
  background:var(--paper-2);
  border-radius:var(--radius-sm);
  padding:12px 14px;
  color:#646A77;
  font-size:13.5px;
}
.helper{
  background:#E6EBF7;
  border:1px solid rgba(30,58,138,.28);
  color:#1A2F6E;
  border-radius:var(--radius-sm);
  padding:12px 14px;
  font-size:13.5px;
  position:relative;
  padding-left:34px;
}
.helper::before{
  content:"§";
  position:absolute;
  left:14px; top:50%; transform:translateY(-50%);
  font-family:'Instrument Serif', serif;
  font-size:18px;
  color:var(--brass-2);
  font-weight:400;
}
.warning-box{
  background:#DEE5F4;
  border:1px solid rgba(30,58,138,.36);
  color:#1A2F6E;
  border-radius:var(--radius-sm);
  padding:12px 14px;
}
.empty, .empty-state{ padding:20px; color:#646A77 }

.message{ margin-top:10px; font-size:13px; color:#646A77; min-height:18px }
.status-text{ font-size:13px; color:#646A77 }

/* =========================== Tabs ====================================== */
.tabs{ display:flex; gap:6px; flex-wrap:wrap; margin-top:14px; border-bottom:1px solid var(--rule); padding-bottom:2px }
.tab{
  padding:9px 14px;
  border:1px solid transparent;
  background:transparent;
  color:#646A77;
  cursor:pointer;
  font-weight:500;
  font-size:13px;
  border-radius:0;
  border-bottom:2px solid transparent;
  min-height:auto;
  letter-spacing:.01em;
}
.tab:hover{ color:var(--ink); background:transparent; transform:none; box-shadow:none }
.tab.active{
  color:var(--ink);
  border-bottom-color:var(--brass);
  background:transparent;
}

/* =========================== Auth grid ================================= */
.auth-grid{
  display:grid;
  grid-template-columns:minmax(320px,560px) minmax(320px,540px);
  gap:24px;
  align-items:start;
  max-width:1240px;
  margin:0 auto;
}
@media(max-width:980px){ .auth-grid{ grid-template-columns:1fr } }

.hero-list{ display:flex; flex-wrap:wrap; gap:8px; margin-top:18px }
.hero-chip{
  border:1px solid var(--rule);
  background:var(--paper-3);
  border-radius:999px;
  padding:8px 14px;
  color:#3C424E;
  font-size:13px;
  font-weight:500;
}
.hero-chip::before{
  content:"§";
  color:var(--brass);
  font-family:'Instrument Serif', serif;
  margin-right:8px;
}

/* =========================== Whoami ==================================== */
.whoami{ max-width:320px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }

/* =========================== Hidden ==================================== */
.hidden{ display:none !important }

/* =========================== Modal ===================================== */
.app-modal-backdrop{
  position:fixed; inset:0;
  background:rgba(28,31,38,.42);
  backdrop-filter:blur(4px);
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:10020;
}
.app-modal-backdrop.show{ display:flex }
.app-modal{
  width:min(560px,100%);
  background:var(--paper-2);
  border:1px solid var(--rule);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);
  padding:24px 26px;
  position:relative;
}
.app-modal::before{
  content:"";
  position:absolute;
  top:0; left:24px; right:24px;
  height:3px;
  background:var(--brass);
  border-radius:0 0 2px 2px;
}
.app-modal h3{
  margin:8px 0 10px 0;
  font-family:'Instrument Serif', serif;
  font-weight:400;
  font-size:24px;
  letter-spacing:-0.01em;
  color:var(--ink);
}
.app-modal p{
  margin:0;
  color:#3C424E;
  line-height:1.55;
  white-space:pre-wrap;
}
.app-modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  margin-top:20px;
}
.app-modal, .app-modal *{ user-select:text }

/* =========================== Busy backdrop ============================ */
body.is-busy{ cursor:wait }
.busy-backdrop{
  position:fixed; inset:0;
  background:rgba(244,238,223,.78);
  backdrop-filter:blur(2px);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:10000;
  padding:16px;
}
.busy-backdrop.show{ display:flex }
.busy-card{
  min-width:min(340px,100%);
  max-width:420px;
  background:var(--paper-2);
  border:1px solid var(--rule);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);
  padding:24px 26px;
  text-align:center;
  position:relative;
}
.busy-scale{
  font-family:'Instrument Serif', serif;
  font-size:40px;
  line-height:1;
  color:var(--brass);
  display:inline-block;
  animation:c2l-sway 1.6s ease-in-out infinite;
}
.busy-title{
  margin-top:10px;
  font-weight:600;
  color:var(--ink);
  letter-spacing:.01em;
}
.busy-text{ margin-top:6px; color:#646A77; font-size:14px }

@keyframes c2l-sway{
  0%,100%{ transform:rotate(-6deg) }
  50%{ transform:rotate(6deg) }
}

.spinner{
  width:14px; height:14px;
  border-radius:50%;
  border:2px solid rgba(28,31,38,.16);
  border-top-color:var(--ink);
  display:inline-block;
  animation:spin 1s linear infinite;
  vertical-align:middle;
}
@keyframes spin{ to{ transform:rotate(360deg) } }

/* =========================== Progress (uploads) ======================== */
.progress-list{ display:flex; flex-direction:column; gap:10px }
.progress-item{
  border:1px solid var(--rule);
  border-radius:var(--radius);
  padding:14px 16px;
  background:var(--paper-2);
}
.progress-top{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:flex-start;
  flex-wrap:wrap;
}
.progress-bar{
  height:6px;
  border-radius:999px;
  background:var(--paper-3);
  border:1px solid var(--rule);
  overflow:hidden;
  margin-top:12px;
}
.progress-bar > span{
  display:block;
  height:100%;
  width:0;
  background:linear-gradient(90deg, var(--ink), var(--brass));
  transition:width .25s ease;
}

/* =========================== Summary grid (minuta) ===================== */
.summary-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:14px;
  margin-top:6px;
}
@media(max-width:780px){ .summary-grid{ grid-template-columns:1fr } }
.summary-card{
  background:var(--paper-2);
  border:1px solid var(--rule);
  border-radius:var(--radius);
  padding:16px 18px;
  min-width:0;
  position:relative;
}
.summary-card::before{
  content:"";
  position:absolute;
  top:14px; left:0;
  width:3px; height:24px;
  background:var(--brass);
  border-radius:0 2px 2px 0;
}
.summary-card h3{
  margin:0 0 10px 0;
  font-family:'Instrument Sans', sans-serif;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.18em;
  color:#646A77;
  font-weight:600;
}
.summary-card ul{ margin:0; padding-left:18px }
.summary-card li{ margin:0 0 6px 0 }
.summary-card p{ margin:0; white-space:pre-wrap; word-break:break-word; line-height:1.55 }
.summary-card.compact{ grid-column:1/-1; background:var(--paper-3) }

/* =========================== Template toolbar ========================== */
.template-toolbar, .template-manager{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  gap:10px;
  align-items:end;
}
@media(max-width:820px){
  .template-toolbar, .template-manager{ grid-template-columns:1fr }
}
.template-list{
  border:1px solid var(--rule);
  border-radius:var(--radius);
  background:var(--paper-2);
  max-height:280px;
  overflow:auto;
}
.template-item{
  padding:12px 14px;
  border-top:1px solid var(--rule);
  cursor:pointer;
  transition:background .15s ease;
}
.template-item:first-of-type{ border-top:none }
.template-item:hover{ background:rgba(28,31,38,.03) }
.template-item.selected{
  background:#fff;
  box-shadow:inset 3px 0 0 var(--brass);
}
.template-name{
  font-weight:600;
  color:var(--ink);
  overflow-wrap:anywhere;
  font-size:14px;
}
.template-meta{ margin-top:6px; color:#646A77; font-size:12px }
.template-selected-bar{ display:flex; gap:8px; flex-wrap:wrap; align-items:center }
.template-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center }
.template-file-status{
  flex-basis:100%;
  font-size:13px;
  color:#646A77;
  padding:4px 2px;
  overflow-wrap:anywhere;
}
.template-file-status.muted-error{ color:var(--danger); font-weight:600 }

/* =========================== Draft shell =============================== */
.draft-shell{
  display:grid;
  grid-template-columns:minmax(0,1.25fr) minmax(340px,0.75fr);
  gap:22px;
  align-items:start;
}
@media(max-width:1160px){ .draft-shell{ grid-template-columns:1fr } }

.draft-box{
  background:var(--paper-2);
  color:var(--ink);
  border:1px solid var(--rule);
  border-radius:var(--radius);
  padding:24px 30px;
  min-height:480px;
  white-space:pre-wrap;
  word-break:break-word;
  overflow:auto;
  max-height:72vh;
  font-family:'Instrument Serif', Georgia, serif;
  font-size:17px;
  line-height:1.7;
  letter-spacing:-0.005em;
  position:relative;
  background-image:
    linear-gradient(transparent 31px, rgba(28,31,38,.04) 32px),
    linear-gradient(var(--paper-2), var(--paper-2));
  background-size:100% 32px;
  background-position:0 8px;
}
.draft-box::first-letter{
  font-family:'Instrument Serif', serif;
  font-size:1em;
}

.chat-box{
  border:1px solid var(--rule);
  background:var(--paper-2);
  border-radius:var(--radius);
  padding:18px 20px;
}
.chat-box h2{
  font-family:'Instrument Serif', serif;
  font-size:22px;
  font-weight:400;
  margin:0 0 4px;
  letter-spacing:-0.01em;
}

.sticky-tools{ position:sticky; top:108px }

.text-sm{ font-size:13px }
.section-subtitle{ font-size:13px; color:#646A77; margin-top:2px }

.top-actions{
  display:flex;
  justify-content:space-between;
  gap:14px;
  align-items:flex-start;
  flex-wrap:wrap;
}
.page-header-actions{
  display:flex; gap:8px; flex-wrap:wrap; align-items:center;
}

/* =========================== Brand home link =========================== */
.brand-home-link{
  color:inherit;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
}
.brand-home-link:hover{ color:var(--brass-2) }
.brand-title-link{ width:max-content }

/* =========================== Responsive shrink ========================= */
@media(max-width:780px){
  header.app-header{ padding:14px 18px; flex-wrap:wrap }
  main.app-main{ padding:0 18px }
  .card{ padding:20px }
  .card h2{ font-size:25px }
}

/* =========================== v5.1.1 layout hotfix ======================= */
header.app-header{
  min-height:72px;
  overflow:visible;
}
header.app-header .brandwrap{
  flex:1 1 auto;
  max-width:calc(100% - 360px);
}
header.app-header a.c2l-brand-mark,
header.app-header .c2l-brand-mark{
  width:46px !important;
  height:46px !important;
  min-width:46px !important;
  max-width:46px !important;
  min-height:46px !important;
  max-height:46px !important;
  overflow:hidden !important;
  box-sizing:border-box;
}
header.app-header .c2l-brand-mark img{
  width:100% !important;
  height:100% !important;
  max-width:100% !important;
  max-height:100% !important;
  object-fit:contain !important;
}
header.app-header .brand{
  display:inline-flex !important;
  flex-direction:column !important;
  align-items:flex-start !important;
  white-space:normal;
}
header.app-header .brand-sub{
  display:block;
  margin-top:2px;
}
header.app-header .brand-text{
  flex:1 1 auto;
  min-width:240px;
}
header.app-header .header-actions{
  flex:0 1 auto;
  justify-content:flex-end;
}
header.app-header .whoami{
  max-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
@media(max-width:980px){
  header.app-header{ align-items:flex-start; }
  header.app-header .brandwrap{ max-width:100%; }
  header.app-header .header-actions{ width:100%; justify-content:flex-start; }
}
@media(max-width:640px){
  header.app-header .brandwrap{ gap:10px; }
  header.app-header a.c2l-brand-mark,
  header.app-header .c2l-brand-mark{
    width:38px !important;
    height:38px !important;
    min-width:38px !important;
    max-width:38px !important;
    min-height:38px !important;
    max-height:38px !important;
  }
  header.app-header .brand{ font-size:24px; }
  header.app-header .nav{ gap:6px; }
  header.app-header .nav a{ padding:7px 10px; }
}

/* =========================== Report widget ============================== */
.c2l-report-button{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:60;
  border:0;
  border-radius:999px;
  padding:12px 16px;
  background:var(--ink);
  color:var(--paper-2);
  box-shadow:0 18px 40px rgba(28,31,38,.22);
  font-weight:700;
  letter-spacing:.01em;
  cursor:pointer;
}
.c2l-report-button:hover{ transform:translateY(-1px); }
.c2l-report-modal-backdrop{
  position:fixed;
  inset:0;
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
  background:rgba(28,31,38,.42);
  z-index:80;
}
.c2l-report-modal-backdrop.show{ display:flex; }
.c2l-report-modal{
  width:min(640px, 100%);
  max-height:92vh;
  overflow:auto;
  background:var(--paper-2);
  border:1px solid var(--rule);
  border-radius:22px;
  padding:22px;
  box-shadow:0 24px 70px rgba(28,31,38,.28);
}
.c2l-report-modal h3{ margin:0 0 6px; }
.c2l-report-modal .muted{ margin-bottom:16px; }
.c2l-report-grid{ display:grid; gap:12px; }
.c2l-report-modal textarea{ min-height:130px; }
.c2l-report-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
  margin-top:16px;
}
.c2l-report-status{
  min-height:20px;
  font-size:13px;
  color:var(--muted);
}
@media(max-width:640px){
  .c2l-report-button{ right:14px; bottom:14px; padding:11px 13px; }
}


/* =========================== v5.2 overrides ============================= */
/* Proteção adicional contra logo desproporcional no header interno. */
header.app-header{
  min-height:112px;
}
header.app-header .brandwrap{
  flex:1 1 auto;
  overflow:hidden;
}
header.app-header a.c2l-brand-mark,
header.app-header .c2l-brand-mark{
  width:64px !important;
  height:64px !important;
  min-width:64px !important;
  max-width:64px !important;
  min-height:64px !important;
  max-height:64px !important;
  padding:7px !important;
  overflow:hidden !important;
}
header.app-header .c2l-brand-mark img,
header.app-header img[alt="CHAT2LAW"]{
  width:100% !important;
  height:100% !important;
  max-width:100% !important;
  max-height:100% !important;
  object-fit:contain !important;
  display:block !important;
}
header.app-header .brand{
  font-size:31px;
}
header.app-header .brand-sub{
  font-size:10.5px;
}
header.app-header .sub{
  font-size:14px;
  margin-top:6px;
}
.header-actions{
  flex:0 0 auto;
}

.c2l-record-box{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  padding:10px 12px;
  border:1px solid var(--rule);
  border-radius:14px;
  background:#fff;
}
.c2l-record-box .muted{
  margin:0;
  font-size:12px;
}

.report-list{
  display:grid;
  gap:12px;
}
.report-card{
  border:1px solid var(--rule);
  border-radius:18px;
  background:#fff;
  padding:16px;
  box-shadow:0 8px 24px rgba(28,31,38,.05);
}
.report-card-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  flex-wrap:wrap;
}
.report-card-title{
  font-weight:700;
  color:var(--ink);
}
.report-meta{
  color:var(--muted);
  font-size:12px;
  line-height:1.5;
}
.report-message{
  white-space:pre-wrap;
  margin-top:10px;
  color:var(--ink);
}
.report-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:12px;
}
.report-filters{
  display:grid;
  grid-template-columns: minmax(180px, 1fr) 180px auto;
  gap:12px;
  align-items:end;
}
@media(max-width:820px){
  .report-filters{ grid-template-columns:1fr; }
  header.app-header{
    align-items:flex-start;
  }
}


/* =========================== v5.2.1 refinements ========================= */
header.app-header .nav a{ font-size:14px; }
header.app-header .header-actions .pill,
header.app-header .header-actions .chip,
header.app-header .whoami{ font-size:13px; }
.c2l-report-modal,
.c2l-report-modal input,
.c2l-report-modal select,
.c2l-report-modal textarea,
.c2l-report-modal button,
.report-card,
.report-filters input,
.report-filters select{ font-family:'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.c2l-nav-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:18px;
  height:18px;
  padding:0 5px;
  margin-left:7px;
  border-radius:999px;
  background:#B42318;
  color:#fff;
  font-size:11px;
  line-height:1;
  font-weight:800;
}
.c2l-nav-badge.hidden{ display:none !important; }
.btn-danger-soft{
  border:1px solid #f2c9c5;
  background:#fff8f7;
  color:#9f1d16;
  border-radius:999px;
  padding:10px 14px;
  font-weight:700;
  cursor:pointer;
}
.btn-danger-soft:hover{ background:#fff1ef; }
.c2l-recording-bar{
  position:fixed;
  top:14px;
  left:50%;
  transform:translateX(-50%);
  z-index:120;
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 14px;
  border-radius:999px;
  background:rgba(28,31,38,.94);
  color:#fff;
  box-shadow:0 18px 40px rgba(28,31,38,.25);
  font-family:'Inter', system-ui, sans-serif;
}
.c2l-recording-bar strong{ display:block; font-size:13px; line-height:1.1; }
.c2l-recording-bar span{ display:block; font-size:12px; opacity:.82; }
.c2l-recording-bar button{
  border:1px solid rgba(255,255,255,.25);
  background:rgba(255,255,255,.12);
  color:#fff;
  border-radius:999px;
  padding:7px 10px;
  font-weight:700;
  cursor:pointer;
}
.c2l-recording-dot{
  width:10px;
  height:10px;
  border-radius:999px;
  background:#ef4444;
  box-shadow:0 0 0 5px rgba(239,68,68,.18);
}
@media(max-width:640px){
  header.app-header a.c2l-brand-mark,
  header.app-header .c2l-brand-mark{
    width:52px !important;
    height:52px !important;
    min-width:52px !important;
    max-width:52px !important;
    min-height:52px !important;
    max-height:52px !important;
  }
  header.app-header .brand{ font-size:27px; }
}


/* =========================== v5.2.2 refinements ========================= */
/* Força atualização visual uniforme em todas as páginas internas. */
header.app-header{
  min-height:128px !important;
  padding:22px 32px !important;
}
header.app-header .brandwrap{
  gap:20px !important;
  align-items:center !important;
  overflow:visible !important;
}
header.app-header a.c2l-brand-mark,
header.app-header .c2l-brand-mark{
  width:76px !important;
  height:76px !important;
  min-width:76px !important;
  max-width:76px !important;
  min-height:76px !important;
  max-height:76px !important;
  padding:8px !important;
  border-radius:15px !important;
}
header.app-header .c2l-brand-mark img,
header.app-header img[alt="CHAT2LAW"]{
  width:100% !important;
  height:100% !important;
  max-width:100% !important;
  max-height:100% !important;
  object-fit:contain !important;
}
header.app-header .brand{
  font-size:34px !important;
  line-height:.92 !important;
}
header.app-header .brand-sub{
  font-size:11px !important;
  margin-top:7px !important;
}
header.app-header .sub{
  font-size:15px !important;
}
header.app-header .nav{
  margin-top:14px !important;
}

/* Consolidação tipográfica das novas áreas com a identidade v5.1. */
.page h1,
.section-head h1,
.card h1,
.c2l-report-modal h3{
  font-family:'Instrument Serif', Georgia, serif !important;
  font-weight:400 !important;
  color:var(--ink) !important;
  letter-spacing:-0.025em !important;
}
.page h1,
.section-head h1,
.card h1{
  font-size:34px !important;
  line-height:1.05 !important;
  margin:0 0 8px !important;
}
.c2l-report-modal h3{
  font-size:30px !important;
  line-height:1.05 !important;
}
.c2l-report-modal .muted,
.c2l-report-modal label,
.c2l-report-modal input,
.c2l-report-modal select,
.c2l-report-modal textarea,
.c2l-report-modal button,
.report-card,
.report-card *,
.report-filters,
.report-filters *{
  font-family:'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}
.c2l-report-modal h3,
.page h1,
.section-head h1,
.card h1{
  font-family:'Instrument Serif', Georgia, serif !important;
}
@media(max-width:760px){
  header.app-header{
    min-height:auto !important;
    padding:18px !important;
  }
  header.app-header a.c2l-brand-mark,
  header.app-header .c2l-brand-mark{
    width:62px !important;
    height:62px !important;
    min-width:62px !important;
    max-width:62px !important;
    min-height:62px !important;
    max-height:62px !important;
  }
  header.app-header .brand{ font-size:29px !important; }
}


/* =========================== v5.3 refinements =========================== */
/* Uniformiza definitivamente logo/cabeçalho em todas as páginas internas, inclusive Meus processos. */
header.app-header{
  min-height:132px !important;
  padding:24px 34px !important;
}
header.app-header .brandwrap{
  gap:20px !important;
  align-items:center !important;
}
header.app-header .c2l-brand-mark,
header.app-header a.c2l-brand-mark,
body.page-processos header.app-header .c2l-brand-mark,
body.page-processos header.app-header a.c2l-brand-mark{
  width:76px !important;
  height:76px !important;
  min-width:76px !important;
  max-width:76px !important;
  min-height:76px !important;
  max-height:76px !important;
  padding:8px !important;
  border-radius:15px !important;
  box-sizing:border-box !important;
  overflow:hidden !important;
}
body.page-processos header.app-header .c2l-brand-mark img,
body.page-processos header.app-header img[alt="CHAT2LAW"],
header.app-header .c2l-brand-mark img,
header.app-header img[alt="CHAT2LAW"]{
  width:100% !important;
  height:100% !important;
  max-width:100% !important;
  max-height:100% !important;
  object-fit:contain !important;
  display:block !important;
}
header.app-header .brand{
  font-size:34px !important;
  line-height:.92 !important;
}
header.app-header .sub{
  font-size:14.5px !important;
}
.whoami{
  max-width:320px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
@media(max-width:720px){
  header.app-header .c2l-brand-mark,
  header.app-header a.c2l-brand-mark,
  body.page-processos header.app-header .c2l-brand-mark,
  body.page-processos header.app-header a.c2l-brand-mark{
    width:62px !important;
    height:62px !important;
    min-width:62px !important;
    max-width:62px !important;
    min-height:62px !important;
    max-height:62px !important;
  }
  header.app-header .brand{ font-size:29px !important; }
}

/* =========================== v5.4 Backoffice =========================== */
.backoffice-page{ display:flex; flex-direction:column; gap:22px; }
.backoffice-kpis{
  display:grid;
  grid-template-columns:repeat(4,minmax(180px,1fr));
  gap:14px;
}
.bo-kpi{
  background:var(--paper-2);
  border:1px solid var(--rule);
  border-radius:var(--radius-lg);
  padding:18px 20px;
  box-shadow:var(--shadow-sm);
  min-height:122px;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}
.bo-kpi span,
.bo-facts span{ color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.12em; font-weight:600; }
.bo-kpi strong{ font-family:'Instrument Serif', serif; font-size:38px; font-weight:400; line-height:1; letter-spacing:-.02em; }
.bo-kpi small{ color:var(--muted); font-size:12px; }
.backoffice-grid{ display:grid; grid-template-columns:minmax(0,1.2fr) minmax(320px,.8fr); gap:22px; align-items:start; }
.backoffice-grid.wide-left{ grid-template-columns:minmax(0,1.45fr) minmax(320px,.55fr); }
.section-head.compact{ align-items:flex-start; gap:16px; }
.section-head.compact h2{ font-size:28px; }
.bo-chart{ min-height:190px; display:flex; gap:7px; align-items:end; padding:18px 8px 4px; border:1px solid var(--rule-soft); border-radius:var(--radius); background:rgba(255,255,255,.38); overflow-x:auto; }
.bo-bar{ min-width:26px; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:7px; color:var(--muted); }
.bo-bar span{ width:16px; border-radius:999px 999px 4px 4px; background:var(--ink); box-shadow:0 8px 18px rgba(28,31,38,.14); }
.bo-bar small{ writing-mode:vertical-rl; transform:rotate(180deg); font-size:10px; font-family:'JetBrains Mono', ui-monospace, monospace; }
.bo-status-list{ display:flex; flex-direction:column; gap:10px; }
.bo-status-row{ display:grid; grid-template-columns:1fr auto auto; gap:12px; align-items:center; padding:12px 0; border-bottom:1px solid var(--rule-soft); }
.bo-status-row:last-child{ border-bottom:none; }
.bo-status-row strong{ font-size:22px; }
.bo-status-row > span:last-child{ color:var(--muted); font-size:13px; }
.bo-table-wrap{ overflow:auto; border:1px solid var(--rule); border-radius:var(--radius); background:var(--paper-2); }
.bo-table{ width:100%; border-collapse:collapse; font-size:13px; }
.bo-table th,
.bo-table td{ text-align:left; padding:11px 13px; border-bottom:1px solid var(--rule-soft); vertical-align:top; }
.bo-table th{ background:var(--paper-3); color:var(--muted); text-transform:uppercase; letter-spacing:.12em; font-size:10.5px; font-weight:700; white-space:nowrap; }
.bo-table td{ overflow-wrap:anywhere; }
.bo-table tr:last-child td{ border-bottom:none; }
.bo-facts{ display:grid; gap:12px; }
.bo-facts div{ border-bottom:1px solid var(--rule-soft); padding-bottom:11px; }
.bo-facts div:last-child{ border-bottom:none; }
.bo-facts strong{ display:block; margin-top:4px; font-size:15px; overflow-wrap:anywhere; }
@media(max-width:1100px){
  .backoffice-kpis{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .backoffice-grid,
  .backoffice-grid.wide-left{ grid-template-columns:1fr; }
}
@media(max-width:680px){ .backoffice-kpis{ grid-template-columns:1fr; } }


/* v5.5 Backoffice isolado */
.office-tabs{display:flex;flex-wrap:wrap;gap:10px;margin:18px 0 0;}
.office-tab{border:1px solid var(--rule);background:var(--paper-2);border-radius:999px;padding:10px 16px;font-weight:800;cursor:pointer;color:var(--ink);}
.office-tab.active{background:var(--ink);color:white;border-color:var(--ink);box-shadow:0 10px 24px rgba(28,31,38,.12);}
.office-section.hidden{display:none!important;}
.office-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;}
.office-grid.two{grid-template-columns:1.4fr .9fr;}
.office-grid.three{grid-template-columns:repeat(3,minmax(0,1fr));}
.office-status{font-size:13px;color:var(--muted);margin-top:10px;}
.office-toolbar{display:flex;gap:12px;align-items:end;flex-wrap:wrap;margin:14px 0;}
.office-toolbar .grow{flex:1;min-width:240px;}
.office-role-note{padding:12px 14px;border:1px solid var(--rule);border-radius:var(--radius);background:var(--paper-3);color:var(--muted);}
@media(max-width:980px){.office-grid,.office-grid.two,.office-grid.three{grid-template-columns:1fr}.office-tabs{gap:8px}.office-tab{padding:9px 12px}}

.app-footer{padding:22px 32px;color:var(--muted);font-size:13px;border-top:1px solid var(--line);background:rgba(250,247,240,.72)}
.app-footer .code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.tiny{font-size:12px}


/* =========================== v5.5 Backoffice bucket tree =========================== */
.backoffice-nav a.active { font-weight: 800; }
.bucket-tree { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: rgba(255,255,255,.72); }
.bucket-tree-head { display:flex; gap:12px; justify-content:space-between; align-items:center; padding:14px 16px; background: rgba(31,35,43,.05); border-bottom:1px solid var(--line); }
.bucket-folder { border-bottom: 1px solid rgba(0,0,0,.06); }
.bucket-folder summary { cursor:pointer; display:flex; align-items:center; gap:10px; padding:12px 16px; list-style:none; }
.bucket-folder summary::-webkit-details-marker { display:none; }
.bucket-folder summary::before { content:'▸'; font-size:12px; transition: transform .15s ease; }
.bucket-folder[open] > summary::before { transform: rotate(90deg); }
.bucket-children { padding-left: 22px; border-left: 2px solid rgba(0,0,0,.05); margin-left: 20px; }
.bucket-icon { width: 22px; display:inline-flex; justify-content:center; }
.bucket-file, .bucket-doc-row { display:flex; justify-content:space-between; gap:16px; align-items:center; padding:12px 16px; border-bottom:1px solid rgba(0,0,0,.05); }
.bucket-file-meta { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }
.bucket-docs-summary { margin-bottom:18px; border:1px solid var(--line); border-radius:18px; overflow:hidden; background:rgba(255,255,255,.72); }
.bucket-docs-summary h3 { padding:14px 16px; margin:0; border-bottom:1px solid var(--line); }
@media (max-width: 820px){ .bucket-file, .bucket-doc-row, .bucket-tree-head { align-items:flex-start; flex-direction:column; } .bucket-file-meta { justify-content:flex-start; } }


/* =========================== v5.6.4 logo asset update ===================== */
header.app-header .c2l-brand-mark,
header.app-header a.c2l-brand-mark,
body.page-processos header.app-header .c2l-brand-mark,
body.page-processos header.app-header a.c2l-brand-mark,
.c2l-brand-mark{
  background:transparent !important;
  border:0 !important;
  padding:0 !important;
  border-radius:18px !important;
  overflow:hidden !important;
  box-shadow:0 8px 22px rgba(28,31,38,.18) !important;
}
header.app-header .c2l-brand-mark img,
header.app-header img[alt="CHAT2LAW"],
.c2l-brand-mark img{
  width:100% !important;
  height:100% !important;
  object-fit:contain !important;
  filter:none !important;
}


/* =========================== v5.6.4 logo final asset ===================== */
header.app-header .c2l-brand-mark,
header.app-header a.c2l-brand-mark,
body.page-processos header.app-header .c2l-brand-mark,
body.page-processos header.app-header a.c2l-brand-mark,
.c2l-brand-mark{
  background:transparent !important;
  border:0 !important;
  padding:0 !important;
  border-radius:16px !important;
  overflow:visible !important;
  box-shadow:none !important;
}
header.app-header .c2l-brand-mark img,
header.app-header img[alt="CHAT2LAW"],
.c2l-brand-mark img{
  width:100% !important;
  height:100% !important;
  object-fit:contain !important;
  filter:none !important;
}
