/* Mobile-only Technician Console refinements. Desktop styling remains in styles.css. */
[hidden] { display: none !important; }

@media (max-width: 720px) {
  :root { scroll-padding-top: calc(64px + env(safe-area-inset-top)); }
  body { padding-bottom: env(safe-area-inset-bottom); }
  .sidebar { width: min(84vw, 300px); padding-top: calc(16px + env(safe-area-inset-top)); }
  /* Keep a legacy viewport fallback for iOS/WebKit releases without dynamic viewport units. */
  .main { min-height: 100vh; min-height: 100dvh; }
  .topbar { min-height: 58px; height: auto; padding-top: max(8px, env(safe-area-inset-top)); }
  .menu-button { width: 44px; height: 44px; min-width: 44px; flex: 0 0 44px; display: inline-grid; place-items: center; }
  .technician-name { display: none; }
  .view { width: 100%; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .page-heading { gap: 12px; }
  .page-heading h1 { line-height: 1.25; }
  .page-heading > .button { min-height: 44px; white-space: normal; }
  .card { border-radius: 9px; }
  .card-head { align-items: flex-start; gap: 10px; }
  .card-head > .button, .card-head .button { flex-shrink: 0; }
  .form-actions { flex-wrap: wrap; justify-content: flex-start; }
  .button, .nav-item, .quick-action, .org-select { min-height: 44px; }
  input, select, textarea { font-size: 16px !important; }
  .table-wrap { max-width: 100%; overscroll-behavior-x: contain; scrollbar-width: thin; }
  .table { min-width: 680px; }
  .custom-grid { min-width: 920px; }
  .grid-actions { flex-wrap: wrap; }
  .search-input { width: 100%; min-width: 0; min-height: 44px; }
  .column-picker { width: max-content; }
  .column-picker summary { min-height: 44px; display: flex; align-items: center; }
  .notice { top: calc(64px + env(safe-area-inset-top)); left: 12px; right: 12px; max-width: none; }
  .login-card { margin-top: 5vh; padding: 24px 20px; }
  .modal-backdrop { align-items: flex-end; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .modal { max-height: 88vh; max-height: 88dvh; overflow: auto; border-radius: 14px 14px 10px 10px; }
  .ai-input-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-input-grid .full { grid-column: auto; }
  :focus-visible { outline: 3px solid #6ba7ef; outline-offset: 2px; }

  /* Queue and RMM keep a real table on desktop but become labeled, readable cards on phones. */
  .responsive-cards { display: block; width: 100%; min-width: 0; }
  .responsive-cards thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .responsive-cards tbody { display: grid; gap: 10px; }
  .responsive-cards tr { display: block; min-width: 0; border: 1px solid #e5eaf1; border-radius: 9px; background: #fff; overflow: hidden; }
  .responsive-cards td { display: grid; grid-template-columns: minmax(76px, 30%) minmax(0, 1fr); gap: 8px; align-items: start; padding: 10px 12px; white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
  .responsive-cards td::before { content: attr(data-label); color: #718196; font-size: 10px; font-weight: 700; }
  .responsive-cards td[colspan] { display: block; }
  .responsive-cards td[colspan]::before { content: none; }
  .responsive-cards td[data-label="Action"] { align-items: center; }
  .responsive-cards td[data-label="Action"] .form-actions { margin: 0; gap: 6px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { min-width: 0; overflow-wrap: anywhere; }
  .stat-value { font-size: clamp(18px, 7vw, 22px); }
  .breadcrumbs strong { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions { margin-left: auto; }
  .avatar { width: 40px; height: 40px; flex: 0 0 40px; }
  .form-grid { gap: 12px; }
  .login-card h1 { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .spinner { animation-duration: 2s; }
}

.setup-card { max-width: 1000px; margin: 0 auto; }
.setup-progress { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px; margin: 4px 0 24px; }
.setup-progress-step { display: grid; justify-items: center; gap: 7px; color: #7c8999; text-align: center; }
.setup-progress-step span { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid #ccd7e4; border-radius: 50%; background: #fff; font-size: 12px; font-weight: 700; }
.setup-progress-step small { font-size: 10px; }
.setup-progress-step.current { color: #215da5; font-weight: 700; }
.setup-progress-step.current span,.setup-progress-step.done span { color: #fff; background: #286fc2; border-color: #286fc2; }
.setup-step { min-height: 280px; }
.setup-step h2 { margin: 5px 0 8px; color: #243b54; }
.setup-step > p { max-width: 760px; color: #66788e; line-height: 1.55; }
.setup-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 18px 0; }
.setup-summary > div { display: grid; gap: 5px; padding: 12px; border: 1px solid #e4eaf1; border-radius: 8px; overflow-wrap: anywhere; }
.setup-summary strong { color: #52667e; font-size: 11px; }
.setup-summary span { color: #263b51; font-size: 12px; }
.setup-links { justify-content: flex-start; }
.setup-actions { border-top: 1px solid #edf0f4; padding-top: 14px; }
@media (max-width: 720px) {
  .setup-progress { gap: 3px; margin-bottom: 18px; }
  .setup-progress-step span { width: 28px; height: 28px; }
  .setup-progress-step small { font-size: 9px; }
  .setup-step { min-height: 0; }
  .setup-summary { grid-template-columns: minmax(0,1fr); }
}
