.mg-shell{--mg-ink:#13283d;--mg-blue:#2674d9;--mg-mint:#22a78a;--mg-line:#dce8ef;max-width:1600px;margin:0 auto;padding:22px;color:var(--mg-ink);font-family:"Inter","Segoe UI",sans-serif}.mg-hero{display:flex;justify-content:space-between;gap:22px;align-items:center;padding:24px 28px;border:1px solid var(--mg-line);border-radius:24px;background:linear-gradient(115deg,#f8fcff 0%,#eef9f6 100%);box-shadow:0 16px 40px rgba(25,76,106,.08)}.mg-eyebrow{color:var(--mg-mint);font-size:12px;font-weight:800;letter-spacing:.12em;text-transform:uppercase}.mg-hero h1{margin:5px 0;font-size:clamp(25px,3vw,39px);letter-spacing:-.04em}.mg-hero p{margin:0;color:#617588}.mg-hero-actions,.mg-actions{display:flex;gap:10px;flex-wrap:wrap}.mg-btn{border:0;border-radius:13px;padding:11px 16px;font-weight:750;cursor:pointer;display:inline-flex;align-items:center;gap:7px;background:#eaf1f6;color:var(--mg-ink)}.mg-btn.primary{background:var(--mg-ink);color:#fff}.mg-btn.accent{background:var(--mg-blue);color:#fff}.mg-btn:focus-visible,.mg-step:focus-visible{outline:3px solid rgba(38,116,217,.3);outline-offset:2px}.mg-grid{display:grid;grid-template-columns:minmax(260px,340px) minmax(0,1fr);gap:18px;margin-top:18px}.mg-panel{border:1px solid var(--mg-line);border-radius:20px;background:#fff;box-shadow:0 8px 25px rgba(28,60,80,.05)}.mg-side{padding:18px;align-self:start;position:sticky;top:18px}.mg-side h2,.mg-work h2{margin:0 0 6px;font-size:18px}.mg-search{width:100%;box-sizing:border-box;border:1px solid var(--mg-line);border-radius:12px;padding:12px;margin:12px 0;font:inherit}.mg-patient-list{max-height:330px;overflow:auto}.mg-patient{width:100%;display:flex;gap:11px;align-items:center;text-align:left;border:0;background:transparent;border-radius:13px;padding:10px;cursor:pointer}.mg-patient:hover,.mg-patient.active{background:#edf7f5}.mg-avatar{width:42px;height:42px;border-radius:12px;display:grid;place-items:center;background:#dff4ee;color:#147761;font-weight:800}.mg-patient small{display:block;color:#718394;margin-top:3px}.mg-recent{border-top:1px solid var(--mg-line);margin-top:15px;padding-top:15px}.mg-recent-item{padding:9px 0;border-bottom:1px solid #edf2f5;font-size:13px}.mg-work{padding:22px;min-width:0}.mg-patient-strip{display:grid;grid-template-columns:auto 1fr repeat(3,auto);gap:14px;align-items:center;padding:15px;border-radius:16px;background:#f4f8fb;margin-bottom:16px}.mg-patient-strip strong{display:block}.mg-patient-strip span{color:#6a7e90;font-size:13px}.mg-steps{display:flex;gap:7px;overflow:auto;padding:3px 0 14px}.mg-step{white-space:nowrap;border:1px solid var(--mg-line);background:#fff;border-radius:999px;padding:9px 13px;font-weight:700;color:#647789;cursor:pointer}.mg-step.active{background:var(--mg-ink);border-color:var(--mg-ink);color:white}.mg-section{display:none}.mg-section.active{display:block;animation:mgIn .18s ease-out}.mg-section-head{margin:7px 0 17px}.mg-section-head h3{margin:0;font-size:24px;letter-spacing:-.02em}.mg-section-head p{margin:5px 0 0;color:#718394}.mg-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.mg-field{display:flex;flex-direction:column;gap:6px;min-width:0}.mg-field.full{grid-column:1/-1}.mg-field label{font-size:12px;font-weight:800;letter-spacing:.035em;color:#52687b;text-transform:uppercase}.mg-field input,.mg-field select,.mg-field textarea{width:100%;box-sizing:border-box;border:1px solid #cfdee7;border-radius:12px;padding:11px 12px;background:#fff;color:var(--mg-ink);font:inherit}.mg-field textarea{min-height:92px;resize:vertical}.mg-subtitle{grid-column:1/-1;margin:10px 0 -2px;padding-top:12px;border-top:1px solid var(--mg-line);font-size:15px}.mg-vitals{display:grid;grid-template-columns:repeat(4,minmax(110px,1fr));gap:10px;grid-column:1/-1}.mg-repeat{grid-column:1/-1;border:1px solid var(--mg-line);border-radius:15px;padding:13px}.mg-repeat-row{display:grid;grid-template-columns:1fr 2fr auto;gap:8px;margin-bottom:8px}.mg-med-row{grid-template-columns:1.4fr repeat(5,1fr) auto}.mg-empty{padding:52px 20px;text-align:center;color:#708394}.mg-docs{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.mg-doc{border:1px solid var(--mg-line);border-radius:15px;padding:16px;background:#f9fbfc;cursor:pointer;text-align:left}.mg-doc strong{display:block;margin-bottom:4px}.mg-footer{display:flex;justify-content:space-between;gap:12px;border-top:1px solid var(--mg-line);padding-top:16px;margin-top:20px}@keyframes mgIn{from{opacity:0;transform:translateY(5px)}}@media(prefers-reduced-motion:reduce){.mg-section.active{animation:none}}@media(max-width:900px){.mg-grid{grid-template-columns:1fr}.mg-side{position:static}.mg-patient-list{max-height:190px}.mg-vitals{grid-template-columns:repeat(2,1fr)}.mg-patient-strip{grid-template-columns:auto 1fr}.mg-patient-strip>span{display:none}.mg-docs{grid-template-columns:1fr 1fr}}@media(max-width:600px){.mg-shell{padding:10px}.mg-hero{align-items:flex-start;flex-direction:column;padding:20px}.mg-work{padding:15px}.mg-fields{grid-template-columns:1fr}.mg-field.full,.mg-subtitle{grid-column:auto}.mg-repeat-row,.mg-med-row{grid-template-columns:1fr}.mg-docs{grid-template-columns:1fr}.mg-footer{position:sticky;bottom:0;background:white;padding:12px 0}.mg-hero-actions{width:100%}.mg-hero-actions .mg-btn{flex:1;justify-content:center}}
/* Expediente longitudinal de Medicina General */
.mg-side-head,.mg-repeat-title{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.mg-count{display:grid;place-items:center;min-width:28px;height:28px;border-radius:999px;background:#e3f2ee;color:#18745f;font-size:12px;font-weight:800}.mg-empty.compact{padding:20px 8px}.mg-recent-item{width:100%;display:flex;justify-content:space-between;gap:8px;align-items:center;text-align:left;border:0;background:transparent;cursor:pointer}.mg-recent-item span,.mg-recent-item small{display:block}.mg-recent-item em,.mg-status{font-style:normal;font-size:11px;font-weight:800;border-radius:999px;padding:5px 8px;background:#fff1cf;color:#8b6200}.mg-recent-item em.closed,.mg-status.closed{background:#dcf4ec;color:#16705b}.mg-recent-item.active{background:#edf7f5;border-radius:11px;padding-inline:9px}.mg-status.new{background:#e8f0ff;color:#245fb1}.mg-timeline{grid-column:1/-1;border:1px solid #d6e5ea;border-radius:15px;background:#f8fbfc;padding:12px}.mg-timeline summary{cursor:pointer;font-weight:800}.mg-timeline article{display:grid;grid-template-columns:95px 1fr;gap:12px;padding:12px 0;border-top:1px solid #e2ebef}.mg-timeline article:first-of-type{margin-top:10px}.mg-timeline time{font-size:12px;font-weight:800;color:#23846e}.mg-timeline p{margin:0 0 4px;font-size:13px}.mg-timeline-empty{grid-column:1/-1;border-left:4px solid #2a9d84;background:#edf8f5;padding:12px 14px;border-radius:0 12px 12px 0;color:#536d78}.mg-repeat-title small{display:block;color:#718394;margin-top:3px}.mg-dx-row{grid-template-columns:112px minmax(130px,.7fr) minmax(240px,2fr) auto}.mg-primary-dx{display:flex;align-items:center;gap:7px;font-size:12px;font-weight:800;color:#406176}.mg-primary-dx input{width:17px;height:17px}.mg-med-row{grid-template-columns:1.35fr repeat(7,minmax(105px,1fr)) auto;overflow-x:auto;padding-bottom:5px}.mg-rips-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:10px;border-top:1px solid #dce8ef;padding-top:14px}.mg-doc{position:relative}.mg-doc em{position:absolute;right:10px;top:10px;font-size:9px;font-style:normal;font-weight:900;letter-spacing:.08em;color:#2674d9}.mg-btn:disabled,.mg-field input:disabled,.mg-field textarea:disabled,.mg-field select:disabled{opacity:.62;cursor:not-allowed}.mg-status{align-self:center}.mg-empty>.material-symbols-outlined{font-size:44px}
@media(max-width:900px){.mg-med-row{grid-template-columns:1fr 1fr}.mg-dx-row{grid-template-columns:100px 1fr 1.7fr auto}.mg-hero-actions{justify-content:flex-end}}
@media(max-width:600px){.mg-dx-row,.mg-med-row{grid-template-columns:1fr}.mg-primary-dx{padding:8px}.mg-rips-actions{flex-direction:column}.mg-rips-actions .mg-btn{justify-content:center}.mg-status{width:100%;box-sizing:border-box;text-align:center}.mg-timeline article{grid-template-columns:1fr}.mg-hero-actions{justify-content:stretch}}

/* Ventana clínica: el expediente se trabaja sin perder el panel principal. */
.mg-hub{max-width:1500px;margin:0 auto;padding:26px;font-family:"Inter","Segoe UI",sans-serif;color:#13283d}.mg-hub-hero{display:flex;align-items:center;justify-content:space-between;gap:20px;padding:26px 30px;border:1px solid #dce8ef;border-radius:24px;background:linear-gradient(120deg,#fff 0%,#eef9f6 100%);box-shadow:0 18px 46px rgba(20,55,77,.08)}.mg-hub-hero h1{margin:5px 0;font-size:clamp(28px,3vw,42px);letter-spacing:-.045em}.mg-hub-hero p{margin:0;color:#65798b}.mg-hub-grid{display:grid;grid-template-columns:minmax(280px,360px) 1fr;gap:18px;margin-top:18px}.mg-hub-grid .mg-side{position:static}.mg-hub-guide{min-height:430px;padding:38px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;background:radial-gradient(circle at 50% 20%,#effaf7,#fff 58%)}.mg-hub-guide>.material-symbols-outlined{font-size:72px;color:#22a78a}.mg-hub-guide h2{font-size:27px;margin:15px 0 6px}.mg-hub-guide p{max-width:560px;color:#65798b;margin:0 0 20px;line-height:1.6}
.mg-modal{--mg-ink:#13283d;--mg-blue:#2674d9;--mg-mint:#22a78a;--mg-line:#dce8ef;position:fixed;inset:0;z-index:2147482000;display:grid;place-items:center;padding:18px;background:rgba(9,27,43,.44);backdrop-filter:blur(8px);font-family:"Inter","Segoe UI",sans-serif;color:var(--mg-ink)}.mg-window{width:min(1540px,calc(100vw - 36px));height:min(940px,calc(100dvh - 36px));display:grid;grid-template-rows:auto auto minmax(0,1fr);overflow:hidden;border:1px solid rgba(255,255,255,.78);border-radius:24px;background:#f7fafc;box-shadow:0 28px 90px rgba(4,24,40,.32);transition:width .2s ease,height .2s ease,border-radius .2s ease}.mg-window.maximized{width:100vw;height:100dvh;border-radius:0}.mg-window.minimized{position:fixed;right:22px;bottom:18px;width:min(520px,calc(100vw - 32px));height:64px;display:block;border-radius:18px}.mg-window.minimized .mg-window-patient,.mg-window.minimized .mg-window-body{display:none}.mg-window-bar{height:62px;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;padding:9px 13px 9px 18px;background:#13283d;color:#fff}.mg-window-title{display:flex;align-items:center;gap:11px;min-width:0}.mg-window-title>.material-symbols-outlined{width:40px;height:40px;display:grid;place-items:center;border-radius:12px;background:#22a78a}.mg-window-title b,.mg-window-title small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-window-title small{margin-top:2px;color:#b8cfdf;font-size:11px}.mg-window-controls{display:flex;gap:5px}.mg-window-controls button{width:38px;height:38px;display:grid;place-items:center;border:0;border-radius:10px;background:rgba(255,255,255,.1);color:#fff;cursor:pointer}.mg-window-controls button:hover{background:rgba(255,255,255,.2)}.mg-window-controls button.danger:hover{background:#d74f5b}.mg-window-controls .material-symbols-outlined{font-size:20px}.mg-window-patient{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 20px;border-bottom:1px solid var(--mg-line);background:#fff}.mg-window-patient>div:first-child{display:flex;align-items:center;gap:11px;min-width:190px}.mg-window-patient strong,.mg-window-patient small{display:block}.mg-window-patient small{color:#6a7e90;margin-top:2px}.mg-clinical-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}.mg-btn.whatsapp{background:#e3f8ee;color:#087a4f}.mg-btn.whatsapp:hover{background:#c9f0df}.mg-window-body{overflow:auto;padding:20px 24px 26px;background:#f7fafc}.mg-window-body>.mg-patient-strip{display:none}.mg-window-body .mg-steps{position:sticky;top:-20px;z-index:8;margin:-20px -24px 20px;padding:14px 24px;background:rgba(247,250,252,.96);border-bottom:1px solid var(--mg-line);backdrop-filter:blur(10px)}.mg-window-body .mg-section{max-width:1380px;margin:0 auto;padding:24px;border:1px solid var(--mg-line);border-radius:20px;background:#fff;box-shadow:0 8px 24px rgba(22,57,78,.045)}.mg-window-body .mg-footer{max-width:1380px;margin:16px auto 0}.mg-document-renderer{font-family:Arial,sans-serif;color:#172536}.mg-ai-panel{max-width:1380px;margin:0 auto 18px}
@media(max-width:900px){.mg-hub{padding:14px}.mg-hub-grid{grid-template-columns:1fr}.mg-hub-guide{min-height:260px}.mg-modal{padding:0}.mg-window,.mg-window.maximized{width:100vw;height:100dvh;border-radius:0}.mg-window-patient{align-items:flex-start;flex-direction:column}.mg-clinical-actions{width:100%;justify-content:flex-start;overflow-x:auto;flex-wrap:nowrap;padding-bottom:3px}.mg-clinical-actions>*{flex:0 0 auto}.mg-window-body{padding:14px}.mg-window-body .mg-steps{top:-14px;margin:-14px -14px 14px;padding:11px 14px}.mg-window-body .mg-section{padding:17px}.mg-hub-hero{align-items:flex-start;flex-direction:column}}
@media(max-width:600px){.mg-window{grid-template-rows:auto auto minmax(0,1fr)}.mg-window-bar{height:58px;padding-left:10px}.mg-window-controls button{width:34px}.mg-window-controls button:nth-child(2){display:none}.mg-window-title b{font-size:13px;max-width:165px}.mg-window-title small{max-width:165px}.mg-window-title>.material-symbols-outlined{width:36px;height:36px}.mg-window-patient{padding:10px 12px}.mg-window-patient>div:first-child{display:none}.mg-clinical-actions .mg-status{display:none}.mg-clinical-actions .mg-btn{padding:9px 11px;font-size:12px}.mg-hub-hero{padding:21px}.mg-hub-guide{padding:24px}.mg-window.minimized{right:8px;bottom:8px;width:calc(100vw - 16px)}}

/* Ordenes CUPS y consentimiento informado */
.swal2-container.mg-swal-layer{z-index:2147483600!important;padding:16px!important}
.swal2-container.app-toast-layer{z-index:2147483647!important}
.swal2-container.mg-swal-layer .swal2-popup.mg-document-picker{width:min(640px,calc(100vw - 32px))!important;max-width:calc(100vw - 32px)!important;box-sizing:border-box!important;overflow:hidden!important;padding:30px!important}
.swal2-container.mg-swal-layer .mg-document-picker .swal2-title{padding:0!important;font-size:clamp(27px,4vw,42px)!important;line-height:1.08!important}
.swal2-container.mg-swal-layer .mg-document-picker select.mg-document-select{display:block!important;width:100%!important;min-width:0!important;max-width:100%!important;box-sizing:border-box!important;margin:26px 0 0!important}
.swal2-container.mg-swal-layer .mg-document-picker .swal2-actions{margin:26px auto 0!important}
@media(max-width:600px){.swal2-container.mg-swal-layer .swal2-popup.mg-document-picker{padding:22px 16px!important}.swal2-container.mg-swal-layer .mg-document-picker .swal2-title{font-size:28px!important}.swal2-container.mg-swal-layer .mg-document-picker select.mg-document-select{font-size:18px!important}}
.mg-order-row{grid-template-columns:minmax(115px,.7fr) minmax(250px,1.7fr) minmax(210px,1.2fr) auto}
.mg-cups-popup{position:absolute;left:0;right:38px;top:calc(100% - 5px);z-index:45;max-height:320px;overflow:auto;padding:7px;border:1px solid #cbdce8;border-radius:14px;background:#fff;box-shadow:0 18px 45px rgba(19,40,61,.18)}
.mg-cups-option{display:grid;grid-template-columns:78px 1fr;gap:10px;width:100%;padding:9px 10px;border:0;border-radius:9px;background:transparent;text-align:left;color:#203449;cursor:pointer}
.mg-cups-option:hover,.mg-cups-option:focus{background:#edf7f5;outline:none}.mg-cups-option strong{color:#166c5d}.mg-cups-option span{line-height:1.3}
.mg-consent-choice{display:flex;flex-wrap:wrap;gap:12px 24px;min-height:45px;align-items:center;padding:10px 12px;border:1px solid #cfdee7;border-radius:12px;background:#f9fbfc}
.mg-consent-choice label{display:flex;align-items:center;gap:8px;font-size:13px;color:#294357;text-transform:none;letter-spacing:0;cursor:pointer}.mg-consent-choice input{width:18px;height:18px}
#medicina-general-root .mg-new-history{min-height:48px;padding:12px 19px!important;border:1px solid #175cae!important;background:linear-gradient(135deg,#173d69,#2479d8)!important;color:#fff!important;box-shadow:0 12px 28px rgba(31,105,190,.25)!important;font-weight:850!important;letter-spacing:.01em;white-space:nowrap}
#medicina-general-root .mg-new-history:hover{background:linear-gradient(135deg,#102f52,#176cc8)!important;transform:translateY(-1px);box-shadow:0 16px 32px rgba(31,105,190,.32)!important}
#medicina-general-root .mg-new-history:focus-visible{outline:3px solid rgba(36,121,216,.3)!important;outline-offset:3px}
#medicina-general-root .mg-new-history:disabled{background:#d8e2eb!important;border-color:#c9d5df!important;color:#718394!important;box-shadow:none!important;transform:none;cursor:not-allowed}
#medicina-general-root .mg-new-history-large{min-width:245px;justify-content:center;font-size:15px}
@media(max-width:900px){.mg-order-row{grid-template-columns:minmax(105px,.7fr) minmax(220px,1.5fr) minmax(180px,1fr) auto}}
@media(max-width:600px){.mg-order-row{grid-template-columns:1fr}.mg-cups-popup{right:0;top:72px}.mg-consent-choice{align-items:flex-start;flex-direction:column}#medicina-general-root .mg-new-history{width:100%;justify-content:center}}

/* Estación clínica compacta: más información útil por pantalla. */
@media(min-width:1100px){
  .mg-window-bar{height:52px}.mg-window-title>.material-symbols-outlined{width:34px;height:34px}.mg-window-controls button{width:34px;height:34px}
  .mg-window-patient{padding:9px 18px}.mg-window-patient .mg-avatar{width:38px;height:38px}.mg-clinical-actions .mg-btn{min-height:38px;padding:8px 12px;font-size:12px}.mg-clinical-actions .material-symbols-outlined{font-size:18px}
  .mg-window-body{padding:12px 18px 16px}.mg-window-body .mg-steps{top:-12px;margin:-12px -18px 12px;padding:9px 18px}.mg-step{padding:7px 11px;font-size:12px}
  .mg-window-body .mg-section{padding:16px 18px}.mg-section-head{display:flex;align-items:baseline;gap:14px;margin:0 0 12px}.mg-section-head h3{font-size:20px}.mg-section-head p{margin:0;font-size:12px}
  .mg-fields{grid-template-columns:repeat(4,minmax(0,1fr));gap:10px 12px}.mg-field{gap:4px}.mg-field label{font-size:10px}.mg-field input,.mg-field select,.mg-field textarea{min-height:38px;padding:8px 10px;border-radius:9px}.mg-field textarea{min-height:68px}
  .mg-section[data-section="2"] .mg-field.full,.mg-section[data-section="3"] .mg-field.full{grid-column:span 2}.mg-section[data-section="3"] .mg-vitals{grid-template-columns:repeat(5,minmax(100px,1fr))}
  .mg-footer{position:sticky;bottom:-16px;z-index:7;margin-top:12px!important;padding:9px 0 0!important;background:linear-gradient(transparent,#fff 24%)}
}
.mg-rips-actions{align-items:center}.mg-rips-copy{margin-right:auto}.mg-rips-copy b,.mg-rips-copy small{display:block}.mg-rips-copy small{margin-top:3px;color:#718394;font-size:11px;font-weight:500}
.mg-btn.mg-danger{border:1px solid #f1c4ca;background:#fff3f4;color:#a82435}.mg-btn.mg-danger:hover{background:#ffe4e7;color:#881b2a}
.mg-validation-list{display:grid;gap:7px;margin:15px 0 0;text-align:left}.mg-validation-list>div{display:flex;align-items:center;gap:8px;padding:9px 11px;border:1px solid #f1d2a9;border-radius:10px;background:#fff8ec;color:#754b14;font-size:14px;font-weight:700}.mg-validation-list .material-symbols-outlined{font-size:18px;color:#d97706}

/* Copiloto clínico continuo de Medicina General. */
.mg-window{position:relative}
.mg-voice-dock{position:absolute;right:22px;bottom:18px;z-index:30;display:grid;grid-template-columns:auto minmax(180px,1fr) auto;align-items:center;gap:11px;width:min(570px,calc(100% - 44px));padding:10px 11px;border:1px solid rgba(164,178,224,.6);border-radius:18px;background:rgba(255,255,255,.94);box-shadow:0 16px 44px rgba(30,49,91,.2);backdrop-filter:blur(20px) saturate(150%)}.mg-voice-orb{position:relative;display:grid;place-items:center;width:42px;height:42px;border-radius:50%;background:linear-gradient(145deg,#edf4ff,#e9e7ff);color:#4f46c8}.mg-voice-orb:before{content:"";position:absolute;inset:-5px;border:2px solid transparent;border-radius:inherit}.mg-voice-copy{min-width:0}.mg-voice-copy b,.mg-voice-copy small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mg-voice-copy b{font-size:12px}.mg-voice-copy small{margin-top:3px;color:#718394;font-size:10px}.mg-voice-button{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:12px;padding:10px 13px;background:#172f46;color:#fff;font-weight:800;cursor:pointer}.mg-voice-button .material-symbols-outlined{font-size:19px}.mg-voice-dock.recording{border-color:#f0a8b4}.mg-voice-dock.recording .mg-voice-orb{background:#fce7eb;color:#b4233b}.mg-voice-dock.recording .mg-voice-orb:before{border-color:rgba(210,45,75,.35);animation:mgVoicePulse 1.4s ease-out infinite}.mg-voice-dock.recording .mg-voice-button{background:#b4233b}.mg-voice-target{border-color:#665bd4!important;box-shadow:0 0 0 3px rgba(102,91,212,.13)!important}.mg-voice-filled{border-left:3px solid #665bd4!important}@keyframes mgVoicePulse{0%{transform:scale(.9);opacity:1}100%{transform:scale(1.35);opacity:0}}@media(max-width:700px){.mg-voice-dock{right:8px;bottom:8px;width:calc(100% - 16px);grid-template-columns:auto 1fr}.mg-voice-button{grid-column:1/-1}.mg-voice-copy small{max-width:230px}}
.mg-ai-btn{background:linear-gradient(135deg,#405de6,#7748d8);color:#fff}.mg-ai-panel{display:none;grid-template-columns:minmax(0,1fr) auto;gap:12px;padding:16px;border:1px solid #d9d6f4;border-radius:17px;background:linear-gradient(120deg,#fbfbff,#f4f8ff);box-shadow:0 12px 30px rgba(65,72,160,.09)}.mg-ai-panel.open{display:grid}.mg-ai-panel label{display:block;margin-bottom:6px;color:#303c69;font-size:11px;font-weight:850;letter-spacing:.06em;text-transform:uppercase}.mg-ai-panel textarea{width:100%;min-height:88px;box-sizing:border-box;padding:11px 12px;border:1px solid #cfd5ec;border-radius:11px;background:#fff;color:#172536;font:inherit;resize:vertical}.mg-ai-panel textarea:focus{outline:3px solid rgba(87,75,211,.14);border-color:#685bd4}.mg-ai-panel small{display:block;margin-top:6px;color:#66758a;line-height:1.4}.mg-ai-actions{display:flex;flex-direction:column;justify-content:center;gap:8px;min-width:180px}.mg-ai-actions .mg-btn{justify-content:center}.mg-ai-actions .recording{background:#b4233b;color:#fff;box-shadow:0 0 0 5px rgba(180,35,59,.12)}.mg-ai-status{grid-column:1/-1;color:#40507b;font-size:12px;font-weight:750}.mg-ai-review{grid-column:1/-1;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}.mg-ai-review:empty{display:none}.mg-ai-review>div{display:flex;align-items:flex-start;gap:7px;padding:8px 10px;border-radius:9px;background:#edf3ff;color:#3e5572;font-size:12px}.mg-ai-review>div.alert{background:#fff4e8;color:#854d0e}.mg-ai-review .material-symbols-outlined{font-size:17px}.mg-ai-filled{border-color:#8c80df!important;box-shadow:inset 3px 0 #685bd4}.mg-field-mic{display:none!important}@media(max-width:700px){.mg-ai-panel.open{grid-template-columns:1fr}.mg-ai-actions{min-width:0;flex-direction:row}.mg-ai-actions .mg-btn{flex:1}.mg-ai-review{grid-template-columns:1fr}}

/* Expediente longitudinal: pacientes arriba, historias clínicas debajo. */
.mg-side{display:flex;flex-direction:column;min-height:0}.mg-side .mg-side-head{padding-bottom:12px;border-bottom:1px solid var(--mg-line)}.mg-side .mg-side-head h2{font-size:20px;letter-spacing:-.025em}.mg-side .mg-side-head small{display:block;margin-top:3px;line-height:1.4;color:#718394}.mg-side .mg-patient-list{max-height:285px;margin-top:8px;padding-right:4px}.mg-side .mg-patient{min-height:58px;padding:8px 9px;border:1px solid transparent}.mg-side .mg-patient.active{border-color:#cbe7df;background:#edf8f5;box-shadow:inset 3px 0 #168b75}.mg-side .mg-patient:not(.active):hover{border-color:#e1ebf0;background:#f7fafb}.mg-history-list{margin-top:16px;padding-top:16px;border-top:1px solid var(--mg-line)}.mg-history-list>header{display:flex;align-items:flex-end;justify-content:space-between;gap:10px;margin-bottom:10px}.mg-history-list h3{margin:2px 0 0;font-size:18px;letter-spacing:-.025em}.mg-history-kicker{color:#168b75;font-size:10px;font-weight:850;letter-spacing:.09em;text-transform:uppercase}.mg-history-list>div{display:grid;gap:8px}.mg-history-list .mg-recent-item{display:grid;grid-template-columns:48px minmax(0,1fr) auto;gap:10px;align-items:center;width:100%;padding:10px;border:1px solid #dce8ed;border-radius:13px;background:#fff;box-shadow:0 4px 12px rgba(19,40,61,.035);transition:border-color .16s ease,box-shadow .16s ease,transform .16s ease}.mg-history-list .mg-recent-item:hover{transform:translateY(-1px);border-color:#acd9ce;box-shadow:0 8px 18px rgba(19,40,61,.08)}.mg-history-list .mg-recent-item.active{padding:10px;border-color:#168b75;background:#f2faf8;box-shadow:0 0 0 2px rgba(22,139,117,.09)}.mg-history-date{display:grid;place-items:center;align-self:stretch;padding:5px 3px;border-radius:9px;background:#edf7f5;color:#146f5f;text-align:center}.mg-history-date b{font-size:17px;line-height:1}.mg-history-date small{margin-top:3px;color:#527a72;font-size:9px;font-weight:750;text-transform:uppercase}.mg-history-data{min-width:0;text-align:left}.mg-history-data b,.mg-history-data small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.mg-history-data b{font-size:12px}.mg-history-data small{margin-top:3px;color:#607586;font-size:10px}.mg-history-data .mg-history-folio{color:#8a9aa6;font-size:9px}.mg-history-action{display:flex;align-items:center;gap:2px}.mg-history-action em{white-space:nowrap}.mg-history-action>.material-symbols-outlined{color:#8da0ad;font-size:18px}.mg-history-empty{display:grid;justify-items:center;gap:5px;padding:20px 12px;border:1px dashed #cddde4;border-radius:13px;background:#fafcfd;color:#718394;text-align:center}.mg-history-empty .material-symbols-outlined{font-size:28px;color:#20a086}.mg-history-empty p{margin:0;font-size:12px;line-height:1.45}@media(max-width:900px){.mg-side .mg-patient-list{max-height:220px}.mg-history-list .mg-recent-item{grid-template-columns:45px minmax(0,1fr) auto}}@media(prefers-reduced-motion:reduce){.mg-history-list .mg-recent-item{transition:none}.mg-history-list .mg-recent-item:hover{transform:none}}

/* El selector de pacientes vive exclusivamente dentro de Nueva historia clínica. */
.mg-hub-grid:has(.mg-history-board){grid-template-columns:1fr}.mg-history-board{padding:24px}.mg-history-board-head{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;padding-bottom:17px;border-bottom:1px solid var(--mg-line)}.mg-history-board-head h2{margin:3px 0 4px;font-size:24px;letter-spacing:-.035em}.mg-history-board-head p{margin:0;color:#687d8e}.mg-history-board>.mg-history-list{margin:0;padding:18px 0 0;border:0}.mg-history-board>.mg-history-list>div{grid-template-columns:repeat(2,minmax(0,1fr));gap:11px}.mg-history-board .mg-recent-item{min-height:82px;padding:12px 14px;grid-template-columns:52px minmax(0,1fr) auto}.mg-history-board .mg-history-data b{font-size:14px}.mg-history-board .mg-history-data small{font-size:11px}.mg-history-board .mg-history-empty{grid-column:1/-1;padding:42px 20px}.mg-history-board .mg-history-empty .mg-btn{margin-top:8px}.mg-history-board .mg-history-empty .mg-btn>.material-symbols-outlined{font-size:18px;color:inherit}@media(max-width:760px){.mg-history-board{padding:17px}.mg-history-board>.mg-history-list>div{grid-template-columns:1fr}.mg-history-board-head{align-items:flex-start}.mg-history-board .mg-recent-item{grid-template-columns:47px minmax(0,1fr) auto}}

/* Minimizar la consulta debe liberar el resto del sistema.
   Antes, `.mg-modal` mantenía `inset:0` con velo opaco aunque la ventana
   estuviera reducida a la píldora: la pestaña quedaba bloqueada. Y la
   píldora nacía en la misma esquina que el dictado y el robot, así que
   tapaban el botón de expandir. */
.mg-modal.mg-modal-minimized{padding:0;background:transparent;backdrop-filter:none;-webkit-backdrop-filter:none;pointer-events:none}
.mg-modal.mg-modal-minimized .mg-window{pointer-events:auto;box-shadow:0 18px 44px rgba(4,24,40,.36)}
/* Esquina contraria al robot/maleta (abajo-derecha) y al dock de dictado. */
.mg-window.minimized{right:auto;left:22px}
/* El dock dicta sobre las casillas del formulario: sin formulario visible no
   tiene función y solo estorba encima de la barra de título. */
.mg-window.minimized .mg-voice-dock{display:none}
/* La barra entera restaura, así que debe verse pulsable. */
.mg-window.minimized .mg-window-bar{cursor:pointer}
.mg-window.minimized .mg-window-bar:hover{background:#1b3a55}
@media(max-width:600px){.mg-window.minimized{left:8px;right:8px;width:auto}}

/* Marca real de WhatsApp (SVG) en lugar del avión de papel de Material
   Symbols: el botón envía documentos por WhatsApp y el icono debe reconocerse. */
.mg-btn.whatsapp .mg-wa-icon{flex:0 0 auto;display:block}

/* Archivo clínico: cada historia lleva acciones propias (imprimir y WhatsApp)
   para usarlas sin abrir la consulta. La tarjeta dejó de ser un <button>
   —no se pueden anidar— y ahora contiene el suyo más las acciones. */
.mg-history-list .mg-recent-item{grid-template-columns:minmax(0,1fr) auto;gap:4px;padding:0;overflow:hidden}
.mg-history-list .mg-recent-item.active{padding:0}
.mg-recent-open{display:grid;grid-template-columns:48px minmax(0,1fr) auto;gap:10px;align-items:center;width:100%;min-width:0;padding:10px;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
.mg-history-board .mg-recent-open{grid-template-columns:52px minmax(0,1fr) auto;padding:12px 14px}
.mg-history-quick{display:flex;align-items:center;gap:6px;padding-right:10px}
.mg-quick{display:grid;place-items:center;width:34px;height:34px;border:1px solid #dce8ed;border-radius:10px;background:#fff;color:#4b6273;cursor:pointer;transition:background .16s ease,border-color .16s ease,color .16s ease}
.mg-quick:hover{background:#eef6f4;border-color:#acd9ce;color:#12604f}
.mg-quick.whatsapp:hover{background:#e3f8ee;border-color:#8fd9b6;color:#087a4f}
.mg-quick:focus-visible{outline:3px solid rgba(38,116,217,.3);outline-offset:2px}
.mg-quick .material-symbols-outlined{font-size:19px}
.mg-quick .mg-wa-icon{display:block}
@media(max-width:600px){.mg-history-quick{padding-right:8px;gap:4px}.mg-quick{width:32px;height:32px}}
@media(prefers-reduced-motion:reduce){.mg-quick{transition:none}}

/* Dictado por voz: vivía en la esquina inferior derecha, justo encima del
   botón «Continuar» del pie. El centro del pie está libre (los botones van a
   los extremos), así que se mueve ahí y se hace más discreto. */
.mg-voice-dock{right:auto;left:50%;transform:translateX(-50%);bottom:12px;
  width:auto;max-width:calc(100% - 40px);grid-template-columns:auto auto auto;gap:9px;
  padding:6px 7px 6px 9px;border-radius:999px;
  border-color:rgba(164,178,224,.45);background:rgba(255,255,255,.88);
  box-shadow:0 6px 20px rgba(30,49,91,.14)}
.mg-voice-orb{width:30px;height:30px}
.mg-voice-orb .material-symbols-outlined{font-size:17px}
.mg-voice-copy b{font-size:11px}
.mg-voice-copy small{margin-top:1px;font-size:9.5px;max-width:230px}
.mg-voice-button{padding:7px 12px;border-radius:999px;font-size:12px}
.mg-voice-button .material-symbols-outlined{font-size:17px}
/* Grabando sí debe notarse. */
.mg-voice-dock.recording{background:rgba(255,255,255,.97);box-shadow:0 10px 28px rgba(180,35,59,.22)}
@media(max-width:700px){
  /* En una pantalla de teléfono no hay sitio para que el dictado flote: se
     posaba encima de «Anterior / Continuar» los tapara donde los tapara,
     porque el pie se mueve con el desplazamiento y el dock no. Aquí deja de
     flotar y pasa a ser la última fila de la ventana: barra fija abajo, sin
     solaparse nunca con el pie y sin robarle alto al formulario. */
  .mg-voice-dock{position:static;transform:none;width:auto;max-width:none;
    grid-template-columns:auto minmax(0,1fr) auto;
    margin:0;padding:8px 10px;border-radius:0;
    border:0;border-top:1px solid rgba(164,178,224,.5);
    background:rgba(255,255,255,.96);box-shadow:0 -4px 14px rgba(30,49,91,.08)}
  .mg-voice-button{grid-column:auto}
  .mg-voice-copy small{max-width:none}
}

/* Móvil y tablet: la ventana clínica declaraba solo filas de rejilla, así que
   la columna implícita crecía hasta el contenido más ancho (la barra de
   acciones, que no envuelve). El interior medía ~470px dentro de una ventana
   de 390 y todo se salía por la derecha. Una columna acotada obliga a los
   hijos a caber y deja que sus propios scrolls horizontales hagan su trabajo.
   El box-sizing evita además que los bordes sumen 2px sobre el 100vw. */
.mg-window{box-sizing:border-box;grid-template-columns:minmax(0,1fr)}
.mg-window-bar,.mg-window-patient,.mg-window-body,.mg-clinical-actions,.mg-steps,.mg-section,.mg-fields{min-width:0}

/* Tablet (601-900px): los signos vitales caían a 2 columnas junto con el
   móvil y desaprovechaban el ancho; 3 entran cómodas. */
@media(min-width:601px) and (max-width:900px){
  .mg-vitals{grid-template-columns:repeat(3,minmax(0,1fr))}
}
/* Móvil: en 390px la tarjeta del archivo dejaba el nombre en "DIEGO FE...".
   La flecha sobra (toda la tarjeta abre) y el botón táctil necesita tamaño. */
@media(max-width:600px){
  #mg-attending{margin-left:auto!important;margin-right:6px!important}
  #mg-attending>span{width:34px!important;height:34px!important;border-radius:10px!important}
  #mg-attending>div{display:none!important}
  .mg-history-action>.material-symbols-outlined{display:none}
  .mg-history-list .mg-recent-item,
  .mg-history-board .mg-recent-item{grid-template-columns:minmax(0,1fr) auto}
  /* La etiqueta de estado ocupaba una columna entera y estrujaba el nombre:
     baja a su propia línea y el nombre se queda con todo el ancho. */
  .mg-history-board .mg-recent-open,
  .mg-recent-open{grid-template-columns:44px minmax(0,1fr);grid-template-areas:"fecha datos" "estado estado";gap:2px 8px;padding:10px}
  .mg-history-date{grid-area:fecha}
  .mg-history-data{grid-area:datos}
  .mg-history-action{grid-area:estado;justify-self:start}
  .mg-history-date b{font-size:15px}
  .mg-quick{width:38px;height:38px}
  .mg-history-quick{gap:6px;padding-right:8px}
  .mg-history-action em{padding:4px 7px;font-size:10px}
  /* El nombre importa para elegir la historia: mejor dos líneas que
     "DIEGO FERN...". El diagnóstico sí puede seguir recortado. */
  .mg-history-data b{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25}
}

/* Sugerencias inteligentes dentro de la ventana clínica.
   El copiloto pinta sus paneles con z-index ~1e7, muy por debajo de la ventana
   de Medicina General (2147482000), así que allí quedarían ocultos. Solo se
   elevan mientras esa ventana existe, para no alterar el resto del sistema. */
body:has(#mg-modal) #hc-ai-pills{z-index:2147482600!important}
body:has(#mg-modal) #hc-ai-ghost{z-index:2147482700!important}

/* Interruptor de sugerencias inteligentes. El copiloto solo dibuja el suyo
   dentro de la ventana de Optometría (#hc-window), que aquí no existe: sin
   este botón no habría forma de activarlas ni de pausarlas. */
.mg-btn.mg-ai-suggest{background:#eef0fb;color:#4338ca}
.mg-btn.mg-ai-suggest.active{background:linear-gradient(135deg,#405de6,#7748d8);color:#fff}
.mg-btn.mg-ai-suggest:disabled{opacity:.55;cursor:not-allowed}

/* ── Archivo clínico rediseñado: resumen, filtros y tarjetas ── */
.mg-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:16px 0 12px}
.mg-stat{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;column-gap:10px;align-items:center;padding:12px 14px;border:1px solid #dce8ed;border-radius:14px;background:#fff;color:#13283d;text-align:left;cursor:pointer;font:inherit;transition:border-color .16s ease,box-shadow .16s ease}
.mg-stat>.material-symbols-outlined{grid-row:1/3;display:grid;place-items:center;width:38px;height:38px;border-radius:11px;background:#edf7f5;color:#168b75;font-size:21px}
.mg-stat b{font-size:22px;line-height:1;letter-spacing:-.03em}
.mg-stat small{color:#687d8e;font-size:11px;font-weight:700}
.mg-stat:hover{border-color:#acd9ce}
.mg-stat.is-active{border-color:#168b75;box-shadow:0 0 0 3px rgba(22,139,117,.12)}
.mg-stat.is-warn>.material-symbols-outlined{background:#fff4d6;color:#a16207}
.mg-stat.is-warn.is-active{border-color:#d69e14;box-shadow:0 0 0 3px rgba(214,158,20,.15)}

.mg-toolbar{display:grid;grid-template-columns:minmax(220px,1fr) 170px 150px 130px;gap:8px;align-items:center}
.mg-hub-search{display:flex;align-items:center;gap:8px;height:42px;padding:0 12px;border:1px solid #d3e1e8;border-radius:12px;background:#fff}
.mg-hub-search:focus-within{border-color:#168b75;box-shadow:0 0 0 3px rgba(22,139,117,.12)}
.mg-hub-search .material-symbols-outlined{color:#7b8f9d;font-size:20px}
.mg-hub-search input{flex:1;min-width:0;border:0;outline:0;background:transparent;color:#13283d;font:inherit;font-size:13px}
.mg-toolbar select,.mg-toolbar input[type=date]{height:42px;padding:0 10px;border:1px solid #d3e1e8;border-radius:12px;background:#fff;color:#13283d;font:inherit;font-size:13px;min-width:0}
.mg-doctor-filter{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.mg-doctor-chip{display:inline-flex;align-items:center;gap:7px;padding:4px 12px 4px 4px;border:1px solid #dce8ed;border-radius:999px;background:#fff;color:#31465a;font:inherit;font-size:12px;font-weight:750;cursor:pointer}
.mg-doctor-chip.is-active{border-color:#168b75;background:#effaf7;color:#12604f;box-shadow:0 0 0 2px rgba(22,139,117,.12)}

.mg-doc-photo{position:relative;flex:0 0 36px;width:36px;height:36px;border-radius:50%;overflow:hidden;display:grid;place-items:center;background:#dbeafe;color:#1d4ed8;font-size:12px;font-weight:900;box-shadow:0 0 0 2px #fff,0 0 0 3px #cfe0ea}
.mg-doc-photo img{width:100%;height:100%;object-fit:cover;transform-origin:center}
.mg-doc-photo.sm{flex-basis:26px;width:26px;height:26px;font-size:9.5px}
.mg-doc-photo .material-symbols-outlined{font-size:16px;color:#475569}

.mg-history-results{margin-top:16px;display:grid;gap:18px}
.mg-history-results>.mg-history-empty{padding:42px 20px}
.mg-day-group>header{display:flex;align-items:baseline;gap:10px;margin:0 0 8px;padding-bottom:6px;border-bottom:1px dashed #dce8ed}
.mg-day-group>header span{color:#13283d;font-size:14px;font-weight:850;text-transform:capitalize}
.mg-day-group>header small{color:#7b8f9d;font-size:11px;font-weight:700}
.mg-day-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(380px,1fr));gap:11px}

.mg-hcard{position:relative;display:flex;flex-direction:column;border:1px solid #dce8ed;border-left:4px solid #e0a82e;border-radius:15px;background:#fff;box-shadow:0 4px 14px rgba(19,40,61,.05);overflow:hidden;transition:border-color .16s ease,box-shadow .16s ease}
.mg-hcard.is-closed{border-left-color:#1aa37f}
.mg-hcard:hover{box-shadow:0 10px 24px rgba(19,40,61,.1)}
.mg-hcard.active{border-color:#168b75;box-shadow:0 0 0 2px rgba(22,139,117,.14)}
.mg-hcard-open{display:flex;flex-direction:column;gap:9px;width:100%;padding:13px 14px 10px;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
.mg-hcard-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
.mg-hcard-time{display:inline-flex;align-items:center;gap:4px;color:#31465a;font-size:12px;font-weight:800}
.mg-hcard-time .material-symbols-outlined{font-size:16px;color:#7b8f9d}
.mg-hcard-status{display:inline-flex;align-items:center;gap:3px;padding:4px 9px;border-radius:999px;background:#fff1cf;color:#8b6200;font-style:normal;font-size:10.5px;font-weight:850}
.mg-hcard-status .material-symbols-outlined{font-size:14px}
.mg-hcard.is-closed .mg-hcard-status{background:#dcf4ec;color:#16705b}
.mg-hcard-patient{display:flex;align-items:center;gap:10px;min-width:0}
.mg-hcard-patient .mg-avatar{flex:0 0 40px;width:40px;height:40px;border-radius:12px;display:grid;place-items:center;background:#edf7f5;color:#146f5f;font-size:13px;font-weight:900}
.mg-hcard-patient>span:last-child{min-width:0}
.mg-hcard-patient b{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14.5px;letter-spacing:-.01em}
.mg-hcard-patient small{display:block;margin-top:2px;color:#687d8e;font-size:11.5px}
.mg-hcard-reason{color:#3d5366;font-size:12px;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.mg-hcard-reason .material-symbols-outlined{font-size:15px;color:#94a8b5;vertical-align:-3px;margin-right:4px}
.mg-hcard-dx{display:flex;align-items:center;gap:7px;min-width:0;padding:7px 9px;border-radius:10px;background:#f3f7fb}
.mg-hcard-dx code{flex:0 0 auto;padding:2px 6px;border-radius:6px;background:#1e3a5f;color:#fff;font-family:inherit;font-size:11px;font-weight:850;letter-spacing:.02em}
.mg-hcard-dx span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#1e3a5f;font-size:12px;font-weight:700}
.mg-hcard-dx small{flex:0 0 auto;margin-left:auto;padding:1px 6px;border-radius:999px;background:#dbe7f3;color:#1e3a5f;font-size:10px;font-weight:850}
.mg-hcard-dx.is-empty{background:#fafbfc}
.mg-hcard-dx.is-empty span{color:#94a3b8;font-weight:600;font-style:italic}
.mg-hcard-vitals{display:flex;flex-wrap:wrap;gap:5px}
.mg-vital{display:inline-flex;align-items:center;gap:2px;padding:3px 8px;border-radius:999px;background:#f1f5f9;color:#475569;font-size:10.5px;font-weight:750}
.mg-vital .material-symbols-outlined{font-size:13px}
.mg-vital.is-alert{background:#fee2e2;color:#b91c1c}
.mg-vital.is-allergy{background:#fff7ed;color:#c2410c;border:1px solid #fed7aa}
.mg-hcard-foot{display:flex;align-items:center;justify-content:space-between;gap:8px;padding-top:9px;border-top:1px solid #eef3f6}
.mg-hcard-doctor{display:flex;align-items:center;gap:8px;min-width:0}
.mg-hcard-doctor>span:last-child{min-width:0}
.mg-hcard-doctor b{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#31465a;font-size:11.5px}
.mg-hcard-doctor small{display:block;color:#94a3b8;font-size:10px}
.mg-hcard-orders{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:4px}
.mg-hcard-orders>span{display:inline-flex;align-items:center;gap:2px;padding:2px 7px;border-radius:7px;background:#eef6ff;color:#1e4f8a;font-size:10px;font-weight:750;white-space:nowrap}
.mg-hcard-orders .material-symbols-outlined{font-size:13px}
.mg-hcard-actions{display:flex;justify-content:flex-end;align-items:center;gap:6px;padding:0 14px 12px}
.mg-hcard-top{padding-bottom:10px;border-bottom:1px solid #eef3f6}
.mg-hcard-top .mg-hcard-doctor b{font-size:12.5px;color:#13283d}
.mg-specialty-badge{display:inline-flex;align-items:center;gap:3px;margin-top:3px;padding:2px 8px 2px 5px;border-radius:999px;background:linear-gradient(135deg,#e0f2fe,#dcfce7);color:#0f5e73;font-size:10px;font-weight:850;letter-spacing:.02em;box-shadow:inset 0 0 0 1px rgba(14,116,144,.18)}
.mg-specialty-badge .material-symbols-outlined{font-size:13px}
.mg-hcard-patient>span:nth-child(2){flex:1 1 auto;min-width:0}
.mg-hcard-patient .mg-hcard-time{flex:0 0 auto;align-self:flex-start;padding:4px 8px;border-radius:9px;background:#f3f7fb;white-space:nowrap}
.mg-hcard-patient b{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.mg-hcard-folio{display:inline-flex;align-items:center;gap:3px;color:#94a3b8;font-size:10.5px;font-weight:650}
.mg-hcard-folio .material-symbols-outlined{font-size:14px}
.mg-detail-btn{display:inline-flex;align-items:center;gap:6px;height:34px;margin-right:auto;padding:0 14px;border:0;border-radius:10px;background:linear-gradient(135deg,#168b75,#1f9d8a);color:#fff;font:inherit;font-size:12.5px;font-weight:800;cursor:pointer;box-shadow:0 6px 14px -8px rgba(22,139,117,.8);transition:transform .18s cubic-bezier(.22,1,.36,1),box-shadow .18s ease}
.mg-detail-btn:hover{transform:translateY(-1px);box-shadow:0 10px 18px -8px rgba(22,139,117,.85)}
.mg-detail-btn .material-symbols-outlined{font-size:18px}
.mg-btn.mg-note-btn{background:#fffbeb;color:#92400e;box-shadow:inset 0 0 0 1px #fcd34d}
/* Cerrada en rojo: la historia ya no se edita, solo admite nota aclaratoria */
.mg-hcard.is-closed{border-left-color:#dc2626}
.mg-hcard.is-closed .mg-hcard-status{background:#fee2e2;color:#b91c1c;box-shadow:inset 0 0 0 1px #fca5a5}
[data-theme="dark"] .mg-hcard.is-closed .mg-hcard-status{background:rgba(185,28,28,.3);color:#fca5a5}
.mg-hcard-notes{display:flex;align-items:center;gap:6px;padding:7px 10px;border:1px solid #fde68a;border-left:4px solid #f59e0b;border-radius:10px;background:#fffbeb;color:#92400e;font-size:12px;font-weight:800}
.mg-hcard-notes .material-symbols-outlined{font-size:17px}
.mg-hcard-notes small{margin-left:auto;color:#b45309;font-size:10.5px;font-weight:700}
.mg-quick.mg-quick-note{border-color:#fcd34d;background:#fffbeb;color:#92400e}
.mg-quick.mg-quick-note:hover{background:#fef3c7;border-color:#f59e0b;color:#78350f}
.na-overlay.mg-na-layer{z-index:2147483000}

/* Barra de acciones de la historia: solo lo que sirve en cada estado */
.mg-window-patient .mg-clinical-actions{flex:1 1 auto;margin-left:18px;flex-wrap:nowrap}
.mg-action-spacer{flex:1 1 auto;min-width:4px}
.mg-action-group{display:inline-flex;align-items:center;gap:4px;padding:3px;border:1px solid #e2eaf0;border-radius:13px;background:#f6f9fb}
.mg-btn.mg-icon-btn{width:38px;height:38px;min-height:38px;padding:0;justify-content:center;border-radius:10px;background:transparent}
.mg-btn.mg-icon-btn:hover{background:#fff;box-shadow:0 2px 6px rgba(19,40,61,.08)}
.mg-btn.mg-icon-btn.whatsapp{color:#087a4f}
.mg-btn.mg-icon-btn.mg-danger{border:1px solid #f1c4ca;background:#fff3f4}
.mg-btn.mg-icon-btn .material-symbols-outlined{font-size:20px}
.mg-status.closed{display:inline-flex;align-items:center;gap:4px;background:#fee2e2;color:#b91c1c;box-shadow:inset 0 0 0 1px #fca5a5}
.mg-status.closed .material-symbols-outlined{font-size:15px}
.mg-btn.mg-note-btn.primary-note{background:linear-gradient(135deg,#f59e0b,#d97706);color:#fff;box-shadow:0 8px 16px -10px rgba(217,119,6,.9)}
.mg-btn.mg-note-btn.primary-note:hover{filter:brightness(1.05)}
@media(max-width:900px){.mg-window-patient .mg-clinical-actions{margin-left:0}.mg-action-spacer{display:none}}

/* Pestaña 6 · Documentos: ocupan todo el ancho y el sello no pisa el título */
.mg-fields>.mg-docs{grid-column:1/-1;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:10px}
.mg-docs .mg-doc{display:flex;flex-direction:column;gap:3px;min-height:86px;padding:14px 14px 12px;transition:border-color .16s ease,box-shadow .16s ease,transform .16s cubic-bezier(.22,1,.36,1)}
.mg-docs .mg-doc strong{padding-right:44px;margin:0;font-size:14px;line-height:1.25}
.mg-docs .mg-doc span{color:#687d8e;font-size:12px;line-height:1.35}
.mg-docs .mg-doc em{padding:2px 6px;border-radius:6px;background:#e8f0ff;white-space:nowrap}
.mg-docs .mg-doc:hover{border-color:#9cc3f0;box-shadow:0 8px 18px -12px rgba(38,116,217,.6);transform:translateY(-1px)}
.mg-docs .mg-doc.is-empty{opacity:.55;background:#fafbfc}
.mg-docs .mg-doc.is-empty strong{padding-right:0;margin-top:18px}
.mg-docs .mg-doc.is-empty em{background:#f1f5f9;color:#64748b;letter-spacing:0;font-size:9.5px}

/* RIPS: tarjeta propia, con el estado dicho en palabras */
.mg-fields>.mg-rips-actions{display:flex;align-items:center;justify-content:flex-start;gap:12px;margin-top:6px;padding:14px 16px;border:1px solid #dce8ef;border-radius:15px;background:#f8fbfd}
.mg-rips-actions .mg-rips-icon{display:grid;place-items:center;flex:0 0 40px;width:40px;height:40px;border-radius:12px;background:#e8f0ff;color:#2674d9;font-size:21px}
.mg-rips-actions.is-draft .mg-rips-icon{background:#f1f5f9;color:#64748b}
.mg-rips-actions .mg-rips-copy{flex:1;min-width:0}
.mg-rips-actions .mg-rips-copy b{display:block;font-size:14px}
.mg-rips-actions .mg-rips-copy small{color:#687d8e;font-size:12px}
/* Que el pie fijo y el dictado no tapen lo último de la pestaña */
.mg-modal:not(.is-closed) .mg-fields>.mg-rips-actions{margin-bottom:84px}
@media(max-width:600px){.mg-fields>.mg-rips-actions{flex-wrap:wrap}.mg-rips-actions .mg-btn{flex:1}}

/* ── Archivo de Medicina General: un solo encabezado compacto ── */
.mg-hub-v2{padding-top:18px}
.mg-archive{padding:18px 20px 22px;border:1px solid #dce8ef;border-radius:22px;background:#fff;box-shadow:0 12px 32px rgba(20,55,77,.06)}
.mg-archive-head{display:flex;align-items:center;gap:16px;padding-bottom:14px;margin-bottom:14px;border-bottom:1px solid #edf2f6}
.mg-archive-title{display:flex;align-items:center;gap:11px;min-width:0}
.mg-archive-icon{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;border-radius:13px;background:linear-gradient(135deg,#dcfce7,#e0f2fe);color:#0f766e;font-size:24px}
.mg-archive-title small{display:block;color:#168b75;font-size:10.5px;font-weight:850;letter-spacing:.09em;text-transform:uppercase}
.mg-archive-title h1{margin:1px 0 0;font-size:24px;line-height:1.1;letter-spacing:-.03em;white-space:nowrap}
.mg-archive-head .mg-stats{display:flex;gap:6px;margin:0 0 0 auto}
.mg-archive-head .mg-stat{display:inline-flex;grid-template-columns:none;align-items:center;gap:6px;height:38px;padding:0 12px 0 6px;border-radius:999px}
.mg-archive-head .mg-stat>.material-symbols-outlined{grid-row:auto;width:28px;height:28px;margin:0;border-radius:50%;font-size:17px}
.mg-archive-head .mg-stat{text-align:left;justify-items:start}
.mg-archive-head .mg-stat b{font-size:16px}
.mg-archive-head .mg-stat small{font-size:11.5px;white-space:nowrap}
.mg-archive-actions{display:flex;align-items:center;gap:8px}
.mg-btn.mg-archive-config{width:42px;height:42px;padding:0;justify-content:center;border-radius:12px}
.mg-archive-actions .mg-new-history{height:42px;white-space:nowrap}
.mg-archive .mg-toolbar{grid-template-columns:minmax(240px,1fr) 170px 160px 140px}
.mg-results-bar{margin:12px 0 -4px;color:#7b8f9d;font-size:11.5px;font-weight:700}
.mg-results-bar span{color:#13283d;font-weight:850}
.mg-archive .mg-history-results{margin-top:10px}
/* El input del buscador heredaba bordes y MAYÚSCULAS de los estilos globales */
.mg-hub-search input,.mg-hub-search input:focus{height:auto;margin:0;padding:0;border:0!important;box-shadow:none!important;background:transparent!important;text-transform:none}
.mg-hub-search input::placeholder{text-transform:none;color:#94a3b8}
.mg-archive .mg-toolbar select,.mg-archive .mg-toolbar input[type=date]{margin:0;box-shadow:none}
[data-theme="dark"] .mg-archive{background:#0f172a;border-color:#22344a}
[data-theme="dark"] .mg-archive-head{border-color:#1e293b}
[data-theme="dark"] .mg-results-bar span{color:#e2e8f0}
@media(max-width:1100px){
  .mg-archive-head{flex-wrap:wrap}
  .mg-archive-head .mg-stats{order:3;width:100%;margin:0}
  .mg-archive-actions{margin-left:auto}
}
@media(max-width:620px){
  .mg-archive{padding:14px}
  .mg-archive-title h1{font-size:20px}
  .mg-archive-actions .mg-new-history{padding:0 12px;font-size:12.5px}
  .mg-archive-head .mg-stats{overflow-x:auto}
  .mg-archive-head .mg-stat{flex:0 0 auto}
  .mg-archive .mg-toolbar{grid-template-columns:1fr 1fr}
}

/* ── Barra del paciente: paciente | pestañas centradas | acciones ── */
/* Paciente y acciones ocupan lo que necesitan; las pestañas, el centro */
.mg-window-patient{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-areas:"patient steps";align-items:center;gap:14px;padding:10px 18px}
/* El nombre completo se ve: si es largo, baja a una segunda línea en vez de cortarse */
.mg-window-patient .mg-patient-id{grid-area:patient;display:flex;align-items:center;gap:11px;min-width:0;max-width:min(460px,42vw)}
.mg-window-patient .mg-patient-id>div{min-width:0}
.mg-window-patient .mg-patient-id strong{white-space:normal;line-height:1.2;overflow-wrap:anywhere}
.mg-window-patient .mg-patient-id small{display:flex;align-items:center;gap:8px;margin-top:3px;white-space:nowrap}
.mg-window-patient .mg-patient-id small>span:last-child{overflow:hidden;text-overflow:ellipsis}
.mg-window-patient .mg-status{display:inline-flex;align-items:center;gap:3px;padding:2px 8px;font-size:10.5px}
.mg-window-patient .mg-status .material-symbols-outlined{font-size:13px}
.mg-window-patient .mg-clinical-actions{grid-area:actions;justify-content:flex-end;margin:0;min-width:0}
.mg-steps.mg-steps-top{grid-area:steps;justify-self:center;max-width:100%;display:flex;gap:4px;margin:0;padding:4px;overflow-x:auto;border:1px solid #e2eaf0;border-radius:14px;background:#f5f8fb;scrollbar-width:none}
.mg-steps.mg-steps-top::-webkit-scrollbar{display:none}
.mg-steps-top .mg-step{display:inline-flex;align-items:center;gap:6px;padding:7px 12px 7px 7px;border:0;border-radius:10px;background:transparent;color:#5b6f81;font-size:12.5px;font-weight:750}
.mg-steps-top .mg-step:hover{background:#fff;color:#13283d}
.mg-steps-top .mg-step-num{display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:#e2eaf0;color:#475569;font-size:10.5px;font-weight:850}
.mg-steps-top .mg-step.active{background:#13283d;color:#fff;box-shadow:0 6px 14px -8px rgba(19,40,61,.7)}
.mg-steps-top .mg-step.active .mg-step-num{background:#fff;color:#13283d}
[data-theme="dark"] .mg-steps.mg-steps-top{background:#111c33;border-color:#22344a}
/* Pantallas medianas: pestañas más compactas para que sigan en la misma línea */
@media(max-width:1400px){
  .mg-window-patient .mg-patient-id{max-width:min(380px,38vw)}
  .mg-steps-top .mg-step{gap:4px;padding:6px 9px 6px 6px;font-size:11.5px}
  .mg-steps-top .mg-step-num{width:18px;height:18px;font-size:10px}
}
@media(max-width:1150px){
  .mg-steps-top .mg-step-num{display:none}
  .mg-steps-top .mg-step{padding:6px 9px}
}
@media(max-width:900px){
  .mg-window-patient{display:grid;grid-template-columns:1fr;grid-template-areas:"patient" "steps"}
  .mg-steps.mg-steps-top{justify-self:stretch}
}
@media(max-width:600px){.mg-window-patient{grid-template-areas:"steps"}}

/* ── Barra de la ventana en claro: blanco con un toque menta/celeste ── */
.mg-window-bar{background:linear-gradient(100deg,#ffffff 0%,#f1faf7 45%,#eef6fd 100%);color:#13283d;border-bottom:1px solid #e2eef0}
.mg-window.minimized .mg-window-bar:hover{background:linear-gradient(100deg,#f5fbf9,#e6f3fb)}
.mg-window-title>.material-symbols-outlined{background:linear-gradient(135deg,#22a78a,#0ea5e9);color:#fff;box-shadow:0 6px 14px -8px rgba(14,165,233,.8)}
.mg-window-title b{color:#13283d}
.mg-window-title small{color:#6b8494}
.mg-window-controls button{background:#f1f5f9;color:#475569;box-shadow:inset 0 0 0 1px #e2e8f0}
.mg-window-controls button:hover{background:#e2e8f0;color:#13283d}
.mg-window-controls button.danger:hover{background:#fee2e2;color:#b91c1c}
.mg-attending-kicker{color:#7b8f9d;font-size:9px;font-weight:800;text-transform:uppercase;letter-spacing:.04em}
.mg-attending-copy [data-doctor-name]{color:#13283d;font-size:12px}
.mg-attending-copy [data-doctor-reg]{color:#7b8f9d;font-size:9px}
#mg-attending{padding:4px 10px 4px 4px;border:1px solid #d6ebe5;border-radius:14px;background:rgba(255,255,255,.7)}

/* Acciones en la barra de la ventana (liberan la fila de las pestañas) */
.mg-window-bar .mg-bar-actions{flex:1 1 auto;width:auto;flex-wrap:nowrap;display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;margin:0 0 0 18px;padding:0;overflow-x:auto;scrollbar-width:none}
.mg-window-bar .mg-bar-actions::-webkit-scrollbar{display:none}
.mg-window-bar .mg-bar-actions>*{flex:0 0 auto}
.mg-window-bar .mg-bar-actions .mg-btn{min-height:38px;height:38px;padding:0 13px;font-size:12.5px;background:#fff;color:#13283d;box-shadow:inset 0 0 0 1px #dce8ef}
.mg-window-bar .mg-bar-actions .mg-btn:hover{background:#f5f9fb}
.mg-window-bar .mg-bar-actions .mg-btn .material-symbols-outlined{font-size:18px}
.mg-window-bar .mg-bar-actions .mg-action-group{padding:2px;border-color:#dce8ef;background:#fff}
.mg-window-bar .mg-bar-actions .mg-btn.mg-icon-btn{width:34px;height:34px;min-height:34px;padding:0;background:transparent;box-shadow:none;color:#475569}
.mg-window-bar .mg-bar-actions .mg-btn.mg-icon-btn:hover{background:#f1f5f9}
.mg-window-bar .mg-bar-actions .mg-btn.mg-icon-btn.whatsapp{color:#16a34a}
.mg-window-bar .mg-bar-actions .mg-btn.mg-icon-btn.mg-danger{width:38px;height:38px;border:0;background:#fff1f2;color:#be123c;box-shadow:inset 0 0 0 1px #fecdd3}
.mg-window-bar .mg-bar-actions .mg-btn.mg-icon-btn.mg-danger:hover{background:#ffe4e6}
.mg-window-bar .mg-bar-actions .mg-ai-suggest{background:#eef0fb;color:#4338ca;box-shadow:inset 0 0 0 1px #c7d2fe}
.mg-window-bar .mg-bar-actions .mg-ai-suggest.active{background:linear-gradient(135deg,#405de6,#7748d8);color:#fff;box-shadow:none}
.mg-window-bar .mg-bar-actions .mg-btn.primary{background:linear-gradient(135deg,#10b981,#0d9488);color:#fff;box-shadow:0 8px 18px -10px rgba(16,185,129,.8)}
.mg-window-bar .mg-bar-actions .mg-btn.primary:hover{filter:brightness(1.07)}
.mg-window-bar .mg-bar-actions .mg-btn.mg-note-btn.primary-note{background:linear-gradient(135deg,#f59e0b,#d97706);box-shadow:0 8px 16px -10px rgba(217,119,6,.9)}
.mg-window-bar .mg-bar-actions .mg-btn:disabled{opacity:.55}
.mg-window.minimized .mg-bar-actions{display:none}
/* Si la barra se queda corta, primero se ocultan los textos secundarios */
@media(max-width:1300px){#mg-attending{display:none!important}}
@media(max-width:1050px){.mg-window-bar .mg-bar-actions [data-ai-label],.mg-window-bar .mg-bar-actions #mg-save{font-size:0;gap:0}.mg-window-bar .mg-bar-actions #mg-save .material-symbols-outlined,.mg-window-bar .mg-bar-actions .mg-ai-suggest .material-symbols-outlined{font-size:19px}}
@media(max-width:600px){.mg-window-bar .mg-bar-actions{margin-left:8px}.mg-window-title small{display:none}}

/* Cierre: confirmación de RIPS completos */
.mg-close-rips-ok,.mg-close-rips-note{display:flex;align-items:flex-start;gap:6px;margin:10px 0 0;padding:8px 10px;border-radius:10px;font-size:13px;text-align:left}
.mg-close-rips-ok{background:#dcfce7;color:#166534;font-weight:700}
.mg-close-rips-note{background:#fffbeb;color:#92400e}
.mg-close-rips-ok .material-symbols-outlined,.mg-close-rips-note .material-symbols-outlined{font-size:18px}
.mgc-missing-doc{color:#b91c1c;font-weight:800}

/* Selector de documentos (imprimir / WhatsApp) */
.mg-doc-chooser{position:fixed;inset:0;z-index:2147483300;display:grid;place-items:center;padding:18px;background:rgba(9,27,43,.5);backdrop-filter:blur(3px);font-family:"Inter","Segoe UI",sans-serif;color:#13283d;animation:mgdc-fade .18s ease-out}
.mgdc-panel{width:min(720px,100%);max-height:90vh;overflow:auto;border:1px solid #e2eaf0;border-radius:22px;background:#fff;box-shadow:0 30px 60px -24px rgba(15,23,42,.5);animation:mgdc-pop .28s cubic-bezier(.22,1,.36,1)}
.mgdc-head{display:flex;align-items:center;gap:12px;padding:18px 20px;border-bottom:1px solid #edf2f6}
.mgdc-head-icon{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;border-radius:13px;background:#e8f0ff;color:#2674d9}
.mgdc-head-icon .material-symbols-outlined{font-size:24px}
.mg-doc-chooser.is-whatsapp .mgdc-head-icon{background:#dcfce7;color:#087a4f}
.mgdc-head-icon .mg-wa-icon{width:22px;height:22px}
.mgdc-head>div{flex:1;min-width:0}
.mgdc-head h3{margin:0;font-size:18px;letter-spacing:-.02em}
.mgdc-head p{margin:2px 0 0;color:#687d8e;font-size:12.5px}
.mgdc-close{display:grid;place-items:center;width:36px;height:36px;border:1px solid #e2eaf0;border-radius:50%;background:#f5f8fb;color:#475569;cursor:pointer}
.mgdc-close:hover{background:#eaf0f5}
.mgdc-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:16px 20px 20px}
.mgdc-option{display:flex;align-items:center;gap:11px;padding:12px;border:1px solid #e2eaf0;border-radius:14px;background:#fff;color:inherit;font:inherit;text-align:left;cursor:pointer;transition:border-color .16s ease,box-shadow .16s ease,transform .16s cubic-bezier(.22,1,.36,1)}
.mgdc-option>.material-symbols-outlined{display:grid;place-items:center;flex:0 0 38px;width:38px;height:38px;border-radius:11px;background:#edf7f5;color:#168b75;font-size:21px}
.mgdc-option b{display:block;font-size:13.5px}
.mgdc-option small{display:block;margin-top:2px;color:#687d8e;font-size:11.5px}
.mgdc-option:hover,.mgdc-option:focus-visible{border-color:#168b75;box-shadow:0 8px 18px -12px rgba(22,139,117,.7);transform:translateY(-1px);outline:none}
.mg-doc-chooser.is-whatsapp .mgdc-option:hover,.mg-doc-chooser.is-whatsapp .mgdc-option:focus-visible{border-color:#16a34a}
.mgdc-option.is-empty{opacity:.5}
.mgdc-option.is-empty>.material-symbols-outlined{background:#f1f5f9;color:#94a3b8}
.mgdc-option.is-empty small{color:#94a3b8;font-style:italic}
@keyframes mgdc-fade{from{opacity:0}}
@keyframes mgdc-pop{from{opacity:0;transform:translateY(8px) scale(.98)}}
[data-theme="dark"] .mgdc-panel{background:#0f172a;border-color:#22344a;color:#e2e8f0}
[data-theme="dark"] .mgdc-option{background:#111c33;border-color:#22344a}
[data-theme="dark"] .mgdc-head{border-color:#1e293b}
@media(max-width:600px){.mg-doc-chooser{padding:0;place-items:end stretch}.mgdc-panel{border-radius:20px 20px 0 0}.mgdc-grid{grid-template-columns:1fr}}
@media(prefers-reduced-motion:reduce){.mg-doc-chooser,.mgdc-panel{animation:none}.mgdc-option{transition:none}}

[data-theme="dark"] .mg-stat,[data-theme="dark"] .mg-hcard,[data-theme="dark"] .mg-hub-search,[data-theme="dark"] .mg-toolbar select,[data-theme="dark"] .mg-toolbar input[type=date],[data-theme="dark"] .mg-doctor-chip{background:#0f1b2d;border-color:#22344a;color:#e2e8f0}
[data-theme="dark"] .mg-hcard-dx{background:#16263b}
[data-theme="dark"] .mg-hcard-dx span,[data-theme="dark"] .mg-hcard-patient b,[data-theme="dark"] .mg-day-group>header span{color:#e2e8f0}
[data-theme="dark"] .mg-hub-search input{color:#e2e8f0}

@media (max-width:900px){
  .mg-toolbar{grid-template-columns:1fr 1fr}
  .mg-hub-search{grid-column:1/-1}
}
@media (max-width:620px){
  .mg-stats{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .mg-stat{grid-template-columns:1fr;padding:9px;text-align:center;justify-items:center}
  .mg-stat>.material-symbols-outlined{grid-row:auto;width:30px;height:30px;font-size:17px;margin-bottom:4px}
  .mg-stat b{font-size:18px}
  .mg-stat small{font-size:9.5px}
  .mg-day-cards{grid-template-columns:1fr}
  .mg-hcard-foot{flex-direction:column;align-items:flex-start}
  .mg-hcard-orders{justify-content:flex-start}
}

/* ══ Celular y tablet vertical (≤900px) ══════════════════════════════
   Barra en dos filas: título + controles arriba, acciones debajo a todo
   el ancho (antes se montaban sobre el título y escondían botones). */
@media(max-width:900px){
  .mg-archive .mg-toolbar{grid-template-columns:repeat(3,minmax(0,1fr))}
  .mg-archive .mg-toolbar .mg-hub-search{grid-column:1/-1}
  .mg-window-bar{height:auto;flex-wrap:wrap;row-gap:8px;padding:10px 12px}
  .mg-window-title{flex:1 1 0}
  .mg-window-bar .mg-window-controls{order:2}
  .mg-window-bar .mg-bar-actions{order:3;flex:1 0 100%;margin:0;justify-content:flex-start}
  .mg-window-bar .mg-bar-actions #mg-close,.mg-window-bar .mg-bar-actions #mg-add-note{flex:1 0 auto;justify-content:center}
  .mg-window.minimized .mg-window-bar{flex-wrap:nowrap}
  .mg-window-patient{padding:10px 14px;gap:10px}
  .mg-window-patient .mg-patient-id{max-width:none}
  /* El pie queda pegado abajo y tapa por completo lo que pasa por detrás */
  .mg-window-body .mg-footer{position:sticky;bottom:-14px;z-index:7;margin:16px -14px -14px;padding:10px 14px calc(10px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid var(--mg-line);box-shadow:0 -8px 18px -14px rgba(19,40,61,.35)}
  .mg-window-body .mg-footer .mg-btn{min-height:44px;padding:0 20px}
}
@media(max-width:620px){
  .mg-archive-head{gap:10px}
  .mg-archive-actions{width:100%;margin:0}
  .mg-archive-actions .mg-new-history{flex:1;justify-content:center;min-height:44px}
  .mg-archive-head .mg-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));overflow:visible}
  .mg-archive .mg-toolbar{grid-template-columns:1fr 1fr}
  .mg-archive .mg-toolbar>select:last-child{grid-column:1/-1}
  .mg-archive .mg-toolbar select,.mg-archive .mg-toolbar input[type=date],.mg-hub-search{height:44px;font-size:16px}
  .mg-hub-search input{font-size:16px}
  .mg-hcard-patient b{-webkit-line-clamp:3;font-size:14px}
}
@media(max-width:600px){
  /* En celular también se ve quién es el paciente, en una línea compacta */
  .mg-window-patient{grid-template-areas:"patient" "steps";padding:8px 12px}
  .mg-window-patient>div:first-child{display:flex}
  .mg-window-patient .mg-avatar{width:34px;height:34px;flex:0 0 34px;font-size:12px}
  .mg-window-patient .mg-patient-id strong{font-size:13.5px}
  .mg-window-patient .mg-patient-id small{flex-wrap:wrap;white-space:normal;font-size:11px}
  .mg-window-bar{height:auto}
  .mg-window-title b{max-width:none;font-size:13.5px}
  .mg-window-bar .mg-bar-actions .mg-btn{height:42px;min-height:42px}
  .mg-steps-top .mg-step{padding:8px 11px;font-size:12.5px}
  .mg-window-body{padding:12px}
  .mg-window-body .mg-section{padding:15px}
  .mg-window-body .mg-footer{bottom:-12px;margin:14px -12px -12px;padding-left:12px;padding-right:12px}
  /* 16px evita que iOS haga zoom al tocar un campo */
  .mg-field input,.mg-field select,.mg-field textarea{font-size:16px;min-height:44px}
}
@media(max-width:620px){
  .mg-window-patient .mg-status{width:auto;flex:0 0 auto}
  /* Nombre completo en la tarjeta: en celular no se corta con puntos suspensivos */
  .mg-hcard-patient b{display:block;-webkit-line-clamp:unset;overflow:visible;overflow-wrap:anywhere}
  .mg-hcard-patient .mg-hcard-time{padding:3px 7px;font-size:11px}
}
/* El botón trae display propio, que le ganaba al atributo hidden */
.mg-footer .mg-btn[hidden]{display:none!important}
@media(max-width:620px){
  #medicina-general-root .mg-hub{padding:6px}
  .mg-archive{padding:12px;border-radius:18px}
  .mg-repeat-row [data-remove-row]{justify-self:end;width:44px;min-height:40px}
}
@media(max-width:620px){
  .mg-hcard-actions{flex-wrap:wrap;gap:6px}
  .mg-hcard-actions .mg-detail-btn{flex:1 0 100%;justify-content:center;white-space:nowrap;min-height:42px}
  .mg-hcard-actions .mg-quick{width:40px;height:40px}
}
