/* Shared responsive shell. No API or business-logic changes. */
.theme-reference .admin-main { position: relative; max-width: 100%; }
.theme-reference .admin-sidebar { height: 100dvh; overflow-y: auto; overscroll-behavior: contain; z-index: 50; }
.theme-reference .admin-topbar { min-width: 0; }
.theme-reference .page-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.theme-reference .page-title { overflow-wrap: anywhere; }
.theme-reference .page-subtitle { flex-basis: 100%; margin: 0; }
.theme-reference.login-page { min-height: 100dvh; padding: 20px 12px; }
.theme-reference .login-card { width: 100%; max-width: 420px; padding: clamp(20px,5vw,36px); }
.theme-reference .login-card h1 { font-size: clamp(22px,5vw,28px); overflow-wrap: anywhere; }
.theme-reference :is(.admin-card,.table-wrapper,.support-main,.chats-main,.support-sidebar,.chats-sidebar) { min-width: 0; }
.theme-reference :is(.table-wrapper,.responsive-table) { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.theme-reference .responsive-table:focus-visible { outline-offset: -3px; }
.theme-reference .admin-table { width: 100%; }
.theme-reference .admin-table :is(td,th) { overflow-wrap: anywhere; }
.theme-reference :is(input,select,textarea) { max-width: 100%; min-width: 0; }
.theme-reference :is(img,video) { max-width: 100%; }
.theme-reference pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.theme-reference :is(.btn-group,.db-toolbar,.chat-header-actions) { flex-wrap: wrap; gap: 8px; }
.theme-reference .support-shell,.theme-reference .chats-layout { grid-template-columns: minmax(240px,30%) minmax(0,1fr); height: calc(100dvh - 210px); min-height: 440px!important; }
.theme-reference :is(.support-messages,.chat-messages) { max-height: none; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.theme-reference :is(.support-chat-list,.chats-list) { min-height: 0; overflow-y: auto; max-height: none; }
.theme-reference #chatPanel { min-height: 0; }
.theme-reference :is(.support-composer,.chat-input-row) { flex-wrap: nowrap; align-items: center; }
.theme-reference :is(.support-input,.chat-input-row .form-control) { min-width: 0; flex: 1 1 0; }
.sidebar-backdrop[hidden],.mobile-chat-back { display: none; }
.mobile-menu-close { display: none; }
.theme-reference :is(.admin-card,.alert-admin,.ref-row,.support-panel-contact,.support-panel-context) { overflow-wrap: anywhere; }
.theme-reference textarea { resize: vertical; }
.theme-reference :is(button,a,input,select,textarea) { touch-action: manipulation; }
.theme-reference button:disabled { cursor: not-allowed; }
.theme-reference .promo-card > :last-child { flex-wrap: wrap; }
.theme-reference :is(.support-msg,.chat-msg) { white-space: normal; }
.theme-reference :is(.support-msg-text,.msg-text) { white-space: pre-wrap; }
@media(max-width:1100px) {
  .theme-reference .admin-main { padding-left: 18px; padding-right: 18px; }
  .theme-reference :is(.stats-grid,.stats-grid-dashboard) { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media(max-width:800px) {
  .mobile-menu-close { display: block; position: absolute; right: 8px; top: 8px; width: 44px; border: 0; border-radius: 8px; background: #31485f; color: white; font-size: 26px; cursor: pointer; }
  .theme-reference .admin-main,.theme-reference.sidebar-collapsed .admin-main { margin-left: 0; width: 100%; padding: 80px 12px 20px; }
  .theme-reference .admin-sidebar,.theme-reference.sidebar-collapsed .admin-sidebar { width: min(290px,85vw); transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility .2s; }
  .theme-reference.sidebar-open .admin-sidebar { transform: translateX(0); visibility: visible; }
  .theme-reference.sidebar-open { overflow: hidden; }
  .theme-reference .admin-sidebar :is(.nav-text,.nav-group,.brand-text) { display: block!important; }
  .theme-reference .admin-sidebar-brand { margin: 0 20px; }
  .theme-reference .admin-sidebar-nav a { min-height: 46px; }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 40; border: 0; background: #101b3680; }
  .theme-reference .admin-topbar { height: 64px; padding: 0 12px; gap: 10px; }
  .admin-breadcrumb { min-width: 0; gap: 8px; }
  #currentPageLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-profile strong,.admin-profile small { display: none; }
  .theme-reference .page-title { font-size: 24px; }
  .theme-reference :is(button,.btn-admin,.btn-outline-admin,select) { min-height: 44px; }
  .theme-reference :is(input,select,textarea) { font-size: 16px; }
  .theme-reference .admin-card { padding: 14px; }
  .theme-reference .admin-table { min-width: 640px; }
  .theme-reference .db-toolbar-select { min-width: 0; max-width: none; width: 100%; }
  .theme-reference :is(.support-shell,.chats-layout) { display: flex; flex-direction: column; height: var(--chat-available-height,calc(100dvh - 220px)); min-height: 240px!important; gap: 0; }
  .theme-reference .support-page .page-subtitle { display: none; }
  .theme-reference :is(.support-sidebar,.chats-sidebar) { flex: 1; min-height: 0; max-height: none; }
  .theme-reference :is(.support-main,.chats-main) { display: none; min-height: 0; flex: 1; }
  .theme-reference .chat-detail-open :is(.support-sidebar,.chats-sidebar) { display: none; }
  .theme-reference .chat-detail-open :is(.support-main,.chats-main) { display: flex; }
  .mobile-chat-back { display: block; align-self: flex-start; border: 0; background: transparent; color: var(--accent); padding: 10px 14px; font: inherit; cursor: pointer; }
  .theme-reference :is(.support-panel-header,.chat-header-row) { padding: 10px; flex-wrap: wrap; }
  .theme-reference :is(.support-messages,.chat-messages) { padding: 12px; }
  .theme-reference :is(.support-msg,.chat-msg) { max-width: 90%; }
  .theme-reference :is(.support-composer,.chat-input-row) { padding: 8px; gap: 6px; flex-wrap: wrap; padding-bottom: max(8px,env(safe-area-inset-bottom)); }
  .theme-reference :is(.support-input,.chat-input-row .form-control) { flex-basis: 55%; }
  .theme-reference .page-header :is(input,select) { max-width: 100%!important; flex: 1 1 150px; }
  .theme-reference .page-header > :is(input,select) { flex-basis: 100%; width: 100%; }
  .theme-reference .page-header > div { width: 100%; min-width: 0; }
  .theme-reference .ref-row,.theme-reference .ref-tag { overflow-wrap: anywhere; }
  .theme-reference :is(.modal-content,.modal-admin) { max-width: calc(100vw - 24px); max-height: 90dvh; overflow-y: auto; }
}
@media(max-width:600px) {
  .theme-reference .admin-table.mobile-records { min-width: 0; display: block; }
  .theme-reference .mobile-records thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .theme-reference .mobile-records tbody { display: block; }
  .theme-reference .mobile-records tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--card-border); }
  .theme-reference .mobile-records tr:last-child { border-bottom: 0; }
  .theme-reference .mobile-records td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 8px 2px; border: 0; text-align: right!important; min-width: 0; }
  .theme-reference .mobile-records td::before { content: attr(data-label); color: var(--text-muted); font-weight: 500; text-align: left; flex: 0 0 32%; }
  .theme-reference .mobile-records td[colspan] { display: block; text-align: center!important; }
  .theme-reference .mobile-records td[colspan]::before { display: none; }
  .theme-reference .mobile-records td > * { min-width: 0; overflow-wrap: anywhere; }
  .theme-reference .promo-card > :last-child { flex: 1 1 100%; }
  .theme-reference .promo-card > :last-child button { flex: 1; }
  .theme-reference :is(.support-panel-header,.chat-header-row) { gap: 8px; }
  .theme-reference :is(.support-panel-actions,.chat-header-actions) { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
  .theme-reference :is(.support-composer,.chat-input-row) { flex-wrap: nowrap; }
  .theme-reference :is(.support-composer,.chat-input-row) #btnSend { flex: 0 0 44px; width: 44px; padding: 0; font-size: 0; }
  .theme-reference :is(.support-composer,.chat-input-row) #btnSend::after { content: '↑'; font-size: 24px; }
  .theme-reference :is(.support-composer,.chat-input-row) #btnAttach { flex: 0 0 44px; width: 44px; padding: 0; font-size: 0; }
  .theme-reference :is(.support-composer,.chat-input-row) #btnAttach::after { content: '+'; font-size: 24px; }
}
@media(max-width:380px) {
  .theme-reference :is(.stats-grid,.stats-grid-dashboard) { grid-template-columns: 1fr; }
  .admin-breadcrumb > a,.admin-breadcrumb > span:first-of-type { display: none; }
}
@media(prefers-reduced-motion:reduce) {
  .theme-reference .admin-sidebar { transition: none; }
}
@media(max-height:600px) {
  .theme-reference.login-page { align-items: flex-start; }
  .theme-reference :is(.support-shell,.chats-layout) { min-height: 240px!important; }
}
