:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-2: #4a4a4a;
  --muted: #8a8378;
  --line: #e6dfd4;
  --gold: #c9a24a;
  --gold-soft: #f3e7c8;
  --gold-ink: #7a5d15;
  --green: #2f7d4f;
  --green-soft: #dcefe3;
  --amber: #a46a00;
  --amber-soft: #f9ecd1;
  --red: #b23a3a;
  --red-soft: #f8dcdc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.06), 0 8px 24px rgba(26, 26, 26, 0.05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-ink); }
button { font-family: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-ink);
  font-weight: 600;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.login-hero {
  background: var(--ink);
  color: #fff;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand {
  font-size: 11px;
  letter-spacing: 0.3em;
  font-weight: 700;
  text-transform: uppercase;
}
.login-hero .brand { color: #fff; }
.login-hero .rule { width: 36px; height: 3px; background: var(--gold); margin-bottom: 18px; }
.login-hero h1 { font-size: 34px; margin-bottom: 14px; }
.login-hero p { color: #cfc8bd; max-width: 380px; font-size: 14px; }
.login-hero .foot { color: #8a8378; font-size: 12px; }
.login-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.login-form form { width: 100%; max-width: 360px; }
.login-form h2 { font-size: 20px; margin-bottom: 4px; }
.login-form .sub { color: var(--muted); font-size: 12px; margin-bottom: 22px; }
.demo-banner {
  margin-top: 26px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--gold-soft);
  color: var(--gold-ink);
  font-size: 12px;
}
.demo-banner button {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--gold-ink);
  color: var(--gold-ink);
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}
.demo-banner button:hover { background: #fff8e6; }

/* ---------- Form controls ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 74, 0.18); }
textarea { resize: vertical; min-height: 72px; }
input[type="file"] { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #000; }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover:not(:disabled) { background: #b9933f; }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-outline:hover:not(:disabled) { border-color: var(--ink-2); }
.btn-outline-gold { background: #fff; color: var(--gold-ink); border-color: var(--gold); }
.btn-outline-gold:hover:not(:disabled) { background: var(--gold-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: rgba(0, 0, 0, 0.05); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-on-dark { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.btn-on-dark:hover:not(:disabled) { border-color: #fff; }
.btn-gold-outline-dark { background: transparent; color: var(--gold); border-color: var(--gold); }
.btn-gold-outline-dark:hover:not(:disabled) { background: rgba(201, 162, 74, 0.12); }
.link-btn { background: none; border: 0; color: var(--gold-ink); cursor: pointer; padding: 0; font: inherit; font-size: 12px; text-decoration: underline; }

/* ---------- App shell ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { color: #fff; }
.topbar .sep { color: #8a8378; font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 12px; font-weight: 600; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: #cfc8bd;
  text-decoration: none;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
}
.topbar nav a.active, .topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card.dark { background: var(--ink); color: #fff; }
.card.dark .muted { color: #a79f92; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--gold-soft);
  color: var(--gold-ink);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.danger { background: var(--red-soft); color: var(--red); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.kpi.dark .value { color: var(--gold); }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.kpi .actions { margin-top: 14px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 18px; }
.grid-form { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: none; }
.table td { font-size: 13px; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { font-weight: 600; }
.table .docs { font-size: 12px; color: var(--ink-2); }
.table .docs a { color: var(--ink-2); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fbf8f3; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.conferido, .badge.pago { background: var(--green-soft); color: var(--green); }
.badge.aguardando, .badge.em_aprovacao { background: var(--amber-soft); color: var(--amber); }
.badge.divergencia, .badge.vencido { background: var(--red-soft); color: var(--red); }
.badge.aberto, .badge.sem { background: #eee9e1; color: var(--ink-2); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal .day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  cursor: default;
  color: var(--ink);
  text-decoration: none;
}
.cal .day.empty { visibility: hidden; }
.cal .day.conferido { background: var(--green-soft); color: var(--green); }
.cal .day.aguardando { background: var(--amber-soft); color: var(--amber); }
.cal .day.divergencia { background: var(--red-soft); color: var(--red); }
.cal .day.sem { background: #fff; border-color: var(--line); color: var(--ink-2); cursor: pointer; }
.cal .day.sem:hover { border-color: var(--gold); background: var(--gold-soft); }
.cal .day.hoje { outline: 2px solid var(--gold); outline-offset: 1px; }
.cal .day.futuro { color: #c8c1b6; border-color: #efeae2; cursor: default; background: transparent; }
.cal .day.divergencia, .cal .day.aguardando { cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 11px; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-conf::before { background: var(--green-soft); border: 1px solid var(--green); }
.legend .l-ag::before { background: var(--amber-soft); border: 1px solid var(--amber); }
.legend .l-div::before { background: var(--red-soft); border: 1px solid var(--red); }
.legend .l-sem::before { background: #fff; border: 1px solid var(--line); }

/* ---------- Fechamento ---------- */
.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.file-item .name { font-weight: 600; font-size: 13px; word-break: break-all; }
.file-item .type { font-size: 11px; color: var(--muted); }
.file-item .remove { color: var(--red); background: none; border: 0; cursor: pointer; font-size: 12px; }
.upload-row { display: flex; gap: 10px; align-items: flex-end; }
.upload-row label.field { flex: 1; margin: 0; }

.calc .line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: 13px; }
.calc .line:last-of-type { border-bottom: 0; }
.calc .big { font-size: 28px; font-weight: 700; color: var(--gold); letter-spacing: -0.02em; margin: 6px 0 2px; }
.calc .acc { font-size: 12px; color: #a79f92; margin-bottom: 14px; }
.calc .acc b { color: #fff; }

.divergencia-box { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: 12px; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(26, 26, 26, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); max-height: 92vh; overflow: auto; }
.modal h2 { margin-bottom: 4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: 0.2s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }

.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--gold); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters label.field { margin: 0; min-width: 160px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-form { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .login { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 20px; min-height: 220px; }
  .login-hero h1 { font-size: 26px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .sep, .topbar .user { display: none; }
  .page { padding: 18px 14px 50px; }
  .kpis { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  .table { min-width: 560px; }
}

/* ---------- Dashboard ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 100%; background: var(--gold); border-radius: 3px 3px 0 0; min-height: 0; transition: height 0.2s; }
.bar.parcial { background: #e2cf98; }
.bar.vazio { height: 3px !important; background: var(--red-soft); border: 1px solid var(--red); border-bottom: 0; box-sizing: border-box; }
.bar.futuro { background: transparent; }
.bar-lbl { font-size: 10px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.legend .l-b-ok::before { background: var(--gold); }
.legend .l-b-parc::before { background: #e2cf98; }
.legend .l-b-vazio::before { background: var(--red-soft); border: 1px solid var(--red); }
.share { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.share-bar { height: 8px; background: var(--gold); border-radius: 4px; max-width: 90px; }
.share span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; background: #fbf8f3; }
@media (max-width: 680px) {
  .bar-lbl { display: none; }
  .bar-col:nth-child(5n+1) .bar-lbl { display: block; }
}
