/* Clinic data tables: one visual contract. Keep column widths, alignment,
   statuses and mobile card layouts owned by their functional modules. */
:root{
  --page-table-head-color:#176fc1;
  --clinic-table-line:#dce5ec;
  --clinic-table-ink:#26384a;
  --clinic-table-muted:#607080;
  --clinic-table-hover:#f1f6fb;
}
#page-lab-orders{--page-table-head-color:#087868;--clinic-table-hover:#edf8f5}
#page-supplies{--page-table-head-color:#b75a3c;--clinic-table-hover:#fbefea}
/* Keep the shell's default content width in both sidebar states. */
@media screen{
  /* Explicit page IDs give this final contract priority over legacy page rules.
     .page also covers pages mounted later by a module. */
  :is(#screen-app.screen,.clinic-table-scope) :is(#page-patients.page,#page-service-orders,#page-lab-orders,
    #page-supplies,#page-cuentas-cobro,#page-referrals,#page-liquidacion,
    #page-radiology-orders,#page-equipment,#page-waste,#page-connections,
    #page-convenios,#page-clinical-codes,#page-settings,#page-dashboard,.page,
    .clinic-table-content,.modal,.modal-box,.modal-card){
    & table:where(:not(.stitch-directory-table)):has(>thead){
      background:var(--clinic-table-body,#fff)!important;
      border-collapse:separate!important;border-spacing:0!important;
      font-family:Roboto,Arial,sans-serif!important;
      border-top-left-radius:0!important;border-top-right-radius:0!important;
    }
    & table:where(:not(.stitch-directory-table))>thead,
    & table:where(:not(.stitch-directory-table))>thead>tr{border-radius:0!important;background:var(--page-table-head-color)!important;box-shadow:none!important}
    & table:where(:not(.stitch-directory-table))>thead>tr>:is(th,td){
      box-sizing:border-box!important;height:44px!important;
      padding:10px 12px!important;
      background:var(--page-table-head-color)!important;background-image:none!important;
      color:#fff!important;font:700 12px/1.35 Roboto,Arial,sans-serif!important;
      letter-spacing:.02em!important;text-transform:uppercase!important;
      border:0!important;border-radius:0!important;box-shadow:none!important;
      vertical-align:middle!important;
    }
    & table:where(:not(.stitch-directory-table))>thead>tr>:is(th,td) :is(span,b,strong,a){color:inherit!important;font:inherit!important}
    & table:where(:not(.stitch-directory-table))>thead>tr:first-child>:first-child{border-top-left-radius:0!important}
    & table:where(:not(.stitch-directory-table))>thead>tr:first-child>:last-child{border-top-right-radius:0!important}
    @media(min-width:769px){
      & table:where(:not(.stitch-directory-table)):has(>thead)>tbody>tr{background:var(--clinic-table-body,#fff)!important;box-shadow:none!important}
      & table:where(:not(.stitch-directory-table)):has(>thead)>tbody>tr>:is(td,th){
        height:48px;box-sizing:border-box!important;padding:10px 12px!important;
        font-family:Roboto,Arial,sans-serif!important;font-size:13px!important;line-height:1.4!important;
        border:0!important;border-bottom:1px solid var(--clinic-table-line)!important;
        border-radius:0!important;background:inherit!important;
        vertical-align:middle!important;
      }
      & table:where(:not(.stitch-directory-table)):has(>thead)>tbody>tr:hover{background:var(--clinic-table-hover)!important}
      & table:where(:not(.stitch-directory-table)):has(>thead)>tbody>tr:is(.olab-grid-group,.supply-order-group-row,.finance-record-group,.finance-record-total),
      & table:where(:not(.stitch-directory-table)):has(>thead)>tfoot>tr{background:var(--clinic-table-hover)!important;font-weight:700}
      & table:where(:not(.stitch-directory-table)):has(>thead)>tbody>tr[aria-selected="true"]{background:var(--clinic-table-hover)!important}
    }
  }
}

/* Sticky copies inherit square corners as well as the original table header. */
body>.page-table-sticky-head,
body>.page-table-sticky-head :is(table,thead,tr,th,td){border-radius:0!important}

/* A rounded scrolling wrapper must never clip a square table heading. */
#screen-app :is(.page,.modal,.modal-box,.modal-card) :has(>table>thead),
.clinic-table-scope :has(>table>thead),
#screen-app #page-referrals #remglobal-table{
 border-top-left-radius:0!important;border-top-right-radius:0!important;
}
#screen-app table>thead,#screen-app table>thead>tr,#screen-app table>thead>tr>:is(th,td){border-radius:0!important}
body>div.page-table-sticky-head,
body>div.page-table-sticky-head :is(table,thead,tr,th,td){border-radius:0!important}

/* Same opening action dimensions across the three coordination tables. */
#screen-app.screen :is(#page-radiology-orders,#page-referrals,#page-lab-orders,#page-supplies).page :is(#rad-table-host,#remglobal-table,#lab-orders-table,#orders-table) :is(.supply-open-detail,.rad-open-detail,.remission-open,.olab-row-actions .clinic-row-icon-action){
 display:inline-flex!important;align-items:center!important;justify-content:center!important;
 box-sizing:border-box!important;width:44px!important;min-width:44px!important;max-width:44px!important;
 height:44px!important;min-height:44px!important;max-height:44px!important;flex:0 0 44px!important;
 padding:0!important;border-radius:10px!important;
}
#screen-app.screen :is(#page-radiology-orders,#page-referrals,#page-lab-orders,#page-supplies).page :is(#rad-table-host,#remglobal-table,#lab-orders-table,#orders-table) :is(.supply-open-detail,.rad-open-detail,.remission-open,.olab-row-actions .clinic-row-icon-action) svg{
 width:20px!important;min-width:20px!important;max-width:20px!important;height:20px!important;
 flex:none!important;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;
}

/* Supply purchases use the same compact coordination-table layout. */
#screen-app.screen #page-supplies.page #orders-table .supply-orders-table th{border-radius:0!important;text-align:center!important;font:700 14px/1.3 Roboto,Arial,sans-serif!important;white-space:normal!important;overflow-wrap:anywhere;letter-spacing:0!important;padding:10px 6px!important;overflow:visible!important;text-overflow:clip!important}
#screen-app.screen #page-supplies.page #orders-table .supply-order-main-row :is(td,strong,time){font-family:Roboto,Arial,sans-serif!important;font-size:14px!important;line-height:1.35!important}
#screen-app.screen #page-supplies.page #orders-table .supply-order-main-row small{font-size:12px!important}
#screen-app.screen #page-supplies.page #orders-table .supply-list-stage{display:flex!important;align-items:center!important;justify-content:flex-start!important;gap:8px!important;background:#e7f5fb;color:#176a8c;border:0!important;border-radius:12px!important;padding:8px!important;min-width:0!important;width:100%!important;max-width:100%!important;min-height:54px!important;box-sizing:border-box;text-align:left!important}
#screen-app.screen #page-supplies.page #orders-table .supply-list-stage::before{content:'';width:6px;height:6px;flex:0 0 6px;border-radius:50%;background:currentColor}
#screen-app.screen #page-supplies.page #orders-table .supply-stage-copy{display:flex;flex-direction:column;gap:4px;min-width:0}
#screen-app.screen #page-supplies.page #orders-table .supply-list-stage :is(strong,time){color:inherit!important;max-width:none!important;text-align:left!important;white-space:normal!important}
#screen-app.screen #page-supplies.page #orders-table .supply-list-stage time{display:block!important;font-size:12px!important}
#screen-app.screen #page-supplies.page #orders-table :is(.supply-list-stage-borrador,.supply-list-stage-en_revision){background:#fff4dd!important;color:#a06009!important}
#screen-app.screen #page-supplies.page #orders-table :is(.supply-list-stage-en_camino,.supply-list-stage-listo_despacho){background:#eeeafb!important;color:#5f49aa!important}
#screen-app.screen #page-supplies.page #orders-table :is(.supply-list-stage-completo,.supply-list-stage-pagado){background:#e7f7ef!important;color:#1b7550!important}
#screen-app.screen #page-supplies.page #orders-table :is(.supply-list-stage-cancelado,.supply-list-stage-inconsistencia){background:#fdecef!important;color:#b72f40!important}
@media(min-width:769px){
 #screen-app.screen #page-supplies.page #orders-table .supply-orders-table{width:100%!important;min-width:0!important;max-width:100%!important;table-layout:fixed!important}
 #screen-app.screen #page-supplies.page #orders-table .supply-orders-table :is(th,td){min-width:0!important;height:auto!important;padding:8px 6px!important;white-space:normal!important;overflow-wrap:anywhere}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(1){width:14%!important}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(2){width:16%!important}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(3){width:11%!important}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(4){width:23%!important}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(5){width:10%!important}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(6){width:17%!important}
 #screen-app.screen #page-supplies.page #orders-table th:nth-child(7){width:9%!important;white-space:nowrap!important;overflow-wrap:normal!important}
}

#screen-app.screen #page-supplies.page #orders-table .clinic-supply-date{display:block!important;white-space:normal!important;overflow-wrap:normal!important;max-width:100%!important}
#screen-app.screen #page-supplies.page #orders-table .clinic-supply-products{max-width:100%!important;min-width:0!important}
@media(min-width:769px){
 #screen-app.screen #page-supplies.page #orders-table .supply-order-main-row>td:nth-child(3){text-align:center!important;padding-right:12px!important}
 #screen-app.screen #page-supplies.page #orders-table .supply-order-main-row>td:nth-child(4){padding-left:12px!important}
}
