:root {
  --primary: #0e7490;
  --primary-dark: #155e75;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1rem; }
main.centered { display: flex; justify-content: center; align-items: center; min-height: 90vh; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--primary-dark); color: #fff;
  padding: 0.6rem 1.2rem;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.topbar nav a { color: #cffafe; text-decoration: none; margin-right: 0.8rem; }
.topbar nav a:hover { color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .username { opacity: 0.85; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.2rem 1.4rem; margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.auth-card { width: 380px; text-align: center; }
.auth-card h1 { margin: 0.2rem 0; }
.auth-card form { text-align: left; }

h1 { font-size: 1.4rem; margin: 0 0 0.4rem; }
h2 { font-size: 1rem; margin: 0 0 0.6rem; color: var(--primary-dark); }
.muted { color: var(--muted); font-weight: 400; }
.strong { font-weight: 600; }
.prewrap { white-space: pre-wrap; margin: 0; line-height: 1.5; }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.search { display: flex; gap: 0.5rem; flex: 1; max-width: 560px; }
.search input { flex: 1; }

label { display: block; margin-bottom: 0.8rem; font-weight: 600; font-size: 0.85rem; }
input, textarea {
  width: 100%; padding: 0.5rem 0.7rem; margin-top: 0.25rem;
  border: 1px solid var(--border); border-radius: 7px;
  font: inherit; font-weight: 400; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
textarea { resize: vertical; }

.btn {
  display: inline-block; padding: 0.5rem 1rem; border-radius: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  text-decoration: none; font: inherit; cursor: pointer;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 0.4rem; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 0.55rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f8fafc; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table tr:hover td { background: #f0fdff; }
.table a { color: var(--primary-dark); text-decoration: none; }
.table a:hover { text-decoration: underline; }

.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.2rem 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

dl { margin: 0; }
dt { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); margin-top: 0.6rem; }
dd { margin: 0.1rem 0 0; }

.alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 0.6rem 0.9rem; border-radius: 7px; margin-bottom: 0.9rem; font-size: 0.9rem; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.form-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }
.actions { white-space: nowrap; }

/* --- agenda, badges, usuarios --- */
.agenda-nav { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.agenda-nav input[type="date"] { width: auto; margin-top: 0; }
.inline-form { display: inline-flex; gap: 0.3rem; align-items: center; margin: 0; }
.inline-form input { margin-top: 0; width: auto; }
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: capitalize; }
.badge-pendiente { background: #fef9c3; color: #854d0e; }
.badge-atendida { background: #dcfce7; color: #166534; }
.badge-anulada { background: #fee2e2; color: #991b1b; text-decoration: line-through; }
.badge-info { background: #cffafe; color: #155e75; }
tr.estado-anulada td { opacity: 0.55; }
tr.estado-atendida td { background: #f0fdf4; }
.alert-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
select { width: 100%; padding: 0.5rem 0.7rem; margin-top: 0.25rem; border: 1px solid var(--border); border-radius: 7px; font: inherit; background: #fff; }
.inline-details { display: inline-block; }
.inline-details summary { list-style: none; cursor: pointer; }
.table-plain { border: none; box-shadow: none; }
.grid-2 .card canvas { max-height: 260px; }
