/* Responsive controls extend the existing black B&S portal. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#app-shell, .main, main, main > section, .toolbar, .heading { min-width: 0; }
.mobile-topbar, .mobile-menu-close, .mobile-menu-backdrop { display: none; }
.table-wrap, .software-table-wrap { max-width: 100%; min-width: 0; -webkit-overflow-scrolling: touch; }
.start-footer { flex-wrap: wrap; }
.app-install-help { flex-basis: 100%; width: 100%; color: #bdbdbd; }
.app-install-help summary { width: fit-content; padding: 12px 0; min-height: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.app-install-help summary:hover { color: #fff; }
.app-install-help p { max-width: 650px; margin: 4px 0 12px; font-size: 13px; }
.app-install-help .app-install-note { color: #aaa; font-size: 12px; }
.app-install-help .button { margin: 0 0 12px; }
.transfer-panel { position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); z-index: 45; width: 390px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px; border: 1px solid #999; border-radius: 12px; background: linear-gradient(135deg, #292929, #101010); color: #fff; box-shadow: inset 0 1px 0 #ffffff25, 0 12px 40px #000c; }
.transfer-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px; font-weight: 650; margin: 0 0 12px; }
.transfer-name { display: block; margin: 0 0 8px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.transfer-detail { margin: 8px 0; font-size: 13px; line-height: 1.5; color: #d0d0d0; overflow-wrap: anywhere; }
.transfer-progress { display: block; width: 100%; height: 9px; margin: 14px 0; border: 0; border-radius: 6px; accent-color: #eee; background: #444; overflow: hidden; }
.transfer-progress::-webkit-progress-bar { background: #444; border-radius: 6px; }
.transfer-progress::-webkit-progress-value { background: #eee; border-radius: 6px; }
.transfer-progress::-moz-progress-bar { background: #eee; border-radius: 6px; }
.transfer-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.transfer-cancel, .transfer-dismiss { min-height: 44px; border: 1px solid #aaa; padding: 10px 14px; border-radius: 7px; background: #202020; color: #fff; font-size: 14px; }
.transfer-panel[data-state="error"] { border-color: #fff; }
.transfer-panel-in-dialog { position: static; width: 100%; max-width: 100%; max-height: none; margin-top: 18px; box-shadow: none; }

@media (max-width: 1024px) {
  .mobile-ui-ready body.portal-menu-open { overflow: hidden; overscroll-behavior: none; }
  .mobile-ui-ready #app-shell > .main { margin-left: 0; width: 100%; }
  .mobile-ui-ready .mobile-topbar { display: flex; align-items: flex-start; gap: 14px; position: sticky; top: 0; z-index: 30; padding: max(12px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 11px max(20px, env(safe-area-inset-left)); background: #090909f5; border-bottom: 1px solid #727272; backdrop-filter: blur(14px); }
  .mobile-menu-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 48px; min-width: 48px; min-height: 54px; margin-top: 2px; padding: 6px; color: #fff; background: linear-gradient(#2d2d2d, #121212); border: 1px solid #888; border-radius: 9px; box-shadow: var(--portal-bevel); }
  .mobile-menu-button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  .mobile-menu-button > span { font-size: 10px; line-height: 1.4; }
  .mobile-brand-block { flex: 1; min-width: 0; }
  .mobile-brand { display: flex; align-items: center; gap: 14px; min-width: 0; min-height: 42px; }
  .mobile-brand img { width: 85px; height: 34px; object-fit: contain; flex-shrink: 0; }
  .mobile-brand > span { display: block; max-width: 300px; font-size: 14px; line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
  .mobile-clock { display: flex; align-items: center; flex-wrap: wrap; gap: 0 12px; margin-top: 3px; font-size: 11px; line-height: 1.6; }
  .mobile-clock .portal-clock-details { gap: 6px; font-size: 11px; }
  .mobile-clock .portal-clock-details time { font-size: 12px; letter-spacing: .2px; }
  .mobile-ui-ready #app-shell > .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(350px, calc(100vw - 34px)); height: 100vh; height: 100dvh; padding: max(18px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; background: #090909; border-right: 1px solid #aaa; border-bottom: 0; box-shadow: 10px 0 45px #000b; visibility: hidden; transform: translateX(-105%); transition: transform .2s ease, visibility .2s; }
  .mobile-ui-ready #app-shell.mobile-menu-is-open > .sidebar { visibility: visible; transform: translateX(0); }
  .mobile-ui-ready .mobile-menu-close { display: flex; align-items: center; align-self: flex-end; gap: 9px; min-height: 44px; margin: 0 0 16px; font-size: 13px; flex-shrink: 0; }
  .mobile-menu-close > span { font-size: 23px; line-height: 1; }
  .mobile-ui-ready .mobile-menu-backdrop { display: block; position: fixed; inset: 0; z-index: 55; width: 100%; height: 100vh; height: 100dvh; min-height: 0; padding: 0; margin: 0; background: #000b; border: 0; border-radius: 0; transform: none; }
  .mobile-ui-ready .sidebar .brand { flex-direction: row; align-items: center; gap: 16px; flex-shrink: 0; }
  .mobile-ui-ready .sidebar .brand-logo { width: 102px; }
  .mobile-ui-ready .sidebar .brand-name { font-size: 16px; }
  .mobile-ui-ready .sidebar .sidebar-clock { margin: 16px 0; padding: 0 0 14px; }
  .mobile-ui-ready .sidebar .workspace { display: block; margin: 0 0 15px; font-size: 11px; }
  .mobile-ui-ready .sidebar nav { display: flex; flex-direction: column; flex-shrink: 0; overflow: visible; gap: 8px; padding: 0; }
  .mobile-ui-ready .sidebar nav .nav { width: 100%; flex-shrink: 0; min-height: 46px; margin: 0; font-size: 14px; }
  .mobile-ui-ready .sidebar .current-employee { display: flex; flex-shrink: 0; margin-top: 20px; }
  .mobile-ui-ready .main > header { height: auto; min-height: 52px; padding: 9px max(24px, env(safe-area-inset-right)) 9px max(24px, env(safe-area-inset-left)); gap: 12px; font-size: 12px; }
  .mobile-ui-ready main { padding: 26px max(24px, env(safe-area-inset-right)) max(26px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
  .breadcrumb { min-width: 0; }
  .breadcrumb > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .home-view { padding-inline: max(24px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-right)); }
  body input:not([type="checkbox"]):not([type="radio"]):not([type="color"]), body select, body textarea { font-size: 16px !important; min-height: 44px; max-width: 100%; }
  body input.pin-input { font-size: 24px !important; }
  .button, .vca-row-actions .button, .vca-delete, .software-file-actions > button { min-height: 44px; }
  .rights-list label, .vca-check-toggle { min-height: 44px; }
  .admin-employees { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats > div { min-width: 0; }
  .stats > div > div { min-width: 0; overflow-wrap: anywhere; }
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar > *, .page-actions, .actions, .software-toolbar-actions, .vca-filters { min-width: 0; max-width: 100%; }
  dialog { scroll-padding-bottom: 20px; overscroll-behavior: contain; }
  dialog form { min-width: 0; }
  dialog input:not([type="checkbox"]):not([type="radio"]), dialog select, dialog textarea { min-width: 0; }
  .dialog-heading > .icon-button { flex-shrink: 0; }
  #toast { bottom: max(20px, env(safe-area-inset-bottom)); z-index: 65; }
}

@media (max-width: 700px) {
  .mobile-ui-ready .mobile-topbar { gap: 10px; padding-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right)); }
  .mobile-brand { gap: 10px; }
  .mobile-brand img { width: 74px; height: 30px; }
  .mobile-brand > span { font-size: 12px; max-width: 200px; }
  .mobile-ui-ready .main > header { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  .mobile-ui-ready main { padding: 22px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .home-view { padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .home-top { padding-bottom: 18px; }
  .home-brand { gap: 16px; }
  .home-brand img { width: 115px; }
  .home-brand span { font-size: 12px; max-width: 190px; }
  .home-session-bar { flex-wrap: wrap; gap: 8px; font-size: 12px; }
  .home-hero { margin: 18px 0 20px; }
  .home-hero h1 { font-size: 28px; }
  /* Two compact columns, including small phones; content can grow naturally. */
  .home-view .employee-grid, .employee-grid, .shortcut-grid, .project-grid, .software-folder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-view .employee-tile, .employee-tile { padding: 12px; min-height: 132px; }
  .employee-tile .initials { width: 32px; height: 32px; margin-bottom: 8px; border-radius: 8px; font-size: 13px; }
  .employee-tile .tile-label, .home-view .shortcut-tile .tile-label, .project-open .tile-label { font-size: 14px; line-height: 1.4; }
  .employee-tile .tile-caption, .project-open .tile-caption { font-size: 12px; line-height: 1.45; }
  .home-view .tile-caption { font-size: 12px; }
  .home-view .shortcut-tile { padding: 12px; min-height: 132px; }
  .home-view .shortcut-tile .tile-caption { font-size: 12px; line-height: 1.45; padding-right: 0; }
  .shortcut-tile .tile-icon { width: 24px; height: 24px; margin-bottom: 10px; }
  .admin-tile .tile-icon { width: 32px; height: 32px; padding: 6px; margin-bottom: 8px; border-radius: 8px; }
  .employee-tile .tile-arrow, .shortcut-tile .tile-arrow { top: 14px; right: 12px; bottom: auto; font-size: 18px; }
  .section-heading { margin: 20px 0 12px; }
  .section-heading .button { font-size: 13px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stats > div { padding: 12px; }
  .stats strong { font-size: 22px; }
  .stats div div > span { font-size: 12px; }
  .heading .actions, .page-actions { gap: 9px; flex-wrap: wrap; }
  .actions .button, .page-actions .button { flex: 1 1 135px; font-size: 14px; }
  .admin-employees { grid-template-columns: 1fr; }
  .project-open { padding: 12px; min-height: 120px; gap: 6px; }
  .project-open .tile-icon { width: 24px; height: 24px; font-size: 24px; margin-bottom: 4px; }
  .project-open .tile-caption { margin-top: 0; }
  .project-tile { display: flex; flex-direction: column; }
  .project-tile-footer { margin-top: auto; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
  .project-tile-footer .button { width: 100%; min-width: 0; padding: 8px; font-size: 12px; }
  .software-folder-open { padding: 12px; min-height: 120px; gap: 8px; }
  .software-folder-open strong { max-width: 100%; font-size: 14px; }
  .software-folder-icon { width: 30px; height: 26px; }
  .software-folder-dates { padding: 0 12px 12px; }
  .software-folder-dates dd { white-space: normal; overflow-wrap: anywhere; }
  .software-folder-actions { padding: 6px 12px; gap: 4px 8px; flex-wrap: wrap; }
  .software-folder-actions button { min-height: 44px; min-width: 44px; max-width: 100%; overflow-wrap: anywhere; }
  .software-toolbar-actions .button { flex: 1 1 135px; }
  .software-files-heading { align-items: flex-start; flex-wrap: wrap; }
  .software-current-meta { padding: 12px; font-size: 12px; }
  .software-current-meta time { white-space: normal; }
  .software-folder-dates { font-size: 12px; }
  .software-folder-count, .software-dropzone small, .vca-upload-zone small { font-size: 12px; }
  .list-heading { flex-wrap: wrap; }
  .sort-label { margin-left: auto; }
  .tabs { gap: 6px; }
  .tabs button { flex: 1 1 auto; font-size: 13px; }
  .dropzone, .software-dropzone, .vca-upload-zone { line-height: 1.6; }
  .vca-tabs { gap: 17px; }
  .vca-tabs > button { flex-wrap: wrap; font-size: 13px; line-height: 1.5; }
  .vca-toolbar { flex-wrap: wrap; }
  .vca-filters, .vca-search, .vca-filter-label { width: 100%; }
  .vca-filter-label { justify-content: space-between; }
  .vca-filter-label select { flex: 1; min-width: 0; }
  .vca-two-fields { grid-template-columns: 1fr; }
  .vca-controls-heading { flex-wrap: wrap; }
  .vca-control-top { flex-wrap: wrap; gap: 6px; }
  .vca-check-toggle { flex: 1; }
  .rights-list { margin-inline: 0; }
  dialog, #employee-dialog, #preview, .vca-dialog, .software-dialog { max-width: calc(100vw - 20px); max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 20px 16px; }
  .dialog-heading { gap: 12px; }
  .dialog-heading h2 { font-size: 21px; }
  .dialog-actions { gap: 9px; flex-wrap: wrap; }
  .dialog-actions .button { min-width: 0; flex: 1 1 110px; }
  .pdf-controls { flex-wrap: wrap; gap: 8px 16px; }
  .pdf-paper { padding: 5px; }
  .transfer-panel { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); width: auto; max-width: none; padding: 17px; max-height: 46dvh; }
  .transfer-panel-in-dialog { margin-top: 16px; width: 100%; max-height: none; }
}

@media (max-width: 359px) {
  .grid { grid-template-columns: 1fr; }
  .mobile-brand img { width: 64px; height: 26px; }
  .mobile-brand > span { font-size: 11px; }
  .home-brand img { width: 98px; }
  .home-brand span { font-size: 11px; }
  .stats > div { gap: 8px; padding: 10px; }
  .stat-icon { width: 28px; min-width: 28px; height: 32px; }
  .stats strong { font-size: 19px; }
}

@media (hover: none) {
  .employee-tile:hover:not(:disabled), .shortcut-tile:hover:not(:disabled), .project-tile:hover, .card:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mobile-ui-ready #app-shell > .sidebar { transition: none; }
}
