:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #f1eee9;
  --border: #e4dfd7;
  --text: #22201c;
  --muted: #736c62;
  --accent: #b5532f;
  --accent-soft: #f6e5dd;
  --accent-text: #ffffff;
  --sidebar: #22201c;
  --sidebar-text: #d9d3c9;
  --ok: #2f7a4f;
  --ok-soft: #e1f1e7;
  --warn: #9a6a0b;
  --warn-soft: #fbf0d6;
  --erro: #b3261e;
  --erro-soft: #fbe3e1;
  --info: #2c5f8a;
  --info-soft: #e1ecf6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161513;
  --surface: #201e1b;
  --surface-2: #2a2724;
  --border: #36322d;
  --text: #ece7df;
  --muted: #a39b8f;
  --accent: #e07a52;
  --accent-soft: #3a261d;
  --accent-text: #1a1310;
  --sidebar: #100f0d;
  --sidebar-text: #c9c2b7;
  --ok: #6cc591;
  --ok-soft: #1d3326;
  --warn: #e3b453;
  --warn-soft: #3a2f16;
  --erro: #f08a82;
  --erro-soft: #3d1e1b;
  --info: #7fb1dc;
  --info-soft: #1b2b3a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
small { font-size: 12px; }
/* Só os ícones de traço (24x24): etiquetas, códigos de barras, QR codes e gráficos mantêm o próprio desenho, sem contorno nas letras. */
svg[viewBox="0 0 24 24"] { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.sidebar .brand strong { color: #fff; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.sidebar nav { flex: 1; padding: 4px 8px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin-bottom: 2px;
  color: var(--sidebar-text); border-radius: 8px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar nav a.active svg { color: var(--accent); }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.me { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text); }
.me:hover { text-decoration: none; }
.me strong { display: block; color: #fff; font-size: 13px; }
.me small { color: var(--muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-grid; place-items: center; font-weight: 600; font-size: 12px; flex-shrink: 0;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 15px; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions form { margin: 0; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }
.only-mobile { display: none !important; }

/* Componentes */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 18px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .hint.erro { color: var(--erro); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(.95); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--erro); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.inline { display: inline; margin: 0; }

/* Formulários */
label { display: block; font-weight: 550; font-size: 13px; }
label + label, .field + .field { margin-top: 12px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
input[type="checkbox"] { display: inline; width: auto; margin: 0 6px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid label + label { margin-top: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.help { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Tabelas */
.table-wrap { overflow-x: auto; margin: 0 -18px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 18px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; border-top: 2px solid var(--border); }
.group-row td { background: var(--surface-2); font-weight: 600; }

/* Etiquetas */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge-verde, .badge-ok, .badge-realizado, .badge-aprovado, .badge-concluido, .badge-concluida { background: var(--ok-soft); color: var(--ok); }
.badge-amarelo, .badge-warn, .badge-hoje, .badge-enviado, .badge-pausado, .badge-alta { background: var(--warn-soft); color: var(--warn); }
.badge-vermelho, .badge-erro, .badge-atrasado, .badge-recusado { background: var(--erro-soft); color: var(--erro); }
.badge-azul, .badge-info, .badge-em_andamento, .badge-avencer { background: var(--info-soft); color: var(--info); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-erro { background: var(--erro-soft); color: var(--erro); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

.empty { text-align: center; padding: 40px 18px; }
.empty p { margin: 8px 0 16px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }

.bars { display: flex; align-items: flex-end; gap: 14px; height: 160px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bars .pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bars .bar { width: 40%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .in { background: var(--ok); }
.bars .out { background: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.score { display: flex; align-items: center; gap: 16px; }
.score-ring {
  width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: conic-gradient(var(--accent) calc(var(--v) * 1%), var(--surface-2) 0);
}
.score-ring span {
  width: 66px; height: 66px; border-radius: 50%; background: var(--surface); display: grid; place-items: center;
  font-size: 17px; font-weight: 700;
}

.summary-table td { padding: 6px 0; border: 0; }
.summary-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.summary-table tr.total td { font-size: 15px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
}
.login-card .brand { padding: 0 0 20px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 6px 0 18px; }
.login-card .btn { margin-top: 18px; }

/* Impressão de documentos */
.print-doc { max-width: 800px; margin: 0 auto; padding: 32px; background: #fff; color: #222; }
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* Responsivo */
@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-side { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -18px; }
}
