:root {
  --navy: #1b2a4a;
  --navy-dark: #12203a;
  --navy-light: #2e4270;
  --gold: #b08d4f;
  --gold-light: #d4b378;
  --bg: #ffffff;
  --surface: #f7f8fa;
  --border: #e3e6ec;
  --text: #22293a;
  --muted: #6b7280;
  --green: #1e8e4e;
  --green-bg: #e3f5ea;
  --red: #c0392b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Logo ---------- */
.logo {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--navy);
  line-height: 1;
  user-select: none;
}
.logo .logo-main {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
}
.logo .logo-main .o-slash {
  position: relative;
  display: inline-block;
}
.logo .logo-main .o-slash::after {
  content: "";
  position: absolute;
  left: 55%;
  top: -12%;
  width: 2.5px;
  height: 124%;
  background: linear-gradient(180deg, var(--gold-light), var(--gold));
  transform: rotate(18deg);
  border-radius: 2px;
}
.logo .logo-sub {
  font-size: 9.5px;
  letter-spacing: 2.6px;
  margin-top: 4px;
  color: var(--navy);
}
.logo.logo-lg .logo-main { font-size: 44px; }
.logo.logo-lg .logo-sub { font-size: 14px; margin-top: 8px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 380px;
  padding: 44px 40px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(27, 42, 74, 0.08);
  text-align: center;
}
.login-card .logo { margin-bottom: 30px; }
.login-card h2 { font-size: 15px; color: var(--muted); font-weight: 500; margin-bottom: 22px; }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 3px solid var(--gold);
  background: var(--bg);
}
.topbar .who { text-align: right; font-size: 13px; }
.topbar .who .name { font-weight: 600; color: var(--navy); }
.topbar .who .acct { color: var(--muted); font-size: 12px; }

.nav {
  display: flex;
  gap: 4px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.nav button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 13px 18px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}
.nav button:hover { color: var(--navy); }
.nav button.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }

.content { padding: 26px 28px; max-width: 1400px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-head h1 { font-size: 20px; color: var(--navy); font-weight: 700; }
.page-head .actions { display: flex; gap: 10px; align-items: center; }

/* ---------- Botões ---------- */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-light); }
.btn-ghost { background: none; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--navy); border-color: var(--navy); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-icon {
  background: none; border: none; cursor: pointer; font-size: 15px;
  padding: 4px 6px; border-radius: 6px; color: var(--muted);
}
.btn-icon:hover { background: var(--surface); color: var(--navy); }
.btn-icon.danger:hover { color: var(--red); }

/* ---------- Formulários ---------- */
.field { margin-bottom: 14px; text-align: left; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #fff;
  color: var(--text);
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176, 141, 79, 0.15);
}
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checks label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--text);
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.checks input { width: auto; accent-color: var(--navy); }
.checks-scroll {
  max-height: 190px;
  overflow-y: auto;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.checks-scroll label { border: none; padding: 6px 10px; }
.checks-scroll label:hover { background: var(--surface); border-radius: 6px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th {
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 11px 12px;
  text-align: left;
  font-weight: 600;
}
td { padding: 10px 12px; border-top: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tbody tr:hover { background: var(--surface); }
tr.totals td {
  background: var(--surface);
  font-weight: 700;
  color: var(--navy);
  border-top: 2px solid var(--gold);
}
.num { text-align: right; }
th.num { text-align: right; }
.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Parcelas ---------- */
.chips { display: flex; gap: 6px; }
.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  background: #fff;
  line-height: 1.35;
  min-width: 62px;
}
.chip .p-num { font-weight: 700; color: var(--navy); font-size: 11.5px; }
.chip .p-date { color: var(--muted); }
.chip.paid { background: var(--green-bg); border-color: var(--green); }
.chip.paid .p-num { color: var(--green); }
.chip.paid .p-num::after { content: " ✓"; }
.chip.overdue { border-color: var(--red); }
.chip.overdue .p-date { color: var(--red); font-weight: 600; }
.chip.locked { cursor: default; opacity: 0.85; }
.chip:not(.locked):hover { box-shadow: 0 2px 8px rgba(27,42,74,0.15); }

/* ---------- Mês ---------- */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav input[type="month"] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; color: var(--navy); font-weight: 600;
}

/* ---------- Cards resumo ---------- */
.cards { display: flex; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.card {
  flex: 1; min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.card .card-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.card .card-value { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 6px; }
.card.gold .card-value { color: var(--gold); }
.card.green .card-value { color: var(--green); }
.card.red .card-value { color: var(--red); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(18, 32, 58, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 26px 28px;
  width: 520px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal h2 { font-size: 17px; color: var(--navy); margin-bottom: 18px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.calc-preview {
  background: var(--surface);
  border: 1px dashed var(--gold);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.calc-preview strong { color: var(--navy); }

/* ---------- Alerta de visitas ---------- */
.visit-alert {
  background: #fdf6ec;
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 20px;
  cursor: pointer;
}
.visit-alert:hover { box-shadow: 0 3px 12px rgba(176, 141, 79, 0.25); }
.visit-alert strong { color: var(--navy); }

/* ---------- Ficha do cliente ---------- */
.client-link { color: var(--navy); font-weight: 600; text-decoration: none; }
.client-link:hover { color: var(--gold); text-decoration: underline; }
.report-section { margin-top: 26px; }
.report-section h2 { font-size: 15px; color: var(--navy); margin-bottom: 12px; font-weight: 700; }
.report-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .report-grid { grid-template-columns: 1fr; } }
.bars {
  display: flex; align-items: flex-end; gap: 6px;
  height: 120px; padding: 10px 12px 26px;
  border: 1px solid var(--border); border-radius: 12px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bar { width: 70%; max-width: 34px; background: linear-gradient(180deg, var(--navy-light), var(--navy)); border-radius: 4px 4px 0 0; min-height: 0; }
.bar-label { position: absolute; bottom: -20px; font-size: 10px; color: var(--muted); }

/* ---------- Projetos ---------- */
.project-grid { display: grid; gap: 12px; }
.project-card {
  display: flex; flex-direction: column; gap: 5px;
  padding: 18px 20px; text-align: left;
  border: 1px solid var(--border); border-radius: 12px;
  background: #fff; cursor: pointer; font-family: inherit;
}
.project-card:hover { border-color: var(--gold); box-shadow: 0 4px 18px rgba(176,141,79,0.18); }
.project-card .project-name { font-size: 17px; font-weight: 700; color: var(--navy); }
.project-card .project-sub { font-size: 12.5px; color: var(--muted); }
.project-badge {
  background: #fff; border: 1px solid var(--border);
  padding: 5px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.4px;
}
.project-badge.dark { background: #0c0c0c; border-color: #0c0c0c; }

/* ---------- Logos dos projetos (wordmarks) ---------- */
.brand {
  font-family: "Arial Rounded MT Bold", "Avenir Next", -apple-system, sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.3px;
  line-height: 1;
}
.brand.lg { font-size: 30px; }
.brand-tecnia { color: #3f4447; }
.brand-tecnia b { color: #2e86c1; font-weight: 800; }
.brand-winflexo {
  background: linear-gradient(90deg, #12a06b, #4cbf52, #8bd943);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-winflexo .wx {
  font-size: 1.18em;
  background: linear-gradient(90deg, #7ed348, #a8e063);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-box { display: inline-flex; align-self: flex-start; padding: 6px 2px; }
.brand-box.dark { background: #0c0c0c; border-radius: 10px; padding: 12px 18px; }
.espelho-items {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; max-height: 140px; overflow-y: auto;
  font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace;
  line-height: 1.7;
}

/* ---------- Conferência ---------- */
.conf-intro {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  max-width: 720px;
}
.conf-intro p { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin-bottom: 14px; }
.conf-upload { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.conf-upload input[type="file"] {
  border: 1px dashed var(--gold);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  flex: 1;
  min-width: 260px;
}

/* ---------- Badges / util ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.badge.on { background: var(--green-bg); color: var(--green); }
.badge.off { background: #fdecea; color: var(--red); }
.badge.wait { background: #fbf4e8; color: var(--gold); }
button.badge-btn { border: none; cursor: pointer; font-family: inherit; }
button.badge-btn:hover { filter: brightness(0.93); }
.error-msg { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.25s;
  z-index: 200;
}
#toast.show { opacity: 1; }
