/* ============================================================
   LG EMPREENDIMENTOS — Financeiro de Obra
   Ouro / grafite / papel de projeto
   ============================================================ */

:root, [data-theme="light"] {
  --gold: #C9A24C;
  --gold-lite: #E8CE8B;
  --gold-deep: #8F6E23;
  --gold-wash: rgba(201, 162, 76, 0.12);

  --ink: #0B0B0C;
  --ink-2: #17181A;
  --ink-3: #2A2B2E;

  --positive: #3E7C59;
  --negative: #C2402A;
  --warn: #D08A1E;

  --bg: #F1EDE4;
  --bg-elev: #FBF9F5;
  --bg-card: #FFFFFF;
  --line: #DDD5C6;
  --line-soft: #EBE5D9;
  --text: #1A1815;
  --text-soft: #6B6459;
  --text-muted: #9C948668;
  --text-dim: #97907F;
  --input-bg: #F6F3EC;
  --head-bg: #F3EFE6;
  --row-hover: #FAF7F1;

  --shadow-card: 0 1px 2px rgba(26, 24, 21, 0.05), 0 8px 24px rgba(26, 24, 21, 0.05);
  --shadow-pop: 0 24px 60px rgba(11, 11, 12, 0.22);
  --overlay: rgba(11, 11, 12, 0.55);

  --f-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --f-text: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, monospace;

  --r-sm: 4px;
  --r: 8px;
  --r-lg: 14px;
}

[data-theme="dark"] {
  --gold: #D9B565;
  --gold-lite: #F0DBA6;
  --gold-deep: #A88337;
  --gold-wash: rgba(217, 181, 101, 0.14);

  --positive: #5FA37C;
  --negative: #E06A50;
  --warn: #E5A73C;

  --bg: #0B0B0C;
  --bg-elev: #131416;
  --bg-card: #17181A;
  --line: #2C2D31;
  --line-soft: #202124;
  --text: #F0EBE1;
  --text-soft: #A29A8C;
  --text-dim: #6F6A60;
  --input-bg: #0E0F11;
  --head-bg: #101113;
  --row-hover: #1D1E21;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.7);
  --overlay: rgba(0, 0, 0, 0.72);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }
svg { flex-shrink: 0; }

.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }

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

/* ===== eyebrow / rótulo técnico ===== */
.eyebrow {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login {
  position: fixed; inset: 0; z-index: 100;
  display: flex;
  background: var(--ink);
  overflow: hidden;
}
.login-left {
  flex: 1;
  padding: 56px 64px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #F0EBE1;
  position: relative;
  min-width: 0;
}
/* Malha de lotes — referência ao plano urbanístico */
.login-left::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(201, 162, 76, 0.10) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 162, 76, 0.10) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 30% 55%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 30% 55%, #000 0%, transparent 72%);
}
.login-left > * { position: relative; }
.login-logo { width: 190px; height: auto; display: block; }
.login-hero h1 {
  font-family: var(--f-display);
  font-size: clamp(40px, 5.2vw, 68px);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.04em;
  margin: 18px 0 20px;
  max-width: 12ch;
}
.login-hero h1 em { font-style: normal; color: var(--gold); }
.login-hero p { font-size: 16px; color: #B9B2A5; max-width: 46ch; }
.login-foot {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: #6F6A60;
  display: flex; gap: 20px; flex-wrap: wrap;
}
.login-right {
  width: 460px; flex-shrink: 0;
  background: var(--bg-elev);
  padding: 56px 52px;
  display: flex; flex-direction: column; justify-content: center;
  border-left: 3px solid var(--gold);
}
.login-title {
  font-family: var(--f-display); font-size: 30px; font-weight: 600;
  letter-spacing: -0.03em; margin-bottom: 4px;
}
.login-sub { color: var(--text-soft); margin-bottom: 28px; }
.login-error {
  display: none; margin-bottom: 16px; padding: 10px 12px;
  background: rgba(194, 64, 42, 0.10); border-left: 3px solid var(--negative);
  color: var(--negative); font-size: 13px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.login-error.show { display: block; }

/* ============================================================
   FORM
   ============================================================ */
.field { margin-bottom: 14px; min-width: 0; }
.field > label, .lbl {
  display: block;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text); font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}
.field .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field-row-3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1fr; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 4px 0; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--gold); cursor: pointer; }
.check span { font-size: 13px; }
.check small { display: block; color: var(--text-dim); font-size: 11.5px; }

/* ===== BOTÕES ===== */
.btn {
  padding: 10px 16px; border-radius: var(--r);
  font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary { background: var(--gold); color: #1A1408; }
.btn-primary:hover { background: var(--gold-lite); }
.btn-dark { background: var(--ink); color: #F0EBE1; }
.btn-dark:hover { background: var(--ink-3); }
[data-theme="dark"] .btn-dark { background: var(--bg-card); border: 1px solid var(--line); }
.btn-ghost { background: var(--bg-elev); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-deep); }
[data-theme="dark"] .btn-ghost:hover { color: var(--gold); }
.btn-danger { background: var(--negative); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  padding: 7px; border-radius: var(--r-sm); color: var(--text-soft);
  border: 1px solid transparent; line-height: 0;
}
.icon-btn:hover { background: var(--row-hover); border-color: var(--line); color: var(--text); }
.icon-btn.danger:hover { color: var(--negative); border-color: var(--negative); }

/* ============================================================
   SHELL
   ============================================================ */
.app { display: none; min-height: 100vh; }
.app.show { display: flex; }

.sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--ink);
  color: #B9B2A5;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid #000;
}
.sidebar-logo { width: 132px; height: auto; margin: 0 8px 26px; display: block; }
.nav-label {
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: #56514A; margin: 0 10px 8px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: #B9B2A5;
  text-align: left; width: 100%;
  border-left: 2px solid transparent;
  transition: background 0.14s, color 0.14s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #F0EBE1; }
.nav-item.active {
  background: rgba(201, 162, 76, 0.14);
  color: var(--gold-lite);
  border-left-color: var(--gold);
}
.nav-item .badge-count {
  margin-left: auto; font-family: var(--f-mono); font-size: 10.5px;
  background: var(--negative); color: #fff; padding: 1px 6px; border-radius: 20px;
}
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid #26272A; }
.theme-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; font-size: 12.5px; color: #8A8378;
}
.theme-toggle {
  width: 38px; height: 21px; border-radius: 20px; background: #2A2B2E;
  position: relative; transition: background 0.18s;
}
.theme-toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 15px; height: 15px; border-radius: 50%; background: #B9B2A5;
  transition: transform 0.18s;
}
[data-theme="dark"] .theme-toggle { background: var(--gold-deep); }
[data-theme="dark"] .theme-toggle::after { transform: translateX(17px); background: var(--gold-lite); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(140deg, var(--gold-lite), var(--gold-deep));
  color: #1A1408; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-row .nm { font-size: 13px; color: #F0EBE1; font-weight: 500; }
.user-row .rl { font-family: var(--f-mono); font-size: 9.5px; color: #56514A; letter-spacing: 0.1em; text-transform: uppercase; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ===== NAVEGAÇÃO NO CELULAR ===== */
.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.topbar .scope { display: flex; align-items: center; gap: 8px; }
.topbar select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg-card); color: var(--text); font-size: 13px; font-weight: 500;
  max-width: 260px;
}
.topbar select:focus { outline: none; border-color: var(--gold); }
.topbar .spacer { flex: 1; }
.topbar .today {
  font-family: var(--f-mono); font-size: 11px; color: var(--text-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
}

.content { padding: 26px 28px 60px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: rise 0.22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 {
  font-family: var(--f-display); font-size: 27px; font-weight: 600;
  letter-spacing: -0.035em; line-height: 1.1;
}
.page-head p { color: var(--text-soft); font-size: 13.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 {
  font-family: var(--f-display); font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
}
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ===== STAT ===== */
.stat {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px 18px;
  box-shadow: var(--shadow-card);
  border-top: 3px solid var(--line);
}
.stat.gold { border-top-color: var(--gold); }
.stat.pos { border-top-color: var(--positive); }
.stat.neg { border-top-color: var(--negative); }
.stat .k {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px;
}
.stat .v {
  font-family: var(--f-mono); font-size: 22px; font-weight: 600;
  letter-spacing: -0.03em; line-height: 1.1;
}
.stat .v.pos { color: var(--positive); }
.stat .v.neg { color: var(--negative); }
.stat .d { font-size: 12px; color: var(--text-soft); margin-top: 6px; }

/* ============================================================
   RÉGUA DE ORÇAMENTO — elemento-assinatura
   ============================================================ */
.ruler { --pct: 0; --ghost: 0; margin-top: 10px; }
.ruler-track {
  position: relative; height: 26px;
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
/* marcações de 10% como fita métrica */
.ruler-track::before {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    var(--line) 0 1px,
    transparent 1px 10%
  );
  opacity: 0.85;
}
.ruler-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(min(var(--pct), 100) * 1%);
  background: linear-gradient(180deg, var(--gold-lite), var(--gold));
  transition: width 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.ruler-ghost {
  position: absolute; top: 0; bottom: 0;
  left: calc(min(var(--pct), 100) * 1%);
  width: calc(min(max(var(--ghost) - var(--pct), 0), 100 - min(var(--pct), 100)) * 1%);
  background: repeating-linear-gradient(45deg, var(--gold-wash) 0 6px, transparent 6px 12px);
  border-right: 1px dashed var(--gold);
  transition: width 0.35s, left 0.35s;
}
.ruler.is-atencao .ruler-fill { background: linear-gradient(180deg, #EFC061, var(--warn)); }
.ruler.is-estourado .ruler-fill { background: linear-gradient(180deg, #E4795F, var(--negative)); }
.ruler-mark {
  position: absolute; top: -2px; bottom: -2px; width: 2px;
  background: var(--ink); left: 100%; transform: translateX(-2px);
}
[data-theme="dark"] .ruler-mark { background: var(--text); }
.ruler-legend {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-top: 7px; font-family: var(--f-mono); font-size: 11px;
  color: var(--text-soft); flex-wrap: wrap;
}
.ruler-legend b { color: var(--text); font-weight: 600; }
.ruler-legend .pct { font-size: 13px; font-weight: 600; }
.ruler.is-atencao .ruler-legend .pct { color: var(--warn); }
.ruler.is-estourado .ruler-legend .pct { color: var(--negative); }
.ruler.is-ok .ruler-legend .pct { color: var(--gold-deep); }
[data-theme="dark"] .ruler.is-ok .ruler-legend .pct { color: var(--gold); }

.budget-item { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.budget-item:last-child { border-bottom: none; padding-bottom: 0; }
.budget-item:first-child { padding-top: 0; }
.budget-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.budget-top .nm { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.budget-top .pd { font-family: var(--f-mono); font-size: 11px; color: var(--text-dim); }
.budget-pace { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; font-family: var(--f-mono); }

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--head-bg);
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--text-dim);
  text-align: left; padding: 10px 14px; font-weight: 500;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.val-in { color: var(--positive); font-weight: 600; }
.val-out { color: var(--negative); font-weight: 600; }

.empty { padding: 44px 20px; text-align: center; color: var(--text-soft); }
.empty h3 { font-family: var(--f-display); font-size: 17px; margin-bottom: 6px; color: var(--text); }
.empty p { font-size: 13px; margin-bottom: 16px; }

/* ===== TAGS / BADGES ===== */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--input-bg); border: 1px solid var(--line); white-space: nowrap;
}
.tag .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tag-ok { background: rgba(62, 124, 89, 0.12); border-color: rgba(62, 124, 89, 0.3); color: var(--positive); }
.tag-warn { background: rgba(208, 138, 30, 0.14); border-color: rgba(208, 138, 30, 0.32); color: var(--warn); }
.tag-bad { background: rgba(194, 64, 42, 0.12); border-color: rgba(194, 64, 42, 0.3); color: var(--negative); }
.tag-gold { background: var(--gold-wash); border-color: rgba(201, 162, 76, 0.35); color: var(--gold-deep); }
[data-theme="dark"] .tag-gold { color: var(--gold); }

/* ===== FILTROS ===== */
.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }

/* ===== CHARTS ===== */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.sm { height: 220px; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--text-dim); font-size: 13px;
}

/* ===== BARRAS (ranking simples) ===== */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row .bar-top {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12.5px; margin-bottom: 5px;
}
.bar-row .bar-top .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-top .vl { font-family: var(--f-mono); color: var(--text-soft); flex-shrink: 0; }
.bar-track { height: 7px; background: var(--input-bg); border-radius: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; transition: width 0.35s; }

/* ============================================================
   EMPREENDIMENTOS
   ============================================================ */
.proj-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.proj-card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-card);
  overflow: hidden; display: flex; flex-direction: column;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}
.proj-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.proj-card .stripe { height: 4px; background: var(--gold); }
.proj-card .body { padding: 16px 18px; flex: 1; }
.proj-card .nm {
  font-family: var(--f-display); font-size: 18px; font-weight: 600;
  letter-spacing: -0.025em; display: flex; align-items: center; gap: 8px;
}
.proj-card .loc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.proj-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 14px; }
.proj-meta .k { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.proj-meta .v { font-family: var(--f-mono); font-size: 14px; font-weight: 600; }
.proj-card .foot {
  padding: 12px 18px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 8px; justify-content: flex-end; background: var(--head-bg);
}

/* ===== DRAWER ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: none; z-index: 60;
}
.drawer-overlay.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%);
  background: var(--bg); z-index: 61;
  transform: translateX(100%); transition: transform 0.26s cubic-bezier(0.2, 0.7, 0.3, 1);
  display: flex; flex-direction: column; box-shadow: var(--shadow-pop);
}
.drawer.show { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 20px 24px; border-bottom: 1px solid var(--line); background: var(--bg-elev);
}
.drawer-head h2 { font-family: var(--f-display); font-size: 21px; font-weight: 600; letter-spacing: -0.03em; }
.drawer-head .sub { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }
.drawer-body { padding: 20px 24px 60px; overflow-y: auto; flex: 1; }
.drawer-section { margin-bottom: 26px; }
.drawer-section > h3 {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* ============================================================
   INADIMPLENTES
   ============================================================ */
.aging { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.aging-cell {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 15px; cursor: pointer;
  border-left: 3px solid var(--line); transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.aging-cell:hover { background: var(--row-hover); }
.aging-cell.active { border-color: var(--gold); background: var(--gold-wash); }
.aging-cell .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.aging-cell .v { font-family: var(--f-mono); font-size: 17px; font-weight: 600; margin-top: 5px; }
.aging-cell:nth-child(1) { border-left-color: var(--warn); }
.aging-cell:nth-child(2) { border-left-color: #D0703C; }
.aging-cell:nth-child(3) { border-left-color: var(--negative); }
.aging-cell:nth-child(4) { border-left-color: #8C2A1B; }

.late-pill {
  font-family: var(--f-mono); font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-sm);
  background: rgba(194, 64, 42, 0.12); color: var(--negative);
}
.late-pill.soft { background: rgba(208, 138, 30, 0.14); color: var(--warn); }

.inst-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap;
}
.inst-row:last-child { border-bottom: none; }
.inst-row .n {
  font-family: var(--f-mono); font-size: 11px; color: var(--text-dim);
  width: 44px; flex-shrink: 0;
}
.inst-row .dt { font-family: var(--f-mono); font-size: 13px; width: 92px; flex-shrink: 0; }
.inst-row .vl { font-family: var(--f-mono); font-size: 13.5px; font-weight: 600; margin-left: auto; }
.inst-row .ac { display: flex; gap: 4px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 80; padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-elev); border-radius: var(--r-lg);
  width: 100%; max-width: 620px;
  max-height: calc(100dvh - 40px);
  margin: auto;
  display: flex; flex-direction: column; box-shadow: var(--shadow-pop);
  border-top: 3px solid var(--gold);
  animation: pop 0.18s ease;
}
.modal.wide { max-width: 780px; }
.modal.narrow { max-width: 440px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.modal-title { font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: -0.025em; }
/* O corpo e o rodapé vivem dentro de um <form>. Sem isso o form não é flex
   e o corpo não consegue encolher, jogando o rodapé pra fora do card. */
.modal > form {
  display: flex; flex-direction: column;
  flex: 1 1 auto; min-height: 0;
}
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 22px; border-top: 1px solid var(--line);
  flex: 0 0 auto;
  background: var(--bg-elev);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ===== SELETOR ENTRADA/SAÍDA ===== */
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.type-opt {
  padding: 11px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--input-bg); font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.type-opt.active[data-type="saida"] { border-color: var(--negative); color: var(--negative); background: rgba(194, 64, 42, 0.08); }
.type-opt.active[data-type="entrada"] { border-color: var(--positive); color: var(--positive); background: rgba(62, 124, 89, 0.08); }

/* ===== PAINEL DE IMPACTO NO LIMITE ===== */
.impact {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; background: var(--input-bg); margin-bottom: 16px;
}
.impact.hidden { display: none; }
.impact-title {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px;
}
.impact.is-estourado { border-color: var(--negative); background: rgba(194, 64, 42, 0.06); }
.impact.is-atencao { border-color: var(--warn); background: rgba(208, 138, 30, 0.07); }
.impact-msg { font-size: 12.5px; margin-top: 9px; font-weight: 500; }
.impact.is-estourado .impact-msg { color: var(--negative); }
.impact.is-atencao .impact-msg { color: var(--warn); }

/* ===== FILTROS DO PAINEL ===== */
.filt-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 5px; margin-left: 3px;
  border-radius: 999px; background: var(--gold-deep); color: #FFF;
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
}

.dash-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dash-chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text-soft);
}
.dash-chip.is-clear {
  border-style: dashed; cursor: pointer; color: var(--text-dim);
  font-family: inherit;
}
.dash-chip.is-clear:hover { color: var(--negative); border-color: var(--negative); }

.filt-group {
  border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: 10px; background: var(--bg-card); overflow: hidden;
}
.filt-group > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; cursor: pointer; font-size: 13px; font-weight: 500;
  list-style: none;
}
.filt-group > summary::-webkit-details-marker { display: none; }
.filt-group > summary::after {
  content: ""; width: 7px; height: 7px; flex-shrink: 0;
  border-right: 1.6px solid var(--text-dim); border-bottom: 1.6px solid var(--text-dim);
  transform: rotate(45deg) translateY(-2px); transition: transform 0.15s;
}
.filt-group[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.filt-count {
  font-family: var(--f-mono); font-size: 10.5px; color: var(--text-dim);
  margin-left: auto; margin-right: 4px;
}
.filt-group[open] > summary { border-bottom: 1px solid var(--line); }

.filt-options { max-height: 210px; overflow-y: auto; padding: 6px; }
.filt-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--r-sm); cursor: pointer; font-size: 12.5px;
}
.filt-opt:hover { background: var(--bg); }
.filt-opt input { width: auto; margin: 0; flex-shrink: 0; accent-color: var(--gold-deep); }
.filt-opt span:not(.filt-hint) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filt-hint { font-size: 10.5px; color: var(--text-dim); }

.fav-box { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
#dashFavs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 11px; }
.fav-chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--gold); border-radius: 999px; overflow: hidden;
  background: rgba(201, 162, 76, 0.08);
}
.fav-load {
  border: 0; background: none; cursor: pointer; font-family: inherit;
  padding: 5px 4px 5px 12px; font-size: 12px; color: var(--gold-deep);
}
[data-theme="dark"] .fav-load { color: var(--gold); }
.fav-del {
  border: 0; background: none; cursor: pointer; color: var(--text-dim);
  padding: 5px 9px 5px 5px; display: flex; align-items: center;
}
.fav-del:hover { color: var(--negative); }
.fav-save { display: flex; gap: 8px; }
.fav-save input { flex: 1; }

/* ===== ARQUIVADOS ===== */
.toggle-pill {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-elev); font-size: 12.5px; color: var(--text-soft);
  white-space: nowrap;
}
.toggle-pill input { width: auto; margin: 0; accent-color: var(--gold-deep); }
.toggle-pill:has(input:checked) { border-color: var(--gold); color: var(--gold-deep); }
[data-theme="dark"] .toggle-pill:has(input:checked) { color: var(--gold); }

.proj-card.is-archived { opacity: 0.62; }
.proj-card.is-archived .stripe { filter: grayscale(1); }
.proj-archived-tag {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 3px;
  background: var(--ink); color: #E0D9CB;
}

/* ===== ALERTAS ===== */
.hint { font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }

.switch-row {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 13px; margin-bottom: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-card);
}
.switch-row.compact { padding: 9px 12px; margin-bottom: 7px; }
.switch-row input { width: auto; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--gold-deep); }
.switch-row .sw-title { font-size: 13px; font-weight: 600; }
.switch-row .sw-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; line-height: 1.5; }
.switch-row:has(input:checked) { border-color: var(--gold); background: rgba(201, 162, 76, 0.07); }

.cfg-group { margin: 20px 0 18px; }
.cfg-group > .eyebrow { display: block; margin-bottom: 9px; }

/* ===== IMPORTAÇÃO DE CSV ===== */
.hidden { display: none !important; }

.imp-lead { font-size: 13px; color: var(--text-soft); line-height: 1.6; margin-bottom: 16px; }
.imp-lead b { color: var(--text); }

.imp-drop {
  display: block; text-align: center; cursor: pointer;
  border: 1px dashed var(--line-strong, var(--line)); border-radius: var(--r);
  padding: 26px 18px; background: var(--bg-card);
  transition: border-color 0.15s, color 0.15s;
}
.imp-drop:hover { border-color: var(--gold); color: var(--gold-deep); }
[data-theme="dark"] .imp-drop:hover { color: var(--gold); }
.imp-drop input { display: none; }
.imp-drop .big { font-size: 13.5px; font-weight: 600; display: block; margin-bottom: 4px; }
.imp-drop .sm { font-size: 11.5px; color: var(--text-dim); }

.imp-or {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px; color: var(--text-dim);
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
}
.imp-or::before, .imp-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.imp-block { margin-bottom: 18px; }
.imp-block-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px; flex-wrap: wrap;
}
.imp-block-head h4 { font-size: 13px; font-weight: 600; }

.imp-map {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 10px;
  padding: 9px 11px; margin-bottom: 7px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg-card);
}
.imp-map.is-pending { border-color: var(--warn); background: rgba(208, 138, 30, 0.06); }
.imp-map-src { min-width: 0; }
.imp-map-src .nm { font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-map-src .qt { font-size: 10.5px; color: var(--text-dim); }
.imp-arrow { color: var(--text-dim); flex-shrink: 0; }
.imp-map select { width: 100%; }

.imp-warn {
  border: 1px solid var(--warn); border-radius: var(--r);
  background: rgba(208, 138, 30, 0.07);
  padding: 12px 14px; margin-bottom: 18px;
}

.imp-errors {
  border: 1px solid var(--negative); border-radius: var(--r);
  background: rgba(194, 64, 42, 0.06);
  padding: 12px 14px; margin-bottom: 18px;
}
.imp-check { display: flex; align-items: center; gap: 7px; font-size: 12px; cursor: pointer; }
.imp-check input { width: auto; margin: 0; }
.imp-error-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.imp-error {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 12px; color: var(--text-soft);
}
.imp-error .mono { font-family: var(--f-mono); font-size: 10.5px; color: var(--text-dim); flex-shrink: 0; }
.imp-error .why { color: var(--negative); margin-left: auto; flex-shrink: 0; font-size: 11.5px; }

.imp-foot-note {
  margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--line);
  font-family: var(--f-mono); font-size: 11px; color: var(--text-dim);
}

/* ===== USUÁRIOS ===== */
.role-hidden { display: none !important; }

.user-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: 11.5px; }

.cell-you {
  font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--gold-deep);
  border: 1px solid var(--gold); border-radius: 3px;
  padding: 1px 5px; margin-left: 7px; vertical-align: middle;
}
[data-theme="dark"] .cell-you { color: var(--gold); }

tr.row-off td { opacity: 0.5; }
tr.row-off .avatar { filter: grayscale(1); }

.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 4px 0 2px; }
.role-box {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 15px; background: var(--bg-card);
}
.role-name { margin-bottom: 8px; }
.role-box p { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

.profile-id {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 13px; margin-bottom: 16px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-card);
  font-size: 12.5px;
}

p.hint { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 24px);
  background: var(--ink); color: #F0EBE1;
  padding: 12px 20px; border-radius: var(--r); font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-pop); z-index: 200;
  border-left: 3px solid var(--gold); max-width: 90vw;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.25s, opacity 0.25s, visibility 0.25s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast.error { border-left-color: var(--negative); }
.toast.success { border-left-color: var(--positive); }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .login-left { display: none; }
  .login-right { width: 100%; border-left: none; border-top: 3px solid var(--gold); }
  /* A sidebar vira gaveta: sai da tela e volta quando o hambúrguer chama */
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 90;
    width: 272px; max-width: 84vw; height: 100dvh;
    padding: 20px 14px 16px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 12px 0 34px rgba(0, 0, 0, 0.34);
  }
  .sidebar.open { transform: none; }
  .sidebar-logo { width: 108px; margin: 0 6px 22px; }

  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 85;
    background: rgba(11, 11, 12, 0.55);
    opacity: 0; pointer-events: none; transition: opacity 0.22s ease;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

  .mobile-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: var(--ink);
    position: sticky; top: 0; z-index: 40;
  }
  .mobile-menu-btn {
    display: grid; place-items: center;
    width: 38px; height: 38px; flex-shrink: 0;
    border: 1px solid #2A2B2E; border-radius: var(--r-sm);
    background: none; color: #E0D9CB; cursor: pointer;
  }
  .mobile-menu-btn:active { background: #1C1D20; }
  .mobile-bar-logo { height: 26px; width: auto; }
  .mobile-bar-page {
    font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.16em;
    text-transform: uppercase; color: #6E685E;
    margin-left: auto; white-space: nowrap;
  }

  .content { padding: 18px 16px 60px; }
  /* Só uma barra gruda no topo, senão as duas se empilham */
  .topbar { padding: 11px 16px; position: static; gap: 10px; }
  .topbar .today { font-size: 10px; }
  .grid-4, .aging { grid-template-columns: 1fr 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .role-grid { grid-template-columns: 1fr; }
  .imp-map { grid-template-columns: 1fr; gap: 7px; }
  .imp-arrow { transform: rotate(90deg); justify-self: start; }
  .drawer { width: 100%; }
  .modal-overlay { padding: 12px; align-items: flex-start; }
  .modal { max-height: calc(100dvh - 24px); }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) {
  .grid-4, .aging { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
}
