/* ==========================================================================
   Estilos de cada sección: inicio, expediente, odontograma, citas, archivos...
   ========================================================================== */

/* ---------- Inicio ---------- */
.hero-search { position: relative; overflow: hidden; padding: 28px; border: 0; color: #fff; background: linear-gradient(120deg, var(--brand-800) 0%, var(--brand-600) 60%, #0ea5a4 100%); box-shadow: var(--shadow); }
.hero-search::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.hero-search h2 { font-size: 1.25rem; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.hero-search p { color: #c9f3ee; margin-bottom: 16px; }
.hero-form { position: relative; z-index: 1; display: flex; gap: 12px; }
.hero-form input { flex: 1; min-width: 0; height: 56px; padding: 0 20px; border: 0; border-radius: 12px; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.02em; background: #fff; color: var(--text); }
.hero-form input::placeholder { color: #94a3b8; font-weight: 500; }
.hero-form input:focus { outline: none; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35); }
.hero-form .btn { height: 56px; min-height: 56px; padding: 0 30px; background: #0b3f3c; font-size: 1rem; letter-spacing: 0.06em; }
.hero-form .btn:hover { background: #082b29; }
.hero-msg { position: relative; z-index: 1; margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: rgba(255, 255, 255, 0.16); font-size: 0.92rem; }
.hero-msg:empty { display: none; }
@media (max-width: 560px) {
  .hero-search { padding: 20px 16px; }
  .hero-form { flex-direction: column; }
  .hero-form .btn { width: 100%; }
}

/* ---------- Ficha del paciente ---------- */
.patient-head { padding: 20px 22px; margin-bottom: 16px; }
.patient-head .top { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 20px; }
.patient-head .avatar-lg { width: 64px; height: 64px; border-radius: 16px; background: var(--brand-100); color: var(--brand-800); display: grid; place-items: center; font-size: 1.4rem; font-weight: 700; flex: none; }
.patient-head .ident { flex: 1; min-width: 220px; }
.exp-code { display: inline-block; font-family: var(--mono); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.05em; color: var(--brand-800); background: var(--brand-100); padding: 2px 10px; border-radius: 6px; }
.patient-head h1 { margin: 6px 0 0; font-size: 1.55rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; color: var(--text-2); font-size: 0.92rem; }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.meta-row svg { color: var(--muted); }
.allergy-strip { margin-top: 14px; }

.summary-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.sum-card { padding: 16px 18px; border-left: 4px solid var(--brand-500); }
.sum-card.danger { border-left-color: var(--red); background: #fffafa; }
.sum-card.ok { border-left-color: var(--green); }
.sum-card .lbl { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.sum-card .val { font-weight: 500; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.sum-card .val.empty { color: #94a3b8; font-weight: 400; }
.sum-card ul { margin: 0; padding-left: 18px; }
@media (max-width: 1180px) { .summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .summary-cards { grid-template-columns: 1fr; } }

.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.quick-link { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.quick-link:hover { border-color: var(--brand-500); background: var(--brand-50); text-decoration: none; }
.quick-link .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.quick-link b { display: block; font-size: 0.92rem; }
.quick-link span { font-size: 0.8rem; color: var(--muted); }

.danger-zone { border-color: #fecaca; }
.danger-zone .card-head { color: #991b1b; }

/* ---------- Odontograma ---------- */
.odonto-scroll { overflow-x: auto; padding: 4px 0; -webkit-overflow-scrolling: touch; }
.odonto-svg { display: block; min-width: 680px; width: 100%; height: auto; }
.tooth-editor { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 22px; align-items: start; }
.tooth-preview-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); position: sticky; top: 0; }
.odonto-svg.tooth-preview { width: 112px; min-width: 0; height: auto; }
.tooth-preview .hit { display: none; }
@media (max-width: 640px) {
  .tooth-editor { grid-template-columns: 1fr; }
  .tooth-preview-box { position: static; }
  .odonto-svg.tooth-preview { width: 90px; }
}
.odonto-svg .tooth { cursor: pointer; outline: none; }
.odonto-svg .tooth .hit { fill: transparent; stroke: transparent; stroke-width: 2; rx: 8; }
.odonto-svg .tooth:hover .hit { fill: rgba(20, 184, 166, 0.10); stroke: rgba(20, 184, 166, 0.5); }
.odonto-svg .tooth:focus-visible .hit { stroke: var(--brand-600); stroke-width: 3; }
.odonto-svg .tooth.selected .hit { fill: rgba(20, 184, 166, 0.16); stroke: var(--brand-600); stroke-width: 3; }
.odonto-svg .root { fill: #f1f5f9; stroke: #94a3b8; stroke-width: 1.3; stroke-linejoin: round; }
.odonto-svg .zone { fill: #fff; stroke: #64748b; stroke-width: 1.3; stroke-linejoin: round; }
.odonto-svg .zone.caries { fill: #ef4444; }
.odonto-svg .zone.restauracion { fill: #3b82f6; }
.odonto-svg .zone.caries.restauracion { fill: #ef4444; stroke: #2563eb; stroke-width: 2.2; }
.odonto-svg .tooth.missing .root, .odonto-svg .tooth.missing .zone { opacity: 0.32; }
.odonto-svg .tooth-num { font-size: 13px; font-weight: 700; fill: #334155; text-anchor: middle; }
.odonto-svg .tooth.selected .tooth-num { fill: var(--brand-700); }
.odonto-svg .mk { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.odonto-svg .mk-missing { stroke: #475569; stroke-width: 3.2; }
.odonto-svg .mk-extract { stroke: #dc2626; stroke-width: 4; }
.odonto-svg .mk-endo { stroke: #2563eb; stroke-width: 3; }
.odonto-svg .mk-crown { stroke: #2563eb; stroke-width: 3.4; }
.odonto-svg .mk-prosthesis { stroke: #2563eb; stroke-width: 4.5; }
.odonto-svg .mk-fracture { stroke: #dc2626; stroke-width: 2.6; }
.odonto-svg .bd { font-size: 10px; font-weight: 800; text-anchor: middle; }
.odonto-svg .bd-mob { fill: #b45309; }
.odonto-svg .bd-other { fill: #7c3aed; }
.odonto-svg .bd-bg { stroke-width: 1; }
.odonto-svg .bd-bg.mob { fill: #fef3c7; stroke: #f59e0b; }
.odonto-svg .bd-bg.other { fill: #ede9fe; stroke: #a78bfa; }
.odonto-svg .note-dot { fill: #0d9488; stroke: #fff; stroke-width: 1.5; }
.odonto-svg .mid-line { stroke: #cbd5e1; stroke-width: 1.5; stroke-dasharray: 4 4; }
.odonto-svg .side-label { font-size: 11px; font-weight: 700; fill: #94a3b8; letter-spacing: 0.08em; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.82rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1.5px solid #64748b; background: #fff; }
.legend i.c-caries { background: #ef4444; border-color: #b91c1c; }
.legend i.c-rest { background: #3b82f6; border-color: #1d4ed8; }
.legend i.c-missing { background: repeating-linear-gradient(45deg, #cbd5e1, #cbd5e1 3px, #f1f5f9 3px, #f1f5f9 6px); border-color: #64748b; }
.legend i.c-extract { border-color: #dc2626; background: linear-gradient(45deg, transparent 44%, #dc2626 44%, #dc2626 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, #dc2626 44%, #dc2626 56%, transparent 56%); }
.legend i.c-endo { border-color: #2563eb; background: linear-gradient(90deg, transparent 42%, #2563eb 42%, #2563eb 58%, transparent 58%); }
.legend i.c-crown { border-color: #2563eb; border-width: 3px; background: #fff; }
.legend i.c-prosthesis { border-color: #2563eb; background: linear-gradient(0deg, transparent 38%, #2563eb 38%, #2563eb 62%, transparent 62%); }
.legend i.c-fracture { border-color: #dc2626; background: linear-gradient(135deg, transparent 40%, #dc2626 40%, #dc2626 55%, transparent 55%); }
.legend i.c-mob { border-color: #f59e0b; background: #fef3c7; }
.legend i.c-other { border-color: #a78bfa; background: #ede9fe; }

.cond-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cond { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 0.88rem; font-weight: 500; text-align: left; }
.cond:hover { border-color: var(--muted); }
.cond .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.cond.on { background: var(--brand-50); border-color: var(--brand-600); font-weight: 700; box-shadow: inset 0 0 0 1px var(--brand-600); }
.cond[disabled] { opacity: 0.4; cursor: not-allowed; }
.sub-opts { padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.sub-opts .label { display: block; margin-bottom: 8px; }
.surf-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.surf-btns button { min-width: 42px; min-height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); font-weight: 700; cursor: pointer; }
.surf-btns button.on { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.findings-chip { display: inline-flex; align-items: center; gap: 6px; margin: 2px 6px 2px 0; padding: 2px 10px; border-radius: 999px; background: var(--slate-bg); font-size: 0.8rem; font-weight: 600; }
.findings-chip.caries, .findings-chip.extraccion, .findings-chip.fractura { background: var(--red-bg); color: #991b1b; }
.findings-chip.restauracion, .findings-chip.endodoncia, .findings-chip.corona, .findings-chip.protesis { background: var(--blue-bg); color: #1e40af; }
.findings-chip.movilidad { background: var(--amber-bg); color: #92400e; }
.findings-chip.otros { background: var(--purple-bg); color: #5b21b6; }

/* ---------- Calendario de citas ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
@media (max-width: 1180px) { .cal-layout { grid-template-columns: 1fr; } }
.cal-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.cal-toolbar h2 { flex: 1; font-size: 1.15rem; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-week div { padding: 10px 0; text-align: center; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 108px; padding: 6px; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: var(--brand-50); }
.cal-day.other { background: var(--surface-2); color: #94a3b8; }
.cal-day.selected { background: var(--brand-50); box-shadow: inset 0 0 0 2px var(--brand-600); }
.cal-day .dn { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 0.85rem; font-weight: 600; }
.cal-day.today .dn { background: var(--brand-700); color: #fff; }
.cal-chip { display: flex; align-items: center; gap: 5px; padding: 1px 6px; border-radius: 5px; font-size: 0.72rem; font-weight: 600; line-height: 1.5; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-chip.confirmada { background: var(--green-bg); color: #166534; }
.cal-chip.atendida { background: var(--blue-bg); color: #1e40af; }
.cal-chip.cancelada { background: var(--red-bg); color: #991b1b; text-decoration: line-through; }
.cal-chip.no_asistio { background: #cbd5e1; color: #1e293b; }
.cal-more { font-size: 0.72rem; color: var(--muted); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .cal-day { min-height: 58px; align-items: center; padding: 4px 2px; }
  .cal-chip, .cal-more { display: none; }
  .cal-dots { display: flex; justify-content: center; }
}
.agenda-item { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; }
.agenda-item:last-child { border-bottom: 0; }
.agenda-item:hover { background: var(--brand-50); }
.agenda-item .t { flex: none; width: 66px; font-weight: 700; font-variant-numeric: tabular-nums; }
.status-select { min-height: 32px; padding: 0 28px 0 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; border: 1px solid transparent; cursor: pointer; }
.status-select.confirmada { background-color: var(--green-bg); color: #166534; }
.status-select.atendida { background-color: var(--blue-bg); color: #1e40af; }
.status-select.cancelada { background-color: var(--red-bg); color: #991b1b; }
.status-select.no_asistio { background-color: #cbd5e1; color: #1e293b; }

/* ---------- Radiografías, fotografías y documentos ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.media-card { display: flex; flex-direction: column; overflow: hidden; }
.media-card .thumb { position: relative; aspect-ratio: 4 / 3; background: #0f172a; display: grid; place-items: center; color: #94a3b8; cursor: pointer; border: 0; padding: 0; width: 100%; overflow: hidden; }
.media-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.25s; }
.media-card .thumb:hover img { transform: scale(1.04); }
.media-card .thumb .tag { position: absolute; left: 8px; top: 8px; }
.media-card .info { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.media-card .info .row-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; }
.filetype { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 700; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.slot { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.slot .img { position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--surface-2); color: #94a3b8; cursor: pointer; border: 0; padding: 0; width: 100%; overflow: hidden; }
.slot .img img { width: 100%; height: 100%; object-fit: cover; }
.slot .img .ph { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; }
.slot .img .cnt { position: absolute; right: 8px; top: 8px; padding: 1px 8px; border-radius: 999px; background: rgba(15, 23, 42, 0.75); color: #fff; font-size: 0.72rem; font-weight: 700; }
.slot .cap { display: flex; align-items: center; gap: 8px; padding: 9px 12px; }
.slot .cap b { flex: 1; font-size: 0.86rem; }
.slot .cap small { color: var(--muted); font-size: 0.75rem; }
.slot.empty .img { border-bottom: 1px dashed var(--border-strong); }
.slot.empty:hover { border-color: var(--brand-500); }

.doc-card { padding: 18px 20px; }
.doc-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; margin-bottom: 14px; }
.doc-head .grow { flex: 1; min-width: 200px; }
.page-strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 2px 10px; }
.page-thumb { flex: none; width: 104px; display: flex; flex-direction: column; gap: 6px; border: 0; background: none; padding: 0; cursor: pointer; text-align: center; position: relative; }
.page-thumb .pic { width: 104px; height: 138px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--slate-bg); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.page-thumb .pic img { width: 100%; height: 100%; object-fit: cover; }
.page-thumb:hover .pic { border-color: var(--brand-600); box-shadow: var(--ring); }
.page-thumb span { font-size: 0.78rem; font-weight: 600; color: var(--text-2); }
.page-thumb .del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(15, 23, 42, 0.75); color: #fff; display: none; place-items: center; cursor: pointer; }
.page-thumb:hover .del, .page-thumb:focus-within .del { display: grid; }
@media (hover: none) { .page-thumb .del { display: grid; } }

/* ---------- Visor de imágenes ---------- */
.viewer { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; background: rgba(2, 6, 12, 0.96); color: #fff; animation: fade 0.15s ease; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(255, 255, 255, 0.06); }
.viewer-bar .title { flex: 1; min-width: 0; line-height: 1.3; }
.viewer-bar .title b { display: block; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .title span { font-size: 0.78rem; color: #94a3b8; }
.viewer .btn { color: #e2e8f0; }
.viewer .btn:hover { background: rgba(255, 255, 255, 0.14); }
.viewer-stage { position: relative; flex: 1; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: grab; }
.viewer-stage.dragging { cursor: grabbing; }
.viewer-stage img { max-width: 100%; max-height: 100%; user-select: none; -webkit-user-drag: none; transform-origin: center center; will-change: transform; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.14); color: #fff; display: grid; place-items: center; cursor: pointer; z-index: 2; }
.viewer-nav:hover { background: rgba(255, 255, 255, 0.28); }
.viewer-nav.prev { left: 14px; }
.viewer-nav.next { right: 14px; }
.viewer-cap { padding: 10px 16px 14px; text-align: center; font-size: 0.88rem; color: #cbd5e1; min-height: 44px; }
.viewer-file { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 24px; }
.zoom-label { min-width: 52px; text-align: center; font-size: 0.82rem; font-variant-numeric: tabular-nums; color: #cbd5e1; }

/* ---------- Signos vitales ---------- */
.vital-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.vital { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.vital b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.vital span { font-size: 0.74rem; color: var(--muted); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }

/* ---------- Administración de cuentas ---------- */
.state-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.state-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state-pill.on { background: var(--green-bg); color: #166534; }
.state-pill.off { background: var(--red-bg); color: #991b1b; }

/* ---------- Recibo imprimible ---------- */
.receipt { padding: 28px; border: 2px solid var(--text); border-radius: 6px; background: #fff; color: #000; }
.receipt h2 { text-align: center; font-size: 1.3rem; letter-spacing: 0.06em; text-transform: uppercase; }
.receipt .rno { text-align: center; font-family: var(--mono); margin: 4px 0 16px; font-weight: 700; }
.receipt table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.receipt td { padding: 7px 0; border-bottom: 1px dotted #999; }
.receipt td:first-child { width: 38%; font-weight: 700; }
.receipt .amount { font-size: 1.6rem; font-weight: 800; text-align: center; margin: 14px 0; padding: 10px; border: 2px solid #000; }
.receipt .sign { display: flex; justify-content: space-between; gap: 40px; margin-top: 50px; font-size: 0.85rem; text-align: center; }
.receipt .sign div { flex: 1; border-top: 1px solid #000; padding-top: 6px; }
