/* smartctrl - identidade visual (família SmarTicket): cabeçalho e fundo escuros, conteúdo e tabelas claros.
   Sem estilos nem scripts embutidos nos templates (a CSP só aceita ficheiros de /static).
   Contrastes de texto verificados com a fórmula WCAG (ver handoff do B4b). */

@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-latin-wght.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk-latin-wght.woff2") format("woff2");
  font-weight: 300 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #070b12; --bar: #0b1524; --panel: #0f2136;
  --on-dark: #f8fafc; --on-dark-soft: #cbd5e1;
  --accent: #7cf03a; --accent-deep: #113b1a;       /* verde de acento e o texto escuro que vai sobre ele */
  --field-border: #7b8ba1;                          /* contorno dos campos: >= 3:1 sobre branco (WCAG 1.4.11) */
  --ink: #142033; --muted: #475569; --line: #dbe4ef; --soft: #eef6f0; --card: #ffffff;
  --link: #17692a;                                  /* verde escuro: o #39b54a não tem contraste de texto sobre branco */
  --accent-light: #39b54a;                          /* só decorativo (traço, borda), nunca texto */
  --danger: #b42318; --danger-bg: #fee4e2; --warn: #92400e; --warn-bg: #fef3c7;
  --ok-bg: #dcfce7; --off: #475569; --off-bg: #e2e8f0;
  --radius-card: 20px; --radius-pill: 999px; --touch: 44px;
  --font-text: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: "Space Grotesk", "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--on-dark); font: 400 1rem/1.55 var(--font-text); }
a { color: var(--link); }
h1, h2, h3, .brand { font-family: var(--font-title); letter-spacing: -.01em; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 .75rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card :focus-visible, .login-card :focus-visible { outline-color: var(--link); }

/* ---- cabeçalho e menu ---- */
.site-header { background: var(--bar); border-bottom: 1px solid var(--panel); }
.bar { max-width: 72rem; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { color: var(--on-dark); text-decoration: none; font-weight: 700; font-size: 1.35rem; min-height: var(--touch); display: inline-flex; align-items: center; }
.brand::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; background: var(--accent); margin-right: .55rem; }
.user { display: flex; align-items: center; gap: .75rem; color: var(--on-dark-soft); font-size: .9rem; }
.menu { max-width: 72rem; margin: 0 auto; padding: 0 1rem .6rem; display: flex; gap: .4rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.menu a { flex: none; display: inline-flex; align-items: center; min-height: var(--touch); padding: 0 1rem; border-radius: var(--radius-pill); color: var(--on-dark-soft); text-decoration: none; font-weight: 600; border: 1px solid transparent; }
.menu a:hover { color: var(--on-dark); border-color: var(--panel); }
.menu a[aria-current="page"] { background: var(--accent); color: var(--accent-deep); }

/* ---- conteúdo ---- */
main { max-width: 72rem; margin: 1rem auto 3rem; padding: 0 1rem; }
.card { background: var(--card); color: var(--ink); border-radius: var(--radius-card); padding: 1.25rem; margin-bottom: 1rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.card h1 { margin-top: 0; }
.muted, small { color: var(--muted); }
.lead { color: var(--muted); margin-top: -.5rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.back { margin: 1rem 0 0; }

/* ---- botões em pílula (alvo de toque confortável) ---- */
.btn, button { font: 700 1rem var(--font-text); display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--touch); padding: 0 1.25rem; border-radius: var(--radius-pill); border: 2px solid transparent; cursor: pointer; text-decoration: none; background: var(--accent); color: var(--accent-deep); }
.btn:hover, button:hover { filter: brightness(.95); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--on-dark); border-color: var(--panel); }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-small { min-height: var(--touch); padding: 0 1rem; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1rem 0 0; }
.actions form { margin: 0; }
form.inline { display: inline; }

/* ---- formulários ---- */
label { display: block; margin: 0 0 1rem; font-weight: 600; }
input, select, textarea { display: block; width: 100%; max-width: 30rem; min-height: var(--touch); margin-top: .3rem; padding: .55rem .85rem; font: 400 1rem var(--font-text); color: var(--ink); background: #ffffff; border: 2px solid var(--field-border); border-radius: 14px; }
textarea { min-height: 7rem; max-width: 40rem; }
input:focus, select:focus, textarea:focus { border-color: var(--link); outline: none; }
.check { display: flex; align-items: center; gap: .75rem; min-height: var(--touch); padding: .25rem .75rem; margin: 0 0 .4rem; border: 2px solid var(--field-border); border-radius: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 1.5rem; height: 1.5rem; min-height: 0; margin: 0; flex: none; accent-color: var(--link); }
.check:hover { background: var(--soft); }
.hint { font-weight: 400; color: var(--muted); display: block; font-size: .9rem; margin-top: .25rem; }

/* ---- avisos ---- */
.notice, .error { padding: .75rem 1rem; border-radius: 14px; margin: 0 0 1rem; font-weight: 600; }
.notice { background: var(--warn-bg); color: var(--warn); }
.error { background: var(--danger-bg); color: var(--danger); }
.flash-area .notice { background: var(--ok-bg); color: var(--link); }

/* ---- tabelas claras, com scroll horizontal dentro do cartão ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; background: var(--card); color: var(--ink); min-width: 34rem; }
th, td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--soft); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--soft); }
td .actions { margin: 0; }
td form.inline button, td .btn { min-height: var(--touch); }

/* ---- etiquetas de estado: cor + texto, nunca só cor ---- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .7rem; border-radius: var(--radius-pill); font-size: .85rem; font-weight: 700; white-space: nowrap; }
.badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.badge-on { background: var(--ok-bg); color: var(--link); }
.badge-off { background: var(--off-bg); color: var(--off); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* ---- detalhe (lista de pares) ---- */
dl { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; gap: .5rem 1rem; margin: 0 0 1rem; }
dt { color: var(--muted); font-weight: 600; }
dd { margin: 0; overflow-wrap: anywhere; }

/* ---- página inicial ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { display: block; background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 1rem 1.25rem; color: var(--ink); text-decoration: none; min-height: var(--touch); }
.stat:hover { border-color: var(--accent-light); }
.stat strong { display: block; font: 700 2.2rem/1.1 var(--font-title); }
.stat span { color: var(--muted); font-weight: 600; }

/* ---- auditoria: filtros e paginação ---- */
.filters { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

/* ---- login (escuro) ---- */
body.login main { max-width: 26rem; margin-top: 3rem; }
.login-card { background: var(--panel); color: var(--on-dark); border-radius: var(--radius-card); padding: 1.5rem; border: 1px solid #1c3350; }
.login-card input { max-width: none; }
.login-card .hint { color: var(--on-dark-soft); }
.login-card .error { background: var(--danger-bg); }

@media (max-width: 40rem) {
  /* tabelas em cartões empilhados: nada fica escondido por scroll lateral (os rótulos vêm de data-label) */
  .table-wrap { border: 0; overflow: visible; }
  table { min-width: 0; background: transparent; }
  table, thead, tbody, tr, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  tbody tr { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: .5rem .85rem; margin-bottom: .75rem; }
  tbody tr:hover td { background: transparent; }
  td { border: 0; padding: .35rem 0; }
  td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
  td[data-label=""]::before { display: none; }
  td[colspan] { display: block; }
  td[colspan]::before { display: none; }
  td .actions { width: 100%; }
  td .actions .btn, td .actions button { flex: 1 1 auto; }
  h1 { font-size: 1.4rem; }
  dl { grid-template-columns: 1fr; gap: .1rem; }
  dd { margin-bottom: .6rem; }
  .card { padding: 1rem; border-radius: 18px; }
  .user .who { display: none; }
  .actions .btn, .actions button { flex: 1 1 auto; }
}
