:root {
  --teal-dark: #12363f;
  --teal: #1d5c58;
  --teal-soft: #2f7a76;
  --gold: #c3964f;
  --gold-soft: #d9b87a;
  --bg: #f7f6f1;
  --card: #ffffff;
  --text: #1c2b2c;
  --muted: #6c7777;
  --border: #e4e1d8;
  --danger: #b3404a;
  --success: #3f7a55;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--teal-dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: conic-gradient(var(--gold), var(--teal-soft), var(--teal-dark), var(--gold));
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.brand strong { display: block; letter-spacing: 2px; font-size: 1.1rem; }
.brand small { color: var(--gold); font-size: 0.7rem; letter-spacing: 1px; }

.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: white; text-decoration: none; font-size: 0.92rem; }
.nav a:hover { color: var(--gold); }

.user-pill {
  background: rgba(255,255,255,0.12);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
}

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

.footer {
  text-align: center;
  padding: 18px;
  color: var(--muted);
  font-size: 0.8rem;
}

h1 { color: var(--teal-dark); margin-top: 0; }
h2 { color: var(--teal-dark); font-size: 1.15rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--teal-dark); color: white; }
.btn-primary:hover { background: var(--teal); }
.btn-secondary { background: var(--gold); color: var(--teal-dark); }
.btn-secondary:hover { opacity: 0.85; }

.auth-box {
  max-width: 420px;
  margin: 40px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}
.auth-box-wide { max-width: 560px; }

form label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--teal-dark);
}
form input, form select, form textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--teal);
}

.role-toggle { display: flex; gap: 14px; margin-bottom: 18px; }
.role-option {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  color: var(--teal-dark);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.role-option:has(input:checked) {
  border-color: var(--gold);
  background: #fbf3e6;
}

.flash-stack { margin-bottom: 20px; }
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.flash-success { background: #e3f3e8; color: var(--success); }
.flash-error { background: #fbe7e9; color: var(--danger); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: box-shadow 0.15s ease;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.card h3 { margin: 8px 0 6px; color: var(--teal-dark); }
.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
  background: var(--teal);
  white-space: nowrap;
}
.status-solicitacao { background: var(--gold); }
.status-analise { background: #9c7a3e; }
.status-planejamento { background: var(--teal-soft); }
.status-confirmacao { background: var(--teal); }
.status-cirurgia { background: var(--teal-dark); }
.status-pos_operatorio { background: #7a5a2a; }
.status-concluida { background: var(--success); }

.empty-state {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.timeline {
  display: flex;
  justify-content: space-between;
  margin: 28px 0 32px;
  flex-wrap: wrap;
  gap: 8px;
}
.timeline-step {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  position: relative;
}
.timeline-step .dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  margin: 0 auto 6px;
}
.timeline-step.done .dot { background: var(--gold); }
.timeline-step.active .dot { background: var(--teal-dark); }
.timeline-step.done span:not(.dot) { color: var(--teal-dark); font-weight: 600; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}

.detail-list { display: grid; grid-template-columns: 1fr; row-gap: 4px; margin-bottom: 18px; }
.detail-list dt { font-size: 0.78rem; color: var(--muted); margin-top: 10px; }
.detail-list dd { margin: 0; font-weight: 500; }

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input[type="text"] { flex: 1; }

.doc-list { list-style: none; padding: 0; margin: 0 0 18px; }
.doc-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.doc-list a { color: var(--teal-dark); font-weight: 600; }

.message-list { max-height: 260px; overflow-y: auto; margin-bottom: 14px; }
.message {
  background: #eef2ee;
  border-left: 3px solid var(--teal-soft);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.message.me { background: #fbf3e6; border-left-color: var(--gold); }
.message p { margin: 4px 0; }
