/* Shared viewport and interaction constraints. Business fields are untouched. */
:root { --ux-layer-menu: 1100; --ux-layer-drawer: 1200; }
html { scrollbar-gutter: stable; }
.app-main, .app-content, .app-content > *, .page-heading > *, .heading-actions,
.form-grid > *, .payment-info-grid > *, .device-details-grid > * { min-width: 0; }
.app-content :where(input:not([type=checkbox]):not([type=radio]), select, textarea) { max-width: 100%; box-sizing: border-box; }
.app-content :where(p, h1, h2, h3, strong, dd, .notice, .flash) { overflow-wrap: anywhere; }
.heading-actions, .actions-row, .section-title { flex-wrap: wrap; }
.heading-actions > .btn { white-space: normal; max-width: 100%; }
:where(button, a.btn, input[type=submit], summary):focus-visible { outline: 3px solid #78baff; outline-offset: 3px; }
.ux-table-scroll { max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.ux-table-scroll:focus-visible { outline: 3px solid #78baff; outline-offset: 2px; }
.ux-table-scroll .ux-actions-cell { position: sticky; right: 0; z-index: 2; background: #fff; box-shadow: -3px 0 5px #244c8b0a; }
.ux-table-scroll th.ux-actions-cell { z-index: 3; background: #f1f6fd; }
.hnav-menu { max-width: calc(100vw - 24px); overscroll-behavior: contain; z-index: var(--ux-layer-menu); }
.hnav-navigation.is-open { overscroll-behavior: contain; z-index: var(--ux-layer-drawer); }
.hnav-mobile-heading { position: sticky; top: -20px; z-index: 2; background: #fff; padding-block: 8px; flex-shrink: 0; }
.hnav-search-panel { max-height: calc(100dvh - 96px); overflow-y: auto; overscroll-behavior: contain; }
html.ux-overlay-open, html.ux-overlay-open body { overflow: hidden !important; }
dialog.ux-dialog { box-sizing: border-box; max-width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px) !important; overscroll-behavior: contain; }
dialog.ux-dialog[open] { display: flex; flex-direction: column; overflow-y: auto; }
dialog.ux-dialog > :is(header, .cc-modal-header) { flex: 0 0 auto; min-width: 0; position: sticky; top: 0; z-index: 4; background: #fff; }
dialog.ux-dialog > :is(header, .cc-modal-header) > div { min-width: 0; }
dialog.ux-dialog :is(h1,h2,h3,p) { overflow-wrap: anywhere; }
dialog.ux-dialog > :is([id$="-body"], #jr-body, #pn-body, .cc-modal-body) { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
dialog.ux-dialog > footer { flex: 0 0 auto; position: sticky; bottom: 0; z-index: 4; background: #fff; display: flex; flex-wrap: wrap; gap: 8px; }
dialog.ux-dialog :is(input, select, textarea, iframe) { box-sizing: border-box; max-width: 100%; min-width: 0; }
dialog.ux-dialog :is(button, .btn) { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
dialog.ux-dialog > header button, .cc-modal-x { flex-shrink: 0; }
dialog.ux-dialog::backdrop { background: #122d5266; }
@media (max-width: 800px) {
  .app-content :where(button, a.btn, input[type=submit], summary) { min-height: 40px; }
  .ux-actions-cell :is(button, a.btn) { min-height: 40px; }
  dialog.ux-dialog { margin: auto; width: calc(100vw - 16px) !important; border-radius: 12px; }
  dialog.ux-dialog > :is(header, .cc-modal-header) { padding: 12px !important; gap: 10px !important; }
  dialog.ux-dialog > :is([id$="-body"], #jr-body, #pn-body, .cc-modal-body) { padding: 12px; }
  dialog.ux-dialog > footer { padding: 10px 12px !important; }
  dialog.ux-dialog > :is(header, .cc-modal-header) button { min-width: 40px; min-height: 40px; }
  .heading-actions { width: 100%; gap: 8px; }
  .heading-actions > :is(a,button,span) { flex: 1 1 150px; text-align: center; }
  .payment-info-grid, .compact-info-grid, .device-details-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .sc .subscription-actions { min-width: 100px; }
}
@media (max-width: 430px) {
  .hnav-shell .app-content { padding: 10px; }
  .hnav-shell .app-content > :is(.cc,.sc,.ai,.rs,.rt,.py,.cl,.dc,.pn,.st,.us,.jr) { min-width: 0; width: 100%; box-sizing: border-box; }
  .sc .subscriptions-filters, .sc .advanced-filters-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .sc .subscriptions-filters > *, .sc .subscriptions-filters > input[type=search] { grid-column: 1 / -1 !important; grid-row: auto !important; max-width: 100%; }
  .sc .cc-header, .ai .cc-header { padding: 18px 14px; }
  .sc-kpi { padding: 12px 8px; gap: 7px; }
  .sc-kpi strong { font-size: 23px; }
  .cc-header, .page-heading { min-width: 0; }
  .cc-modal-header h2, #ai-modal-title { font-size: 19px !important; }
  .form-grid, .register-filters, .payment-form-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > *, .register-filters > * { max-width: 100%; }
  .se-actions { flex-wrap: wrap; }
  .se-actions button { flex: 1; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  dialog, .hnav-menu { scroll-behavior: auto; animation: none; }
}
@media (max-width: 360px) {
  .app-topbar.hnav { padding-inline: 8px; gap: 4px; }
  .hnav-brand { flex: 1 1 90px; min-width: 0; gap: 5px; }
  .hnav-brand > span:last-child { min-width: 0; }
  .hnav-brand strong { font-size: 10px; overflow-wrap: anywhere; }
  .hnav-brand small { display: none; }
  .hnav-mark { width: 29px; height: 34px; flex-shrink: 0; }
  .hnav-icon, .hnav-user, .hnav-search-wrap { flex-shrink: 0; }
}
@media (max-width: 600px) {
  .ae-tabs, .dc-tabs, .st-tabs, .dq-tabs { flex-wrap: wrap; white-space: normal; overflow: visible; }
  .ae-tabs > button, .dc-tabs > button, .st-tabs > button, .dq-tabs > button { flex: 1 1 auto; white-space: normal; }
  .rs-kpis .stat-card { min-width: 0; }
  .rs-kpis .stat-card > div { min-width: 0; }
  .rs-kpis strong { white-space: normal !important; overflow-wrap: anywhere; font-size: clamp(18px,5vw,25px); }
}
@media (max-width: 1100px) {
  .st-tabs { flex-wrap: wrap; white-space: normal; overflow: visible; }
  .st-tabs > button { flex: 1 1 auto; white-space: normal; }
}
@media (max-width: 800px) {
  .app-content :where(button, a.btn, input[type=submit]) {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
    min-width: 0;
    height: auto;
  }
  .actions-row > * { min-width: 0; max-width: 100%; }
}
/* Intrinsic widths of imported notes must not expand a nested test form grid. */
.form.iptv-test-form { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.form.iptv-test-form > * { min-width: 0; max-width: 100%; }
.form.iptv-test-form .form-grid { min-width: 0; }
@media (max-width: 800px) {
  .panel-offers-table .compact-offer-form {
    min-width: 0;
    width: min(240px, calc(100vw - 64px));
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 800px) {
  #rs-period { white-space: normal; overflow-wrap: anywhere; height: auto; min-height: 40px; }
}
/* Keep history metadata from imposing its intrinsic JSON width on forms. */
.client-history-item, .client-history-item > * { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .iptv-test-form .device-row { grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
  .iptv-test-form .device-rows { min-width: 0; }
}
@media (max-width: 600px) {
  .iptv-test-form .device-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .sc .subscription-actions .sc-action-btn { min-width: 100px; width: 100px; white-space: nowrap; }
}
@media (max-width: 800px) {
  .rs #rs-period { white-space: normal !important; height: auto !important; min-height: 40px; }
}
@media (max-width: 800px) {
  .cl .cl-top-actions :is(button,a) { white-space: normal !important; height: auto; }
}
@media (max-width: 800px) {
  .cl #cl-reconcile-all { white-space: normal !important; height: auto; }
}
.client-history-item { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.client-history-item > .btn { width: auto; justify-self: start; }
@media (max-height: 900px) {
  .ca .subscription-live-summary { position: static; }
}
.ai-aside .ai-quick { width: 100%; max-width: 100%; min-width: 0; height: auto; min-height: 50px; white-space: normal; flex-wrap: wrap; }
.ai-aside .ai-quick > span { flex: 1 1 120px; min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 1151px) {
  .ai-aside { grid-template-columns: minmax(0, 1fr) !important; }
}
