:root {
  --bg: #f4f7f5;
  --panel: #ffffff;
  --ink: #14201c;
  --muted: #66736e;
  --line: #dce5df;
  --brand: #0f7a55;
  --brand-2: #f2b544;
  --danger: #c44236;
  --warn: #a66b00;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--brand); text-decoration: none; font-weight: 700; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  background: #101916;
  color: white;
  padding: 22px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 30px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--brand-2);
  color: #101916;
  font-weight: 900;
  font-size: 22px;
}
.brand strong, .brand small { display: block; }
.brand small { color: #b9c7c0; }
nav { display: grid; gap: 6px; }
nav a {
  color: #dce8e2;
  padding: 11px 12px;
  border-radius: 8px;
  font-weight: 650;
}
nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.content { margin-left: 250px; padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}
.eyebrow { color: var(--muted); margin: 0 0 4px; font-weight: 700; text-transform: uppercase; font-size: 12px; }
h1 { margin: 0; font-size: 30px; letter-spacing: 0; }
h2 { margin: 0; font-size: 18px; }
.button, .btn-success {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kpi, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(20,32,28,.06);
}
.kpi { padding: 18px; }
.kpi span, .metric-list span { color: var(--muted); display: block; font-weight: 700; font-size: 12px; text-transform: uppercase; }
.kpi strong { display: block; margin-top: 8px; font-size: 25px; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.two { grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); }
.panel { padding: 18px; overflow: hidden; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0; }
tr:hover td { background: #f8faf8; }
.table-clean { margin-bottom: 0; }
.table-clean > :not(caption) > * > * {
  border-bottom-color: var(--line);
  padding: 12px 10px;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.actions { white-space: nowrap; }
.actions a { margin-right: 10px; }
.actions .danger { color: var(--danger); }
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar .form-control { max-width: 360px; }
.toolbar .form-select { max-width: 230px; }
.narrow { max-width: 820px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field-check {
  display: flex;
  align-items: center;
  gap: 10px;
}
.field-check .form-label { margin: 0; order: 2; }
.field-check input { width: auto; order: 1; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.formset-list { display: grid; gap: 12px; }
.formset-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(110px, 1fr) minmax(110px, 1fr) minmax(110px, 1fr) minmax(80px, .6fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}
.metric-list { display: grid; gap: 10px; }
.metric-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfb;
}
.status {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e8f3ee;
  color: var(--brand);
  font-weight: 800;
  font-size: 11px;
}
.status.baixa { background: #fff4dc; color: var(--warn); }
.status.perda { background: #ffe8e5; color: var(--danger); }
.status.sem { background: #edf1ef; color: var(--muted); }

@media (max-width: 980px) {
  .sidebar { position: static; width: auto; }
  .content { margin-left: 0; padding: 18px; }
  .kpi-grid, .grid.two { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar .form-control, .toolbar .form-select { max-width: none; }
  .form-grid, .formset-row { grid-template-columns: 1fr; }
  .responsive-cards thead { display: none; }
  .responsive-cards tbody, .responsive-cards tr, .responsive-cards td { display: block; width: 100%; }
  .responsive-cards tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: white;
  }
  .responsive-cards td {
    border: 0;
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    text-align: right;
  }
  .responsive-cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
    text-align: left;
  }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at top left, #f7d36b 0, #f7d36b 220px, transparent 221px), var(--bg);
}
.login-shell {
  width: min(430px, calc(100vw - 32px));
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(20,32,28,.12);
}
.login-brand { color: var(--ink); margin-bottom: 22px; }
.login-brand small { color: var(--muted); }
.login-form { display: grid; gap: 14px; margin-top: 22px; }
.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}
.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  font: inherit;
  color: var(--ink);
  background: #fbfdfc;
}
.login-form button {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}
.login-error {
  background: #ffe8e5;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
}
