:root {
  --bg: #f3f5f7;
  --paper: #ffffff;
  --ink: #1c2430;
  --muted: #5c6b7a;
  --line: #d9e0e7;
  --sidebar: #15243a;
  --accent: #15243a;
  --accent-dark: #0e1a2c;
  --wine: #8d2424;
  --ok: #0c6b45;
  --ok-bg: #e5f6ee;
  --wait: #1d3f73;
  --wait-bg: #e8eef8;
  --warn: #6d5200;
  --warn-bg: #fff4d6;
  --danger: #8d2424;
  --danger-bg: #fdecec;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, p { margin-top: 0; }
h2 { font-size: 1.05rem; margin: 16px 0 8px; }
a { color: var(--sidebar); }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px;
  flex: none;
  background: var(--sidebar);
  color: #d5dde6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; }
.brand-logo { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; flex: none; }
.brand strong { color: white; font-size: 0.98rem; line-height: 1.2; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  color: #d5dde6;
  text-decoration: none;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 8px;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.sidebar a.active { background: #243652; color: white; box-shadow: inset 3px 0 0 var(--wine); }
.sidebar .config { margin-top: auto; }
.backdrop { display: none; }
.main { flex: 1; min-width: 0; }
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.top h1 { font-size: 1.15rem; margin: 0; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn {
  display: none;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #c5d0db;
  background: white;
  cursor: pointer;
}

.content { padding: 24px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { border-color: #c5d0db; background: white; color: var(--ink); }
.btn-secondary:hover { border-color: #8ea0b3; }
.btn-danger { background: white; color: var(--danger); border-color: #e4b4b4; }
.row-actions .btn, .actions .btn { min-height: 34px; padding: 0 10px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.grid h2, .grid-3 h2, .full { grid-column: 1 / -1; }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-weight: 650; }
.hint, .field small { color: var(--muted); font-size: 0.92rem; }
.note {
  background: #fff8e8;
  border: 1px solid #ead7a2;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 14px 0;
}
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c5d0db;
  border-radius: 8px;
  padding: 8px 10px;
  background: white;
}
textarea { min-height: 88px; resize: vertical; }
.readonly {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background: #f4f7fa;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.check { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check input { width: 20px; min-height: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; flex: 1; }
.grand { margin: 0 0 0 auto; font-size: 1.15rem; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.kpis, .shortcuts { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.page-tools .toolbar { flex: 1; margin: 0; min-width: min(100%, 280px); }
.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 650;
}
.subnav a.active { background: var(--sidebar); color: white; border-color: var(--sidebar); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 8px 0 16px; }
.compare-card strong { display: block; margin-top: 8px; font-size: 1.8rem; letter-spacing: -0.03em; }
.money-in { color: var(--ok); font-weight: 700; }
.money-out { color: var(--danger); font-weight: 700; }
.badge-direct { background: #fff4e5; color: #8a5a00; }
.badge-out { background: var(--danger-bg); color: var(--danger); }
.tone-in { box-shadow: inset 3px 0 0 var(--ok); }
.tone-out { box-shadow: inset 3px 0 0 var(--danger); }
.tone-direct { box-shadow: inset 3px 0 0 #c9842a; }
.tone-wait { box-shadow: inset 3px 0 0 var(--warn); }
.tone-off { opacity: 0.72; }
.closing p { display: flex; justify-content: space-between; gap: 16px; margin: 8px 0; }
.filters { margin-bottom: 16px; }
.shortcuts { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 16px; }
.recent tbody tr { position: relative; }
.recent tbody a::after { content: ""; position: absolute; inset: 0; }
.kpi, .shortcut {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi span, .shortcut span, .kpi small { color: var(--muted); }
.kpi strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.shortcut {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 0;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
}
.shortcut:hover { border-color: var(--sidebar); }
.shortcut strong { font-size: 0.98rem; }
.shortcut span { font-size: 0.82rem; }

.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 12px; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.neg { color: var(--danger); font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 28px 14px; }
tfoot td { font-weight: 700; }
.lines select, .lines input { min-width: 140px; }
.lines input[type="search"] { margin-bottom: 6px; }

.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: var(--danger-bg); color: var(--danger); }
.badge-draft { background: var(--warn-bg); color: var(--warn); }
.badge-wait { background: var(--wait-bg); color: var(--wait); }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--danger-bg); color: var(--danger); }

.chart-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 0; }
.chart-wrap svg { width: 100%; min-width: 520px; height: auto; }
.legend { color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin: 0 6px 0 14px; vertical-align: -1px; }
.swatch.sale { background: #1b2838; margin-left: 0; }
.swatch.buy { background: #9d2c2c; }
.logo-preview { display: block; max-width: 180px; max-height: 72px; object-fit: contain; margin-top: 8px; }
.tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.tab {
  min-height: 40px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.address-grid { display: grid; grid-template-columns: 1.15fr 0.55fr 1.25fr 1.25fr; gap: 12px 16px; }
.address-grid .span-2 { grid-column: span 2; }
.cep-line { display: flex; gap: 8px; }
.cep-line input { flex: 1; }
.cep-line .btn { width: auto; min-width: 96px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(460px, 100%); }
.brand-mark { display: grid; justify-items: center; gap: 8px; font-weight: 750; color: var(--sidebar); margin-bottom: 8px; }
.auth-logo { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
:focus-visible { outline: 3px solid #e7b4b4; outline-offset: 2px; }

@media (max-width: 1100px) {
  .shortcuts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .split, .grid, .grid-3, .address-grid, .compare { grid-template-columns: 1fr; }
  .span-2, .address-grid .span-2 { grid-column: auto; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; z-index: 30; transform: translateX(-105%); transition: none; }
  .sidebar.open { transform: none; }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(18, 24, 33, 0.45); z-index: 20; }
  .who span { display: none; }
  .content, .top { padding-left: 14px; padding-right: 14px; }
}

.period { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 8px; }
.period > span { color: var(--muted); font-weight: 650; }
.period-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.period-picks a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}
.period-picks a.on { background: var(--ink); color: white; }
.period-custom { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0 20px; }
.period-custom label { display: grid; gap: 4px; color: var(--muted); font-size: 0.92rem; }
.cash-top { margin-bottom: 8px; }
.cash-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  margin: 16px 0 24px;
}
a.cash-total { color: inherit; text-decoration: none; }
.money-wait { color: var(--wait); }
.balance-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px;
  margin: 32px 0 48px;
}
.cash-totals span, .balance-totals span { display: block; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.82rem; }
.cash-totals strong, .balance-totals strong { display: block; margin-top: 6px; font-size: 1.6rem; font-weight: 720; }

.list-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.list-head h2 { margin: 0; }
.filters-panel { margin: 8px 0 20px; }
.filters-panel summary { cursor: pointer; font-weight: 650; width: fit-content; }
.filters-panel[open] summary { margin-bottom: 12px; }
table.plain { background: transparent; }
table.plain th { background: transparent; border-bottom: 1px solid var(--line); }
.account-list { display: grid; gap: 4px; margin-bottom: 28px; }
.account-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  font-size: 1.15rem;
}
.closing-simple { margin: 28px 0; display: grid; gap: 10px; font-size: 1.15rem; }
.closing-simple .grand { font-size: 1.45rem; margin-top: 8px; }
.badge-direct { margin-left: 8px; }

.sale-picks { display: flex; gap: 4px; margin: 0; }
.sale-pick {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  min-height: 36px;
  cursor: pointer;
  font: inherit;
}
.sale-pick.on.paid { background: var(--ok-bg); color: var(--ok); }
.sale-pick.on.pending { background: var(--wait-bg); color: var(--wait); }

@media (max-width: 900px) {
  .cash-totals, .balance-totals { grid-template-columns: 1fr 1fr; }
  .list-head { grid-template-columns: 1fr; display: grid; }
}
@media (max-width: 560px) {
  .balance-totals { grid-template-columns: 1fr; }
}


