/* ==========================================================================
   Cockpit Corporativo — Design System
   Navy de marca + neutros frios · status só com significado.
   Tipografia: Archivo (títulos/rótulos) · IBM Plex Sans (corpo) · IBM Plex Mono (números)
   ========================================================================== */
:root {
  --brand: #1e3a5f;
  --brand-600: #182f4c;
  --brand-700: #13273f;
  --brand-050: #eef3f9;
  --brand-100: #dce7f2;
  --topbar: #0e2138;

  --canvas: #f1f4f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;

  --ink: #0f1b2d;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --line: #e6ebf1;
  --line-2: #eff3f8;
  --line-strong: #d7dee8;

  --pos: #15803d; --pos-bg: #e8f5ee;
  --neg: #b91c1c; --neg-bg: #fbeaea;
  --warn: #b45309; --warn-bg: #fbf1e3;

  --r: 10px; --r-sm: 8px; --r-lg: 12px;
  --sh: 0 1px 2px rgba(15,27,45,.05);
  --sh-2: 0 1px 3px rgba(15,27,45,.07), 0 1px 2px rgba(15,27,45,.04);

  --ff-d: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ff-b: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ff-m: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

body {
  background: var(--canvas);
  color: var(--ink-2);
  font-family: var(--ff-b);
}
h1, h2, h3, h4, h5, h6, .fw-bold, .fw-semibold { font-family: var(--ff-d); }

/* sombras globais mais discretas (herdado pelos demais módulos) */
.shadow-sm { box-shadow: var(--sh) !important; }
.card { border-radius: var(--r); }

/* ---- Botões da marca ---- */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-brand-ghost { color: #fff; border: none; background: transparent; }
.btn-brand-ghost:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* ---- Login ---- */
.login-bg { background: #e2e8f0; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.brand-badge { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 13px; background: var(--brand); color: #fff; font-size: 24px; }

/* ---- Topbar ---- */
.cockpit-topbar { background: var(--topbar); color: #fff; height: 60px; }
.cockpit-topbar .navbar-brand { color: #fff; }
.brand-word { font-family: var(--ff-d); font-weight: 700; font-size: 19px; letter-spacing: .01em; color: #fff; text-decoration: none; }
.company-pick { background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; }
.company-pick .form-select, .company-pick .input-group-text { color: #fff; background: transparent; }
.company-pick .form-select option { color: #1e293b; }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); color: #fff; font-size: 12px; font-weight: 600; font-family: var(--ff-d); }

/* ---- Layout ---- */
.cockpit-body { display: flex; min-height: calc(100vh - 60px); }
.cockpit-sidebar { width: 236px; background: var(--surface); border-right: 1px solid var(--line); flex-shrink: 0; }
@media (min-width: 992px) {
  .cockpit-sidebar { visibility: visible !important; transform: none !important; width: 236px !important; max-width: 236px !important; flex: 0 0 236px !important; background: var(--surface) !important; border-right: 1px solid var(--line) !important; }
  .cockpit-sidebar .offcanvas-body { display: block !important; flex-grow: 0 !important; padding: 8px !important; overflow-y: auto; background: transparent !important; }
}
.cockpit-content { flex: 1; padding: 22px 24px; min-width: 0; }

/* ---- Sidebar: logo + rótulo + links ---- */
.sb-brand { display: flex; align-items: center; padding: 4px 10px 12px; margin: 2px -8px 8px; border-bottom: 1px solid var(--line); }
.sb-logo { display: inline-flex; align-items: center; line-height: 0; }
.sb-logo img { height: 42px; width: auto; display: block; }
.sb-h { font-family: var(--ff-d); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 12px 10px 6px; }
.sb-link { color: var(--ink-2); border-radius: 8px; padding: 9px 11px; font-weight: 500; font-size: 13.5px; position: relative; }
.sb-link i { color: var(--muted); }
.sb-link:hover { background: var(--surface-2); color: var(--ink); }
.sb-link.active { background: var(--brand); color: #fff; }
.sb-link.active i { color: #fff; }

/* Módulo com submenu: clicar no nome abre/fecha */
.sb-parent { cursor: pointer; }
.sb-parent .sb-caret-ic { font-size: .72rem; color: var(--muted); transition: transform .15s ease; }
.sb-parent[aria-expanded="true"] .sb-caret-ic { transform: rotate(180deg); }
.sb-parent[aria-expanded="true"] { color: var(--ink); }
.sb-link.active-parent { background: var(--surface-2); color: var(--ink); }
.sb-link.active-parent i.bi:first-child { color: var(--brand); }

/* Botão Voltar — presente em todas as telas (exceto dashboard) */
.page-back { margin-bottom: 14px; display: flex; justify-content: flex-end; }
.btn-back { display: inline-flex; align-items: center; gap: 7px; font-family: var(--ff-d); font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.btn-back:hover { border-color: var(--brand); color: var(--brand); background: var(--surface-2); }
.btn-back i { font-size: 14px; }

/* ---- KPIs legados (compat com outras telas) ---- */
.kpi-label { font-size: 12px; color: var(--muted); font-family: var(--ff-d); }
.kpi-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; font-family: var(--ff-m); color: var(--ink); }
.kpi-value.sm { font-size: 16px; }

/* ---- Chip de variação (delta) ---- */
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; font-family: var(--ff-d); padding: 2px 8px; border-radius: 999px; }
.delta-up { color: var(--pos); background: var(--pos-bg); }
.delta-down { color: var(--neg); background: var(--neg-bg); }

/* ---- Barras (compat) ---- */
.bar-track { height: 12px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--brand); }
.bar-fill.muted { background: var(--faint); }
.tnum { font-variant-numeric: tabular-nums; font-family: var(--ff-m); }

/* =========================== DASHBOARD =========================== */
.pagehead { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-title { font-family: var(--ff-d); font-weight: 700; font-size: 20px; letter-spacing: -.01em; margin: 0; color: var(--ink); }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.page-sub strong { color: var(--ink-2); font-weight: 600; }

.ctl-bar { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px 6px 5px 12px; box-shadow: var(--sh); }
.ctl-bar .ctl-lbl { font-family: var(--ff-d); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ctl-bar select.form-select { font-size: 12.5px; font-weight: 600; color: var(--ink); border: 1px solid var(--line); background: var(--surface-2); border-radius: 7px; padding: 5px 26px 5px 8px; width: auto; }
.ctl-bar .btn-exp { display: inline-flex; align-items: center; gap: 6px; font-family: var(--ff-d); font-weight: 600; font-size: 12.5px; color: #fff; background: var(--brand); border: 1px solid var(--brand); border-radius: 7px; padding: 6px 12px; text-decoration: none; }
.ctl-bar .btn-exp:hover { background: var(--brand-600); color: #fff; }

.sectionbar { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; }
.sectionbar .t { font-family: var(--ff-d); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); }
.sectionbar .rule { height: 1px; background: var(--line); flex: 1; }

.lead-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.lead { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 15px 16px 15px 18px; overflow: hidden; }
.lead::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.lead.good::before { background: var(--pos); }
.lead.bad::before { background: var(--neg); }

.op-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.op { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 11px 12px; }

.k-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.k-label { font-family: var(--ff-d); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.op .k-label { font-size: 10.5px; }
.k-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-050); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: none; box-shadow: inset 0 0 0 1px rgba(15,23,42,.04); }
.k-ic svg { width: 21px; height: 21px; }
.op .k-ic { width: 32px; height: 32px; border-radius: 9px; } .op .k-ic svg { width: 17px; height: 17px; }
.k-ic.t-blue   { background: #dbeafe; color: #1d4ed8; }
.k-ic.t-green  { background: #dcfce7; color: #15803d; }
.k-ic.t-violet { background: #ede9fe; color: #6d28d9; }
.k-ic.t-indigo { background: #e0e7ff; color: #4338ca; }
.k-ic.t-teal   { background: #ccfbf1; color: #0f766e; }
.k-ic.t-amber  { background: #fef3c7; color: #b45309; }
.k-ic.t-red    { background: #fee2e2; color: #b91c1c; }
.k-ic.t-slate  { background: #e2e8f0; color: #334155; }
.k-ic.t-orange { background: #ffedd5; color: #c2410c; }
.k-val { font-family: var(--ff-m); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.lead .k-val { font-size: 25px; margin-top: 6px; letter-spacing: -.01em; }
.op .k-val { font-size: 16px; margin-top: 5px; }
.k-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 20px; }
.op .k-foot { margin-top: 5px; min-height: 18px; }
.k-note { font-size: 10.5px; color: var(--faint); }

/* ---- Painéis (dashboard) ---- */
.cols { display: grid; grid-template-columns: 5fr 7fr; gap: 16px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.panel-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--line-2); }
.panel-h h2 { font-family: var(--ff-d); font-weight: 600; font-size: 13px; margin: 0; color: var(--ink); }
.panel-b { padding: 14px 15px; }

/* budget com rosca em degradê */
.bud-wrap { display: flex; align-items: center; gap: 20px; }
.donut { flex: none; width: 128px; height: 128px; }
.dnum { font-family: var(--ff-m); font-weight: 600; font-size: 21px; fill: var(--ink); }
.dlbl { font-family: var(--ff-d); font-size: 7.5px; letter-spacing: .14em; text-transform: uppercase; fill: var(--muted); }
.bud-figs { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.bf { display: flex; align-items: center; gap: 10px; }
.bf .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--brand); flex: none; }
.bf .dot.muted { background: var(--brand-100); }
.bf-l { font-family: var(--ff-d); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bf-v { font-family: var(--ff-m); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 16px; color: var(--ink); }
.bf.var { justify-content: space-between; border-top: 1px solid var(--line-2); padding-top: 13px; margin-top: 2px; }

/* tabela de empresas */
.dash-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dash-table thead th { font-family: var(--ff-d); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.dash-table thead th:first-child { text-align: left; }
.dash-table tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: right; }
.dash-table tbody tr:last-child td { border-bottom: none; }
.dash-table tbody tr:hover td { background: var(--surface-2); }
.dash-table .ent { text-align: left; }
.dash-table .ent .nm { font-weight: 600; color: var(--ink); font-size: 13px; }
.dash-table .bar { height: 4px; border-radius: 999px; background: var(--brand-100); margin-top: 5px; overflow: hidden; max-width: 160px; }
.dash-table .bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.dash-table .num { font-family: var(--ff-m); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.dash-table .num.strong { color: var(--ink); font-weight: 600; }
.mg { font-family: var(--ff-m); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: var(--pos-bg); color: var(--pos); }
.mg.neg { background: var(--neg-bg); color: var(--neg); }
.foot-note { font-size: 11px; color: var(--faint); margin-top: 16px; font-family: var(--ff-m); }

@media (max-width: 1040px) { .op-row { grid-template-columns: repeat(4, 1fr); } .cols { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .lead-row { grid-template-columns: 1fr; } .op-row { grid-template-columns: repeat(2, 1fr); } .cockpit-content { padding: 16px; } }

/* ---- Submenu recolhível (sidebar) ---- */
.sb-sub { font-size: .8rem; }
.sb-caret { border: none; background: transparent; color: #94a3b8; padding: 2px 9px; }
.sb-caret:hover { color: var(--brand); }
.sb-caret i { font-size: .78rem; transition: transform .12s ease; display: inline-block; }
.sb-caret[aria-expanded="false"] i { transform: rotate(-90deg); }

/* ---- Árvore de pastas expansível ---- */
.tnode .trow { display: flex; align-items: center; gap: 4px; border-radius: 7px; padding: 5px 6px; font-size: 14px; }
.tnode .trow:hover { background: #f1f5f9; }
.tnode .trow.active { background: var(--brand-050); }
.tnode .trow.active .tlink { color: var(--brand); font-weight: 600; }
.tnode .trow.active .bi-folder-fill { color: var(--brand) !important; }
.tcaret { width: 18px; flex-shrink: 0; color: #94a3b8; cursor: pointer; display: inline-flex; justify-content: center; }
.tcaret.empty { cursor: default; }
.tcaret i { font-size: .72rem; transition: transform .12s ease; }
.tlink { display: flex; align-items: center; gap: 7px; text-decoration: none; color: inherit; min-width: 0; flex: 1; }
.tnode.collapsed > .tchildren { display: none; }
.tnode.collapsed > .trow .tcaret i { transform: rotate(-90deg); }

/* ---- Logo LOTTOSYS (compat) ---- */
.brand-logo { display:inline-flex; align-items:center; background:#fff; border-radius:8px; padding:4px 9px; line-height:0; box-shadow:0 1px 3px rgba(0,0,0,.18); }
.brand-logo img { height:22px; width:auto; display:block; }
.login-logo { height:52px; width:auto; max-width:80%; display:inline-block; }
