:root {
  --bg: #eef4ff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d9e2ef;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
}

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

html,
body {
  min-height: 100vh;
}

body {
  font-family: Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  margin-bottom: 14px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
  min-height: 84px;
  resize: none;
  overflow: hidden;
}

a {
  color: var(--primary);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #dbeafe 0%, #eff6ff 50%, #e0f2fe 100%);
  padding: 24px;
  gap: 24px;
}

/* ── Topbar flutuante ── */
.login-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 40px;
  background: transparent;
}

.login-logo {
  height: 180px;
  width: auto;
}

.btn-contato {
  padding: 9px 20px;
  border-radius: 8px;
  background: #2563eb;
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-contato:hover {
  background: #1d4ed8;
}

/* ── Wrapper central ── */
.login-wrapper {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: min(100%, 980px);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.18);
}

/* ── Lado imagem ── */
.login-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  padding: 0;
}

.login-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Lado formulário ── */
.login-right {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 36px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
}

.login-card {
  width: 100%;
}

.brand {
  margin-bottom: 24px;
}

.brand strong {
  display: block;
  color: #0f172a;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.brand-sub {
  color: #64748b;
  font-size: 14px;
  margin-top: 4px;
}

.tabs-login {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: #f1f5f9;
}

.tab-btn {
  padding: 9px;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.15s;
}

.tab-btn.active {
  background: #fff;
  color: #1e3a8a;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app .container {
  flex: 1;
}

.container {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo-nome {
  display: block;
  color: #172554;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-usuario-nome {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.header small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.lab-code-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.lab-code-badge {
  display: inline-block;
  padding: 7px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 800;
}

.btn-copy-code {
  padding: 7px 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 16px;
}

.stat h3 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat p {
  margin-top: 8px;
  color: var(--primary);
  font-size: 30px;
  font-weight: 800;
}

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

.grid.lab-view {
  grid-template-columns: 1fr;
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.card h2 {
  margin-bottom: 16px;
  color: #1e3a8a;
  font-size: 18px;
}

.btn-primary,
.btn-secondary,
.btn-aceitar,
.btn-recusar,
.btn-icon,
.btn-link {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 11px 14px;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
  padding: 10px 13px;
}

.full {
  width: 100%;
}

.urgencia-container {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
}

.urgencia-container input {
  width: auto;
  margin: 0;
}

.field-note {
  margin: -4px 0 12px;
  font-size: 12px;
  font-weight: 700;
}

.muted-note {
  color: var(--muted);
  font-weight: 600;
}

.danger {
  color: var(--danger);
}

.dente-cor-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: end;
}

.btn-icon {
  height: 40px;
  margin-bottom: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
}

.escala-cores-box {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  max-height: 118px;
  overflow: auto;
  margin-bottom: 10px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.cor-pill {
  padding: 7px 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.cor-pill.selected {
  border-color: #0f172a;
  background: #0f172a;
  color: #fff;
}

.lista-dentes-selecionados {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.dente-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 12px;
}

.dente-tag button {
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-weight: 800;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.list-header h2 {
  margin-bottom: 0;
}

.list-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.list-controls input,
.list-controls select {
  margin-bottom: 0;
}

.list-controls input {
  width: min(100%, 220px);
}

.list-controls select {
  width: auto;
  padding: 10px 11px;
  font-size: 13px;
}

.ultima-atualizacao {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
  background: #fff;
}

tbody tr:hover {
  background: #f8fbff;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.alerta-urgente {
  display: inline-block;
  margin-top: 5px;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.urgente-row {
  background: #fff7f7;
}

.anexo-link {
  display: inline-block;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
  text-decoration: none;
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 6px;
}

.btn-aceitar,
.btn-recusar {
  padding: 6px 9px;
  color: #fff;
  font-size: 12px;
}

.btn-aceitar {
  background: var(--success);
}

.btn-recusar {
  background: var(--danger);
}

.status-select {
  width: 140px;
  margin: 0;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.st-pendente {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.st-nova,
.st-aceita {
  background: #e0f2fe;
  color: #0369a1;
}

.st-producao {
  background: #e0e7ff;
  color: #4338ca;
}

.st-concluida {
  background: #dcfce7;
  color: #15803d;
}

.st-recusado {
  background: #fee2e2;
  color: #b91c1c;
}

.st-cancelada {
  background: #e2e8f0;
  color: #475569;
}

.btn-link {
  display: block;
  margin-top: 6px;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
}

.danger-link {
  color: var(--danger);
}

.empty-row {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.62);
}

.modal-content {
  width: min(100%, 620px);
  max-height: 90vh;
  overflow: auto;
  border-radius: 12px;
  background: #fff;
  padding: 22px;
  box-shadow: 0 20px 70px rgba(15, 23, 42, 0.28);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h2 {
  color: #1e3a8a;
  font-size: 20px;
}

.modal-info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 14px;
  font-size: 14px;
}

.modal-info-grid > div:nth-child(odd) {
  color: var(--muted);
  font-weight: 800;
}

.obs-box {
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
}

.obs-lab {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

#areaRespostaLab {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.saas-footer {
  padding: 18px 24px;
  border-top: 1px solid rgba(203, 213, 225, 0.75);
  background: #fff;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.footer-on-login {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 10px;
  color: #64748b;
  font-size: 12px;
  background: transparent;
}

.footer-on-login b {
  color: #1e3a8a;
}

.saas-footer span {
  margin: 0 8px;
  color: #93c5fd;
}

/* Responsivo mobile */
@media (max-width: 768px) {
  .login-wrapper {
    flex-direction: column;
    width: 100%;
  }
  .login-hero {
    max-height: 260px;
  }
  .login-right {
    width: 100%;
    padding: 28px 20px;
  }
  .login-topbar {
    padding: 10px 20px;
  }
  .login-logo {
    height: 52px;
  }
}

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

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .container {
    padding: 16px;
  }

  .header,
  .list-header,
  .modal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .list-header input {
    width: 100%;
  }

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

  .dente-cor-row {
    grid-template-columns: 1fr;
  }

  .btn-icon {
    width: 100%;
  }

  .modal-info-grid {
    grid-template-columns: 1fr;
  }
}


.notif-banner {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #1e3a8a;
  color: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  font-size: 14px;
  font-weight: 700;
  animation: slideIn 0.3s ease;
}

.notif-banner button {
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.notif-banner button:hover {
  background: rgba(255,255,255,0.35);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.relatorio-section {
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.relatorio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.relatorio-header h2 {
  color: #1e3a8a;
  font-size: 17px;
  font-weight: 800;
}

.relatorio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.relatorio-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.relatorio-card h3 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.rel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
}

.rel-row:last-child {
  border-bottom: none;
}

.rel-row b {
  color: var(--primary);
  font-size: 16px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  font-size: 13px;
  font-weight: 800;
}
