/**
 * RADIX — Painel administrativo (visual alinhado ao app mobile)
 */
:root {
  --radix-green: #1b4332;
  --radix-green-mid: #2d6a4f;
  --radix-green-light: #40916c;
  --radix-bg: #f4f6f5;
  --radix-card: #ffffff;
  --radix-text: #1c2e42;
  --radix-muted: #6b7280;
  --radix-danger: #c62828;
  --radix-warning: #e6c200;
  --sidebar-width: 260px;
  --radius: 12px;
  --shadow: 0 4px 14px rgba(27, 67, 50, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--radix-text);
  background: var(--radix-bg);
  min-height: 100vh;
}

a {
  color: var(--radix-green-mid);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Login */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  overflow-x: hidden;
  background: linear-gradient(160deg, #e8f5e9 0%, var(--radix-bg) 45%, #d8f3dc 100%);
}

.login-page .login-card {
  flex: 0 0 auto;
  margin-top: auto;
  margin-bottom: auto;
}

.login-card {
  width: 100%;
  max-width: min(420px, 100%);
  background: var(--radix-card);
  border-radius: 20px;
  padding: clamp(22px, 4.5vw, 40px) clamp(16px, 4vw, 32px);
  box-shadow: var(--shadow);
  border: 1px solid rgba(27, 67, 50, 0.08);
  overflow-x: hidden;
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-brand h1 {
  margin: 12px 0 4px;
  font-size: 1.75rem;
  letter-spacing: 0.06em;
  color: var(--radix-green);
}

.login-brand p {
  margin: 0;
  color: var(--radix-muted);
  font-size: 0.9rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  max-width: 100%;
  padding: 0 2px;
}

.logo-x {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--radix-green-light), var(--radix-green));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.75rem;
  box-shadow: 0 8px 24px rgba(27, 67, 50, 0.25);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--radix-text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 1rem;
  background: #f3f4f6;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--radix-green-mid);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--radix-green-mid), var(--radix-green));
  color: #fff;
  width: 100%;
  padding: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(27, 67, 50, 0.35);
}

.btn-secondary {
  background: #fff;
  color: var(--radix-green);
  border: 1px solid var(--radix-green-mid);
}

.btn-danger {
  background: var(--radix-danger);
  color: #fff;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: #ffebee;
  color: #b71c1c;
  border: 1px solid #ffcdd2;
}

.alert-success {
  background: #d8f3dc;
  color: #1b4332;
  border: 1px solid #95d5b2;
}

.nav-section + nav + .nav-section {
  margin-top: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.dl-detail {
  margin: 0;
}

.dl-detail dt {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--radix-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 14px;
}

.dl-detail dt:first-child {
  margin-top: 0;
}

.dl-detail dd {
  margin: 4px 0 0;
  font-size: 0.95rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 18px;
}

.form-grid .form-group-full {
  grid-column: 1 / -1;
}

textarea.input-wide {
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font: inherit;
}

.login-hint {
  font-size: 0.8rem;
  color: var(--radix-muted);
  margin: 0 0 14px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.login-hint code {
  word-break: break-all;
  font-size: 0.78em;
  line-height: 1.3;
}

details.login-hint-details {
  margin: 0 0 14px;
  font-size: 0.8rem;
  color: var(--radix-muted);
  line-height: 1.45;
}

details.login-hint-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--radix-green-mid);
  user-select: none;
}

details.login-hint-details[open] summary {
  margin-bottom: 8px;
}

.login-footer-links {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e8ece9;
  text-align: center;
  font-size: 0.88rem;
}

.login-footer-links a {
  display: inline-block;
  margin: 4px 8px;
}

/* Área paciente / laudos */
.paciente-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--radix-bg);
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px 24px;
  overflow-x: hidden;
}

.paciente-header {
  max-width: 720px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.paciente-header h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--radix-green);
}

.paciente-card {
  max-width: 720px;
  margin: 0 auto 16px;
  background: var(--radix-card);
  border-radius: var(--radius);
  border: 1px solid #e8ece9;
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 22px);
  overflow-x: hidden;
}

.laudo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid #eee;
}

.laudo-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.laudo-row:first-of-type {
  padding-top: 0;
}

@media (max-width: 480px) {
  .laudo-row {
    grid-template-columns: 1fr;
  }
}

/* Layout painel */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--radix-green);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand .logo-x {
  margin: 0 0 10px;
  width: 48px;
  height: 48px;
  font-size: 1.35rem;
  border-radius: 12px;
}

.sidebar-brand strong {
  display: block;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
}

.sidebar-brand span {
  font-size: 0.75rem;
  opacity: 0.85;
}

.nav-section {
  padding: 12px 16px 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.55;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.88);
  text-decoration: none;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: #95d5b2;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.85rem;
}

.sidebar-footer a {
  color: #b7e4c7;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--radix-card);
  padding: 16px 28px;
  border-bottom: 1px solid #e8ece9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--radix-text);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--radix-muted);
  font-size: 0.9rem;
}

.content {
  padding: 24px 28px 40px;
  flex: 1;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-4 {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  background: var(--radix-card);
  border-radius: var(--radius);
  border: 1px solid #e8ece9;
  box-shadow: var(--shadow);
  padding: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  color: var(--radix-green);
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--radix-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--radix-green);
  margin-top: 6px;
}

.stat-card .hint {
  font-size: 0.8rem;
  color: var(--radix-muted);
  margin-top: 8px;
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

table.data th {
  background: #f8faf8;
  font-weight: 600;
  color: var(--radix-green);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: #d8f3dc;
  color: var(--radix-green);
}

.badge-warn {
  background: #fff3cd;
  color: #856404;
}

.badge-danger {
  background: #ffebee;
  color: var(--radix-danger);
}

.badge-muted {
  background: #f3f4f6;
  color: var(--radix-muted);
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-mobile {
  max-width: 420px;
  margin: 0 auto;
  border: 12px solid #1c1c1e;
  border-radius: 36px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
}

.preview-mobile .preview-header {
  background: var(--radix-green);
  color: #fff;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.preview-mobile .preview-body {
  padding: 16px;
  min-height: 280px;
  font-size: 0.85rem;
  color: var(--radix-text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: #e8f5e9;
  color: var(--radix-green);
  font-size: 0.75rem;
  font-weight: 600;
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 12px;
  }

  .sidebar nav a {
    border-left: none;
    border-bottom: 3px solid transparent;
  }

  .sidebar nav a.active {
    border-bottom-color: #95d5b2;
  }
}
