:root {
  --bg: #f4f7f8; --card: #fff; --ink: #1f2937; --muted: #6b7280; --line: #e2e8ec;
  --brand: #0047ab; --brand-d: #003585; --brand-l: #dbe8fa; --red: #d62828; --blue: #1d4ed8;
  --warn: #b45309; --warn-bg: #fef3c7; --ok: #15803d;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 14px 0 8px; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .center { text-align: center; }

/* Login */
.login { max-width: 360px; margin: 5vh auto; padding: 0 16px; }
.login .card { padding: 24px; }
.login h1 { text-align: center; color: var(--brand); }

/* Layout */
.app { display: flex; min-height: 100vh; }
.side { width: 220px; background: #0a2a5e; color: #dbe6f8; padding: 16px 10px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { font-weight: 700; font-size: 17px; padding: 4px 10px 14px; color: #fff; }
.side a { display: block; padding: 9px 12px; border-radius: 8px; color: #dbe6f8; text-decoration: none; margin-bottom: 2px; }
.side a:hover { background: #123a7a; } .side a.on { background: var(--brand); color: #fff; }
.side .who { margin-top: 18px; padding: 10px; font-size: 13px; border-top: 1px solid #1f4a8a; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1180px; }
.menu-btn { display: none; }
@media (max-width: 800px) {
  .app { display: block; }
  .side { position: fixed; z-index: 30; left: -230px; transition: left .2s; height: 100%; }
  .side.open { left: 0; }
  .menu-btn { display: inline-block; margin-bottom: 10px; }
  .main { padding: 14px 12px 60px; }
}

/* Componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 10px 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: #374151; }
label.f > input, label.f > select, label.f > textarea { display: block; width: 100%; margin-top: 3px; font-weight: 400; }
input, select, textarea { padding: 8px 10px; border: 1px solid #cbd5dc; border-radius: 8px; background: #fff; }
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
.btn { border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--brand-d); } .btn:disabled { opacity: .5; cursor: default; }
.btn.alt { background: #fff; color: var(--brand); } .btn.alt:hover { background: var(--brand-l); }
.btn.danger { background: #fff; color: var(--red); border-color: #f1b5b5; } .btn.danger:hover { background: #fdeaea; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.click { cursor: pointer; } tr.click:hover td { background: #f1f8f7; }
.tbl-wrap { overflow-x: auto; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e5e7eb; }
.chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.ok { background: #dcfce7; color: var(--ok); }
.chip.red { background: #fee2e2; color: #b91c1c; } .chip.blue { background: #dbeafe; color: #1e40af; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 14px 0; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.alerts { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.sec { border-left: 4px solid var(--brand); padding-left: 10px; margin: 18px 0 8px; font-weight: 700; }
.sec small { font-weight: 400; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.hint { background: #eef4fc; border: 1px solid var(--brand-l); padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; max-width: 90vw; }
.toast.err { background: #b91c1c; }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow: auto; }
.modal { background: #fff; border-radius: 14px; padding: 18px; width: 100%; max-width: 560px; }
.modal.wide { max-width: 860px; }
.modal h2 { margin-top: 0; }
.stat { font-size: 22px; font-weight: 700; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(#fff0, #f4f7f8 30%); padding: 12px 0 4px; display: flex; gap: 8px; z-index: 5; }

/* Odontograma */
.odo-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.odo-wrap svg { min-width: 700px; display: block; }
.odo-it .of { cursor: pointer; } .odo-it .of:hover { filter: brightness(.88); stroke: #000; }
.odo-it .om { cursor: pointer; } .odo-it .om:hover rect { fill: #eef4fc; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tool { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid #cbd5dc; border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; }
.tool:hover { background: #f1f5f9; }
.tool.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-l); background: #eef4fd; font-weight: 600; }
.tool i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; border: 1px solid #0003; }
.tool i.r { background: var(--red); } .tool i.b { background: var(--blue); } .tool i.x { background: #fff; }
.sig { border: 2px dashed #94a3b8; border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 180px; display: block; }
.items input { width: 100%; }
.items td { padding: 4px 6px; }
.total-box { margin-left: auto; width: 280px; max-width: 100%; }
.total-box div { display: flex; justify-content: space-between; padding: 3px 0; }
.total-box .big { font-weight: 700; font-size: 18px; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 6px; }
.mini-t td, .mini-t th { padding: 4px 6px; } .mini-t input, .mini-t select { width: 100%; padding: 4px 6px; }

/* ---- Servismile: logo patrocinador y animación de carga ---- */
.login .spons { text-align: center; margin-bottom: 14px; }
.login .spons img { width: 110px; max-width: 40%; height: auto; }
.login .by { text-align: center; font-size: 12px; line-height: 1.7; color: #64748b; margin-top: 16px; } .login .by a { font-weight: 700; text-decoration: none; } .login .by a:hover { text-decoration: underline; }
.side .brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.side .brand img { width: 120px; max-height: 110px; object-fit: contain; background: #fff; border-radius: 12px; padding: 8px; }
.side .by { margin-top: 14px; font-size: 12px; text-align: center; color: #9db4de; } .side .by a { display: inline; padding: 0; color: #fff; font-weight: 700; text-decoration: underline; }
.sv-loader { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 0; color: #0047ab; }
.sv-loader svg { width: 96px; height: 96px; overflow: visible; }
.sv-loader span { font-size: 13px; color: #64748b; animation: svfade 1.6s ease-in-out infinite; }
.sv-arc { fill: none; stroke-width: 70; stroke-linecap: round; stroke-linejoin: round; }
.sv-dark { stroke: #0047ab; } .sv-light { stroke: #74cfff; }
.sv-d1 { fill: #0047ab; } .sv-d2 { fill: #74cfff; }
.sv-g { transform-origin: 960px 765px; animation: svspin 2.4s cubic-bezier(.6,0,.3,1) infinite; }
.sv-arc { stroke-dasharray: 100; stroke-dashoffset: 100; animation: svdraw 2.4s ease-in-out infinite; }
.sv-light { animation-delay: .25s; }
.sv-dot { transform-box: fill-box; transform-origin: center; animation: svpop 2.4s ease-in-out infinite; }
@keyframes svdraw { 0% { stroke-dashoffset: 100; } 45%, 75% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -100; } }
@keyframes svspin { 0%, 55% { transform: rotate(0); } 100% { transform: rotate(180deg); } }
@keyframes svpop { 0%, 30% { transform: scale(0); } 50% { transform: scale(1.25); } 62%, 85% { transform: scale(1); } 100% { transform: scale(0); } }
@keyframes svfade { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.sv-top { position: fixed; right: 14px; bottom: 14px; z-index: 9000; background: #fff; border-radius: 14px; padding: 8px; box-shadow: 0 6px 24px rgba(0,71,171,.25); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sv-top.on { opacity: 1; }
.sv-top svg { width: 44px; height: 44px; display: block; }
.btn.busy { position: relative; color: transparent; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border: 3px solid #ffffff66; border-top-color: #fff; border-radius: 50%; animation: svrot .7s linear infinite; }
@keyframes svrot { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sv-g, .sv-arc, .sv-dot, .sv-loader span { animation: none; stroke-dashoffset: 0; } }
