/* OdontoSuite — estilos base */
:root {
    --azul: #1565c0; --azul-osc: #0d47a1; --verde: #2e7d32; --rojo: #c62828;
    --gris: #f4f6f9; --borde: #e0e4ea; --texto: #2a2f36; --muted: #7a828c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto); background: var(--gris); font-size: 14px; }
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h3 { margin: 0 0 12px; }
.muted { color: var(--muted); }
.text-danger { color: var(--rojo); }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #fff; border-right: 1px solid var(--borde); padding: 18px 0; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 0 20px 18px; color: var(--azul-osc); }
.sidebar nav a { display: block; padding: 11px 20px; color: var(--texto); border-left: 3px solid transparent; }
.sidebar nav a:hover { background: var(--gris); text-decoration: none; }
.sidebar nav a.activo { border-left-color: var(--azul); color: var(--azul); background: #eaf2fc; font-weight: 600; }
.content { flex: 1; padding: 0 28px 40px; max-width: 1200px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; margin-bottom: 8px; }
.userbox { display: flex; align-items: center; gap: 12px; }

/* Cards */
.card { background: #fff; border: 1px solid var(--borde); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.metric { display: flex; flex-direction: column; gap: 6px; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-size: 26px; font-weight: 700; color: var(--azul-osc); }

/* Botones */
.btn { display: inline-block; padding: 8px 14px; border: 1px solid var(--borde); background: #fff; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--texto); }
.btn:hover { background: var(--gris); text-decoration: none; }
.btn-primary { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn-primary:hover { background: var(--azul-osc); }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--azul); cursor: pointer; padding: 0; font-size: 13px; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--borde); }
.table th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }

/* Formularios */
.form label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--borde); border-radius: 8px; font-size: 14px; font-family: inherit; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-row.inline-add { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); align-items: end; gap: 10px; }
.form.inline { display: flex; gap: 10px; align-items: center; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; margin: 12px 0; }
.check input { width: auto; }
.checks-grid { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 8px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.searchbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.searchbar input { max-width: 320px; }

/* Alertas */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-success { background: #e8f5e9; color: var(--verde); border: 1px solid #c8e6c9; }
.alert-error { background: #ffebee; color: var(--rojo); border: 1px solid #ffcdd2; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; background: #eceff1; color: #455a64; }
.badge-agendada { background: #e3f2fd; color: #1565c0; }
.badge-confirmada { background: #e8f5e9; color: #2e7d32; }
.badge-en_sala { background: #fff3e0; color: #e65100; }
.badge-atendida { background: #ede7f6; color: #5e35b1; }
.badge-no_asistio { background: #ffebee; color: #c62828; }
.badge-cancelada { background: #eceff1; color: #78909c; }
.badge-pendiente { background: #fff8e1; color: #f9a825; }
.badge-realizado, .badge-aceptado, .badge-terminado { background: #e8f5e9; color: #2e7d32; }

/* Paginación */
.pagination { display: flex; gap: 6px; }
.pagination a { padding: 6px 11px; border: 1px solid var(--borde); border-radius: 6px; background: #fff; }
.pagination a.activo { background: var(--azul); color: #fff; border-color: var(--azul); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--borde); margin-bottom: 18px; }
.tabs button { background: none; border: none; padding: 11px 16px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs button.activo { color: var(--azul); border-bottom-color: var(--azul); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.activo { display: block; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 12px 0; border-bottom: 1px solid var(--borde); }
.timeline-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* Auth */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1565c0, #0d47a1); }
.auth-card { background: #fff; padding: 36px; border-radius: 14px; width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.brand-big { font-size: 30px; font-weight: 700; text-align: center; margin-bottom: 18px; color: var(--azul-osc); }

/* Odontograma */
.odo-controls { display: flex; gap: 18px; }
.odo-controls label { font-size: 13px; }
.odo-controls select { width: auto; }
.odo-svg { width: 100%; height: auto; }
.odo-num { font-size: 9px; fill: var(--muted); text-anchor: middle; }
.odo-cara { fill: #fff; stroke: #90a4ae; stroke-width: 1; cursor: pointer; }
.odo-cara:hover { fill: #e3f2fd; }
.odo-x { stroke: #c62828; stroke-width: 2.5; fill: none; }
.odo-simbolo { font-size: 9px; text-anchor: middle; font-weight: 700; }
.leyenda { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--borde); }
.leyenda-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.leyenda-item i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.oculto { display: none; }
.modal-box { background: #fff; padding: 24px; border-radius: 12px; width: 360px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Calendario */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px; }
.cal-cell { min-height: 88px; border: 1px solid var(--borde); border-radius: 6px; padding: 4px; background: #fff; }
.cal-cell.vacio { background: var(--gris); border: none; }
.cal-dia { font-size: 12px; color: var(--muted); }
.cal-ev { display: block; font-size: 10px; padding: 2px 4px; border-radius: 4px; margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Barchart */
.barchart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-fill { width: 70%; background: var(--azul); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-label { font-size: 10px; color: var(--muted); margin-top: 4px; }

/* Formularios clínicos */
.form-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.form-card { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--borde); border-radius: 8px; background: #fff; }
.form-card:hover { border-color: var(--azul); text-decoration: none; background: #f7fafe; }
.form-card strong { color: var(--azul-osc); }
.campo { margin: 10px 0; }
.campo > label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 13px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 14px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
.radio input { width: auto; }
.escala .radio-row { flex-direction: column; gap: 4px; }
.score-box { background: #eaf2fc; padding: 10px 16px; border-radius: 8px; font-size: 16px; }
.medida-row { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1.6fr; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--borde); }
.medida-label { font-weight: 600; font-size: 13px; }
.medida-norma { font-size: 12px; color: var(--muted); }
.medida-clasif { font-size: 12px; font-weight: 600; }
.bilateral { display: flex; align-items: center; gap: 18px; padding: 6px 0; border-bottom: 1px solid var(--borde); }
.bilat-label { font-weight: 600; font-size: 13px; min-width: 160px; }

/* Consentimientos / firma */
.consent-text { white-space: pre-line; line-height: 1.55; font-size: 14px; }
.firma-wrap { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#firma-canvas { border: 1px dashed #999; border-radius: 8px; background: #fff; touch-action: none; max-width: 100%; }

/* Periodontograma */
.perio-table th, .perio-table td { padding: 3px 4px; text-align: center; vertical-align: middle; }
.perio-table .perio-pieza { font-weight: 700; color: var(--azul-osc); }
.perio-ps { width: 40px; padding: 4px 2px; text-align: center; display: inline-block; }
.perio-sang { display: block; margin-top: 2px; }
.perio-sang input { width: auto; accent-color: var(--rojo); }
.perio-mov { width: 52px; padding: 4px; }

@media (max-width: 800px) {
    .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); }
    .grid-2, .form-row { grid-template-columns: 1fr; }
    .medida-row { grid-template-columns: 1fr 1fr; }
}
