:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --border: #e2e6eb;
  --text: #1a2233;
  --text-muted: #64748b;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8f0fe;

  --secondary: #16a34a;
  --secondary-dark: #0f7a37;
  --secondary-soft: #e7f7ed;

  --success-bg: #e7f7ed;
  --success-text: #0f7a37;
  --error-bg: #fdecec;
  --error-text: #d64545;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 12px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 4px 8px rgba(16, 24, 40, 0.07), 0 14px 28px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; }

.container { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.navbar-brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.navbar-logo { color: var(--primary); }
.navbar-links { display: flex; gap: 4px; flex-wrap: wrap; overflow-x: auto; }
.navbar-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.navbar-links a:hover { color: var(--text); background: var(--bg); }
.navbar-links a.nav-active { color: var(--primary-dark); background: var(--primary-soft); }
.navbar-user { display: flex; align-items: center; gap: 14px; font-size: 14px; flex-wrap: wrap; }
.navbar-name { color: var(--text-muted); }
.credits-pill {
  background: var(--secondary-soft);
  color: var(--secondary-dark);
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.btn-link { color: var(--text-muted); text-decoration: none; font-size: 14px; }
.btn-link:hover { color: var(--error-text); }

/* Page header */
.page-header { margin-bottom: 28px; }
.page-header h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.02em; }
.muted { color: var(--text-muted); font-size: 14px; margin: 0; }
.section-title { font-size: 18px; margin: 36px 0 14px; letter-spacing: -0.01em; }

/* Auth */
.auth-card {
  max-width: 380px;
  width: 100%;
  margin: 72px auto;
  background: var(--surface);
  padding: 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.auth-card h1 { margin-top: 0; font-size: 22px; letter-spacing: -0.02em; }
.auth-footer { margin-top: 18px; font-size: 14px; color: var(--text-muted); }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }

form label { display: block; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--text); }
form input, form textarea, form select {
  width: 100%;
  padding: 11px 12px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
form input:focus, form textarea:focus, form select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--surface);
}
.inline-form { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 160px; }

.btn-primary {
  margin-top: 22px;
  display: inline-block;
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }
.btn-secondary {
  background: var(--secondary);
}
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-sm { width: auto; margin-top: 0; padding: 9px 18px; font-size: 13.5px; }
.inline-form .btn-primary { width: auto; margin-top: 0; padding: 11px 20px; }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* Dashboard stat cards */
.cards-row { display: flex; gap: 16px; margin: 0 0 8px; flex-wrap: wrap; }
.stat-card {
  background: var(--surface);
  padding: 22px;
  border-radius: var(--radius);
  flex: 1;
  min-width: 200px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-icon { font-size: 20px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--primary-dark); }
.stat-card-action { justify-content: space-between; }

/* Consulta cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 12px;
}
.consulta-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  padding-top: 30px;
  box-shadow: var(--shadow);
  transition: box-shadow .18s, transform .18s;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.consulta-card:not(.consulta-card-disabled):hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.consulta-card-disabled { opacity: 0.6; }
.card-ribbon {
  position: absolute;
  top: 14px;
  right: -34px;
  transform: rotate(40deg);
  background: var(--secondary);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 40px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.consulta-card-icon {
  font-size: 26px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  border-radius: 12px;
  margin-bottom: 14px;
}
.consulta-card h3 { margin: 0 0 8px; font-size: 16px; letter-spacing: -0.01em; }
.consulta-card-desc { color: var(--text-muted); font-size: 13.5px; line-height: 1.5; margin: 0; }
.consulta-card-campos {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.consulta-card-campos li {
  font-size: 12.5px;
  color: var(--text);
  padding-left: 16px;
  position: relative;
  line-height: 1.4;
}
.consulta-card-campos li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--secondary);
  font-weight: 700;
  font-size: 11px;
}
.consulta-card-actions { margin-top: 18px; }
.consulta-card-actions .btn-primary { margin-top: 0; width: 100%; }
.consulta-card-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}
.status-tag { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-weight: 600; }
.status-dot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }
.status-dot-ok { background: var(--secondary); }
.status-dot-off { background: #c7ccd4; }
.consulta-card-price { text-align: right; font-weight: 700; color: var(--text); }
.price-label { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }

.chip {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-muted { background: var(--border); color: var(--text-muted); }

/* Table */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13.5px; }
.table th { background: var(--bg); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }
.table-row-link { cursor: pointer; }

/* Detail page */
.detalhe-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.back-link { display: inline-block; color: var(--text-muted); text-decoration: none; font-size: 13px; margin-bottom: 10px; }
.back-link:hover { color: var(--primary); }
.detalhe-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.detalhe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.detalhe-card h3 { margin: 0 0 14px; font-size: 15px; }
.detalhe-list { display: grid; grid-template-columns: 1fr 1fr; row-gap: 10px; column-gap: 8px; margin: 0; }
.detalhe-list dt { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.detalhe-list dd { margin: 2px 0 0; font-size: 14px; word-break: break-word; }
.restricoes-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.restricoes-list li { padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.restricao-ok { background: var(--success-bg); color: var(--success-text); }
.restricao-alerta { background: var(--error-bg); color: var(--error-text); font-weight: 600; }

/* Admin */
.admin-form-card { margin-bottom: 32px; }
.admin-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.admin-form-actions { display: flex; align-items: center; gap: 16px; margin-top: 18px; flex-wrap: wrap; }
.admin-form-actions .btn-primary { margin-top: 0; }
.admin-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.admin-checkbox input { width: auto; margin: 0; }
.admin-card-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.admin-inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.admin-inline-form button {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.admin-inline-form button:hover { color: var(--primary); }
.btn-link-danger:hover { color: var(--error-text) !important; }
.chip-ativo { background: var(--success-bg); color: var(--success-text); }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-sucesso { background: var(--success-bg); color: var(--success-text); }
.badge-erro { background: var(--error-bg); color: var(--error-text); }
.badge-pendente { background: #fff4e0; color: #b26a00; }
.badge-em_atendimento { background: var(--primary-soft); color: var(--primary-dark); }

.result-box {
  background: #14161f;
  color: #d8f0d8;
  padding: 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 12.5px;
  max-height: 420px;
  border: 1px solid var(--border);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  padding: 16px;
}
.modal-overlay.modal-open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-hover);
}
.modal-box h3 { margin: 0 0 4px; font-size: 18px; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* Footer */
.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.footer a { color: var(--text-muted); text-decoration: none; }
.footer a:hover { color: var(--primary); text-decoration: underline; }
.footer span { margin: 0 8px; }

/* Legal pages */
.legal-page h1 { margin-bottom: 4px; }
.legal-page h2 { margin-top: 28px; font-size: 17px; }
.legal-page p, .legal-page li { color: var(--text-muted); line-height: 1.6; }

/* Cadastro / aprovação */
.doc-link { display: inline-block; margin-top: 4px; }
.logo-preview { max-height: 48px; margin-top: 8px; }
.chip-pendente { background: #fff4e0; color: #b06a00; }
.chip-rejeitado { background: var(--error-bg); color: var(--error-text); }
.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 12px 0;
}
.checkbox-line input { width: auto; margin-top: 2px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin: -6px 0 12px; }
.documentos-upload-list { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.documentos-upload-list label { margin-bottom: 2px; }
.documentos-lista { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.documentos-lista li a { display: inline-flex; align-items: center; gap: 6px; }

/* Nav badge (não lidas) */
.nav-badge {
  display: inline-block;
  background: var(--error-text);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Chat */
.chat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg { display: flex; }
.chat-msg-theirs { justify-content: flex-start; }
.chat-msg-mine { justify-content: flex-end; }
.chat-msg-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--bg);
}
.chat-msg-mine .chat-msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-theirs .chat-msg-bubble { border-bottom-left-radius: 4px; }
.chat-msg-text { margin: 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.chat-msg-meta { display: block; margin-top: 4px; font-size: 11px; opacity: 0.7; }
.chat-form {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.chat-form input {
  flex: 1;
  margin-top: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
}
.chat-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chat-form .btn-primary { margin-top: 0; width: auto; padding: 12px 22px; }

/* ---------------------------------------------------------------- */
/* Responsivo: tablet (<=900px) e celular (<=560px)                 */
/* ---------------------------------------------------------------- */
@media (max-width: 900px) {
  .container { padding: 24px 18px 48px; }
  .navbar { padding: 12px 18px; }
  .navbar-links { gap: 2px; }
  .detalhe-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 560px) {
  .container { padding: 18px 14px 40px; }
  .navbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }
  .navbar-brand { justify-content: center; }
  .navbar-links { justify-content: center; }
  .navbar-user { justify-content: center; }
  .page-header h1 { font-size: 21px; }
  .cards-grid { grid-template-columns: 1fr; }
  .cards-row { flex-direction: column; }
  .stat-card { min-width: 0; }
  .admin-form-row { grid-template-columns: 1fr; }
  .detalhe-list { grid-template-columns: 1fr; }
  .auth-card { margin: 32px auto; padding: 26px 20px; }
  .modal-box { padding: 22px; }
  .admin-card-actions { font-size: 12.5px; }
  .chat-box { height: 62vh; padding: 14px; }
  .chat-msg-bubble { max-width: 86%; }
  .footer { padding: 20px 14px; font-size: 12px; }
}
