/* =================================================================
   WYARP SISTEMAS · Design System
   Editorial corporate aesthetic — azul-petróleo + laranja queimado
   ================================================================= */

:root {
  /* Paleta */
  --ink-900: #0a1820;
  --ink-800: #0f2b3d;
  --ink-700: #163a52;
  --ink-600: #1c5d7a;
  --ink-500: #2b7a9b;
  --ink-300: #5fa8c4;
  --ink-200: #a4c7d6;
  --ink-100: #d8e5ec;
  --ink-050: #eef3f7;

  --paper: #f6f1e8;
  --paper-deep: #ede5d4;
  --paper-warm: #fbf7ef;

  --accent: #e87722;
  --accent-deep: #c25e10;
  --accent-soft: #ffe6cf;

  --success: #1c7a5d;
  --danger: #c0392b;
  --warning: #b8860b;

  --line: rgba(15, 43, 61, 0.12);
  --line-soft: rgba(15, 43, 61, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 43, 61, 0.06), 0 2px 8px rgba(15, 43, 61, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 43, 61, 0.08), 0 12px 32px rgba(15, 43, 61, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 43, 61, 0.12), 0 30px 60px -20px rgba(15, 43, 61, 0.18);

  /* Tipografia */
  --font-display: 'Fraunces', 'Times New Roman', serif;
  --font-body: 'Geist', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', monospace;

  /* Geometria */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Textura papel global */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(232, 119, 34, 0.04), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(28, 93, 122, 0.05), transparent 50%);
  z-index: 0;
}

.hide { display: none !important; }

/* =================================================================
   AUTH / LOGIN
   ================================================================= */
.auth-body {
  min-height: 100vh;
  background: var(--paper);
  display: flex;
  align-items: stretch;
}

.auth-canvas {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  width: 100%;
  min-height: 100vh;
}

.auth-brand {
  position: relative;
  background: linear-gradient(135deg, var(--ink-900) 0%, var(--ink-800) 60%, var(--ink-700) 100%);
  color: var(--paper-warm);
  padding: 3rem 3.5rem;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.auth-brand-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 50%, black 30%, transparent 80%);
}

.auth-brand-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,119,34,0.18), transparent 60%);
  top: -150px;
  right: -150px;
  filter: blur(20px);
}

.auth-brand-inner {
  position: relative;
  z-index: 2;
  max-width: 480px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 4rem;
}

.brand-mark-svg {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.brand-mark-svg.sm {
  width: 32px;
  height: 32px;
}

.brand-mark-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 0.3rem;
}

.auth-headline {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin-bottom: 1.5rem;
}

.auth-headline em {
  font-style: italic;
  font-weight: 500;
  color: var(--ink-300);
  position: relative;
}

.auth-headline em::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 8px;
  background: var(--accent);
  opacity: 0.4;
  z-index: -1;
}

.auth-tagline {
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(246, 241, 232, 0.7);
  margin-bottom: 2.5rem;
  max-width: 420px;
}

.auth-features {
  list-style: none;
  margin-bottom: 3rem;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: rgba(246, 241, 232, 0.85);
}

.auth-features .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(232, 119, 34, 0.6);
}

.auth-footnote {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(246, 241, 232, 0.4);
  text-transform: uppercase;
  display: flex;
  gap: 0.5rem;
}

.dot-sep { opacity: 0.5; }

/* Formulário */
.auth-form-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: var(--paper);
  position: relative;
}

.auth-form-card {
  width: 100%;
  max-width: 420px;
}

.auth-eyebrow,
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--accent-deep);
  text-transform: lowercase;
  display: block;
  margin-bottom: 0.8rem;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin-bottom: 0.5rem;
}

.auth-desc {
  color: var(--ink-600);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-700);
}

.field input,
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-warm);
  color: var(--ink-900);
  transition: 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink-600);
  background: white;
  box-shadow: 0 0 0 4px rgba(28, 93, 122, 0.12);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-700);
  cursor: pointer;
}

.checkbox-line input { accent-color: var(--ink-600); width: 16px; height: 16px; }

.btn-solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--ink-900);
  color: var(--paper-warm);
  padding: 0.95rem 1.6rem;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: 0.18s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn-solid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, var(--accent));
  opacity: 0;
  transition: 0.25s;
}

.btn-solid:hover:not(:disabled) {
  background: var(--ink-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-solid:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-solid > * { position: relative; z-index: 1; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--ink-800);
  border: 1.5px solid var(--line);
  padding: 0.7rem 1.2rem;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.18s;
}

.btn-ghost:hover {
  background: var(--ink-050);
  border-color: var(--ink-300);
}

.auth-error {
  background: #fdecea;
  color: var(--danger);
  padding: 0.7rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  border-left: 3px solid var(--danger);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 2rem 0 1rem;
  color: var(--ink-600);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-divider span { padding: 0 0.8rem; }

.auth-demo {
  background: var(--paper-deep);
  border-radius: var(--r-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-700);
  border: 1px dashed var(--line);
}

.auth-demo code {
  background: transparent;
  display: block;
}

/* =================================================================
   APP / TOPBAR
   ================================================================= */
.app-body {
  min-height: 100vh;
  background: var(--paper);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink-900);
}

.topbar-brand span {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.topbar-brand span strong {
  font-weight: 700;
  color: var(--ink-800);
}

.topbar-link {
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-700);
  padding: 0.5rem 1rem;
  border-radius: var(--r-sm);
  transition: 0.18s;
}

.topbar-link:hover { background: var(--ink-050); color: var(--ink-900); }
.topbar-link.active { background: var(--ink-900); color: var(--paper-warm); }

.topbar-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

/* =================================================================
   APP MAIN
   ================================================================= */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
  position: relative;
  z-index: 1;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: var(--ink-900);
}

.page-sub {
  margin-top: 0.7rem;
  color: var(--ink-700);
  font-size: 1rem;
  max-width: 600px;
}

.page-head-meta { display: flex; gap: 0.5rem; }

.meta-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  padding: 0.6rem 1rem;
  border-radius: var(--r-md);
}

.meta-pill-key {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-700);
}

.meta-pill-val {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-900);
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(28, 122, 93, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(28, 122, 93, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(28, 122, 93, 0); }
  100% { box-shadow: 0 0 0 0 rgba(28, 122, 93, 0); }
}

.page-head-actions { display: flex; gap: 0.6rem; }

/* =================================================================
   PROGRESS BAR (questionário)
   ================================================================= */
.progress-wrap { margin-bottom: 2.5rem; }

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--ink-100);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ink-800), var(--accent));
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-700);
}

/* =================================================================
   QUESTION CARD
   ================================================================= */
.q-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  animation: cardIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.q-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 60px;
  height: 4px;
  background: var(--accent);
}

.q-step {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--accent-deep);
  text-transform: uppercase;
  margin-bottom: 1rem;
  display: block;
}

.q-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink-900);
  margin-bottom: 0.8rem;
  line-height: 1.2;
}

.q-desc {
  color: var(--ink-700);
  font-size: 0.95rem;
  margin-bottom: 1.8rem;
  border-left: 3px solid var(--ink-300);
  padding-left: 1rem;
  font-style: italic;
}

.q-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.q-flag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ink-050);
  color: var(--ink-700);
  padding: 0.3rem 0.7rem;
  border-radius: 40px;
  border: 1px solid var(--line);
}

.q-input,
.q-select,
.q-textarea {
  width: 100%;
  padding: 1rem 1.2rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 1rem;
  background: white;
  color: var(--ink-900);
  transition: 0.18s;
}

.q-input:focus,
.q-select:focus,
.q-textarea:focus {
  outline: none;
  border-color: var(--ink-600);
  box-shadow: 0 0 0 4px rgba(28, 93, 122, 0.1);
}

.q-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.q-option {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1.1rem;
  background: white;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: 0.18s;
  font-size: 0.95rem;
}

.q-option:hover {
  border-color: var(--ink-300);
  background: var(--paper-warm);
  transform: translateX(2px);
}

.q-option input {
  accent-color: var(--ink-800);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.q-option.selected {
  border-color: var(--ink-800);
  background: var(--ink-050);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Departamentos */
.dept-custom-area {
  margin-top: 1.2rem;
  padding: 1.2rem;
  background: var(--paper-deep);
  border-radius: var(--r-md);
  border: 1px dashed var(--line);
}

.dept-custom-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-700);
  margin-bottom: 0.7rem;
}

.dept-inline {
  display: flex;
  gap: 0.5rem;
}

.dept-inline input { flex: 1; }

.dept-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.dept-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--ink-800);
  color: var(--paper-warm);
  padding: 0.35rem 0.4rem 0.35rem 0.85rem;
  border-radius: 40px;
  font-size: 0.8rem;
  font-weight: 500;
}

.dept-tag button {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
}

.dept-tag button:hover { background: var(--accent); }

/* Navegação do questionário */
.q-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.q-nav .right-side {
  display: flex;
  gap: 0.6rem;
  margin-left: auto;
}

/* =================================================================
   RESUMO / DIAGNÓSTICO
   ================================================================= */
.diag-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.diag-hero {
  background: linear-gradient(135deg, var(--ink-900), var(--ink-700));
  color: var(--paper-warm);
  border-radius: var(--r-xl);
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.diag-hero::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,119,34,0.25), transparent 70%);
  top: -100px;
  right: -100px;
}

.diag-hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: block;
  position: relative;
}

.diag-hero h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
  position: relative;
  z-index: 1;
}

.diag-hero h2 em {
  font-style: italic;
  color: var(--ink-300);
}

.diag-hero-meta {
  display: flex;
  gap: 2rem;
  margin-top: 2rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.diag-hero-meta div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.diag-hero-meta dt {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(246, 241, 232, 0.5);
}

.diag-hero-meta dd { font-size: 1rem; font-weight: 500; }

.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.diag-cell {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.3rem 1.4rem;
  transition: 0.2s;
}

.diag-cell:hover { box-shadow: var(--shadow-sm); border-color: var(--ink-200); }

.diag-cell dt {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-700);
  margin-bottom: 0.3rem;
}

.diag-cell dd {
  font-size: 1rem;
  color: var(--ink-900);
  font-weight: 500;
}

.diag-flags-section {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 2rem;
}

.diag-flags-section h3,
.diag-recs-section h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: 1.2rem;
  color: var(--ink-900);
}

.diag-flags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.diag-flag {
  background: var(--ink-050);
  border: 1px solid var(--line);
  padding: 0.5rem 0.9rem;
  border-radius: 40px;
  font-size: 0.85rem;
  color: var(--ink-800);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.diag-flag.critical {
  background: #fef3e3;
  border-color: var(--accent);
  color: var(--accent-deep);
}

.diag-recs-section {
  background: linear-gradient(135deg, var(--paper-deep), var(--paper-warm));
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 2rem;
}

.diag-rec {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.diag-rec:last-child { border-bottom: none; }

.diag-rec-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 300;
  color: var(--accent);
  font-style: italic;
  line-height: 1;
  flex-shrink: 0;
  min-width: 50px;
}

.diag-rec-body { font-size: 0.95rem; color: var(--ink-800); line-height: 1.6; }

/* Notas */
.notes-section {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 2rem;
}

.notes-section h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--ink-900);
}

.notes-section .field-label { margin-bottom: 0.8rem; display: block; color: var(--ink-700); }

.notes-section textarea {
  width: 100%;
  padding: 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: white;
  color: var(--ink-900);
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.notes-section textarea:focus {
  outline: none;
  border-color: var(--ink-600);
  box-shadow: 0 0 0 4px rgba(28, 93, 122, 0.1);
}

.notes-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--success);
  color: white;
  border: none;
  padding: 0.7rem 1.2rem;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.18s;
}

.btn-success:hover { background: #0f5e46; transform: translateY(-1px); }

.diag-actions {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* =================================================================
   DASHBOARD
   ================================================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: 0.2s;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  height: 3px;
  width: 30px;
  background: var(--ink-300);
}

.kpi-card.kpi-primary { background: linear-gradient(135deg, var(--ink-900), var(--ink-700)); color: var(--paper-warm); }
.kpi-card.kpi-primary::before { background: var(--accent); width: 60px; }
.kpi-card.kpi-primary .kpi-label { color: rgba(246, 241, 232, 0.6); }
.kpi-card.kpi-primary .kpi-delta { color: rgba(246, 241, 232, 0.5); }

.kpi-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-700);
  display: block;
  margin-bottom: 0.5rem;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  display: block;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.kpi-delta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-700);
  letter-spacing: 0.05em;
}

.filters {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--paper-warm);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 0 1rem;
  flex: 1;
  min-width: 250px;
  transition: 0.18s;
}

.search-field svg { color: var(--ink-700); flex-shrink: 0; }

.search-field input {
  border: none;
  background: transparent;
  padding: 0.75rem 0;
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  font-family: var(--font-body);
  color: var(--ink-900);
}

.search-field:focus-within {
  border-color: var(--ink-600);
  background: white;
  box-shadow: 0 0 0 4px rgba(28, 93, 122, 0.1);
}

.filter-select {
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-warm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--ink-900);
  cursor: pointer;
  transition: 0.18s;
}

.filter-select:focus { outline: none; border-color: var(--ink-600); }

.table-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
}

.table-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.table-card-head h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink-900);
}

.table-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-700);
  background: var(--ink-050);
  padding: 0.3rem 0.7rem;
  border-radius: 40px;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table thead th {
  text-align: left;
  padding: 0.9rem 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-700);
  background: var(--paper-deep);
  border-bottom: 1px solid var(--line);
}

.data-table tbody td {
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-800);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: 0.15s;
  cursor: pointer;
}

.data-table tbody tr:hover { background: var(--paper); }

.data-table .empresa-cell {
  font-weight: 600;
  color: var(--ink-900);
  font-family: var(--font-display);
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 40px;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tag-positive { background: #e4f3ed; color: var(--success); }
.tag-warning { background: #fef3e3; color: var(--accent-deep); }
.tag-neutral { background: var(--ink-050); color: var(--ink-700); }

.row-action {
  background: transparent;
  border: none;
  color: var(--ink-700);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--r-sm);
  transition: 0.15s;
}

.row-action:hover { background: var(--ink-050); color: var(--ink-900); }

.table-empty {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--ink-700);
  font-style: italic;
}

/* =================================================================
   MODAL
   ================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 32, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  background: var(--paper);
  border-radius: var(--r-xl);
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.8rem 2rem 1.2rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

.modal-close {
  background: var(--ink-050);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--ink-700);
  line-height: 1;
  transition: 0.15s;
}

.modal-close:hover { background: var(--ink-900); color: white; }

.modal-body { padding: 1.5rem 2rem; overflow-y: auto; flex: 1; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1.2rem 2rem;
  border-top: 1px solid var(--line);
}

/* =================================================================
   RESPONSIVE
   ================================================================= */
@media (max-width: 900px) {
  .auth-canvas { grid-template-columns: 1fr; }
  .auth-brand { padding: 2.5rem 2rem; min-height: auto; }
  .auth-brand-inner { max-width: 100%; }
  .brand-mark { margin-bottom: 2rem; }
  .auth-features { margin-bottom: 1rem; }
  .auth-form-area { padding: 2rem; }
}

/* =================================================================
   USER MENU / TOPBAR · Dropdown do usuário
   ================================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(246, 241, 232, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  padding-top: max(0.9rem, env(safe-area-inset-top));
}

.topbar-burger {
  display: none;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  width: 40px;
  height: 40px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 0;
}
.topbar-burger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink-800);
  border-radius: 2px;
  transition: 0.2s;
}
.topbar-burger.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar-burger.is-open span:nth-child(2) { opacity: 0; }
.topbar-burger.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.topbar-nav {
  display: flex;
  gap: 0.3rem;
  justify-self: center;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: transparent;
  border: 1.5px solid var(--line);
  padding: 0.4rem 0.75rem 0.4rem 0.4rem;
  border-radius: 40px;
  cursor: pointer;
  transition: 0.18s;
  font-family: var(--font-body);
}

.user-trigger:hover { background: var(--ink-050); border-color: var(--ink-300); }

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--ink-800), var(--ink-600));
  color: var(--paper-warm);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}
.user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-900);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-600);
}
.user-chev { color: var(--ink-600); }

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 1.5rem;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  padding: 0.4rem;
  z-index: 60;
  animation: menuIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-menu-head {
  padding: 0.7rem 0.85rem 0.5rem;
}
.user-menu-name { display: block; font-weight: 600; color: var(--ink-900); font-size: 0.9rem; }
.user-menu-email { display: block; font-size: 0.75rem; color: var(--ink-600); font-family: var(--font-mono); margin-top: 0.15rem; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--ink-800);
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.88rem;
  transition: 0.12s;
}
.user-menu-item:hover { background: var(--ink-050); color: var(--ink-900); }
.user-menu-item.is-active { background: var(--ink-050); color: var(--ink-900); font-weight: 500; }
.user-menu-item svg { flex-shrink: 0; color: var(--ink-600); }
.user-menu-item:hover svg { color: var(--accent); }
.user-menu-logout { color: var(--danger); }
.user-menu-logout svg { color: var(--danger); }
.user-menu-logout:hover { background: #fdecea; }

.user-menu-sep {
  height: 1px;
  background: var(--line);
  border: none;
  margin: 0.4rem 0;
}

/* =================================================================
   PROFILE PAGE
   ================================================================= */
.profile-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.profile-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.profile-card-head {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--ink-800), var(--ink-600));
  color: var(--paper-warm);
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(15, 43, 61, 0.15);
}

.profile-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ink-900);
  margin-bottom: 0.2rem;
}

.profile-email {
  color: var(--ink-600);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.profile-card-section h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: 0.4rem;
  color: var(--ink-900);
}
.profile-card-section p {
  color: var(--ink-700);
  font-size: 0.9rem;
}

.auth-success {
  background: #e4f3ed;
  color: var(--success);
  padding: 0.7rem 1rem;
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  border-left: 3px solid var(--success);
}

/* =================================================================
   USERS PAGE
   ================================================================= */
.row-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--ink-700), var(--ink-500));
  color: var(--paper-warm);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-right: 0.6rem;
  vertical-align: middle;
}

.row-action-danger {
  color: var(--danger);
}
.row-action-danger:hover { background: #fdecea; }

/* =================================================================
   PWA INSTALL BANNER
   ================================================================= */
.pwa-banner {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  background: var(--ink-900);
  color: var(--paper-warm);
  padding: 0.85rem 1.2rem;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: calc(100% - 2rem);
  animation: bannerIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255,255,255,0.08);
}
@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.pwa-banner-text { display: flex; flex-direction: column; gap: 0.1rem; }
.pwa-banner-text strong { font-size: 0.9rem; }
.pwa-banner-text span { font-size: 0.75rem; color: rgba(246,241,232,0.6); }
.pwa-banner-actions { display: flex; gap: 0.4rem; }
.pwa-banner-actions .btn-ghost {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
  color: var(--paper-warm);
  font-size: 0.8rem;
  padding: 0.5rem 0.85rem;
}
.pwa-banner-actions .btn-ghost:hover { background: rgba(255,255,255,0.12); }
.pwa-banner-actions .btn-solid {
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  padding: 0.5rem 0.85rem;
}
.pwa-banner-actions .btn-solid:hover { background: var(--accent-deep); }

/* =================================================================
   RESPONSIVE · Mobile-first refinements
   ================================================================= */
@media (max-width: 900px) {
  .auth-canvas { grid-template-columns: 1fr; }
  .auth-brand { padding: 2.5rem 2rem; min-height: auto; }
  .auth-brand-inner { max-width: 100%; }
  .brand-mark { margin-bottom: 2rem; }
  .auth-features { margin-bottom: 1rem; }
  .auth-form-area { padding: 2rem; }

  .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  /* TOPBAR mobile */
  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }
  .topbar-brand span { font-size: 1rem; }
  .topbar-burger {
    display: flex;
    order: -1;
  }
  .topbar-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper-warm);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 0.6rem;
    gap: 0.2rem;
    box-shadow: var(--shadow-md);
  }
  .topbar-nav.is-open { display: flex; }
  .topbar-nav .topbar-link {
    padding: 0.85rem 1rem;
    border-radius: var(--r-sm);
    text-align: left;
  }

  .user-trigger { padding: 0.35rem; border-radius: 50%; border: none; }
  .user-meta, .user-chev { display: none; }
  .user-menu { right: 0.75rem; min-width: 250px; }

  .app-main { padding: 1.5rem 1rem 5rem; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 1rem; margin-bottom: 2rem; }
  .page-head-actions, .page-head-meta { width: 100%; }
  .page-head-actions .btn-solid, .page-head-actions a.btn-solid { width: 100%; justify-content: center; }
  .page-title { font-size: 1.8rem; }

  .q-card { padding: 1.5rem 1.3rem; border-radius: var(--r-lg); }
  .q-title { font-size: 1.3rem; }
  .q-nav { flex-direction: column-reverse; gap: 0.6rem; align-items: stretch; }
  .q-nav > * { width: 100%; justify-content: center; }
  .q-nav .right-side { display: flex; flex-direction: column-reverse; gap: 0.6rem; margin-left: 0; }
  .q-option { padding: 0.85rem 1rem; }

  .diag-hero { padding: 1.6rem 1.3rem; border-radius: var(--r-lg); }
  .diag-hero h2 { font-size: 1.7rem; }
  .diag-hero-meta { gap: 1rem; }
  .diag-flags-section, .diag-recs-section, .notes-section { padding: 1.3rem; border-radius: var(--r-lg); }

  .filters { flex-direction: column; align-items: stretch; }
  .search-field { min-width: auto; width: 100%; }
  .filter-select { width: 100%; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .kpi-card { padding: 1rem; }
  .kpi-value { font-size: 1.7rem; }
  .kpi-label { font-size: 0.6rem; }

  /* Tabela com scroll horizontal suave */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 0.85rem; min-width: 600px; }
  .data-table thead th, .data-table tbody td { padding: 0.7rem 0.9rem; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-panel {
    max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: modalInMobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes modalInMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-head { padding: 1.3rem 1.3rem 1rem; }
  .modal-body { padding: 1rem 1.3rem; }
  .modal-foot { padding: 1rem 1.3rem; flex-direction: column-reverse; gap: 0.5rem; }
  .modal-foot button { width: 100%; justify-content: center; }

  .auth-form-area { padding: 1.5rem 1.2rem; }
  .auth-title { font-size: 1.7rem; }

  .pwa-banner { flex-direction: column; gap: 0.7rem; align-items: stretch; bottom: 0.8rem; }
  .pwa-banner-actions { width: 100%; }
  .pwa-banner-actions button { flex: 1; justify-content: center; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem 1.3rem; }
  .auth-headline { font-size: 2rem; }
  .page-title { font-size: 1.5rem; }
  .q-title { font-size: 1.15rem; }
  .diag-hero h2 { font-size: 1.4rem; }
}

/* Safe area para iPhone com notch */
@supports (padding: env(safe-area-inset-bottom)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* Modo standalone (PWA instalado) */
@media (display-mode: standalone) {
  body { background: var(--paper); }
  /* Esconde elementos de "instalar PWA" quando já está instalado */
  .pwa-banner { display: none !important; }
}

/* Impressão */
@media print {
  body::before, .topbar, .modal-backdrop, .diag-actions, .notes-section .notes-actions, .pwa-banner { display: none !important; }
  .app-main { padding: 0; max-width: 100%; }
  .diag-hero { background: var(--ink-800) !important; -webkit-print-color-adjust: exact; color-adjust: exact; }
}
