:root {
  color-scheme: dark;
  --bg: #070101;
  --bg-soft: #100404;
  --panel: rgba(21, 5, 6, 0.78);
  --panel-strong: rgba(31, 7, 9, 0.86);
  --card: rgba(12, 3, 4, 0.76);
  --line: rgba(255, 49, 59, 0.18);
  --line-strong: rgba(255, 49, 59, 0.38);
  --text: #f5dfdf;
  --muted: #a97979;
  --red: #ff313b;
  --red-dark: #7d1117;
  --red-soft: rgba(255, 49, 59, 0.12);
  --danger: #ff737a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
  --sidebar-width: 282px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 92% 8%, rgba(132, 15, 22, 0.42), transparent 28rem),
    radial-gradient(circle at 0% 100%, rgba(91, 8, 13, 0.22), transparent 24rem),
    #050000;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.dashboard-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 49, 59, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 49, 59, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, rgba(0, 0, 0, 0.72));
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.download-button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 49, 59, 0.07);
  color: var(--red);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

button:hover,
button:focus,
.download-button:hover,
.download-button:focus {
  border-color: rgba(255, 49, 59, 0.72);
  background: rgba(255, 49, 59, 0.16);
  color: #ffdada;
}

button:active,
.download-button:active {
  transform: translateY(1px);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  margin-bottom: 16px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(4, 0, 1, 0.72);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select {
  margin-top: 8px;
}

textarea {
  min-height: 180px;
  padding: 12px 13px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(169, 121, 121, 0.72);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 49, 59, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 49, 59, 0.12);
  background: rgba(8, 1, 2, 0.92);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-box {
  width: min(100%, 390px);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-box h1 {
  margin: 0 0 22px;
  color: var(--text);
  text-align: center;
  font-size: 1.45rem;
  font-weight: 900;
}

.login-box button {
  width: 100%;
}

.login-links {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

.login-links a {
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 900;
  text-decoration: none;
}

.login-links a:hover,
.login-links a:focus {
  color: #ffdada;
  text-decoration: underline;
}

.login-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  text-align: center;
}

.message {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 115, 122, 0.34);
  border-radius: 10px;
  background: rgba(255, 115, 122, 0.08);
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(13, 3, 4, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 22px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 49, 59, 0.58);
  border-radius: 14px;
  background: rgba(255, 49, 59, 0.12);
  color: var(--red);
  font-weight: 950;
  box-shadow: 0 0 34px rgba(255, 49, 59, 0.16);
}

.brand strong,
.brand small {
  display: block;
  overflow-wrap: anywhere;
}

.brand strong {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 900;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.nav-stack {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 10px;
}

.menu-group {
  border: 0;
  background: transparent;
}

.menu-group summary {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0.22em;
  list-style: none;
  text-transform: uppercase;
}

.menu-group summary::-webkit-details-marker {
  display: none;
}

.menu-links {
  display: grid;
  gap: 8px;
}

.menu-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  text-align: left;
}

.menu-icon {
  width: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: currentColor;
  font-size: 1rem;
}

.menu-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.menu-arrow {
  opacity: 0;
  color: var(--red);
}

.menu-button:hover,
.menu-button:focus {
  border-color: rgba(255, 49, 59, 0.16);
  background: rgba(255, 49, 59, 0.08);
  color: var(--text);
}

.menu-button.is-active {
  border-color: rgba(255, 49, 59, 0.42);
  background: linear-gradient(90deg, rgba(255, 49, 59, 0.22), rgba(255, 49, 59, 0.08));
  color: var(--red);
  box-shadow: inset 0 0 24px rgba(255, 49, 59, 0.08), 0 10px 28px rgba(0, 0, 0, 0.28);
}

.menu-button.is-active .menu-arrow {
  opacity: 1;
}

.logout-form {
  margin-top: auto;
  padding: 16px 10px;
  border-top: 1px solid var(--line);
}

.logout-button {
  width: 100%;
  background: rgba(255, 49, 59, 0.06);
}

.dashboard-main {
  min-width: 0;
}

.dashboard-header {
  min-height: 105px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 32px 24px 40px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(5, 0, 1, 0.72), rgba(23, 4, 6, 0.42));
  backdrop-filter: blur(14px);
}

.dashboard-header h1 {
  margin: 7px 0 0;
  color: var(--text);
  font-size: clamp(1.65rem, 3vw, 2.05rem);
  line-height: 1.05;
  font-weight: 950;
  letter-spacing: -0.03em;
  text-shadow: 0 0 28px rgba(255, 49, 59, 0.25);
}

.dashboard-header h1 span {
  color: var(--red);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.eyebrow b {
  color: rgba(255, 49, 59, 0.72);
  font-weight: 900;
}

#selected-breadcrumb {
  color: var(--red);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.online-badge,
.role-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(255, 49, 59, 0.32);
  border-radius: 999px;
  background: rgba(255, 49, 59, 0.1);
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 850;
}

.online-badge i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 14px rgba(255, 49, 59, 0.9);
}

.role-badge {
  border-color: rgba(255, 49, 59, 0.14);
  background: rgba(0, 0, 0, 0.46);
  color: var(--text);
  text-transform: uppercase;
}

.role-badge b {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-left: -8px;
  border-radius: 999px;
  background: rgba(255, 49, 59, 0.16);
  color: var(--red);
  font-size: 0.76rem;
}

.selected-panel {
  width: min(100% - 64px, 1072px);
  min-height: 290px;
  display: grid;
  align-content: start;
  gap: 24px;
  margin: 40px 0 0 40px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(31, 7, 9, 0.78), rgba(7, 1, 2, 0.82));
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.selected-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}

.selected-panel p {
  margin: 0;
}

#selected-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

#selected-kicker::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--red);
}

.selected-panel h2 {
  margin: 10px 0 0;
  color: var(--red);
  font-size: clamp(2.7rem, 7vw, 4.8rem);
  line-height: 0.95;
  font-weight: 950;
  letter-spacing: -0.06em;
  text-transform: uppercase;
  text-shadow: 0 0 26px rgba(255, 49, 59, 0.55);
  overflow-wrap: anywhere;
}

.selected-description {
  max-width: 320px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 750;
  line-height: 1.45;
  text-transform: none !important;
}

.module-content {
  display: grid;
  gap: 22px;
}

.dashboard-footer {
  width: min(100% - 64px, 1072px);
  margin: 40px 0 18px 40px;
  color: rgba(169, 121, 121, 0.7);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 750;
}

.dashboard-footer strong {
  color: var(--red);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-weight: 850;
}

.muted-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.admin-panel,
.users-panel,
.jobs-panel,
.adv-panel,
.oficio-panel,
.benca-panel,
.cpf-panel,
.zap-panel {
  display: grid;
  gap: 18px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.admin-stats span,
.metric-card,
.admin-card,
.user-card,
.job-card,
.cpf-result-card,
.benca-status-card,
.oficio-form,
.user-form,
.admin-intro {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(5, 0, 1, 0.68);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
}

.admin-stats span {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-stats span::before {
  content: "";
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 49, 59, 0.32);
  border-radius: 12px;
  background: rgba(255, 49, 59, 0.12);
}

.admin-stats strong {
  color: var(--text);
  font-size: 1.2rem;
  letter-spacing: 0;
}

.admin-stats strong[data-type="ok"] {
  color: #46ff7a;
}

.admin-stats strong[data-type="error"] {
  color: var(--red);
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 0;
  border-bottom: 0;
}

.admin-tab {
  min-height: 34px;
  padding: 0 16px;
  border-radius: 10px;
  background: rgba(255, 49, 59, 0.04);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-tab.is-active {
  border-color: rgba(255, 49, 59, 0.68);
  background: rgba(255, 49, 59, 0.12);
  color: var(--red);
  box-shadow: 0 0 28px rgba(255, 49, 59, 0.12);
}

.admin-section {
  display: grid;
  gap: 14px;
}

.admin-section[hidden] {
  display: none !important;
}

.admin-search,
.users-toolbar input,
#jobs-search {
  min-height: 48px;
  margin-bottom: 0;
}

.admin-list,
.users-list,
.cpf-result,
.cpf-field-list,
.cpf-address-list {
  display: grid;
  gap: 10px;
}

.admin-card,
.user-card,
.job-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.admin-card strong,
.admin-card small,
.user-card strong,
.user-card small,
.job-card strong,
.job-card small {
  display: block;
  overflow-wrap: anywhere;
}

.admin-card strong,
.user-card strong,
.job-card strong {
  color: var(--text);
  font-weight: 950;
}

.admin-card small,
.user-card small,
.job-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-card-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.admin-card-actions button,
.admin-card-actions .download-button {
  min-height: 36px;
  padding: 0 12px;
}

.admin-add input {
  margin-bottom: 0;
}

.admin-add button,
.oficio-form button {
  width: max-content;
  padding: 0 18px;
}

.admin-toast,
.zap-result {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.admin-toast[data-type="ok"],
.zap-result[data-type="ok"] {
  color: #ff8b90;
}

.admin-toast[data-type="error"],
.zap-result[data-type="error"] {
  color: var(--danger);
}

.admin-toast[data-type="pending"],
.zap-result[data-type="pending"] {
  color: var(--muted);
}

.admin-intro,
.user-form,
.oficio-form,
.benca-status-card {
  padding: 16px;
}

.admin-intro {
  gap: 6px;
}

.admin-intro strong,
.oficio-form h3,
.cpf-result-card h3 {
  margin: 0;
  color: var(--red);
  font-size: 1rem;
  font-weight: 950;
}

.admin-intro span {
  color: var(--muted);
  font-weight: 800;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 110px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 15px;
}

.metric-card strong {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.metric-card b {
  color: var(--red);
  font-size: 2rem;
  line-height: 1;
  text-shadow: 0 0 22px rgba(255, 49, 59, 0.38);
}

.metric-card span {
  color: #d89a9a;
  font-size: 0.78rem;
  font-weight: 850;
}

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

.form-grid label,
.check-row {
  margin-bottom: 0;
}

.form-grid input,
.oficio-form input,
.oficio-form textarea {
  margin-top: 8px;
  margin-bottom: 0;
}

.check-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(4, 0, 1, 0.72);
  color: var(--red);
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--red);
}

.check-row:has(input:disabled) {
  opacity: 0.62;
}

.user-form-actions,
.zap-actions,
.zap-input-row {
  display: flex;
  gap: 10px;
}

.user-form-actions button,
.zap-actions button {
  width: 100%;
}

.limit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.limit-tags span {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(255, 49, 59, 0.28);
  border-radius: 999px;
  background: rgba(255, 49, 59, 0.09);
  color: #ff989d;
  font-size: 0.74rem;
  font-weight: 900;
}

.zap-status {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 0, 1, 0.68);
  color: var(--muted);
  font-weight: 850;
}

.zap-status strong,
.zap-status span {
  color: var(--red);
}

.zap-qr-wrap {
  width: max-content;
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--red);
  border-radius: 14px;
  background: #ffffff;
}

.zap-qr-wrap img {
  display: block;
  width: min(280px, 100%);
  height: auto;
}

.zap-form {
  display: grid;
  gap: 8px;
}

.zap-form input,
.zap-input-row input {
  margin-bottom: 0;
}

.zap-input-row input {
  flex: 1;
}

.zap-input-row button {
  width: 140px;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
}

.cpf-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.cpf-result-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 15px;
}

.cpf-result-card-wide {
  grid-column: 1 / -1;
}

.cpf-result-card h3 {
  overflow-wrap: anywhere;
}

.cpf-field {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid rgba(255, 49, 59, 0.18);
  border-radius: 10px;
  background: rgba(8, 1, 2, 0.72);
}

.cpf-field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.cpf-field strong,
.cpf-address-item {
  color: var(--text);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.cpf-address-item {
  padding: 10px;
  border: 1px solid rgba(255, 49, 59, 0.18);
  border-radius: 10px;
  background: rgba(8, 1, 2, 0.72);
}

.raw-json {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(5, 0, 1, 0.68);
}

.raw-json summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  color: var(--red);
  cursor: pointer;
  font-weight: 950;
}

.raw-json pre,
.diagnostic-box {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 13px;
  border-top: 1px solid var(--line);
  color: #ff9ea2;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.84rem;
  white-space: pre-wrap;
}

.diagnostic-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(5, 0, 1, 0.68);
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-stack {
    padding: 12px 10px;
  }

  .menu-links {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .logout-form {
    padding-top: 0;
    border-top: 0;
  }

  .dashboard-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px 18px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .selected-panel,
  .dashboard-footer {
    width: calc(100% - 28px);
    margin-left: 14px;
  }

  .selected-panel {
    margin-top: 18px;
    padding: 22px;
  }

  .selected-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .selected-description {
    max-width: none;
  }

  .form-grid,
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .zap-actions,
  .zap-input-row,
  .user-form-actions {
    flex-direction: column;
  }

  .zap-input-row button,
  .admin-add button,
  .oficio-form button,
  .download-button {
    width: 100%;
  }

  .admin-card,
  .admin-card-actions,
  .user-card,
  .job-card {
    align-items: stretch;
    flex-direction: column;
  }
}
