:root {
  --black: #050505;
  --panel: #111111;
  --line: #2c2c2c;
  --text: #f8f8f8;
  --muted: #b8b8b8;
  --paper: #f5f6f8;
  --ink: #161616;
  --accent: #009abb;
  --green: #21a67a;
  --red: #d84c4c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--black);
  color: var(--text);
  font-family: "Poppins", Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 24px;
  scroll-margin-top: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0 28px;
}

.brand-logo {
  width: min(360px, 52vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 38px rgba(0, 154, 187, 0.24));
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  font-weight: 900;
}

.reg-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 10px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.reg-badge:hover {
  border-color: var(--accent);
  color: #fff;
}

.main-flow {
  display: grid;
  gap: 20px;
}

.analysis-panel,
.history-section {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.section-heading {
  margin-bottom: 26px;
}

.section-heading h2,
.history-section h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.2rem);
  font-weight: 900;
}

.analysis-form {
  display: grid;
  gap: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: grid;
  gap: 12px;
  min-height: 142px;
  padding: 18px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: #fff;
}

.field-wide {
  min-height: 132px;
}

.field span,
.metric-card span,
.status-card span {
  color: #303030;
  font-size: 1.05rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  border: 0;
  outline: 0;
  color: #060606;
  background: transparent;
  font-size: clamp(1.28rem, 3vw, 2rem);
  font-weight: 900;
}

.field input[readonly] {
  color: #555;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 52px;
  border-radius: 8px;
  border: 0;
  padding: 0 18px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.analysis-submit {
  font-size: 1.12rem;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  border: 1px solid #d0d0d0;
  background: #fff;
  color: #111;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
}

.alert {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #fff4e8;
  color: #7a3600;
  font-weight: 700;
}

.alert--success {
  background: #e8f8f2;
  color: #145c3e;
}

.alert--info {
  background: #e8f4fb;
  color: #0a4a6b;
}

.results,
.expected-section {
  margin-top: 28px;
}

.results h3,
.expected-section h3 {
  font-size: 1.45rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.metric-card,
.status-card {
  display: grid;
  gap: 20px;
  min-height: 142px;
  padding: 18px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: #fff;
}

.metric-card strong,
.status-card strong {
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.status-card {
  margin-top: 18px;
}

.status-card.conforme {
  border-color: rgba(33, 166, 122, 0.7);
}

.status-card.nao-conforme {
  border-color: rgba(216, 76, 76, 0.75);
}

.expected-box {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #d5d5d5;
}

.expected-box dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}

.expected-box dt {
  color: #555;
  font-size: 0.9rem;
  font-weight: 800;
}

.expected-box dd {
  margin: 2px 0 0;
  font-weight: 600;
}

.expected-box strong {
  font-weight: 800;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.two-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.volume-panel {
  border: 2px solid rgba(255, 106, 42, 0.26);
}

.compact-results {
  margin-top: 22px;
}

.history-section {
  margin-top: 20px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #e8e8e8;
  text-align: left;
  vertical-align: top;
}

th {
  background: #101010;
  color: #fff;
  font-size: 0.82rem;
}

td {
  color: #222;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .history-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .reg-badge {
    white-space: normal;
  }

  .field-grid,
  .result-grid,
  .action-row,
  .two-actions {
    grid-template-columns: 1fr;
  }

  .analysis-panel,
  .history-section {
    padding: 18px;
  }
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .topbar,
  .analysis-form,
  .action-row,
  .history-actions {
    display: none;
  }

  .app-shell {
    padding: 0;
  }

  .analysis-panel,
  .history-section {
    box-shadow: none;
    border-radius: 0;
  }
}

/* ===== TELA DE LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 24px;
  position: fixed;
  inset: 0;
  z-index: 999;
  overflow-y: auto;
}

.login-screen[hidden] {
  display: none !important;
}

.login-card {
  background: var(--black);
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

.login-card h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
  text-align: center;
  color: var(--text);
}

.login-card .brand-logo {
  width: min(280px, 80%);
  margin: 0 auto;
  display: block;
}

.login-input {
  width: 100%;
  min-height: 52px;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 1rem;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

.login-input:focus {
  border-color: var(--accent);
}

/* ===== TOGGLE TIPO DE LOGIN ===== */
.login-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid #3a3a3a;
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn--active {
  background: var(--accent);
  color: #fff;
}

/* ===== CAMPO DOCUMENTO (CPF/CNPJ) ===== */
.documento-wrap {
  position: relative;
  width: 100%;
}

.documento-wrap .login-input {
  padding-right: 70px;
}

.documento-tipo {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent);
  pointer-events: none;
  letter-spacing: 0.04em;
}

/* Link discreto abaixo dos botões */
.login-signup-link {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Botão que parece link */
.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button:hover {
  color: #fff;
}

/* ===== TELA DE CONFIRMAÇÃO DE E-MAIL ===== */
.confirm-icon {
  display: flex;
  justify-content: center;
  color: var(--accent);
  margin: 4px 0;
}

.confirm-text {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.confirm-text strong {
  color: var(--text);
  font-weight: 700;
  word-break: break-all;
}

#editEmailSection {
  display: grid;
  gap: 10px;
  width: 100%;
}

.confirm-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.confirm-links-divider {
  color: var(--muted);
  font-size: 0.85rem;
}