*{
  box-sizing:border-box;
}

html{
  width:100%;
  height:100%;
  overflow:hidden;
}

body{
  margin:0;
  width:100%;
  height:100vh;
  height:100dvh;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  font-family:system-ui,Arial,sans-serif;
  background:#0e1620;
  color:#e9f0f3;
}

button,input,textarea,select{
  font:inherit;
}

button{
  cursor:pointer;
  border:1px solid #385160;
  background:#1d3341;
  color:#eaf3f4;
  border-radius:9px;
  padding:9px;
}

button:hover,
.active{
  background:#18796d!important;
}

button:disabled{
  opacity:.35;
}

input,textarea,select{
  background:#111f2c;
  color:#fff;
  border:1px solid #49606c;
  border-radius:8px;
  padding:9px;
  min-width:0;
}

input[type=range]{
  padding:0;
  width:100%;
}

textarea{
  resize:vertical;
}

header{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  flex:0 0 auto;
  background:#14252e;
  padding:10px 15px;
  border-bottom:1px solid #3a5059;
}

header b{
  font-size:17px;
}

header small{
  color:#a9c1c6;
}

header .grow{
  flex:1;
}

.nav{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  flex:0 0 auto;
  padding:9px 14px;
  background:#182934;
  border-bottom:1px solid #3b515e;
}

.nav button{
  font-size:13px;
}

.screen{
  display:none;
  min-height:0;
}

.screen.activeScreen{
  display:block;
}

.screen.activeScreen:not(#editor){
  flex:1 1 auto;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-y;
}

.layout{
  width:100%;
  max-width:1250px;
  margin:0 auto;
  padding:20px 14px;
}

.card{
  background:#172936;
  border:1px solid #39505c;
  border-radius:13px;
  padding:16px;
  margin-bottom:14px;
}

.flex{
  display:flex;
  align-items:center;
  gap:9px;
  flex-wrap:wrap;
}

.grow{
  flex:1;
}

.grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(210px,1fr));
  gap:12px;
}

.field{
  display:grid;
  gap:5px;
  margin-bottom:9px;
}

.muted{
  color:#9eb6c2;
  font-size:13px;
}

.tag{
  font-size:11px;
  color:#b7d4cd;
}

.hidden{
  display:none!important;
}

h2{
  font-size:19px;
  margin:0 0 13px;
}

h3{
  font-size:15px;
  margin:8px 0;
}

.patientrow{
  padding:11px;
  border-bottom:1px solid #344c57;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.patientrow:last-child{
  border:0;
}

.mini{
  font-size:12px;
  padding:6px 9px;
}

/* EDITOR: ALTURA CONTROLADA */

#editor.activeScreen{
  flex:1 1 auto;
  display:flex;
  flex-direction:column;
  width:100%;
  height:0;
  min-height:0;
  overflow:hidden;
}

.editor{
  display:grid;
  grid-template-columns:170px minmax(0,1fr) 170px;
  flex:1 1 auto;
  width:100%;
  height:100%;
  min-height:0;
  overflow:hidden;
  background:#080d14;
}

.editor.leftclosed{
  grid-template-columns:0 minmax(0,1fr) 170px;
}

.editor.rightclosed{
  grid-template-columns:170px minmax(0,1fr) 0;
}

.editor.leftclosed.rightclosed{
  grid-template-columns:0 minmax(0,1fr) 0;
}

/* PANELES LATERALES */

.panel{
  background:#162630;
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:0;
  height:100%;
  overflow:hidden;
  border-right:1px solid #3b515e;
}

.panel.right{
  border-right:0;
  border-left:1px solid #3b515e;
}

.panel.closed{
  width:0;
  overflow:hidden;
  border:0;
}

.panelhead{
  flex:0 0 auto;
  padding:9px;
  text-align:center;
  font-size:12px;
  font-weight:700;
  background:#243946;
}

/* PNG: DESPLAZAMIENTO TÁCTIL VERTICAL */

.tools{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:6px;
  padding:8px;
  align-content:start;
  flex:1 1 auto;
  height:0;
  min-height:0;
  max-height:100%;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior-y:contain;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-y;
  scrollbar-width:thin;
  scrollbar-color:#547985 #162630;
}

.tool{
  border:1px solid #48606d;
  background:#0d1922;
  border-radius:7px;
  padding:5px;
  min-height:73px;
  cursor:grab;
  touch-action:pan-y;
}

.tool img{
  display:block;
  width:100%;
  height:49px;
  object-fit:contain;
  pointer-events:none;
}

.tool span{
  font-size:10px;
  display:block;
  color:#b7cbd3;
  text-align:center;
  overflow-wrap:anywhere;
}

/* COLUMNA CENTRAL */

.middle{
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:0;
  height:100%;
  overflow:hidden;
}

/* BARRA SUPERIOR */

.edtop{
  display:flex;
  gap:5px;
  align-items:center;
  flex-wrap:wrap;
  flex:0 0 auto;
  padding:7px;
  background:#172936;
  max-height:32%;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-y;
}

.edtop button{
  font-size:12px;
  padding:7px;
}

.edtop .spacer{
  flex:1;
}

/* ÁREA DE RADIOGRAFÍA */

.workspace{
  flex:1 1 auto;
  position:relative;
  overflow:hidden;
  min-height:0;
  height:0;
  background:#070a10;
  touch-action:none;
}

.viewport{
  position:absolute;
  inset:0;
  overflow:hidden;
  touch-action:none;
}

.world{
  position:absolute;
  left:50%;
  top:50%;
  width:100%;
  height:100%;
  transform-origin:center;
  touch-action:none;
}

.rx{
  width:100%;
  height:100%;
  object-fit:contain;
  pointer-events:none;
  user-select:none;
}

.overlay{
  position:absolute;
  touch-action:none;
  user-select:none;
  cursor:grab;
  transform-origin:center;
  max-width:none;
}

.overlay.selected{
  outline:2px dashed #ffcd68;
  outline-offset:3px;
}

.drawer{
  position:absolute;
  z-index:50;
  top:8px;
  padding:6px!important;
  background:#227c72!important;
}

.drawer.left{
  left:6px;
}

.drawer.right{
  right:6px;
}

/* BARRA INFERIOR SIEMPRE ACCESIBLE */

.edbottom{
  display:flex;
  gap:5px;
  align-items:center;
  flex-wrap:wrap;
  flex:0 0 auto;
  padding:7px;
  background:#172936;
  border-top:1px solid #42515e;
  max-height:34%;
  min-height:44px;
  overflow-x:hidden;
  overflow-y:auto;
  align-content:flex-start;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-y;
  scrollbar-width:thin;
  scrollbar-color:#547985 #172936;
}

.edbottom button{
  font-size:12px;
  padding:7px;
  flex:0 0 auto;
}

.edbottom input[type=range]{
  flex:0 0 auto;
  max-width:90px;
}

.edbottom select{
  max-width:180px;
  font-size:11px;
  padding:6px;
}

.ruler img{
  height:25px;
  max-width:100px;
  vertical-align:middle;
}

.badge{
  padding:3px 7px;
  border-radius:15px;
  font-size:11px;
  background:#2d4752;
}

.tabs{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
}

.tabs button{
  font-size:12px;
}

/* MODALES */

.modal{
  position:fixed;
  inset:0;
  background:#000a;
  display:none;
  z-index:1000;
  align-items:center;
  justify-content:center;
  padding:12px;
}

.modal.show{
  display:flex;
}

.dialog{
  width:min(550px,100%);
  background:#182a35;
  padding:20px;
  border-radius:14px;
  border:1px solid #66808a;
  max-height:90vh;
  max-height:90dvh;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
}

/* MAPEO Y RESUMEN */

.painrow{
  border:1px solid #3c5360;
  border-radius:10px;
  padding:11px;
  margin:8px 0;
}

.paincols{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}

.paincol{
  background:#10212c;
  border-radius:9px;
  padding:10px;
}

.paincol label{
  font-size:12px;
  color:#b3c9d0;
}

.paincol input{
  width:100%;
}

.paincol .number{
  width:66px;
}

.dot{
  display:inline-block;
  width:14px;
  height:14px;
  border-radius:50%;
  vertical-align:middle;
  margin-right:5px;
}

.dot.green{
  background:#27b86b;
}

.dot.yellow{
  background:#e8c43a;
}

.dot.red{
  background:#e55355;
}

.dot.gray{
  background:#78858a;
}

.note{
  border-left:3px solid #58a89a;
  padding:9px 12px;
  background:#19333a;
  font-size:13px;
}

.smalltext{
  font-size:12px;
  color:#adc2c9;
}

.viewgrid{
  display:grid;
  grid-template-columns:repeat(var(--cols),minmax(0,1fr));
  gap:8px;
  height:100%;
}

.viewgrid .viewport{
  position:relative;
  border:1px solid #41525b;
}

.danger{
  background:#65303c;
}

.status{
  font-size:11px;
  color:#b8c7c9;
}

a{
  color:#9ce1d4;
}

/* TABLETS */

@media(max-width:1100px){

  header{
    padding:6px 10px;
    gap:6px;
  }

  header b{
    font-size:14px;
  }

  header small{
    font-size:10px;
  }

  .nav{
    padding:5px 7px;
    gap:4px;
  }

  .nav button{
    font-size:11px;
    padding:6px 8px;
  }

  .editor{
    grid-template-columns:104px minmax(0,1fr) 104px;
  }

  .editor.leftclosed{
    grid-template-columns:0 minmax(0,1fr) 104px;
  }

  .editor.rightclosed{
    grid-template-columns:104px minmax(0,1fr) 0;
  }

  .editor.leftclosed.rightclosed{
    grid-template-columns:0 minmax(0,1fr) 0;
  }

  .panelhead{
    padding:7px 4px;
    font-size:11px;
  }

  .tools{
    grid-template-columns:minmax(0,1fr);
    padding:5px;
    gap:5px;
  }

  .tool{
    min-height:65px;
    padding:4px;
  }

  .tool img{
    height:42px;
  }

  .tool span{
    font-size:9px;
  }

  .edtop,
  .edbottom{
    gap:4px;
    padding:5px;
  }

  .edtop button,
  .edbottom button{
    font-size:11px;
    padding:6px;
  }

  .edtop select{
    font-size:12px;
    padding:6px;
    max-width:100%;
  }

  .edbottom{
    max-height:36%;
  }

  .edbottom input[type=range]{
    max-width:75px;
  }

  .paincols{
    grid-template-columns:1fr;
  }

  #rxLoupe{
    max-width:calc(100vw - 20px);
    max-height:75dvh;
    overflow:auto;
  }

  #rxLoupeCanvas{
    max-width:65vw!important;
    height:auto;
  }
}

/* TELÉFONOS Y TABLETS PEQUEÑAS */

@media(max-width:600px){

  header small{
    display:none;
  }

  .nav{
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
    touch-action:pan-x;
  }

  .nav button{
    white-space:nowrap;
    flex-shrink:0;
  }

  .editor{
    grid-template-columns:76px minmax(0,1fr) 76px;
  }

  .editor.leftclosed{
    grid-template-columns:0 minmax(0,1fr) 76px;
  }

  .editor.rightclosed{
    grid-template-columns:76px minmax(0,1fr) 0;
  }

  .editor.leftclosed.rightclosed{
    grid-template-columns:0 minmax(0,1fr) 0;
  }

  .panelhead{
    font-size:9px;
    padding:5px 2px;
  }

  .tools{
    padding:3px;
    gap:4px;
  }

  .tool{
    min-height:55px;
    padding:2px;
  }

  .tool img{
    height:34px;
  }

  .tool span{
    font-size:8px;
  }

  .edtop{
    max-height:28%;
  }

  .edbottom{
    max-height:40%;
  }

  .edtop button,
  .edbottom button{
    font-size:10px;
    padding:5px;
  }

  .edbottom input[type=range]{
    max-width:65px;
  }

  .drawer{
    font-size:11px;
  }

  #rxLoupeCanvas{
    max-width:75vw!important;
  }
}

/* PANTALLAS DE POCA ALTURA */

@media(max-height:650px){

  header{
    padding-top:4px;
    padding-bottom:4px;
  }

  .nav{
    padding-top:3px;
    padding-bottom:3px;
  }

  .edtop{
    max-height:28%;
  }

  .edbottom{
    max-height:40%;
  }
}


/* BODYDENT V4 - PRESENTACION; sin alterar coordenadas de RX */
#editor .edtop{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;max-height:none;min-height:44px;padding-right:104px;touch-action:pan-x;scrollbar-width:thin}
#editor .edtop #bdTopTools{display:flex;align-items:center;gap:5px;flex:0 0 auto;margin-left:auto;white-space:nowrap}
#bdTopTools .bd-icon{min-width:36px;font-size:18px;padding:5px}
#bdTopTools .ruler img{height:22px;max-width:90px;object-fit:contain}
#bdTopTools button:disabled{opacity:.55}
#editor .middle{position:relative}
#editor #rxToggleTop{right:4px!important;top:4px!important;z-index:810!important}
#editor .edtop.rx-collapsed{min-height:0!important}
#bdTopTools.bd-collapsed{display:none!important}
#bdClinicalTools{display:flex;flex:0 0 auto;align-items:center;gap:7px;flex-wrap:wrap;background:#132c38;border-top:1px solid #3e5664;padding:5px 8px;min-height:37px}
#bdClinicalTools button{font-size:11px;padding:5px 8px}
#bdColorDots{display:inline-flex;gap:9px;align-items:center}
#bdClinicalTools .bdColorDot{width:23px;height:23px;min-width:23px;padding:0;border:1.5px solid white;border-radius:50%;opacity:1}
#bdClinicalTools .bdColorDot.red{background:#f32e3b}
#bdClinicalTools .bdColorDot.green{background:#19d954}
#bdClinicalTools .bdColorDot.yellow{background:#ffdc26}
#bdClinicalTools .bdColorDot.active{outline:2px solid #fff;outline-offset:2px}
#bdHelpBtn{min-width:32px;font-size:19px;font-weight:700;padding:4px 8px}
#bdHelp,#bdLayers{position:fixed;display:none;z-index:2500;background:#112a35;color:#fff;border:1px solid #558b96;border-radius:10px;padding:12px;box-shadow:0 12px 30px #0009}
#bdHelp.open,#bdLayers.open{display:block}
#bdHelp{right:12px;top:50px;width:min(410px,calc(100vw - 24px));max-height:75vh;overflow:auto}
#bdHelpClose{float:right}
#bdHelp li{margin:7px 0}
#bdLayers{width:235px;max-width:calc(100vw - 16px)}
#bdLayersHead{display:flex;align-items:center;justify-content:space-between;cursor:move;touch-action:none;border-bottom:1px solid #486674;padding-bottom:7px;margin-bottom:7px}
#bdLayers label{display:flex;align-items:center;gap:8px;font-size:12px;margin:8px 0}
#bdLayers input{width:15px;height:15px}
#editor .bd-rx-point.selected{outline:2px solid #ffe59b;outline-offset:2px}
@media(max-width:1100px){.editor{grid-template-columns:105px minmax(0,1fr) 105px}.editor.leftclosed{grid-template-columns:0 minmax(0,1fr) 105px}.editor.rightclosed{grid-template-columns:105px minmax(0,1fr) 0}#editor .edtop{padding:4px 94px 4px 5px}#editor .edtop button,#editor .edtop select{font-size:10px;padding:5px}#bdTopTools button{font-size:10px}#bdClinicalTools{gap:5px;padding:4px}#bdClinicalTools button{font-size:10px;padding:5px}#editor .tools{gap:3px;padding:3px}#editor .tool{min-height:60px;padding:3px}#editor .tool img{height:35px}#editor .tool span{font-size:8px}}