:root {
  /* Identidade visual JP2 Auto (Manual da Marca): preto, amarelo #FFCC00 e vermelho #FE3200 (uso pontual). */
  --ink: #000000;
  --ink-2: #1c1c1c;
  --ink-3: #2e2e2e;
  --brand-yellow: #ffcc00;
  --brand-yellow-dark: #e6b800;
  --brand-red: #fe3200;
  --gray-dark: #292827;
  --gray: #4d4d4d;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #666666;
  --border: #e1e1dd;
  --danger: #d42a00;
  --danger-bg: #fff0eb;
  --ok: #1e7a45;
  --ok-bg: #e9f5ee;
  --warn-bg: #fff7d1;
  --warn-text: #5c4a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.06);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
a { color: var(--ink-3); }
[hidden] { display: none !important; }

.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ---------- botoes e formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 40px; padding: 0 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(255, 204, 0, 0.55); outline-offset: 1px; }
.btn-primary { background: var(--brand-yellow); border-color: var(--brand-yellow); color: var(--ink); }
.btn-primary:hover { background: #ffd633; border-color: var(--brand-yellow-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-small { min-height: 32px; padding: 0 0.7rem; font-size: 0.875rem; }
.btn[disabled] { opacity: 0.6; cursor: wait; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.9rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.field input, .field select {
  min-height: 42px; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text); width: 100%;
}
.field .hint { font-size: 0.8rem; color: var(--muted); }
.field .error { font-size: 0.82rem; color: var(--danger); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.9rem; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.92rem; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); border-left: 4px solid var(--brand-yellow); }

/* ---------- login ---------- */
.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: var(--ink);
}
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); border-top: 4px solid var(--brand-yellow); }
.auth-card .brand { margin-bottom: 1.5rem; }
.auth-card .brand img { width: 72px; height: auto; }
.auth-card .btn { width: 100%; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.2rem; letter-spacing: 0.02em; }
.brand img { width: 44px; height: auto; }
.brand { gap: 0.75rem; }
.brand-sub { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding-left: 0.75rem; border-left: 2px solid var(--brand-yellow); line-height: 1.2; }
.sidebar .brand-sub, .topbar .brand-sub { color: #ededed; }
.auth-card .brand-sub { color: var(--gray); }

/* ---------- layout principal ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #ededed; display: flex; flex-direction: column; padding: 1.25rem 0.75rem; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0.25rem 0.5rem 1.5rem; color: #fff; }
.sidebar .brand img { width: 58px; }
.nav { display: flex; flex-direction: column; gap: 0.2rem; }
.nav a { color: #cfcfcf; text-decoration: none; padding: 0.6rem 0.75rem; border-radius: 8px; font-weight: 600; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--ink-2); color: var(--brand-yellow); box-shadow: inset 3px 0 0 var(--brand-yellow); }
.nav .soon { font-size: 0.7rem; background: var(--ink-2); color: #9a9a9a; padding: 0.05rem 0.4rem; border-radius: 99px; margin-left: 0.35rem; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 0.75rem 0.5rem 0; border-top: 1px solid var(--ink-2); font-size: 0.85rem; }
.sidebar-foot .who { color: #fff; font-weight: 700; }
.sidebar-foot .role { color: var(--brand-yellow); margin-bottom: 0.6rem; }
.sidebar-foot .btn { width: 100%; background: transparent; color: #ededed; border-color: var(--ink-3); }
.sidebar-foot .btn:hover { border-color: var(--brand-yellow); color: var(--brand-yellow); }

.topbar { display: none; }
.menu-overlay { display: none; }
.main { padding: 2rem; max-width: 1200px; width: 100%; }
.page-head { border-bottom: 2px solid var(--brand-red); padding-bottom: 0.9rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head p { margin: 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.module-card h3 { font-size: 1rem; }
.module-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 99px; background: #efefec; color: var(--muted); margin-bottom: 0.5rem; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-off { background: #efefec; color: #7a7a7a; }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }

.toolbar { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar input[type='search'] { min-height: 40px; padding: 0 0.75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; min-width: 240px; flex: 1; max-width: 360px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fafaf8; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: 0.82rem; }
td.actions { text-align: right; white-space: nowrap; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
code.small { font-size: 0.8rem; color: var(--muted); }

/* ---------- janela (dialog) ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-head { padding: 1.1rem 1.25rem 0; border-top: 4px solid var(--brand-yellow); border-radius: 14px 14px 0 0; }
.dialog-body { padding: 1rem 1.25rem; }
.dialog-foot { padding: 0 1.25rem 1.25rem; display: flex; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.secret { font: 700 1.35rem/1.2 ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; letter-spacing: 0.05em; background: #fffbe6; border: 1px dashed var(--ink); border-radius: 8px; padding: 0.8rem; text-align: center; margin: 0.75rem 0; user-select: all; }

/* ---------- avisos ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; }
.toast { background: var(--ink); color: #fff; border-left: 4px solid var(--brand-yellow); padding: 0.7rem 1rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
.toast-error { background: var(--ink); border-left-color: var(--brand-red); }

/* ---------- celular ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; }
  .layout.menu-open .sidebar { transform: none; }
  .layout.menu-open .menu-overlay { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 35; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 0.6rem 1rem; position: sticky; top: 0; z-index: 30; border-bottom: 3px solid var(--brand-yellow); }
  .topbar .btn { background: transparent; color: #fff; border-color: var(--ink-3); }
  .topbar .brand img { width: 38px; }
  .main { padding: 1rem; }
  .toasts { left: 1rem; right: 1rem; bottom: auto; top: 4.5rem; }
  .toast { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  th.hide-sm, td.hide-sm { display: none; }
  .toolbar input[type='search'] { min-width: 0; max-width: none; }
}

/* ---------- utilitarios ---------- */
.mb-lg { margin-bottom: 1.25rem; }
.mt { margin-top: 1rem; }
.mt-sm { margin-top: 0.75rem; }
.w-full { width: 100%; }
.muted { margin: 0; color: var(--muted); }
.hint { font-size: 0.85rem; color: var(--muted); }
.form-grid > .alert, .form-grid > .check, .form-grid > .hint { grid-column: 1 / -1; }
