/* =====================================================================
   Odontología · Hoja de estilos
   Paleta fucsia · sin iconografía: jerarquía con tipografía, color y forma
   ===================================================================== */
:root {
  --f-50:  #FDF4FF;
  --f-100: #FAE8FF;
  --f-200: #F5D0FE;
  --f-300: #F0ABFC;
  --f-400: #E879F9;
  --f-500: #D946EF;
  --f-600: #C026D3;
  --f-700: #A21CAF;
  --f-800: #86198F;
  --f-900: #701A75;
  --f-950: #3B0A3F;

  --rose:   #E11D74;
  --plum:   #2A0B2E;
  --plum-2: #3A1240;

  --ink:    #2B1630;
  --ink-2:  #5B4762;
  --muted:  #8A7690;
  --line:   #EEDFF0;
  --line-2: #E3CCE6;
  --bg:     #FAF5FA;
  --surface:#FFFFFF;

  --ok:      #0F7B5F;  --ok-bg:   #E3F6EF;
  --warn:    #A15C07;  --warn-bg: #FDF1DC;
  --danger:  #BE123C;  --danger-bg:#FDE7EC;
  --info:    #6D28D9;  --info-bg: #EFE7FD;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px rgba(59,10,63,.06), 0 1px 1px rgba(59,10,63,.04);
  --shadow-2: 0 10px 30px -12px rgba(59,10,63,.25), 0 2px 6px rgba(59,10,63,.06);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --side: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--f-700); text-decoration: none; }
a:hover { color: var(--f-900); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 750; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .6rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .9em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.sidebar {
  background: radial-gradient(120% 60% at 0% 0%, #4B1150 0%, transparent 60%), var(--plum);
  color: #F6E8F8; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 22px 14px;
}
.brand { padding: 4px 10px 22px; }
.brand-mark { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; color: #fff; }
.brand-mark span { color: var(--f-300); }
.brand-sub { font-size: .76rem; color: #C9A9CF; margin-top: 2px; }
.nav-group { margin-bottom: 18px; }
.nav-title { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #B08AB7; padding: 0 12px 6px; font-weight: 700; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-radius: 9px; color: #EBD5EF; font-weight: 550; font-size: .92rem;
  position: relative;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(217,70,239,.28), rgba(217,70,239,.08)); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--f-400); }
.nav .count { font-size: .72rem; background: var(--f-600); color: #fff; border-radius: 99px; padding: 0 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; color: #C9A9CF; }
.sidebar-foot strong { color: #fff; display: block; font-size: .9rem; }
.sidebar-foot form { margin-top: 8px; }
.linklike { background: none; border: 0; padding: 0; color: var(--f-300); cursor: pointer; font: inherit; }
.linklike:hover { color: #fff; text-decoration: underline; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px;
  background: rgba(250,245,250,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { width: 100%; padding-left: 14px; background: #fff; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-2); overflow: hidden; z-index: 40;
}
.search-results a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a.focus { background: var(--f-50); }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; }
.topbar .menu-toggle { display: none; }
.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--f-700); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 650; font-size: .9rem; line-height: 1;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  background: var(--f-600); color: #fff; transition: background .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--f-700); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--f-300); outline-offset: 2px; }
.btn-soft { background: var(--f-100); color: var(--f-800); }
.btn-soft:hover { background: var(--f-200); color: var(--f-900); }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--f-50); color: var(--f-800); border-color: var(--f-300); }
.btn-danger { background: #fff; color: var(--danger); border-color: #F5C2CF; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ok { background: var(--ok); }
.btn-wa { background: var(--ok-bg); color: var(--ok); border-color: #BCE6D6; }
.btn-wa:hover { background: var(--ok); color: #fff; }
.btn-ok:hover { background: #0B6650; }
.btn-sm { padding: 7px 11px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- Formularios ---------- */
label, .label { display: block; font-size: .8rem; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; min-height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--f-500); box-shadow: 0 0 0 4px rgba(217,70,239,.14); }
input[type=color] { width: 64px; height: 40px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; }
input[readonly] { background: var(--f-50); }
.field { margin-bottom: 14px; }
.field-error { display: block; color: var(--danger); font-size: .78rem; margin-top: 4px; font-weight: 600; }
.help { display: block; color: var(--muted); font-size: .78rem; margin-top: 4px; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.grid { display: grid; gap: 14px 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; font-weight: 550; color: var(--ink); cursor: pointer; margin: 0; padding: 7px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--f-600); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; color: var(--f-800); margin-bottom: 12px; padding: 0; }

/* ---------- Superficies ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { font-size: 1rem; }
.card-body { padding: 18px 22px; }
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }
.cols { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: 4px; }

/* ---------- Indicadores (solo tipografía) ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: auto 0 0 0; height: 3px; background: linear-gradient(90deg, var(--f-500), var(--rose)); opacity: .85; }
.kpi .k-label { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kpi .k-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: .8rem; color: var(--ink-2); margin-top: 2px; }
.kpi.accent { background: linear-gradient(135deg, var(--f-700), var(--f-900)); color: #fff; border-color: transparent; }
.kpi.accent .k-label, .kpi.accent .k-foot { color: var(--f-200); }
.kpi.accent::after { display: none; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 750; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FDF9FD; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #FEFAFE; }
.table tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 750; background: #FDF9FD; border-top: 1px solid var(--line-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn, .table .actions form + .btn, .table .actions .btn + form { margin-left: 4px; }
.row-off td { opacity: .55; }
.table-compact th, .table-compact td { padding: 8px 7px; font-size: .82rem; }
.table-compact input { min-height: 32px; padding: 4px 7px; font-size: .82rem; }
.table-compact .actions .btn { padding: 6px 8px; }

/* ---------- Etiquetas de estado ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: .74rem; font-weight: 700; line-height: 1.35; white-space: nowrap; background: var(--f-100); color: var(--f-800); }
.badge-pendiente, .badge-borrador, .badge-programado { background: var(--warn-bg); color: var(--warn); }
.badge-confirmado, .badge-presentado, .badge-enviado, .badge-en_sala { background: var(--info-bg); color: var(--info); }
.badge-atendido, .badge-aprobado, .badge-pagado, .badge-realizado, .badge-facturado, .badge-registrada, .badge-finalizado, .badge-activo, .badge-entrada, .badge-simulado { background: var(--ok-bg); color: var(--ok); }
.badge-cancelado, .badge-rechazado, .badge-anulado, .badge-anulada, .badge-ausente, .badge-fallido, .badge-inactivo, .badge-salida { background: var(--danger-bg); color: var(--danger); }
.badge-ajuste, .badge-no { background: #F1ECF2; color: var(--ink-2); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .74rem; font-weight: 700; background: #F4EEF5; color: var(--ink-2); }
.tag-alert { background: var(--danger-bg); color: var(--danger); }
.tag-f { background: var(--f-100); color: var(--f-800); }

/* ---------- Avisos ---------- */
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 12px 16px; border-radius: 12px; font-weight: 600; border: 1px solid; display: flex; justify-content: space-between; gap: 10px; }
.flash-ok { background: var(--ok-bg); border-color: #BCE6D6; color: #0B5E49; }
.flash-error { background: var(--danger-bg); border-color: #F5C2CF; color: #9F1239; }
.flash-info { background: var(--f-50); border-color: var(--f-200); color: var(--f-900); }
.flash button { background: none; border: 0; color: inherit; font-weight: 800; cursor: pointer; font-size: 1rem; line-height: 1; }
.callout { padding: 12px 16px; border-radius: 12px; background: var(--f-50); border: 1px dashed var(--f-300); color: var(--f-900); font-size: .9rem; }
.callout-danger { background: var(--danger-bg); border: 1px solid #F5C2CF; color: #9F1239; }
.callout-warn { background: var(--warn-bg); border: 1px solid #F3D9A9; color: #7A4505; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .field { margin: 0; }
.filters input, .filters select { min-width: 170px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; }
.seg a { padding: 6px 12px; border-radius: 7px; font-size: .84rem; font-weight: 650; color: var(--ink-2); }
.seg a.active { background: var(--f-600); color: #fff; }
.seg a:not(.active):hover { background: var(--f-50); }

/* ---------- Tarjetas de pacientes ---------- */
.patient-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }
.patient-card {
  text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 16px 14px;
  box-shadow: var(--shadow-1); position: relative; transition: transform .15s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; gap: 12px; overflow: hidden;
}
.patient-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--f-500), var(--rose)); opacity: 0; transition: opacity .15s; }
.patient-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--f-200); }
.patient-card:hover::before, .patient-card:focus-visible::before { opacity: 1; }
.patient-card:focus-visible { outline: 3px solid var(--f-300); outline-offset: 2px; }
.patient-card.inactive { opacity: .6; }
.pc-top { display: flex; gap: 12px; align-items: center; }
.monogram {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 800; font-size: 1rem; letter-spacing: .02em; color: var(--f-900);
  background: linear-gradient(145deg, var(--f-100), var(--f-200));
}
.monogram.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 1.35rem; }
.monogram.v1 { background: linear-gradient(145deg, #FCE7F3, #FBCFE8); color: #9D174D; }
.monogram.v2 { background: linear-gradient(145deg, #F3E8FF, #E9D5FF); color: #6B21A8; }
.monogram.v3 { background: linear-gradient(145deg, #FFE4E6, #FECDD3); color: #9F1239; }
.pc-name { font-weight: 750; font-size: 1rem; line-height: 1.25; }
.pc-doc { font-size: .8rem; color: var(--muted); }
.pc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: .82rem; }
.pc-meta dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.pc-meta dd { margin: 0; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-foot { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px dashed var(--line-2); padding-top: 10px; min-height: 30px; }
.pc-hint { margin-left: auto; font-size: .76rem; font-weight: 700; color: var(--f-700); opacity: 0; transition: opacity .15s; }
.patient-card:hover .pc-hint { opacity: 1; }

/* ---------- Panel lateral de funcionalidades ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(42,11,46,.45); backdrop-filter: blur(2px); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--bg); z-index: 90; transform: translateX(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; box-shadow: -20px 0 50px -20px rgba(42,11,46,.45); }
.drawer.open { transform: none; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer-head { padding: 22px 24px 18px; background: linear-gradient(135deg, var(--f-800), var(--plum)); color: #fff; position: relative; }
.drawer-head .monogram { background: rgba(255,255,255,.16); color: #fff; }
.drawer-head .muted { color: var(--f-200); }
.drawer-close { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 9px; padding: 6px 10px; cursor: pointer; font: inherit; font-weight: 700; font-size: .8rem; }
.drawer-close:hover { background: rgba(255,255,255,.22); }
.drawer-body { padding: 18px 20px 30px; overflow-y: auto; flex: 1; }
.drawer-loading { padding: 40px; text-align: center; color: var(--muted); }
.quick-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 0; }
.quick-facts div { background: rgba(255,255,255,.1); border-radius: 10px; padding: 8px 10px; }
.quick-facts b { display: block; font-size: 1rem; }
.quick-facts span { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--f-200); }
.func-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.func {
  display: block; padding: 14px 14px 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s; position: relative;
}
.func:hover { border-color: var(--f-400); background: var(--f-50); color: var(--ink); transform: translateY(-1px); }
.func b { display: block; font-size: .93rem; }
.func span { display: block; font-size: .77rem; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.func .n { font-style: normal; position: absolute; top: 10px; right: 12px; font-size: .72rem; font-weight: 800; color: var(--f-700); background: var(--f-100); border-radius: 99px; padding: 0 7px; }
.func.primary { background: linear-gradient(135deg, var(--f-600), var(--f-800)); border-color: transparent; color: #fff; }
.func.primary span { color: var(--f-100); }
.func.primary:hover { color: #fff; filter: brightness(1.06); }
.drawer-section { margin-top: 20px; }
.drawer-section h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--f-800); margin-bottom: 8px; }

/* ---------- Ficha del paciente ---------- */
.patient-hero { display: flex; gap: 18px; align-items: center; padding: 22px 24px; background: linear-gradient(135deg, var(--f-800) 0%, #551158 55%, var(--plum) 100%); color: #fff; border-radius: 18px; margin-bottom: 16px; flex-wrap: wrap; position: relative; overflow: hidden; }
.patient-hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(240,171,252,.35), transparent 70%); }
.patient-hero .monogram { background: rgba(255,255,255,.16); color: #fff; }
.patient-hero h1 { color: #fff; }
.patient-hero .meta { color: var(--f-200); font-size: .88rem; margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.patient-hero .hero-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.patient-hero .btn-ghost { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); }
.patient-hero .btn-ghost:hover { background: rgba(255,255,255,.2); }
.patient-hero .btn { background: #fff; color: var(--f-800); }
.patient-hero .btn:hover { background: var(--f-100); }
.alert-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 16px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-2); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; font-weight: 650; font-size: .9rem; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--f-700); }
.tabs a.active { color: var(--f-800); border-bottom-color: var(--f-600); }
.tabs a .n { font-size: .72rem; color: var(--muted); margin-left: 3px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 550; }

/* ---------- Línea de tiempo (evoluciones) ---------- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--f-200); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--f-500); }
.tl-date { font-size: .78rem; font-weight: 700; color: var(--f-800); text-transform: uppercase; letter-spacing: .06em; }
.tl-card { margin-top: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tl-card h4 { font-size: .95rem; margin-bottom: 6px; }
.tl-card .row { font-size: .88rem; margin-top: 4px; }
.tl-card .row b { color: var(--ink-2); font-weight: 700; }

/* ---------- Odontograma ---------- */
.odonto-wrap { overflow-x: auto; padding: 8px 0 4px; }
.odonto { min-width: 860px; display: grid; gap: 6px; }
.odonto-row { display: flex; justify-content: center; gap: 4px; }
.odonto-row .half { display: flex; gap: 4px; padding: 0 8px; }
.odonto-row .half:first-child { border-right: 2px solid var(--f-200); }
.odonto-row.temp .tooth svg { width: 38px; height: 38px; }
.odonto-sep { height: 2px; background: var(--f-200); margin: 6px 40px; }
.tooth { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tooth .tn { font-size: .72rem; font-weight: 750; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tooth svg { width: 46px; height: 46px; cursor: pointer; display: block; }
.tooth svg .face { fill: #fff; stroke: #B99DBD; stroke-width: 1.2; transition: fill .1s; }
.tooth svg .face:hover { fill: var(--f-100); }
.tooth svg .mark { pointer-events: none; }
.tooth.sel svg .outline { stroke: var(--f-600); stroke-width: 3; }
.st-caries { fill: #E11D48 !important; }
.st-obturado { fill: #2563EB !important; }
.st-obturado_defectuoso { fill: #F59E0B !important; }
.st-sellante { fill: #10B981 !important; }
.st-fractura { fill: #FB7185 !important; }
.odonto-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); background: #fff; border-radius: 99px; padding: 5px 11px 5px 6px; font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer; color: var(--ink-2); }
.legend-btn i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0,0,0,.12); font-style: normal; font-size: 10px; line-height: 12px; text-align: center; font-weight: 900; }
.legend-btn.active { border-color: var(--f-600); background: var(--f-50); color: var(--f-900); box-shadow: 0 0 0 3px rgba(217,70,239,.15); }

/* ---------- Agenda ---------- */
.agenda-day { display: grid; gap: 8px; }
.slot { display: grid; grid-template-columns: 74px 1fr auto; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--slot, var(--f-500)); border-radius: 12px; padding: 12px 14px; }
.slot .time { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.slot .time small { display: block; font-weight: 600; color: var(--muted); font-size: .74rem; }
.slot .who { font-weight: 700; }
.slot .what { font-size: .85rem; color: var(--ink-2); }
.slot.is-cancelado, .slot.is-ausente { opacity: .55; }
.slot.is-atendido { background: #FBFEFC; }
.slot .slot-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 8px; overflow-x: auto; }
.week-col { background: #fff; border: 1px solid var(--line); border-radius: 12px; min-height: 260px; }
.week-col.today { border-color: var(--f-400); box-shadow: 0 0 0 3px rgba(217,70,239,.12); }
.week-col h4 { font-size: .8rem; padding: 10px 12px; border-bottom: 1px solid var(--line); text-transform: capitalize; }
.week-col h4 a { color: var(--ink); }
.week-item { display: block; margin: 6px; padding: 7px 9px; border-radius: 8px; background: var(--f-50); border-left: 4px solid var(--slot, var(--f-500)); font-size: .78rem; color: var(--ink); }
.week-item b { display: block; font-variant-numeric: tabular-nums; }
.week-item:hover { background: var(--f-100); color: var(--ink); }

/* ---------- Ítems editables (presupuesto, factura, compra) ---------- */
.items-table input, .items-table select { min-height: 36px; padding: 6px 9px; }
.items-table td { padding: 8px 8px; }
.items-table .w-num { width: 92px; } .items-table .w-money { width: 140px; } .items-table .w-iva { width: 96px; } .items-table .w-pieza { width: 90px; }
.totals { margin-left: auto; width: min(360px, 100%); font-size: .95rem; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line-2); }
.totals div.grand { font-size: 1.25rem; font-weight: 800; border-bottom: 0; color: var(--f-900); padding-top: 10px; }

/* ---------- Paginación ---------- */
.pager { display: flex; gap: 4px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.pager a, .pager-gap { min-width: 36px; padding: 7px 10px; border-radius: 9px; text-align: center; font-weight: 650; font-size: .86rem; color: var(--ink-2); background: #fff; border: 1px solid var(--line); }
.pager a.active { background: var(--f-600); border-color: var(--f-600); color: #fff; }
.pager-gap { border-color: transparent; background: none; }

/* ---------- Modal ---------- */
dialog.modal { border: 0; border-radius: 18px; padding: 0; width: min(620px, calc(100vw - 32px)); box-shadow: var(--shadow-2); color: var(--ink); }
dialog.modal::backdrop { background: rgba(42,11,46,.5); backdrop-filter: blur(2px); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #FDF9FD; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(80% 60% at 20% 20%, #9D2BA5 0%, transparent 60%), radial-gradient(70% 60% at 90% 90%, #E11D74 0%, transparent 55%), var(--plum); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art .big { font-size: clamp(2.2rem, 4vw, 3.4rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.02; max-width: 560px; }
.auth-art .big span { color: var(--f-300); }
.auth-art p { color: var(--f-200); max-width: 460px; font-size: 1.02rem; }
.auth-list { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; max-width: 460px; }
.auth-list li { padding: 10px 14px; border-radius: 12px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); font-weight: 600; font-size: .92rem; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: min(400px, 100%); }
.auth-box h1 { font-size: 1.7rem; margin-bottom: 4px; }

/* ---------- Errores ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 30px; }
.error-code { font-size: 5rem; font-weight: 800; letter-spacing: -.05em; background: linear-gradient(135deg, var(--f-500), var(--rose)); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }

/* ---------- Documentos imprimibles ---------- */
.print-body { background: #EDE3EE; }
.sheet { background: #fff; width: 210mm; min-height: 297mm; margin: 20px auto; padding: 16mm 15mm; box-shadow: 0 10px 40px rgba(0,0,0,.12); font-size: 12px; color: #222; }
.sheet h1 { font-size: 18px; } .sheet h2 { font-size: 14px; margin: 14px 0 6px; color: var(--f-900); border-bottom: 2px solid var(--f-200); padding-bottom: 3px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet th, .sheet td { border: 1px solid #DDD; padding: 5px 7px; text-align: left; vertical-align: top; }
.sheet th { background: #F8F0F9; font-size: 11px; }
.sheet .no-border td, .sheet .no-border th { border: 0; padding: 2px 4px; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--f-600); padding-bottom: 10px; margin-bottom: 12px; }
.doc-head .box { border: 1px solid #CCC; border-radius: 6px; padding: 8px 12px; text-align: center; min-width: 220px; }
.print-bar { position: sticky; top: 0; background: var(--plum); color: #fff; padding: 10px 20px; display: flex; gap: 10px; justify-content: center; z-index: 5; }
.print-bar .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.signature { margin-top: 60px; display: flex; justify-content: space-around; }
.signature div { border-top: 1px solid #555; padding-top: 4px; width: 220px; text-align: center; font-size: 11px; }

@media print {
  .print-bar { display: none; }
  .print-body { background: #fff; }
  .sheet { box-shadow: none; margin: 0; width: auto; min-height: 0; padding: 0; }
  @page { size: A4; margin: 12mm; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cols-main, .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; z-index: 70; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .topbar .actions .btn-text { display: none; }
  .content { padding: 18px 16px 50px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 32px 24px; }
  .auth-list { display: none; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .k-value { font-size: 1.25rem; }
  .slot { grid-template-columns: 60px 1fr; }
  .slot .slot-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .func-grid { grid-template-columns: 1fr; }
  .topbar .actions { display: none; }
}

/* Matriz de perfiles y permisos */
.matriz th, .matriz td { vertical-align: middle; }
.matriz thead th.rol { text-align: center; min-width: 118px; white-space: normal; line-height: 1.25; }
.matriz thead th.rol small { display: block; font-weight: 500; color: var(--muted, #6b5a6e); text-transform: none; letter-spacing: 0; }
.matriz td.celda { text-align: center; }
.matriz td.celda input { width: 19px; height: 19px; accent-color: var(--f-600); cursor: pointer; }
.matriz td.celda .fijo { color: var(--f-700); font-weight: 700; font-size: .8rem; }
.matriz tr.grupo td { background: var(--f-50); color: var(--f-800); font-weight: 750; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.matriz td.permiso b { display: block; }
.matriz td.permiso small { color: var(--muted, #6b5a6e); }
.matriz th:first-child, .matriz td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 240px; }
.matriz tr.grupo td:first-child { background: var(--f-50); }
[hidden] { display: none !important; }
