/* =====================================================================
   Painel administrativo — folha de estilo unica
   Mobile first. Sem dependencias externas.
   ===================================================================== */

:root {
  --pine-900: #08382C;
  --pine-700: #0B6B53;
  --pine-100: #DDEBE5;
  --gold:     #C8891F;
  --gold-100: #FBF0DC;
  --ink:      #16211D;
  --muted:    #6B7A74;
  --line:     #DFE5E2;
  --paper:    #F4F6F5;
  --card:     #FFFFFF;
  --danger:   #B3261E;
  --danger-100:#FBE9E7;

  --radius:   14px;
  --radius-sm:10px;
  --shadow:   0 1px 2px rgba(8,56,44,.06), 0 8px 24px rgba(8,56,44,.06);
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:     ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  padding-bottom: 84px; /* espaco do menu inferior */
}

a { color: var(--pine-700); }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------- topo */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--pine-900);
  color: #fff;
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  min-width: 0;
}

.brand__mark { color: var(--gold); font-size: 18px; }

.brand__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.nav-desktop { display: none; margin-left: auto; gap: 4px; }

.nav-desktop__link {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 999px;
}

.nav-desktop__link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-desktop__link.is-active { color: var(--pine-900); background: #fff; font-weight: 600; }

.usermenu { margin-left: auto; position: relative; }
.nav-desktop + .usermenu { margin-left: 4px; }

.usermenu > summary { list-style: none; cursor: pointer; }
.usermenu > summary::-webkit-details-marker { display: none; }

.usermenu__avatar {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--pine-700);
  border: 1px solid rgba(255,255,255,.25);
  font-weight: 600;
}

.usermenu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 210px;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 14px;
}

.usermenu__name { margin: 0; font-weight: 600; }
.usermenu__role { margin: 2px 0 12px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------- pagina */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.page__head { margin-bottom: 18px; }

.page__title { font-size: 24px; font-weight: 650; }

.page__subtitle { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------- alerta */

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 15px;
  border-left: 4px solid;
}

.alert--success { background: var(--pine-100); border-color: var(--pine-700); }
.alert--error   { background: var(--danger-100); border-color: var(--danger); }
.alert--info    { background: var(--gold-100); border-color: var(--gold); }

/* -------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.card__title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 14px;
}

/* --------------------------------------------------------- indicadores */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--pine-700);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.stat--gold { border-left-color: var(--gold); }
.stat--muted { border-left-color: var(--muted); }

.stat__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}

.stat__value {
  font-size: 28px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.stat__hint { font-size: 12px; color: var(--muted); }

/* -------------------------------------------- metricas dentro do card */

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 12px;
}

.metric__label {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}

.metric__value {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.card__foot {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

/* ------------------------------------------------------------- botoes */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--pine-700);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}

.btn:hover { background: var(--pine-900); }
.btn:active { transform: translateY(1px); }

.btn--ghost { background: transparent; color: var(--pine-700); border-color: var(--line); }
.btn--ghost:hover { background: var(--pine-100); }

.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #8C1D18; }

.btn--block { width: 100%; }

.btn--sm { min-height: 38px; padding: 0 14px; font-size: 14px; }

/* ---------------------------------------------------------- formulario */

.field { margin-bottom: 16px; }

.field__label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field__hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  color: var(--ink);
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--pine-700);
  box-shadow: 0 0 0 3px var(--pine-100);
  outline: none;
}

.textarea { min-height: 190px; resize: vertical; font-size: 15px; line-height: 1.6; }

.textarea--mono { font-family: var(--mono); font-size: 14px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  margin-bottom: 16px;
}

.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--pine-700); }

.grid-2 { display: grid; gap: 0 16px; }

.form-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------------- lista */

.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.toolbar .input { min-width: 0; }

.toolbar__actions { display: flex; gap: 10px; }

.toolbar__actions > * { flex: 1; }

.list { display: grid; gap: 10px; }

.item {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
}

.item:hover { border-color: var(--pine-700); }

.item__top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.item__name { font-weight: 620; }

.item__meta { font-size: 14px; color: var(--muted); margin-top: 3px; }

.code {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  background: var(--gold-100);
  color: #7A5211;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 11px 4px 8px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.pill__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.pill--off { color: var(--muted); }

.empty {
  text-align: center;
  padding: 44px 20px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty__title { font-weight: 620; margin-bottom: 6px; }
.empty__text { color: var(--muted); font-size: 15px; margin: 0 0 18px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  font-size: 14px;
  color: var(--muted);
}

/* --------------------------------------------------------- fieldset UI */

.section { margin-bottom: 26px; }

.section__title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--pine-700);
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--pine-100);
}

.vars { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }

.vars button {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--pine-100);
  color: var(--pine-900);
  border: 0;
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
}

.vars button:hover { background: var(--pine-700); color: #fff; }

.preview {
  background: #E7F0E9;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.55;
  min-height: 60px;
}

/* --------------------------------------------------------------- login */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(120% 70% at 50% 0%, #0F5A47 0%, var(--pine-900) 60%, #05261E 100%);
}

.auth__box {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 20px;
  padding: 30px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}

.auth__mark {
  font-size: 26px;
  color: var(--gold);
  text-align: center;
  margin-bottom: 6px;
}

.auth__title { font-size: 21px; text-align: center; margin-bottom: 4px; }

.auth__sub { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.auth__foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 20px; }

/* --------------------------------------------------------- menu mobile */

.nav-mobile {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 16px rgba(8,56,44,.07);
}

.nav-mobile__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 4px 10px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  border-top: 2px solid transparent;
  margin-top: -1px;
}

.nav-mobile__icon { font-size: 19px; line-height: 1; }

.nav-mobile__link.is-active { color: var(--pine-700); border-top-color: var(--pine-700); }

/* ------------------------------------------------------------ desktop */

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: row; align-items: center; }
  .toolbar .input { flex: 1; }
  .toolbar__actions > * { flex: none; }
  .form-actions { flex-direction: row; justify-content: flex-end; }
  .page__title { font-size: 28px; }
}

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav-mobile { display: none; }
  .nav-desktop { display: flex; }
  .page { padding: 28px 24px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
