/* pwr_dash — UI tokens & layout (light theme) */
:root {
  /* Marca */
  --brand: #0a55ae;            /* azul principal (logo) */
  --brand-700: #07407f;        /* azul escuro para hover/pressed */
  --brand-200: #5596ed;        /* azul claro — accent, focus, links */
  --brand-50:  #eaf2fc;        /* tinta de fundo p/ destaques sutis */

  /* Superfícies */
  --bg:        #ffffff;
  --bg-soft:   #f7f9fc;        /* fundo de página com leve diferenciação */
  --surface:   #ffffff;        /* cards */
  --surface-2: #f3f6fa;        /* superfícies elevadas / hover */

  /* Texto / linhas */
  --text:       #0f1d33;       /* texto principal — quase preto com tom azulado */
  --text-soft:  #3a4a63;       /* texto secundário */
  --text-muted: #6b7888;       /* texto desabilitado / placeholders */
  --neutral:    #b7bec6;       /* cinza da paleta — bordas, divisores */
  --border:     #d9dee5;
  --border-strong: #b7bec6;

  /* Estados */
  --ok:     #1e9d62;
  --danger: #d93b3b;
  --warn:   #c47c00;

  /* Forma */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 29, 51, 0.04), 0 1px 3px rgba(15, 29, 51, 0.06);
  --shadow:    0 4px 16px rgba(10, 85, 174, 0.08), 0 1px 4px rgba(15, 29, 51, 0.06);
  --shadow-lg: 0 18px 40px rgba(10, 85, 174, 0.14);

  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-feature-settings: "ss01", "cv11"; /* leve refinamento se a fonte suportar */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; color: var(--text); margin: 0 0 12px; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.25rem; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
code { font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace; font-size: 0.85em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.inline { display: inline-flex; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: #e9eef5; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(85, 150, 237, 0.4); outline-offset: 2px; }

.btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--brand-700); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b62a2a; color: #fff; }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }

/* ---------- alerts ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert.error {
  background: #fdecec;
  color: #8c2424;
  border-color: #f4c2c2;
}

/* ---------- brand (logo) ---------- */
.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 0;
}
.brand-logo img { display: block; height: 80px; width: auto; }
.brand-logo.sm img { height: 36px; }
.brand-logo.xs img { height: 28px; }

.brand-tag {
  margin: 14px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input,
.field textarea,
.field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 14px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field input::placeholder { color: var(--text-muted); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--brand-200);
  box-shadow: 0 0 0 4px rgba(85, 150, 237, 0.18);
}
.field-row { display: flex; gap: 18px; flex-wrap: wrap; }
.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-soft);
  padding: 4px 0;
}
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.actions { display: flex; gap: 10px; margin-top: 12px; }

/* ---------- login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  min-height: 100vh;
}
.login-shell { width: 100%; padding: 32px; display: flex; justify-content: center; }
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-card .brand { text-align: center; margin-bottom: 28px; display: flex; flex-direction: column; align-items: center; }
.login-card .brand-logo img { height: 96px; }

/* ---------- topbar (azul de marca) ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background-color: #0a55ae;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .brand-logo.xs img { height: 44px; }
.topbar-spacer { flex: 1; }

.crumb { color: rgba(255, 255, 255, 0.72); font-size: 0.9rem; font-weight: 500; }
.crumb a { color: inherit; }
.crumb a:hover { color: #fff; }

/* User chip dentro da topbar azul */
.topbar .user-chip {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 0.88rem;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge.admin { background: rgba(10, 85, 174, 0.12); color: var(--brand); }
.badge.ok    { background: rgba(30, 157, 98, 0.12); color: var(--ok); }
.badge.muted { background: var(--surface-2); color: var(--text-muted); }

/* Badge admin dentro da topbar azul: variação clara */
.topbar .user-chip .badge.admin {
  background: rgba(255, 255, 255, 0.24);
  color: #fff;
}

/* Botões fantasma da topbar: contorno branco translúcido */
.topbar .btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
}
.topbar .btn.ghost:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* ---------- home ---------- */
.home-page { background: var(--bg-soft); min-height: 100vh; }
.home-shell { max-width: 980px; margin: 0 auto; padding: 40px 24px 64px; }
.hero { margin-bottom: 32px; }
.hero h1 { font-size: 2rem; margin: 0 0 8px; }
.hero p { color: var(--text-soft); margin: 0; }

.menu { display: flex; flex-direction: column; gap: 16px; }
.menu-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}
.menu-group > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  list-style: none;
  color: var(--text);
}
.menu-group > summary::-webkit-details-marker { display: none; }
.menu-group > summary::after {
  content: "›";
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1.4rem;
  transition: transform 0.18s ease;
  transform: rotate(90deg);
}
.menu-group:not([open]) > summary::after { transform: rotate(0deg); }
.menu-group .ico {
  font-size: 1.05rem;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
  border-radius: var(--radius-sm);
}
.menu-children {
  margin-top: 14px;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-leaf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
}
.menu-leaf:hover {
  border-color: var(--brand-200);
  background: var(--brand-50);
  color: var(--brand-700);
  text-decoration: none;
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
}
.menu-leaf .leaf-arrow { color: var(--brand-200); font-size: 1.1rem; transition: transform 0.12s ease; }
.menu-leaf:hover .leaf-arrow { transform: translateX(3px); color: var(--brand); }

/* Grupo aninhado: linha guia à esquerda */
.menu-children .menu-group {
  border: 1px dashed var(--border);
  box-shadow: none;
  padding: 14px 18px;
}

.empty {
  padding: 40px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty p { margin: 0 0 6px; color: var(--text-soft); }

/* ---------- admin ---------- */
.admin-page { background: var(--bg-soft); min-height: 100vh; }
.admin-shell { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
  box-shadow: var(--shadow-sm);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
table.data th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}
table.data tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

fieldset.perms {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 8px 0;
}
fieldset.perms legend {
  padding: 0 8px;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
fieldset.perms .check { display: flex; padding: 6px 0; }

.perm-list { list-style: none; padding: 0; margin: 8px 0 0; }
.perm-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 0.92rem; }
.perm-list li:last-child { border-bottom: none; }
.perm-list code { background: var(--brand-50); color: var(--brand-700); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar .brand-logo.xs img { height: 72px; }
  .crumb { display: none; }
  .home-shell, .admin-shell { padding: 24px 16px 48px; }
  .hero h1 { font-size: 1.5rem; }
  .login-card { padding: 32px 24px 24px; }
  .login-card .brand-logo img { height: 72px; }
  .row-actions { flex-wrap: wrap; }
}
