/* ==========================================================================
   Identidade visual CNDL — azul royal (logo), acentos amarelo/verde (swoosh).
   ========================================================================== */
:root {
  /* Marca */
  --brand-900: #0a2c63;
  --brand-800: #0c3473;
  --brand-700: #0e3b85;   /* azul principal CNDL */
  --brand-600: #16479a;
  --brand-500: #2d4a93;
  --brand-300: #6c83c4;
  --brand-100: #e7ecf7;
  --brand-50:  #f1f4fb;
  --accent-yellow: #f4b41a;
  --accent-green:  #1f9d4d;

  --grad-brand: linear-gradient(135deg, #0a2c63 0%, #0e3b85 45%, #2d4a93 80%, #51629f 100%);

  /* Superfícies / texto */
  --bg: #eef1f8;
  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --ink: #16223d;
  --ink-soft: #5a6480;
  --line: #dfe4f0;

  --danger: #b3261e;
  --danger-soft: #fbeaea;
  --ok: #1f7a44;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(14, 59, 133, .06);
  --shadow: 0 2px 6px rgba(14, 59, 133, .08), 0 18px 40px -22px rgba(10, 44, 99, .45);
  --shadow-brand: 0 14px 30px -12px rgba(14, 59, 133, .55);

  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Marca / logo ---------- */
.brand { display: inline-flex; align-items: center; gap: .8rem; color: inherit; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 38px; width: auto; object-fit: contain; display: block; }
.brand-sub {
  color: rgba(255,255,255,.85);
  font-weight: 600; font-size: .8rem; letter-spacing: .01em;
  border-left: 1px solid rgba(255,255,255,.28);
  padding-left: .8rem;
}

/* ---------- Header público (azul, logo branca da CNDL) ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .95rem 1.5rem;
  background: var(--brand-900);
}
/* faixa fina tricolor (azul→amarelo→verde) do símbolo */
.flag-stripe { height: 4px; background: linear-gradient(90deg, var(--brand-600) 0 55%, var(--accent-yellow) 55% 80%, var(--accent-green) 80% 100%); }

.container { max-width: 1080px; margin: 0 auto; padding: 2.2rem 1.5rem 4rem; }
.container.narrow { max-width: 560px; }

/* ---------- Hero público (banner azul) ---------- */
.hero-band {
  background: var(--grad-brand);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.hero-band::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.12), transparent 70%);
}
.hero-band .inner { max-width: 1080px; margin: 0 auto; padding: 3.2rem 1.5rem; position: relative; z-index: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; font-weight: 700; color: var(--accent-yellow); }
.hero-band h1 { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3rem); line-height: 1.08; letter-spacing: -.02em; margin: .5rem 0 .7rem; }
.hero-band .lead { color: rgba(255,255,255,.88); font-size: 1.05rem; max-width: 52ch; }

h1 { letter-spacing: -.02em; }
.lead { color: var(--ink-soft); font-size: 1.05rem; }
.eyebrow.dark { color: var(--brand-700); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.7rem;
}
.card-accent { border-top: 4px solid var(--brand-700); }

.doc-meta { color: var(--ink-soft); font-size: .92rem; }

/* ---------- Grade de materiais (home) ---------- */
.materials { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.material-card {
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand-700);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem; color: inherit;
  transition: transform .1s, box-shadow .15s;
}
.material-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-brand); }
.material-card h3 { margin: 0; color: var(--brand-700); font-size: 1.1rem; }
.material-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; }
.material-link { margin-top: auto; padding-top: .4rem; font-weight: 700; color: var(--brand-700); }

/* ---------- Forms ---------- */
form .field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: .8rem; }

input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: .72rem .85rem; font: inherit; color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; background: #fff;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px var(--brand-100);
}
textarea { resize: vertical; min-height: 90px; }

/* Estados de validação dos campos */
.field-msg { font-size: .78rem; margin-top: .35rem; min-height: 1em; }
.field.invalid input { border-color: var(--danger); background: #fff; box-shadow: 0 0 0 3px var(--danger-soft); }
.field.invalid .field-msg { color: var(--danger); font-weight: 600; }
.field.valid input { border-color: var(--accent-green); }
.field.valid .field-msg { color: var(--ok); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .75rem 1.2rem; font: inherit; font-weight: 700;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand-700); color: #fff; cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand-700); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); box-shadow: none; }
.btn.sm { padding: .42rem .7rem; font-size: .82rem; box-shadow: none; }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius-sm); padding: .8rem 1rem; font-size: .92rem; margin-bottom: 1.2rem; border: 1px solid; }
.alert.error { background: var(--danger-soft); border-color: #eec3c1; color: var(--danger); }
.alert.ok { background: #e7f3ec; border-color: #bfe0cc; color: var(--ok); }
.alert.warn { background: #fdf3d7; border-color: #f0dca0; color: #8a6d1a; }

/* ---------- Admin ---------- */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 760px) { .admin-shell { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--grad-brand); color: #fff;
  padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: .25rem;
}
.sidebar .brand { margin-bottom: 1.2rem; }
.sidebar nav a {
  display: block; padding: .6rem .8rem; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.82); font-weight: 600; font-size: .92rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: #fff; color: var(--brand-700); }
.sidebar .spacer { flex: 1; }
.sidebar .btn.ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.sidebar .btn.ghost:hover { background: rgba(255,255,255,.12); }

.admin-main { padding: 2.2rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.5rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; border-left: 4px solid var(--brand-700); }
.stat .n { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; color: var(--brand-700); }
.stat .l { color: var(--ink-soft); font-size: .85rem; }

/* ---------- Tabelas ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--brand-50); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-700); }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; display: flex; gap: .4rem; }

code, .mono { font-family: var(--mono); font-size: .85em; }
.link-pill { display: inline-flex; align-items: center; gap: .4rem; background: var(--brand-50); border: 1px solid var(--line); padding: .25rem .55rem; border-radius: 999px; font-family: var(--mono); font-size: .78rem; }

.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.badge.on { background: #e7f3ec; color: var(--ok); }
.badge.off { background: #eceff6; color: var(--ink-soft); }
.badge.warn { background: #fdf3d7; color: #8a6d1a; }

.empty { text-align: center; color: var(--ink-soft); padding: 3rem 1rem; }

details.inline-form > summary { cursor: pointer; font-weight: 700; color: var(--brand-700); margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tela centrada (login / código) ---------- */
.auth-bg { min-height: 100vh; background: var(--grad-brand); display: flex; align-items: center; justify-content: center; padding: 2rem 1.2rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card { box-shadow: 0 30px 60px -25px rgba(10,44,99,.7); }

/* código OTP */
.otp-input { font-size: 1.6rem; letter-spacing: .5rem; text-align: center; font-weight: 700; }

.footer { background: var(--brand-900); color: rgba(255,255,255,.78); font-size: .82rem; text-align: center; padding: 2.4rem 1rem; margin-top: 3rem; }
.footer .regua { display: block; width: 100%; max-width: 380px; height: auto; margin: 0 auto 1.1rem; }
.footer p { margin: 0; }
.inline { display: inline; }
.muted { color: var(--ink-soft); }
.right { text-align: right; }
