:root {
[hidden] { display: none !important; }
  --bg: #121a24;
  --surface: #1a2533;
  --surface-2: #213044;
  --line: #2b3a4d;
  --text: #e6edf5;
  --muted: #93a3b6;
  --accent: #f2b544;
  --accent-ink: #1d1406;
  --ok: #4cc38a;
  --warn: #f2b544;
  --danger: #f0656a;
  --info: #79aefc;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; font-weight: 600; }
p { max-width: 75ch; }
.num, td.num, .metric-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Estrutura */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.05rem; padding: 0 6px; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--muted); padding: 8px 10px; border-radius: var(--radius-sm); }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav .group { color: var(--muted); font-size: .78rem; padding: 12px 10px 4px; }
.side-foot { margin-top: auto; font-size: .85rem; color: var(--muted); padding: 0 6px; }
.side-foot form { margin-top: 8px; }
.main { padding: 0 32px 48px; min-width: 0; }

/* Faixa de ambiente com motivo de código de barras */
.envbar { margin: 0 -32px 24px; padding: 8px 32px; display: flex; align-items: center; gap: 12px; font-size: .88rem; border-bottom: 1px solid var(--line); }
.envbar .bars { width: 64px; height: 16px; background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 4px, currentColor 4px 5px, transparent 5px 8px, currentColor 8px 11px, transparent 11px 13px); opacity: .9; }
.envbar.sandbox { background: #2a2312; color: var(--accent); }
.envbar.production { background: #2b1518; color: var(--danger); }
.envbar strong { color: var(--text); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }

/* Botões e formulários */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.link { background: none; border: none; color: var(--info); padding: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; }
label { display: block; font-weight: 550; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], select, input[type=file] {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; font: inherit;
}
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

/* Filtros de período */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.chips a:hover { color: var(--text); text-decoration: none; border-color: var(--muted); }
.chips a[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.custom-range { display: flex; gap: 6px; align-items: center; }
.custom-range input { width: auto; padding: 5px 8px; }

/* Indicadores */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; }
.metric h3 { margin: 0; font-size: .9rem; color: var(--muted); font-weight: 500; }
.metric-value { font-size: 1.9rem; font-weight: 650; margin: 6px 0 2px; letter-spacing: -.02em; }
.metric .sub { color: var(--muted); font-size: .9rem; }
.metric.ok .metric-value { color: var(--ok); }
.metric.warn .metric-value { color: var(--warn); }
.metric.danger .metric-value { color: var(--danger); }
.rate { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 18px; }
.rate .big { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.formula { font-size: .9rem; color: var(--muted); }
.btn.wide { width: 100%; justify-content: center; }
meter.meter, progress.progress { display: block; width: 100%; height: 10px; margin-top: 10px; border: none; border-radius: 99px; background: var(--surface-2); overflow: hidden; -webkit-appearance: none; appearance: none; }
meter.meter::-webkit-meter-bar { background: var(--surface-2); border: none; border-radius: 99px; }
meter.meter::-webkit-meter-optimum-value, meter.meter::-webkit-meter-suboptimum-value, meter.meter::-webkit-meter-even-less-good-value { background: var(--ok); }
meter.meter::-moz-meter-bar { background: var(--ok); }
progress.progress::-webkit-progress-bar { background: var(--surface-2); }
progress.progress::-webkit-progress-value { background: var(--accent); }
progress.progress::-moz-progress-bar { background: var(--accent); }

.status-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.danger { background: var(--danger); } .dot.warn { background: var(--warn); }

/* Painéis e tabelas */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 18px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 550; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; border: 1px solid currentColor; }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.danger { color: var(--danger); }
.badge.info { color: var(--info); } .badge.muted { color: var(--muted); }
.errors { margin: 0; padding-left: 18px; color: var(--danger); font-size: .85rem; }
.warnings { margin: 0; padding-left: 18px; color: var(--warn); font-size: .85rem; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 180px; }
.pager { display: flex; gap: 12px; justify-content: flex-end; margin-top: 12px; }
.alert { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; border: 1px solid; }
.alert.danger { border-color: var(--danger); background: #2b1518; }
.alert.warn { border-color: var(--warn); background: #2a2312; }
.alert.info { border-color: var(--info); background: #15243a; }
.alert.ok { border-color: var(--ok); background: #12291f; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.confirm-box { border: 1px solid var(--accent); border-radius: var(--radius-lg); padding: 18px; background: #1f1c14; }
.confirm-box .totals { display: flex; gap: 32px; margin: 8px 0 16px; }
.confirm-box .totals div strong { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
code.line { display: block; background: var(--bg); border: 1px solid var(--line); padding: 10px; border-radius: var(--radius-sm); font-size: 1rem; word-break: break-all; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px; }
.login .brand { margin-bottom: 22px; padding: 0; }

@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .group { display: none; }
  .side-foot { margin: 0; width: 100%; }
  .main { padding: 0 16px 32px; }
  .envbar { margin: 0 -16px 18px; padding: 8px 16px; }
  .metrics { grid-template-columns: 1fr; }
  .rate { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
