/* ============================================================
   Wert Design System
   Paleta oficial + tokens de espaçamento, raio, alturas e sombra.
   ============================================================ */

:root {
  /* Paleta oficial Wert */
  --wert-1: #101b28;
  --wert-2: #1c2639;
  --wert-3: #23588b;
  --wert-4: #dedfdb;
  --wert-5: #baafa6;

  /* Aliases semânticos */
  --bg: #ffffff;
  --soft: #f8f8f6;
  --line: rgba(16, 27, 40, .10);
  --line-strong: rgba(16, 27, 40, .18);
  --text: #101b28;
  --text-soft: #354252;
  --muted: #6c7580;
  --blue: #23588b;
  --blue-dark: #1c2639;
  --blue-soft: #eef5fb;
  --beige: #f1eee9;
  --taupe: #baafa6;
  --danger: #ad2d22;
  --danger-soft: #fff1ef;
  --green: #177049;
  --green-soft: #e8f5ee;
  --warn: #946214;
  --warn-soft: #fff5e6;

  /* Espaçamento (escala consistente) */
  --space-1: 8px;
  --space-2: 14px;
  --space-3: 20px;
  --space-4: 28px;
  --space-5: 40px;

  /* Raios */
  --radius: 24px;
  --radius-sm: 14px;
  --radius-xs: 12px;
  --radius-pill: 999px;

  /* Alturas de controles (padroniza inputs/selects/botões) */
  --control-h: 44px;
  --control-h-sm: 36px;

  /* Sombras */
  --shadow: 0 24px 60px rgba(16, 27, 40, .08);
  --shadow-soft: 0 10px 26px rgba(16, 27, 40, .055);

  /* Tipografia */
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============================================================
   Reset / Base
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 0 0, rgba(35, 88, 139, .10), transparent 28%),
    linear-gradient(180deg, #fff 0%, #fbfbfa 45%, #f7f7f4 100%);
  font-family: var(--font-stack);
  color: var(--text);
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

/* ============================================================
   Headings
   ============================================================ */

h1 {
  font-size: 34px;
  letter-spacing: -.055em;
  line-height: 1.1;
  margin: 0;
}
h1::after {
  content: "";
  display: block;
  width: 52px;
  height: 4px;
  border-radius: var(--radius-pill);
  margin-top: 14px;
  background: linear-gradient(90deg, var(--blue), var(--taupe));
}
h2 {
  font-size: 20px;
  letter-spacing: -.025em;
  margin: 0 0 var(--space-1);
}
h3 {
  font-size: 15px;
  letter-spacing: -.01em;
  margin: 0 0 var(--space-1);
}

/* ============================================================
   NAV
   ============================================================ */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.nav::before {
  content: "";
  display: block;
  height: 4px;
  background: linear-gradient(90deg, var(--wert-1), var(--wert-2), var(--wert-3), var(--wert-4), var(--wert-5));
}
.nav-inner {
  max-width: 1260px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.logo, .brand-mark {
  font-weight: 900;
  letter-spacing: .12em;
}
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo::before {
  content: "W";
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--wert-1), var(--wert-3));
  color: #fff;
  font-size: 14px;
}
.nav-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.nav-links a {
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  color: rgba(16, 27, 40, .76);
  font-size: 13px;
  font-weight: 700;
  transition: background .15s ease, color .15s ease;
}
.nav-links a:hover {
  background: var(--blue-soft);
  color: var(--blue);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.container {
  max-width: 1260px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Utilitários de espaçamento e alinhamento */
.mt { margin-top: var(--space-3); }
.mt-sm { margin-top: var(--space-2); }
.text-center { text-align: center; }

/* ============================================================
   HERO
   ============================================================ */

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  background: linear-gradient(135deg, #fff 0%, #fff 60%, var(--blue-soft) 100%);
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: var(--space-4);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(35, 88, 139, .16), transparent 66%);
  pointer-events: none;
}
.hero > div:first-child { flex: 1; min-width: 0; position: relative; z-index: 1; }
.hero p { color: var(--muted); margin: 10px 0 0; max-width: 70ch; }
.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  align-items: flex-start;
}
.muted { color: var(--muted); }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
  box-shadow: var(--shadow-soft);
}
.card > h2 + p.muted,
.card > h2 + .muted,
.card > h3 + p.muted,
.card > h3 + .muted {
  margin: -2px 0 var(--space-2);
}
.card > .grid:not(:first-child) { margin-top: var(--space-2); }
.card hr { margin: var(--space-3) 0; }
.card > p:last-child { margin-bottom: 0; }
.card > form + p { margin-top: var(--space-2); }

/* Cabeçalho de seção dentro de card */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.section-head > div:first-child { flex: 1; min-width: 0; }
.section-head form { display: inline-flex; }

/* ============================================================
   GRID
   ============================================================ */

.grid { display: grid; gap: var(--space-2); }
.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)); }

/* ============================================================
   STATS
   ============================================================ */

.stat {
  min-height: 116px;
  background: linear-gradient(180deg, #fff, #fbfcfd);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 26px;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--blue), var(--taupe));
}
.stat span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  letter-spacing: -.04em;
  line-height: 1.1;
}

/* ============================================================
   BOTÕES
   ============================================================ */

.btn {
  appearance: none;
  border: 0;
  height: var(--control-h);
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: linear-gradient(145deg, var(--wert-2), var(--blue));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 12px 24px rgba(35, 88, 139, .18);
  transition: transform .1s ease, filter .15s ease, opacity .15s ease;
  white-space: nowrap;
  letter-spacing: .01em;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled,
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  filter: grayscale(.3);
  box-shadow: none;
}
.btn.secondary {
  background: #fff;
  color: var(--wert-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.btn.small {
  height: var(--control-h-sm);
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
}
.btn.danger { background: var(--danger); box-shadow: 0 12px 24px rgba(173, 45, 34, .18); }
.btn.full { width: 100%; }

/* ============================================================
   FORM CONTROLS
   ============================================================ */

label {
  display: block;
  margin: var(--space-2) 0 6px;
  color: var(--text-soft);
  font-weight: 700;
  font-size: 13px;
}
.card > form > label:first-child,
.card > label:first-child { margin-top: 0; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  height: var(--control-h);
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 88, 139, .14);
}
textarea {
  min-height: 100px;
  height: auto;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  vertical-align: middle;
  cursor: pointer;
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form input,
.inline-form select { width: auto; min-width: 140px; }

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-3) 0;
}

/* ============================================================
   TABELAS
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
th {
  text-align: left;
  color: #66727e;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #fafafa;
  font-weight: 700;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }

/* Tabela usada como formulário (uma linha por grupo) */
.form-table { table-layout: auto; }
.form-table th.th-check,
.form-table td.td-check {
  width: 56px;
  text-align: center;
  padding-left: 18px;
  padding-right: 6px;
}
.form-table input,
.form-table select {
  height: var(--control-h-sm);
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  min-width: 130px;
}
.form-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: auto;
  padding: 0;
}
.form-table select { padding-right: 30px; background-position: calc(100% - 14px) 50%, calc(100% - 10px) 50%; }
.form-table label { margin: 0; font-weight: 700; }

/* ============================================================
   CODE / COPY
   ============================================================ */

.copy, td code, code, pre {
  background: #f5f5f2;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 10px;
  display: inline-block;
  color: var(--blue-dark);
  font-family: var(--font-mono);
  font-size: 12.5px;
}
pre {
  display: block;
  white-space: pre-wrap;
  overflow: auto;
  padding: 14px 16px;
  line-height: 1.5;
  font-size: 12.5px;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: #eef2f5;
  color: #26384c;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1;
  min-height: 22px;
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: #ffeae7; color: var(--danger); }

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin: var(--space-2) 0;
  line-height: 1.5;
}
.alert.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(173, 45, 34, .18);
}
.alert.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: rgba(148, 98, 20, .22);
}
.alert.info {
  background: var(--blue-soft);
  color: var(--blue-dark);
  border-color: rgba(35, 88, 139, .18);
}

.notice {
  background: linear-gradient(135deg, #fff, var(--beige));
  border: 1px solid var(--line);
  padding: var(--space-3);
  border-radius: var(--radius);
}

/* ============================================================
   LISTAS DE REGRAS
   ============================================================ */

.rule-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.rule-row:last-child { border-bottom: 0; }

.rules { padding-left: 20px; margin: 0; }
.rules li { margin: 8px 0; line-height: 1.55; }

/* ============================================================
   AUTH (login screens)
   ============================================================ */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-3);
}
.auth-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 32px;
  padding: var(--space-4);
  box-shadow: var(--shadow);
}
.brand-mark {
  display: inline-flex;
  background: linear-gradient(145deg, var(--wert-1), var(--wert-3));
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: var(--space-2);
  font-size: 13px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  .container { padding: var(--space-3) var(--space-2) var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero { flex-direction: column; padding: var(--space-3); }
  .hero-actions { width: 100%; }
  .nav-inner { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 28px; }
  h1::after { width: 42px; }
  .section-head { flex-direction: column; align-items: stretch; }
  .form-table { font-size: 12.5px; }
  .form-table input,
  .form-table select { min-width: 110px; }
}
