/* Browser-QA responsive shell.
   The packaged Electron app keeps its desktop minimum window. These rules only
   activate when the Vercel QA bootstrap marks the document as browser QA. */

@media (max-width: 980px) {
  html[data-kirchhoff-browser-qa="true"],
  html[data-kirchhoff-browser-qa="true"] body {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  html[data-kirchhoff-browser-qa="true"] #kd-app {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-main {
    grid-column: 1;
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    height: 100dvh;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1300;
    width: min(330px, 86vw);
    max-width: 86vw;
    height: 100dvh;
    transform: translateX(0);
    transition: transform 180ms ease, box-shadow 180ms ease;
    box-shadow: 12px 0 32px rgba(15, 23, 42, 0.22);
    padding-left: env(safe-area-inset-left);
  }

  html[data-kirchhoff-browser-qa="true"] #kd-app.kd-sidebar-collapsed .kd-sidebar {
    transform: translateX(-102%);
    box-shadow: none;
  }

  /* The desktop collapsed-rail rules hide labels. In narrow QA mode the rail
     becomes a drawer instead, so labels stay intact whenever the drawer is open. */
  html[data-kirchhoff-browser-qa="true"] #kd-app:not(.kd-sidebar-collapsed) .kd-brand-text,
  html[data-kirchhoff-browser-qa="true"] #kd-app:not(.kd-sidebar-collapsed) .kd-nav-label,
  html[data-kirchhoff-browser-qa="true"] #kd-app:not(.kd-sidebar-collapsed) .kd-nav-label-text,
  html[data-kirchhoff-browser-qa="true"] #kd-app:not(.kd-sidebar-collapsed) .kd-nav-count,
  html[data-kirchhoff-browser-qa="true"] #kd-app:not(.kd-sidebar-collapsed) .kd-sidebar-footer-text {
    display: initial;
  }

  html[data-kirchhoff-browser-qa="true"] #kd-app:not(.kd-sidebar-collapsed) .kd-nav-item {
    justify-content: flex-start;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 1200;
    border: 0;
    margin: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
  }

  html[data-kirchhoff-browser-qa="true"] #kd-app.kd-sidebar-collapsed .kd-nav-scrim {
    display: none;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-sidebar-brand {
    min-height: 50px;
    padding-right: 12px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-sidebar-footer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 50px;
    padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    gap: 6px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-title h1 {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-search {
    flex: 0 0 34px;
    width: 34px;
    min-width: 34px;
    height: 32px;
    margin: 0;
    padding: 0;
    justify-content: center;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-search > span,
  html[data-kirchhoff-browser-qa="true"] .kd-topbar-search > kbd,
  html[data-kirchhoff-browser-qa="true"] #kd-shortcuts-btn {
    display: none;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-actions {
    flex: 0 0 auto;
    gap: 4px;
    margin-left: 0;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-collapse-btn,
  html[data-kirchhoff-browser-qa="true"] .kd-topbar .kd-btn-icon,
  html[data-kirchhoff-browser-qa="true"] #kd-quick-add {
    min-width: 34px;
    height: 32px;
  }

  html[data-kirchhoff-browser-qa="true"] #kd-app.kd-sidebar-collapsed .kd-collapse-btn svg {
    transform: rotate(180deg);
  }

  html[data-kirchhoff-browser-qa="true"] .kd-enterprise-centers {
    height: 34px;
    padding-left: max(0px, env(safe-area-inset-left));
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-enterprise-centers::-webkit-scrollbar {
    display: none;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-enterprise-center-tab {
    flex: 0 0 auto;
    padding: 0 10px;
    scroll-snap-align: start;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-enterprise-role {
    display: none;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-content {
    padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-page {
    gap: 10px;
    max-width: none;
    width: 100%;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-page-header,
  html[data-kirchhoff-browser-qa="true"] .kd-erp-record-header {
    padding: 9px 10px;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr);
  }

  html[data-kirchhoff-browser-qa="true"] .kd-page-header h2,
  html[data-kirchhoff-browser-qa="true"] .kd-erp-record-title {
    font-size: 17px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-page-header p {
    max-width: none;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-card-pad,
  html[data-kirchhoff-browser-qa="true"] .kd-card-body {
    padding: 10px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-card-header {
    padding: 7px 9px;
    flex-wrap: wrap;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-table-wrap,
  html[data-kirchhoff-browser-qa="true"] .kd-scroll-x,
  html[data-kirchhoff-browser-qa="true"] .kd-erp-subtabs,
  html[data-kirchhoff-browser-qa="true"] .kd-tabs {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-table {
    width: max-content;
    min-width: 100%;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-kanban {
    grid-auto-columns: minmax(265px, 82vw);
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-kanban-col {
    scroll-snap-align: start;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-modal {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  html[data-kirchhoff-browser-qa="true"] .kd-overlay {
    padding: 10px;
    align-items: center;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-palette-box {
    max-width: calc(100vw - 20px);
  }

  html[data-kirchhoff-browser-qa="true"] #kd-toasts {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  html[data-kirchhoff-browser-qa="true"] .kd-toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  /* Keep the QA disclosure visible without covering a meaningful strip of the
     application on small devices. */
  html[data-kirchhoff-browser-qa="true"] #kd-browser-qa-banner {
    left: auto !important;
    right: max(8px, env(safe-area-inset-right)) !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    max-width: 190px !important;
    padding: 5px 7px !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: .92;
  }
}

@media (max-width: 640px) {
  html[data-kirchhoff-browser-qa="true"] .kd-sidebar {
    width: min(310px, 90vw);
    max-width: 90vw;
  }

  html[data-kirchhoff-browser-qa="true"] #kd-quick-add {
    width: 34px;
    padding: 0;
    font-size: 0;
  }

  html[data-kirchhoff-browser-qa="true"] #kd-quick-add svg {
    width: 16px;
    height: 16px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-title h1 {
    font-size: 13px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-content {
    padding-top: 8px;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-page-actions,
  html[data-kirchhoff-browser-qa="true"] .kd-erp-toolbar {
    width: 100%;
    flex-wrap: wrap;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-page-actions > .kd-btn,
  html[data-kirchhoff-browser-qa="true"] .kd-erp-toolbar > .kd-btn {
    min-height: 32px;
  }
}

@media (max-width: 520px) {
  html[data-kirchhoff-browser-qa="true"] .kd-topbar-title {
    display: none;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-topbar-search {
    margin-left: auto;
  }

  html[data-kirchhoff-browser-qa="true"] .kd-enterprise-center-tab {
    padding: 0 9px;
    font-size: 11px;
  }
}
