:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface2: #f0f1f4;
  --border: #dde1e8;
  --border2: #c8cdd7;
  --text: #1a1f2e;
  --text2: #4a5162;
  --text3: #8a8f9e;
  --accent: #2563a8;
  --accent-light: #e8f0fb;
  --green: #1a7a3a;
  --green-bg: #eaf4ee;
  --green-border: #b5d9c2;
  --amber: #7a5c00;
  --amber-bg: #fef9e8;
  --amber-border: #e8d48a;
  --red: #c0392b;
  --red-bg: #fdecea;
  --red-border: #f5b7b1;
  --radius: 5px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

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

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 200;
  box-shadow: var(--shadow);
  gap: 16px;
}
.header-left { display: flex; align-items: center; gap: 20px; flex: 1; min-width: 0; }
.logo { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 600; color: var(--accent); letter-spacing: -0.3px; white-space: nowrap; flex-shrink: 0; }
.logo span { color: var(--text3); font-weight: 400; font-size: 12px; margin-left: 8px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.clock { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text2); background: var(--surface2); padding: 4px 10px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ===== NAV TABS ===== */
.header-nav { display: flex; align-items: center; gap: 6px; }
.nav-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: none;
  color: var(--text2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  position: relative;
  white-space: nowrap;
}
.nav-tab:hover { background: var(--surface2); color: var(--text); }
.nav-tab.active { background: var(--accent); color: #fff; font-weight: 600; border-color: var(--accent); }
.nav-tab-badge {
  background: rgba(255,255,255,0.25);
  color: inherit;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===== PAGE PANELS ===== */
.page-panel { display: none; flex: 1; flex-direction: column; }
.page-panel.active { display: flex; }

/* ============================================================
   ABA 1 — CONSULTA CPF
   ============================================================ */

.main-content {
  flex: 1;
  padding: 32px 24px;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

.search-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.search-module {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.search-module .search-card {
  margin-bottom: 0;
}

/* SEARCH CARD */
.search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.search-card-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.search-card-title svg { color: var(--accent); }
.search-card-subtitle { font-size: 12px; color: var(--text3); margin-bottom: 20px; }

.input-row { display: flex; gap: 10px; align-items: flex-end; }
.field-group { flex: 1; }
label.field-label {
  display: block;
  font-size: 11px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 5px;
}
.cpf-input-wrapper { position: relative; display: flex; align-items: center; }

input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  outline: none;
  letter-spacing: 0.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,168,0.1);
  background: var(--surface);
}

.btn-search {
  background: var(--accent); color: #fff;
  border: none; padding: 9px 22px;
  border-radius: var(--radius); font-weight: 600; font-size: 13px;
  cursor: pointer; display: flex; align-items: center; gap: 7px;
  white-space: nowrap; transition: background 0.15s; height: 38px;
}
.btn-search:hover { background: #1a4e8a; }
.btn-search:disabled { background: var(--text3); cursor: not-allowed; }

.btn-clear {
  background: none; color: var(--text3);
  border: 1px solid var(--border); padding: 9px 14px;
  border-radius: var(--radius); font-weight: 500; font-size: 13px;
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  white-space: nowrap; transition: all 0.15s; height: 38px;
}
.btn-clear:hover { background: var(--surface2); color: var(--text); }

/* STATUS BADGE */
.status-badge {
  display: none; margin-top: 12px;
  padding: 6px 12px; border-radius: var(--radius);
  font-size: 12px; font-weight: 500;
  align-items: center; gap: 7px;
}
.status-badge.show { display: flex; }
.status-badge.success { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.status-badge.loading { background: rgba(37,99,168,0.08); border: 1px solid rgba(37,99,168,0.2); color: var(--accent); }
.status-badge.error   { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red); }
.status-badge.warn    { background: var(--amber-bg); border: 1px solid var(--amber-border); color: var(--amber); }

/* RESULT CARD */
.result-card {
  display: none;
  background: var(--surface);
  border: 1px solid var(--green-border);
  border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow);
  animation: fadeSlideIn 0.25s ease;
}
.result-card.found { border-color: var(--green-border); }
.result-card.not-found { border-color: var(--red-border); }
.result-card.show { display: block; }
.result-card-plate .result-header {
  background: rgba(37,99,168,0.09);
  border-bottom-color: rgba(37,99,168,0.18);
}
.result-card-plate.result-card.not-found .result-header {
  background: var(--red-bg);
  border-bottom-color: var(--red-border);
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-header {
  background: var(--green-bg);
  border-bottom: 1px solid var(--green-border);
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.result-card.not-found .result-header {
  background: var(--red-bg);
  border-bottom-color: var(--red-border);
}
.result-header-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.result-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--green); color: #fff;
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: 'IBM Plex Mono', monospace; flex-shrink: 0;
}
.result-card.not-found .result-avatar { background: var(--red); }
.result-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.plate-result-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
.plate-result-topline { display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; flex-wrap: nowrap; }
.plate-result-topline .result-name { flex: 0 1 auto; min-width: 0; }
.plate-result-topline .result-copy-btn { flex-shrink: 0; }
.result-line { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: nowrap; width: 100%; }
.result-line-name { margin-bottom: 0; }
.result-line-cpf { margin-top: 0; }
.result-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.result-cpf-display {
  font-size: 12px;
  color: var(--text3);
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.result-found-badge {
  background: rgba(26,122,58,0.15); color: var(--green);
  border: 1px solid var(--green-border);
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 5px;
}
.result-found-badge.not-found {
  background: rgba(192,57,43,0.12);
  color: var(--red);
  border-color: var(--red-border);
}
.result-copy-btn {
  width: 22px; height: 22px;
  border: 1px solid var(--border2);
  border-radius: 5px;
  background: #fff;
  color: var(--text2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: 0;
}
.result-copy-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.result-copy-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.result-copy-btn:focus,
.result-copy-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37,99,168,0.15);
}

/* FIELDS GRID */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0; padding: 20px;
}
.result-empty-state {
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(240,241,244,0.55));
}
.field-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.field-item[data-sensitive-field="true"] { position: relative; padding-right: 34px; }
.field-item:last-child { border-right: none; }
.field-item-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text3); margin-bottom: 4px; }
.field-item-value { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-word; }
.field-item-value.mono { font-family: 'IBM Plex Mono', monospace; font-size: 12px; }
.field-item-value.empty { color: var(--text3); font-weight: 400; font-style: italic; }
.field-item-value.sensitive-blur {
  filter: blur(6px);
  cursor: default;
  user-select: none;
  transition: filter 0.18s ease;
}
.field-item-value.sensitive-blur.revealed {
  filter: none;
  user-select: text;
}
.field-item-value.sensitive-blur:focus,
.field-item-value.sensitive-blur:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.sensitive-eye-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-10%);
  color: var(--text3);
  opacity: 0.9;
  pointer-events: auto;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plate-result-actions {
  margin-top: 12px;
}
.plate-cadastro-cta {
  appearance: none;
  border: 1px solid rgba(37,99,168,0.22);
  background: rgba(37,99,168,0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.plate-cadastro-cta:hover {
  background: rgba(37,99,168,0.14);
  border-color: rgba(37,99,168,0.32);
}
.plate-cadastro-cta.locked {
  position: relative;
}
.plate-cadastro-cta.locked .plate-cadastro-cta-text {
  filter: blur(1.35px);
}
.plate-cadastro-cta-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.plate-cadastro-cta.locked .plate-cadastro-cta-icon {
  opacity: 0.95;
}

body.modal-open {
  overflow: hidden;
}
.plate-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1200;
}
.plate-modal-overlay.show {
  display: flex;
}
.plate-modal {
  width: min(100%, 520px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(15, 23, 42, 0.08);
  overflow: hidden;
}
.plate-modal-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.plate-modal-kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 4px;
}
.plate-modal-header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: var(--text);
}
.plate-modal-close {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text2);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.plate-modal-body {
  padding: 18px 20px;
  color: var(--text2);
  display: grid;
  gap: 12px;
}
.plate-modal-body p {
  margin: 0;
}
.plate-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.plate-type-btn {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.plate-type-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(37,99,168,0.08);
}
.plate-modal-footer {
  padding: 0 20px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.plate-modal-btn {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
}
.plate-modal-btn.ghost {
  background: #fff;
  border-color: var(--border);
  color: var(--text2);
}
.plate-modal-btn.primary {
  background: var(--accent);
  color: #fff;
}
.plate-modal-btn.danger {
  background: var(--red);
  color: #fff;
}
.plate-modal-btn:hover {
  transform: translateY(-1px);
}

/* SPINNER */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(37,99,168,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* CPF INPUT */
input.cpf-field {
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 1.5px; font-size: 15px;
}

/* ===== TOAST COPIADO ===== */
#toast-copiado {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1000;
}
#toast-copiado.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1080px) {
  .search-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 20px 14px;
  }

  .search-card,
  .result-card {
    border-radius: 10px;
  }
  .plate-type-grid {
    grid-template-columns: 1fr;
  }
  .plate-modal-footer {
    flex-direction: column;
  }
  .plate-modal-btn {
    width: 100%;
  }
}
