/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:#e8eaee; --card:#fff; --line:#e4e7ec; --line-2:#eef0f3; --chip:#eef0f3;
  --navy:#16243c; --navy-2:#1f3a63;
  --ink:#192231; --body:#4d5868; --mut:#5b6472; --mut-2:#7a8390;
  --blue:#2563eb; --green:#1f9d57; --amber:#d9911a; --red:#d23b3b;
  --r:14px; --shadow:0 1px 2px rgba(16,24,40,.05),0 1px 3px rgba(16,24,40,.04); --maxw:1440px;
  --mse:#e51943;
  /* aliases backward-compat */
  --primary:var(--blue); --accent:var(--blue);
  --dark:var(--navy); --dark2:var(--card); --dark3:var(--line-2);
  --surface:var(--card); --surface2:var(--line-2); --border:var(--line);
  --text:var(--ink); --text1:var(--ink); --text2:var(--mut);
  --muted:var(--mut); --gray:var(--mut); --light:var(--line-2); --white:#fff;
  --yellow:var(--amber); --radius:var(--r);
}
body {
  font-family:'IBM Plex Sans','Segoe UI',Arial,sans-serif;
  background:var(--bg); color:var(--ink); font-size:13px;
  -webkit-font-smoothing:antialiased; line-height:1.5;
}
a { text-decoration:none; color:inherit; }
button { cursor:pointer; font-family:inherit; }

/* ═══ HEADER full-width navy ═══ */
.hdr {
  position:sticky; top:0; z-index:200; overflow:hidden; color:#fff;
  background:
    radial-gradient(640px 360px at 85% -30%, rgba(64,120,210,.5), transparent 62%),
    linear-gradient(118deg,#13223b 0%,#193053 68%,#1f3a63 100%);
  border-bottom:1px solid rgba(255,255,255,.06);
}
.hrow {
  display:flex; align-items:center; gap:18px; padding:14px 20px;
  height:60px;
}
.brand { display:flex; align-items:center; gap:20px; min-width:0; }
.logo  { height:44px; width:auto; display:block; filter:brightness(0)invert(1); opacity:.95; }
.hsep  { width:1px; height:42px; background:rgba(255,255,255,.16); flex:none; }
.titles .t {
  font-weight:700; font-size:15px; letter-spacing:.2px; text-transform:uppercase;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.titles .t b { color:#5b9bf0; font-weight:700; }
.titles .s {
  font-family:'IBM Plex Mono',monospace; font-size:10px; letter-spacing:.6px;
  color:rgba(255,255,255,.5); margin-top:3px;
}
.grow { flex:1; }
.hdr-acts { display:flex; align-items:center; gap:6px; }
.hdr-badge { color:rgba(255,255,255,.82); font-size:11.5px; }
.hdr-bc {
  font-size:10.5px; color:rgba(255,255,255,.45);
  font-family:'IBM Plex Mono',monospace; letter-spacing:.5px; padding-right:8px;
}
.ic {
  width:34px; height:34px; border:0; border-radius:9px;
  background:transparent; color:rgba(255,255,255,.62);
  display:grid; place-items:center; cursor:pointer; transition:.15s;
}
.ic:hover { background:rgba(255,255,255,.1); color:#fff; }
.ic svg { width:18px; height:18px; stroke-width:1.7; }
.ic i   { font-size:14px; }

/* ═══ SHELL: sidebar card + main ═══ */
.shell {
  display:flex; align-items:flex-start; padding:0 8px 0 12px;
}
.side {
  width:216px; flex:none; position:sticky; top:72px;
  align-self:flex-start; max-height:calc(100vh - 86px);
  overflow-y:auto; background:var(--navy);
  border:1px solid rgba(255,255,255,.06); border-radius:16px;
  box-shadow:var(--shadow); margin-top:20px; padding:10px;
}
.side::-webkit-scrollbar { width:6px; }
.side::-webkit-scrollbar-thumb { background:rgba(255,255,255,.14); border-radius:6px; }
.main { flex:1; min-width:0; padding:20px 0 70px 18px; }
.shell.sidebar-hidden .side { display:none; }
.shell.sidebar-hidden .main { padding-left:0; }

/* ═══ SIDEBAR: busca ═══ */
.ssearch {
  display:flex; align-items:center; gap:10px;
  background:rgba(255,255,255,.06); border-radius:999px; padding:8px 14px;
  margin-bottom:8px;
}
.ssearch svg { width:16px; height:16px; color:rgba(255,255,255,.4); flex:none; }
.ssearch input {
  flex:1; border:none; background:transparent; outline:none;
  font-size:13px; color:#fff; font-family:inherit;
  min-width:0;
}
.ssearch input::placeholder { color:rgba(255,255,255,.35); }
.ssearch .ss-clear {
  display:none; border:none; background:none; cursor:pointer;
  color:rgba(255,255,255,.5); font-size:13px; padding:0; line-height:1;
}
.ssearch:focus-within { background:rgba(255,255,255,.1); }

/* ═══ SIDEBAR: grupo/label ═══ */
.grp {
  font-family:'IBM Plex Mono',monospace; font-size:10px; font-weight:500;
  letter-spacing:1.4px; text-transform:uppercase; color:rgba(255,255,255,.32);
  padding:14px 12px 6px;
}

/* ═══ SIDEBAR: item de nav ═══ */
.nv {
  display:flex; align-items:center; gap:13px;
  padding:9px 12px; border-radius:999px;
  cursor:pointer; color:rgba(255,255,255,.72); transition:.13s;
  white-space:nowrap; overflow:hidden;
}
.nv:hover { background:rgba(255,255,255,.07); }
.nv .ni {
  width:20px; height:20px; flex:none; color:rgba(255,255,255,.5);
  display:grid; place-items:center; flex-shrink:0;
}
.nv .ni i   { font-size:14px; }
.nv .ni svg { width:19px; height:19px; stroke-width:1.8; }
.nv .nl {
  font-size:14px; font-weight:500; flex:1;
  white-space:normal; line-height:1.25; word-break:break-word;
}
.nv .chev { flex:none; color:rgba(255,255,255,.32); display:grid; place-items:center; border-radius:6px; padding:4px; }
.nv .chev:hover { background:rgba(255,255,255,.1); }
.nv .chev svg { width:14px; height:14px; stroke-width:2; transition:transform .15s; transform:rotate(90deg); }
.nv.nv-collapsed .chev svg { transform:rotate(0deg); }
/* Ativo */
.nv.on { background:rgba(91,155,240,.18); color:#8ec1ff; }
.nv.on .ni { color:#8ec1ff; }
.nv.on .nl { font-weight:600; }
.nv.on .chev { color:#8ec1ff; }
/* Subitem (indentado) */
.nv.nv-sub { padding-left:26px; }
.nv.nv-sub .nl { font-size:13px; }

/* Badge numérico na nav */
.nav-badge {
  background:var(--red); color:#fff; font-size:9px; font-weight:700;
  min-width:16px; height:16px; border-radius:8px;
  display:inline-flex; align-items:center; justify-content:center;
  padding:0 4px; flex-shrink:0; margin-left:auto;
}
.nv.on .nav-badge { background:rgba(142,193,255,.25); color:#8ec1ff; }

/* Footer da sidebar */
.side-footer {
  padding:12px 12px 4px; border-top:1px solid rgba(255,255,255,.1); margin-top:8px;
  font-size:9.5px; color:rgba(255,255,255,.35);
  font-family:'IBM Plex Mono',monospace; letter-spacing:.5px;
}

/* ═══ PÁGINAS ═══ */
.page { display:none; }
.page.active { display:block; }

/* Aliases legacy — mantém compatibilidade com regras CSS abaixo */
.layout { display: block; }
#usuario-badge { color: rgba(255,255,255,.82); font-size: 12px; }

/* ═══════════════════════════════════════════════════
   BOTÕES
═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: none; transition: all .15s;
}
.btn-primary        { background: var(--blue); color: #fff; }
.btn-primary:hover  { background: #1d4ed8; }
.btn-secondary      { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--line-2); }
.btn-ghost          { background: rgba(255,255,255,.12); color: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.2); }
.btn-ghost:hover    { background: rgba(255,255,255,.2); color: #fff; }

/* btn-ghost em áreas claras */
.page .btn-ghost,
.modal .btn-ghost,
.modal-overlay .btn-ghost          { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.page .btn-ghost:hover,
.modal .btn-ghost:hover,
.modal-overlay .btn-ghost:hover    { background: var(--line-2); }

.btn-sm     { padding: 4px 10px; font-size: 11px; }
.btn-danger { background: #fee2e2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; }

/* ═══════════════════════════════════════════════════
   PÁGINAS (conteúdo interno)
═══════════════════════════════════════════════════ */

/* ── Section Header ── */
.section-hdr {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; margin-top: 2px;
}
.section-hdr-label {
  font-size: 9px; font-weight: 600; color: var(--mut);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 2px;
  white-space: nowrap;
}
.section-hdr-line  { flex: 1; height: 1px; background: var(--line); }
.section-hdr-badge { background: var(--blue); color: #fff; font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 8px; }

/* ═══════════════════════════════════════════════════
   KPI STRIPS
═══════════════════════════════════════════════════ */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }

.dc-kpi-strip {
  border-radius: var(--r);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dc-kpi-strip.blue   { border-left-color: var(--blue); }
.dc-kpi-strip.green  { border-left-color: var(--green); }
.dc-kpi-strip.yellow { border-left-color: var(--amber); }
.dc-kpi-strip.gray   { border-left-color: var(--mut); }
.dc-kpi-strip.accent { border-left-color: var(--blue); }
.dc-kpi-strip.red    { border-left-color: var(--red); }
.dc-kpi-strip.red .dc-kpi-icon { background: #fee2e2; color: var(--red); }

.dc-kpi-card  { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.dc-kpi-icon  {
  width: 36px; height: 36px; background: #dbeafe; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--blue); font-size: 14px; flex-shrink: 0;
}
.dc-kpi-strip.blue .dc-kpi-icon   { background: #dbeafe; color: var(--blue); }
.dc-kpi-strip.green .dc-kpi-icon  { background: #d1fae5; color: var(--green); }
.dc-kpi-strip.yellow .dc-kpi-icon { background: #fef3c7; color: var(--amber); }
.dc-kpi-strip.gray .dc-kpi-icon   { background: var(--line-2); color: var(--mut); }

.dc-kpi-body  { flex: 1; min-width: 0; }
.dc-kpi-label {
  font-size: 9px; color: var(--mut);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px;
}
.dc-kpi-value { font-size: 18px; font-weight: 700; line-height: 1; color: var(--ink); }
.dc-kpi-sub   { font-size: 10px; color: var(--mut); margin-top: 3px; }

/* ── Dashboard alert panel ── */
.dash-alert-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px;
  border-radius: 8px; cursor: pointer; transition: background .15s;
  border-bottom: 1px solid var(--line);
}
.dash-alert-row:last-child { border-bottom: none; }
.dash-alert-row:hover { background: var(--line-2); }
.dash-alert-label { flex: 1; font-size: 12px; font-weight: 500; color: var(--ink); }
.dash-alert-badge {
  font-size: 11px; font-weight: 700; min-width: 28px; text-align: center;
  padding: 2px 8px; border-radius: 12px;
}
.dash-alert-badge.red    { background: #fee2e2; color: var(--red); }
.dash-alert-badge.yellow { background: #fef3c7; color: var(--amber); }
.dash-alert-badge.gray   { background: var(--line-2); color: var(--mut); }
.dash-alert-badge.purple { background: #f5f3ff; color: #6366f1; }
.dash-alert-badge.blue   { background: #dbeafe; color: var(--blue); }

/* Legacy kpi-card */
.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; border-left: 4px solid var(--green); box-shadow: var(--shadow);
}
.kpi-card.accent { border-left-color: var(--blue); }
.kpi-card.yellow { border-left-color: var(--amber); }
.kpi-card.blue   { border-left-color: var(--blue); }
.kpi-card.gray   { border-left-color: var(--mut); }
.kpi-label {
  font-size: 9px; color: var(--mut);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 6px;
}
.kpi-value { font-size: 18px; font-weight: 700; line-height: 1; }
.kpi-sub   { font-size: 10px; color: var(--mut); margin-top: 4px; }

/* ── Direct Card ── */
.direct-modules { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.direct-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  min-width: 140px; box-shadow: var(--shadow);
}
.direct-card:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(37,99,235,.12); }
.dc-icon {
  width: 36px; height: 36px; background: var(--blue);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; flex-shrink: 0;
}
.dc-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }

/* ── DC Block ── */
.dc-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow);
}
.dc-block-header {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-bottom: 2px solid var(--blue);
}
.dc-block-icon {
  width: 28px; height: 28px; background: var(--blue);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; flex-shrink: 0;
}
.dc-block-icon.obra  { background: var(--amber); }
.dc-block-icon.blue  { background: var(--blue); }
.dc-block-icon.green { background: var(--green); }
.dc-block-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  font-family: 'IBM Plex Mono', monospace;
}
.dc-block-fields { padding: 14px 16px; display: grid; gap: 10px; }
.dc-grid-2col { grid-template-columns: 1fr 1fr; }
.dc-field-label {
  font-size: 9px; color: var(--mut);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px;
}
.dc-field-value { font-size: 13px; font-weight: 500; }

/* ═══════════════════════════════════════════════════
   CHARTS
═══════════════════════════════════════════════════ */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 20px; }
.chart-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow);
}
.chart-card h3 {
  font-size: 9px; font-weight: 600; color: var(--mut);
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════
   TABELAS
═══════════════════════════════════════════════════ */
.table-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow); overflow-x: auto;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.table-header h3 { font-size: 12px; font-weight: 700; }
.table-count { font-size: 11px; color: var(--mut); margin-left: 6px; }
.table-filters { display: flex; gap: 8px; align-items: center; }
.table-filters input,
.table-filters select {
  background: var(--line-2); border: 1px solid var(--line); color: var(--ink);
  padding: 5px 10px; border-radius: 8px; font-size: 11px; font-family: inherit;
}
.table-filters input::placeholder { color: var(--mut); }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--line-2); padding: 9px 12px; text-align: left;
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--body); white-space: nowrap; border-bottom: 1px solid var(--line);
}
thead th.nr { text-align: right; }
thead th.ct { text-align: center; }
tbody td {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 12px; white-space: nowrap;
}
tbody td.nr, tfoot td.nr { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.ct { text-align: center; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover td { background: var(--line-2); }
tbody tr:last-child td { border-bottom: none; }

/* table-mse */
.table-mse { width: 100%; border-collapse: collapse; }
.table-mse thead th {
  background: var(--line-2); padding: 9px 12px; text-align: left;
  font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--body); white-space: nowrap; border-bottom: 1px solid var(--line);
}
.table-mse thead th.nr { text-align: right; }
.table-mse thead th.ct { text-align: center; }
.table-mse tbody td {
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  font-size: 12px; white-space: nowrap;
}
.table-mse tbody td.nr { text-align: right; font-variant-numeric: tabular-nums; }
.table-mse tbody td.ct { text-align: center; }
.table-mse tbody tr { cursor: pointer; transition: background .1s; }
.table-mse tbody tr:hover td { background: var(--line-2); }
.table-mse tbody tr:last-child td { border-bottom: none; }

/* ── Chips de perfil ── */
.mp-perfil-chip {
  display: inline-block; padding: 2px 9px; border-radius: 10px;
  font-size: 10px; font-weight: 700; white-space: nowrap; letter-spacing: .3px;
}
.mp-master  { background: #ede9fe; color: #7c3aed; }
.mp-mse     { background: #dbeafe; color: #1d4ed8; }
.mp-cliente { background: #dcfce7; color: #15803d; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.badge-ok     { background: #dcfce7; color: #16a34a; }
.badge-warn   { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: var(--red); }

.cc-badge      { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.cc-badge-ok   { background: #dcfce7; color: #16a34a; }
.cc-badge-off  { background: #fee2e2; color: var(--red); }
.cc-badge-warn { background: #fef3c7; color: #d97706; }

.badge-sc-ativo     { background: #dcfce7; color: #16a34a; }
.badge-sc-distrato  { background: #fef3c7; color: #d97706; }
.badge-sc-encerrado { background: var(--line-2); color: var(--mut); }
.badge-sc-cancelado { background: #fee2e2; color: #dc2626; }

/* ── Progress bar ── */
.prog { position: relative; background: var(--line-2); border-radius: 3px; height: 14px; min-width: 60px; }
.prog-fill { height: 100%; border-radius: 3px; position: absolute; top: 0; left: 0; transition: width .3s; }
.prog span { position: relative; z-index: 1; font-size: 9px; padding: 0 4px; line-height: 14px; display: block; text-align: center; }

.obra-progress { margin-top: 2px; }
.obra-progress-label { display: flex; justify-content: space-between; font-size: 10px; color: var(--mut); margin-bottom: 3px; }
.obra-bar { height: 5px; background: var(--line-2); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.obra-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.obra-bar-fill.fisico     { background: var(--green); }
.obra-bar-fill.financeiro { background: var(--blue); }
.obra-bar-fill.prazo      { background: var(--amber); }

/* ── Obras grid ── */
.obras-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.obra-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.obra-card:hover { border-color: var(--blue); box-shadow: 0 4px 14px rgba(37,99,235,.12); }
.obra-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 2px solid var(--amber);
}
.obra-card-icon {
  width: 30px; height: 30px; background: var(--amber);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; flex-shrink: 0;
}
.obra-card-title { font-size: 12px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.obra-card-body  { padding: 12px 16px; }
.obra-stat { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 11px; }
.obra-stat .lbl { color: var(--mut); }
.obra-alert {
  background: #fef3c7; color: var(--amber);
  padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 700;
  display: inline-block; margin-top: 8px;
}

/* ═══════════════════════════════════════════════════
   MODAIS
═══════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(25,34,49,.55);
  display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 24px; width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(25,34,49,.18);
}
.modal h2 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--ink); }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block; font-size: 10.5px; color: var(--mut);
  font-family: 'IBM Plex Mono', monospace;
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 1.2px;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%; background: var(--line-2); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; font-family: inherit;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { outline: none; border-color: var(--blue); }
.form-row input::placeholder,
.form-row textarea::placeholder { color: var(--mut); opacity: 1; }
.form-row select option { background: var(--card); }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
#detalhe-body { font-size: 13px; }

/* ═══════════════════════════════════════════════════
   RELATÓRIO MSE (dashboard gerado — mesmo layout do e-mail)
═══════════════════════════════════════════════════ */
.mse-report-overlay {
  position: fixed; inset: 0; background: rgba(25,34,49,.65); z-index: 2000;
  display: none; align-items: flex-start; justify-content: center;
  padding: 28px 16px; overflow-y: auto;
}
.mse-report-overlay.open { display: flex; }
.mse-report-toolbar {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: flex-end;
  gap: 8px; width: 100%; max-width: 980px; margin: 0 auto 10px;
}
/* .btn-ghost por padrão tem texto quase branco (pensado pra fundo escuro);
   aqui o fundo é forçado branco inline — sem isso o texto ficava invisível
   ("botão em branco", pedido da Daniele, 2026-08-19). */
.mse-report-toolbar .btn-ghost { color: var(--ink) !important; }
.mse-report-page {
  background: #fff; width: 100%; max-width: 980px; border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35); overflow: hidden;
  font-family: 'IBM Plex Sans','Segoe UI',Arial,sans-serif; color: var(--ink);
}
.mse-report-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; padding: 20px 26px 16px; flex-wrap: wrap;
}
.mse-report-brand { display: flex; align-items: center; gap: 14px; }
.mse-report-brand img { height: 34px; width: auto; }
.mse-report-brand .t { font-size: 15px; font-weight: 800; letter-spacing: .3px; }
.mse-report-brand .t b { color: var(--mse-report-accent, var(--mse)); }
.mse-report-brand .s { font-size: 10.5px; color: var(--mut); margin-top: 2px; text-transform: uppercase; letter-spacing: .8px; }
.mse-report-kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.mse-report-kpi {
  background: var(--line-2); border-left: 3px solid var(--mse-report-accent, var(--mse)); border-radius: 6px;
  padding: 7px 12px; min-width: 118px;
}
.mse-report-kpi .l { font-size: 9px; color: var(--mut); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.mse-report-kpi .v { font-size: 14px; font-weight: 800; margin-top: 2px; }
.mse-report-kpi .v.neg { color: var(--mse); }
.mse-report-redbar { height: 6px; background: linear-gradient(90deg, var(--mse-report-accent, var(--mse)), var(--mse-report-accent-2, #ff5470)); }
.mse-report-body { padding: 20px 26px 24px; }
.mse-report-section-title {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  color: var(--mse-report-accent, var(--mse)); margin: 18px 0 8px;
}
.mse-report-section-title:first-child { margin-top: 0; }
.mse-report-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mse-report-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mse-report-table th {
  background: var(--mse-report-accent, var(--mse)); color: #fff; text-align: left; font-weight: 700;
  padding: 6px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .3px;
}
.mse-report-table th.nr, .mse-report-table td.nr { text-align: right; }
.mse-report-table th.ct, .mse-report-table td.ct { text-align: center; }
.mse-report-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mse-report-table tbody tr:nth-child(even) td { background: var(--line-2); }
.mse-report-table tfoot td {
  font-weight: 800; border-top: 2px solid var(--mse-report-accent, var(--mse)); border-bottom: none;
  background: var(--mse-report-accent-soft, #fff5f6);
}
.mse-report-bottom { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-top: 18px; }
.mse-report-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.mse-report-bar-label { width: 150px; font-size: 11px; font-weight: 600; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mse-report-bar-track { flex: 1; background: var(--line-2); border-radius: 5px; height: 16px; overflow: hidden; }
.mse-report-bar-fill { height: 100%; background: linear-gradient(90deg, var(--mse-report-accent, var(--mse)), var(--mse-report-accent-2, #ff5470)); border-radius: 5px 0 0 5px; }
.mse-report-bar-value { width: 92px; text-align: right; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.mse-report-destaques { background: var(--line-2); border-radius: 8px; padding: 14px 16px; }
.mse-report-destaque { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.mse-report-destaque:last-child { margin-bottom: 0; }
.mse-report-destaque .ic {
  width: 32px; height: 32px; border-radius: 50%; background: var(--mse-report-accent, var(--mse)); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.mse-report-destaque .l { font-size: 9.5px; color: var(--mut); text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.mse-report-destaque .v { font-size: 12.5px; font-weight: 700; }
.mse-report-foot { padding: 10px 26px 16px; font-size: 10px; color: var(--mut); border-top: 1px solid var(--line); text-align: right; }

@media print {
  /* Esconde todo o resto da página (dashboard por trás do overlay) via
     display:none — mais robusto que o truque antigo de visibility+
     position:absolute, que estava saindo em branco na impressão/PDF
     (relatado pela Daniele, 2026-08-19). */
  body > *:not(.mse-report-overlay):not(#tpl-print-root) { display: none !important; }
  .mse-report-overlay {
    position: static !important; inset: auto !important; background: none !important;
    padding: 0 !important; display: block !important;
  }
  .mse-report-toolbar, .no-print { display: none !important; }
  .mse-report-page { box-shadow: none !important; max-width: 100% !important; margin: 0 !important; }
}

/* ── Loading ── */
.loading { text-align: center; padding: 40px; color: var(--mut); font-size: 13px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line);
  border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ic.spin svg { animation: spin .7s linear infinite; }

/* ── Risco Sacado Tabs ── */
.rs-tab-btn {
  background: none; border: none; border-bottom: 3px solid transparent;
  padding: 8px 20px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--mut); transition: color .15s, border-color .15s; white-space: nowrap;
}
.rs-tab-btn:hover  { color: var(--ink); }
.rs-tab-active     { color: var(--blue) !important; border-bottom-color: var(--blue) !important; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--navy); color: #fff;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 12px 18px; font-size: 12px;
  box-shadow: 0 4px 20px rgba(25,34,49,.3);
  transform: translateY(20px); opacity: 0; transition: all .25s; pointer-events: none;
}
#toast.show    { transform: translateY(0); opacity: 1; }
#toast.success { border-left: 4px solid var(--green); }
#toast.error   { border-left: 4px solid var(--red); }

/* ── Semáforo ── */
.sema        { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: middle; }
.sema-green  { background: #16a34a; box-shadow: 0 0 6px #16a34a55; }
.sema-yellow { background: #d97706; box-shadow: 0 0 6px #d9770655; }
.sema-red    { background: var(--red); box-shadow: 0 0 6px rgba(210,59,59,.4); }
.sema-gray   { background: var(--mut); }

/* ── Detalhe contrato ── */
.detail-header {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 20px; margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: flex-start;
  box-shadow: var(--shadow);
}
.detail-header h2 { font-size: 15px; font-weight: 700; }
.detail-header p  { font-size: 11px; color: var(--mut); margin-top: 4px; }
.detail-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }

/* ── GD Modal Tabs ── */
.gd-tabs {
  display: flex; border-bottom: 2px solid var(--line);
  margin-bottom: 16px; overflow-x: auto; flex-shrink: 0;
}
.gd-tab {
  padding: 10px 18px; font-size: 12px; font-weight: 600;
  border: none; background: none; cursor: pointer;
  color: var(--mut); transition: all .15s; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  display: flex; align-items: center; gap: 6px;
}
.gd-tab:hover  { color: var(--ink); background: var(--line-2); }
.gd-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--mut-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--mut); }
* { scrollbar-width: thin; scrollbar-color: var(--mut-2) transparent; }

/* ── Responsive ── */
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) { .charts-grid { grid-template-columns: 1fr; } .obras-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .sidebar { display: none; } .kpi-grid { grid-template-columns: repeat(2, 1fr); } .obras-grid { grid-template-columns: 1fr; } .detail-kpis { grid-template-columns: repeat(2, 1fr); } }


/* ══════════════════════════════════════════════════════════════════
   MÓDULO: SOLICITAÇÃO DE DESCONTO — EMPREITA
══════════════════════════════════════════════════════════════════ */
.desc-section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--blue); border-bottom: 2px solid var(--blue);
  padding: 4px 0 6px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 6px;
}

#modal-nova-solicitacao .form-row > label,
#modal-nova-solicitacao .form-2col .form-row > label {
  text-transform: uppercase; font-size: 12px; letter-spacing: 1px;
  color: var(--ink) !important; font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
}
#modal-nova-solicitacao .form-row input,
#modal-nova-solicitacao .form-row select,
#modal-nova-solicitacao .form-row textarea {
  font-size: 14px !important; color: var(--ink) !important; padding: 9px 11px;
}
#modal-nova-solicitacao { font-size: 14px; }
#modal-nova-solicitacao [style*="color:var(--muted)"],
#modal-nova-solicitacao [style*="color:var(--text2)"] { color: #334155 !important; }

#modal-bloco-docs .form-row input,
#modal-bloco-docs .form-row select,
#modal-bloco-docs .form-row textarea {
  color: #0f1115 !important; font-weight: 500;
}
#modal-bloco-docs .form-row label { color: #475569 !important; }

/* Mesmo ajuste de contraste do #modal-bloco-docs acima, aplicado também ao
   Status do Distrato — texto digitado/selecionado ficava claro demais pra
   ler (pedido da Daniele, 2026-08-18). */
#modal-distrato-edit .form-row input,
#modal-distrato-edit .form-row select,
#modal-distrato-edit .form-row textarea {
  color: #0f1115 !important; font-weight: 500;
}
#modal-distrato-edit .form-row label { color: #000 !important; }
#modal-distrato-edit .form-row input,
#modal-distrato-edit .form-row select,
#modal-distrato-edit .form-row textarea {
  background: #fff; border: 1px solid #e2e8f0;
}

/* Stepper + acordeão do "Status do Distrato" — layout pedido direto pela
   Daniele (mockup próprio), 2026-08-18, pra organizar os muitos campos que
   tinham virado uma lista longa sem hierarquia visual. */
.dist-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 1; min-width: 78px; cursor: pointer; position: relative;
}
.dist-step-num {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0;
  background: #e2e8f0; color: #64748b; border: 2px solid transparent;
}
.dist-step.ativo .dist-step-num { background: #2563eb; color: #fff; }
.dist-step-label { font-size: 10px; color: #64748b; text-align: center; line-height: 1.2; }
.dist-step.ativo .dist-step-label { color: #2563eb; font-weight: 700; }

.dist-secao {
  border: 1px solid #bfdbfe; border-radius: 10px; margin-bottom: 10px; overflow: hidden;
}
.dist-secao-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer;
  background: #fff;
}
.dist-secao.ativa .dist-secao-head { background: #eff6ff; }
.dist-secao-titulo { font-size: 13px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dist-secao-resumo { font-size: 11px; color: #64748b; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist-secao-chevron { color: #94a3b8; font-size: 12px; transition: transform .15s; flex-shrink: 0; }
.dist-secao.ativa .dist-secao-chevron { transform: rotate(180deg); }
.dist-secao-body { display: none; padding: 4px 16px 16px; }
.dist-secao.ativa .dist-secao-body { display: block; }
.dist-secao.ativa .dist-secao-resumo { display: none; }

.dist-resumo-item { display: flex; flex-direction: column; gap: 2px; }
.dist-resumo-item .l { font-size: 9px; color: #94a3b8; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.dist-resumo-item .v { font-size: 13px; font-weight: 700; color: #0f172a; }

.desc-decl-box {
  background: #fefce8; border: 1px solid #fde68a; border-radius: 8px;
  padding: 12px 14px; margin-bottom: 14px;
}
.desc-check-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12px; color: var(--ink); margin-bottom: 6px; cursor: pointer;
  font-weight: 400; line-height: 1.4;
}
.desc-check-row:last-child { margin-bottom: 0; }
.desc-check-row input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--blue); }

.desc-motivo-radio {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  transition: border-color .15s, background .15s; font-weight: 400;
}
.desc-motivo-radio:has(input:checked) { border-color: var(--blue); background: #eff6ff; }
.desc-motivo-radio input[type="radio"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--blue); }
.desc-motivo-label { display: flex; flex-direction: column; gap: 2px; }
.desc-motivo-label strong { font-size: 12px; color: var(--ink); }
.desc-motivo-label span   { font-size: 10px; color: var(--mut); }

.desc-detail-block {
  background: var(--line-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px;
}
.desc-detail-label { font-size: 9px; color: var(--mut); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; }
.desc-detail-value { font-size: 13px; color: var(--ink); margin-top: 2px; }

/* Timeline de histórico */
.desc-timeline { display: flex; flex-direction: column; gap: 0; }
.desc-timeline-item {
  display: flex; gap: 12px; padding-bottom: 12px;
  position: relative;
}
.desc-timeline-item:not(:last-child)::before {
  content: ''; position: absolute; left: 6px; top: 18px; bottom: 0;
  width: 1px; background: var(--line);
}
.desc-timeline-dot {
  width: 13px; height: 13px; border-radius: 50%; background: var(--blue);
  flex-shrink: 0; margin-top: 3px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.desc-timeline-content { flex: 1; min-width: 0; }

/* Badges de ação */
.desc-acao-badge {
  font-size: 9px; border-radius: 3px; padding: 1px 5px; margin-left: 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  font-family: 'IBM Plex Mono', monospace;
}
.desc-acao-criou     { background: #dbeafe; color: #1d4ed8; }
.desc-acao-editou    { background: #dcfce7; color: #15803d; }
.desc-acao-finalizou { background: #dcfce7; color: #15803d; }
.desc-acao-cancelou  { background: #fee2e2; color: var(--red); }
.desc-acao-email_enviado { background: #e0f2fe; color: #0369a1; }

/* Badge count na tabela */
.table-count {
  background: var(--blue); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 10px; padding: 1px 7px; display: none;
}

/* ── Componente de Evidência ── */
.desc-ev-group { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.desc-ev-tabs  { display: flex; border-bottom: 1px solid var(--line); background: var(--line-2); }
.desc-ev-tab {
  flex: 1; padding: 7px 10px; font-size: 11px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--mut); transition: all .15s;
  border-bottom: 2px solid transparent; display: flex; align-items: center; justify-content: center; gap: 5px;
}
.desc-ev-tab.active     { color: var(--blue); border-bottom-color: var(--blue); background: var(--card); }
.desc-ev-tab:hover:not(.active) { background: var(--card); color: var(--ink); }
.desc-ev-group > div:not(.desc-ev-tabs) { padding: 10px; }
.desc-ev-group input[type="text"] {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 12px; background: var(--card); color: var(--ink);
}
.desc-ev-dropzone {
  border: 2px dashed var(--line); border-radius: 8px; padding: 20px;
  text-align: center; cursor: pointer; color: var(--mut); font-size: 12px;
  transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.desc-ev-dropzone:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
.desc-ev-dropzone i     { font-size: 18px; }
.desc-ev-preview        { margin-top: 8px; }


/* ══════════════════════════════════════════════════════════════════
   MÓDULO: DISTRATO (editor nativo)
══════════════════════════════════════════════════════════════════ */
.tpl-field {
  border-bottom: 1.5px dashed var(--green);
  outline: none; display: inline; min-width: 30px; cursor: text;
  background: rgba(31,157,87,.07); border-radius: 2px;
  padding: 0 3px; transition: background 0.15s;
  font-family: inherit; font-size: inherit; color: inherit;
}
.tpl-field:focus  { background: rgba(31,157,87,.18); border-bottom-color: #0e7a57; }
.tpl-field:hover  { background: rgba(31,157,87,.12); }

#tpl-doc-content p  { text-align: justify; margin: 0 0 10px; line-height: 1.75; }
#tpl-doc-content b,
#tpl-doc-content strong { font-weight: bold; }

@media print {
  body > *:not(#tpl-print-root):not(.mse-report-overlay) { display: none !important; }
  #tpl-print-root {
    display: block !important; position: fixed; inset: 0;
    padding: 20mm; background: #fff;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt; line-height: 1.75; color: #000; overflow: visible;
  }
  .tpl-no-print { display: none !important; }
  .tpl-field { border-bottom: none !important; background: none !important; padding: 0 !important; }
}

/* ══════════════════════════════════════════════════════════════════
   MÓDULO: GD MODAL — CABEÇALHO E COLLAPSIBLE
══════════════════════════════════════════════════════════════════ */
.gd-modal-hdr2 {
  display:flex; align-items:center; gap:16px; padding:12px 20px;
  background:#f8f9fb; border-bottom:1px solid var(--line);
  font-size:13px; flex-wrap:wrap;
  position:sticky; top:0; z-index:10;
}
.gd-modal-hdr2 .gd-empresa { font-weight:700; font-size:15px; color:var(--ink); }
.gd-modal-hdr2 .gd-hdr-info { display:flex; align-items:center; gap:6px; color:var(--mut); }
.gd-modal-hdr2 .gd-hdr-info strong {
  color:var(--ink); font-weight:600;
  border-bottom:1px dashed transparent; transition:.15s;
}
.gd-modal-hdr2 .gd-hdr-info strong[contenteditable] { cursor:text; }
.gd-modal-hdr2 .gd-hdr-info strong[contenteditable]:hover { border-bottom-color:var(--blue); }
.gd-modal-hdr2 .gd-hdr-info strong[contenteditable]:focus { border-bottom-color:var(--blue); outline:none; background:#eef4ff; border-radius:3px; padding:1px 3px; }
.gd-modal-hdr2 .gd-hdr-sep { color:var(--line); }
.gd-modal-hdr2 select.gd-comp-sel {
  border:1px solid var(--line); border-radius:6px; padding:4px 8px;
  font-size:12px; font-family:inherit; color:var(--ink); background:#fff;
}
.gd-modal-hdr2 .gd-updated { font-size:11px; color:var(--mut); font-family:'IBM Plex Mono',monospace; }
.gd-modal-hdr2 .gd-hdr-actions { display:flex; align-items:center; gap:6px; margin-left:auto; }
.gd-modal-hdr2 .gd-btn-refresh {
  display:flex; align-items:center; gap:5px; padding:5px 10px;
  border:1px solid var(--line); border-radius:6px; background:#fff;
  font-size:11px; color:var(--body); cursor:pointer; transition:.15s;
}
.gd-modal-hdr2 .gd-btn-refresh:hover { background:var(--line-2); }
.gd-modal-hdr2 .gd-btn-close {
  width:28px; height:28px; border-radius:6px; border:none; background:transparent;
  color:var(--mut); display:grid; place-items:center; cursor:pointer; font-size:16px;
}
.gd-modal-hdr2 .gd-btn-close:hover { background:#fee2e2; color:var(--red); }

.gd-info-collapsible { border:1px solid var(--line); border-radius:8px; margin-bottom:12px; overflow:hidden; }
.gd-info-toggle {
  display:flex; align-items:center; gap:8px; padding:8px 12px;
  background:var(--line-2); cursor:pointer; font-size:12px; font-weight:600; color:var(--ink);
  user-select:none;
}
.gd-info-toggle:hover { background:#e2e6ea; }
.gd-info-chev { flex:none; color:var(--mut); transition:.2s; }
.gd-info-collapsible.open .gd-info-chev { transform:rotate(180deg); }
.gd-info-body { display:none; padding:12px; }
.gd-info-collapsible.open .gd-info-body { display:block; }
