/* Clinic v4.7.1 — UI Stabilization
   Presentation-only layer. No booking/payment/ownership/business logic. */

:root{
  --ux471-safe-bottom:max(10px,env(safe-area-inset-bottom));
  --ux471-line:rgba(148,163,184,.26);
  --ux471-muted:#64748b;
  --ux471-soft:#f8fafc;
}

html{max-width:100%;overflow-x:hidden}
@supports(overflow:clip){html{overflow-x:clip}}
body.admin-body,body.secretary-body,body.public-shell{max-width:100%;min-width:0;overflow-x:hidden}
@supports(overflow:clip){body.admin-body,body.secretary-body,body.public-shell{overflow-x:clip}}
body.admin-body *,body.secretary-body *,body.public-shell *{box-sizing:border-box}
body.admin-body :is(.admin-wrapper,.admin-content,.admin-card,.admin-table-card,.row,[class*=grid]),
body.secretary-body :is(.secretary-main,.secretary-container,.secretary-appointment-card,.registry-sheet,.registry-table-wrap,.row,[class*=grid]),
body.public-shell :is(.meet-site-main,.container,.clinic-booking-container,.booking-redesign-shell,.booking-redesign-card,.row,[class*=grid]){min-width:0}
body.admin-body :is(p,span,small,strong,a,td,th),
body.secretary-body :is(p,span,small,strong,a,td,th),
body.public-shell :is(p,span,small,strong,a){overflow-wrap:anywhere}
body.admin-body :is(button,a),body.secretary-body :is(button,a),body.public-shell :is(button,a){touch-action:manipulation}
body.admin-body :is(input,select,textarea)::placeholder,
body.secretary-body :is(input,select,textarea)::placeholder,
body.public-shell :is(input,select,textarea)::placeholder{color:#94a3b8;opacity:1}
body.admin-body label>span,body.secretary-body label>span,body.public-shell label>span{line-height:1.65}

/* Active filters make the current registry state visible without altering query semantics. */
.registry-active-filters{
  display:flex;align-items:center;gap:9px;flex-wrap:wrap;
  margin-top:10px;padding:10px 12px;border:1px solid var(--ux471-line);
  border-radius:14px;background:#fff;color:#334155;
}
.registry-active-filters__count{font-size:.72rem;font-weight:900;color:#0f172a}
.registry-active-filters__chips{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-width:0;flex:1}
.registry-active-filters__chip{
  display:inline-flex;align-items:center;min-height:28px;padding:4px 9px;border-radius:999px;
  background:#eef7f8;color:#0f6f78;font-size:.66rem;font-weight:850;white-space:nowrap;
}
.registry-active-filters__clear{font-size:.68rem;font-weight:900;text-decoration:none;white-space:nowrap}
.registry-active-filters__clear:hover{text-decoration:underline}
.registry-filter-search input[type=search]{appearance:auto;-webkit-appearance:none}
.registry-table th[aria-sort=ascending] a,.registry-table th[aria-sort=descending] a{color:#0f6f78}
.registry-table td :is(.status-badge,.badge){max-width:100%;white-space:normal}
.registry-pagination{overflow-x:auto;overscroll-behavior-inline:contain;padding-bottom:3px}
.registry-pagination .pagination{flex-wrap:wrap;gap:4px;margin-bottom:0}
.registry-empty{border:1px dashed rgba(148,163,184,.38);border-radius:16px;background:var(--ux471-soft)}

/* Stable dialogs across dynamic mobile browser chrome. */
.registry-dialog{max-width:min(760px,calc(100vw - 24px));max-height:min(88dvh,820px);overflow:hidden}
.registry-edit-form{max-height:inherit;overflow:auto;overscroll-behavior:contain}
.registry-edit-form>header,.registry-edit-form>footer{background:#fff}
.registry-edit-form>footer{position:sticky;bottom:0;z-index:2;border-top:1px solid var(--ux471-line)}

/* Notification popup: constrain to the actually visible mobile viewport. */
.internal-notification-popup-v453{max-width:calc(100vw - 20px)}
.internal-notification-popup-v453__list{min-height:0}

/* Small controls remain readable instead of becoming tiny. */
body.admin-body .btn-sm,body.secretary-body .btn-sm{min-height:38px;padding-block:7px}
body.admin-body :is(.admin-card,.admin-table-card) .table-responsive,
body.secretary-body :is(.registry-sheet,.secretary-appointment-card) .table-responsive{overscroll-behavior-inline:contain}

@media(max-width:767.98px){
  body.admin-body .admin-topbar{position:sticky;top:0;z-index:1030;padding-top:max(8px,env(safe-area-inset-top))}
  body.admin-body .admin-topbar-actions{min-width:0;flex:0 1 auto}
  body.admin-body .admin-topbar-actions>*{flex-shrink:0}
  body.admin-body .admin-content{padding-bottom:calc(28px + env(safe-area-inset-bottom))!important}
  body.admin-body .admin-sidebar{padding-bottom:calc(14px + env(safe-area-inset-bottom))}

  body.secretary-body{padding-bottom:calc(78px + env(safe-area-inset-bottom))}
  body.secretary-body .secretary-main{padding-bottom:calc(18px + env(safe-area-inset-bottom))!important}
  body.secretary-body .secretary-nav{
    min-height:68px;
    padding-bottom:max(7px,env(safe-area-inset-bottom))!important;
  }
  body.secretary-body .secretary-nav a{overflow:hidden;text-overflow:ellipsis}
  body.secretary-body .internal-notification-popup-v453{
    top:auto!important;
    right:10px!important;left:10px!important;
    bottom:calc(80px + env(safe-area-inset-bottom))!important;
    max-height:min(68dvh,560px)!important;
    width:auto!important;
  }
  body.admin-body .internal-notification-popup-v453{
    max-height:min(72dvh,620px)!important;
    width:auto!important;
  }

  .registry-active-filters{align-items:flex-start}
  .registry-active-filters__count{width:100%}
  .registry-active-filters__clear{min-height:34px;display:inline-flex;align-items:center}
  .registry-table tbody tr>td[data-label]{grid-template-columns:minmax(72px,88px) minmax(0,1fr)}
  .registry-table tbody tr>td[data-column=phone] :is(a,small){max-width:100%;overflow-wrap:anywhere}
  .registry-action-group .btn{min-width:0;overflow-wrap:anywhere}
  .registry-pagination{margin-inline:-4px;padding-inline:4px}

  .registry-dialog{
    width:100%;max-width:100%;max-height:min(92dvh,820px);
    padding-bottom:env(safe-area-inset-bottom);
  }
  .registry-edit-form{max-height:min(92dvh,820px)}
  .registry-edit-form>footer{padding-bottom:max(12px,env(safe-area-inset-bottom))}

  body.public-shell .doctor-mobile-dock.meet-mobile-dock{
    left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right));
    bottom:var(--ux471-safe-bottom);
    max-width:calc(100vw - max(16px,env(safe-area-inset-left) + env(safe-area-inset-right)));
  }
  body.public-shell .meet-site-main{min-width:0}
  body.public-shell :is(.clinic-booking-card,.booking-redesign-card,.booking-easy-panel,.patient-appointment-card){max-width:100%}
}

@media(max-width:430px){
  body.admin-body .admin-topbar{gap:6px}
  body.admin-body .admin-page-title{font-size:.92rem}
  body.admin-body .admin-topbar-actions{gap:5px}
  body.admin-body .admin-topbar-actions .btn{min-width:40px;padding-inline:8px}

  body.secretary-body .secretary-nav{grid-template-columns:repeat(4,minmax(0,1fr));gap:1px;background:#fff;backdrop-filter:none;-webkit-backdrop-filter:none}
  body.secretary-body .secretary-nav a{min-height:50px;padding-inline:2px!important;font-size:.64rem!important}
  body.secretary-body .secretary-nav a svg{width:19px;height:19px}

  .registry-filter-card{padding-inline:12px}
  .registry-active-filters{padding:9px 10px}
  .registry-active-filters__chips{gap:5px}
  .registry-active-filters__chip{font-size:.62rem}
  .registry-table tbody{padding:9px}
  .registry-table tbody tr>td[data-label]{grid-template-columns:76px minmax(0,1fr);padding-inline:10px}
}

@media(max-width:350px){
  body.secretary-body .secretary-nav a{font-size:.58rem!important}
  body.secretary-body .secretary-nav a svg{width:18px;height:18px}
  .registry-table tbody tr>td[data-label]{grid-template-columns:1fr;gap:2px}
  .registry-table tbody tr>td[data-label]::before{margin-bottom:1px}
}

@media(prefers-reduced-motion:reduce){
  body.admin-body *,body.secretary-body *,body.public-shell *{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}
}

@media(forced-colors:active){
  .registry-active-filters,.registry-active-filters__chip,.registry-empty{border:1px solid CanvasText}
  .registry-active-filters__chip{background:Canvas;color:CanvasText}
}
