/* Loaded after the component styles. Keep factory rows and columns intact. */
.mobile-menu-toggle { display: none; }

@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { min-width: 0; }
  .app { min-height: 100vh; min-height: 100dvh; }
  .main-area, .content, .card, .admin-grid > *, .team-layout > *, .request-layout > * { min-width: 0; }

  .sidebar {
    position: relative;
    padding: calc(16px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 14px max(14px, env(safe-area-inset-left, 0px));
  }
  .sidebar .brand-mark { font-size: 30px; }
  .side-label { display: block; padding: 0; margin: 8px 0 0; font-size: 10px; }
  .sidebar nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; overflow: visible; margin-top: 18px; }
  html.js-mobile-nav .sidebar .side-label { max-width: calc(100% - 100px); line-height: 1.4; }
  html.js-mobile-nav .mobile-menu-toggle {
    position: absolute;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: max(14px, env(safe-area-inset-right, 0px));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    min-width: 88px;
    padding: 10px 12px;
    border: 1px solid #52637d;
    border-radius: 8px;
    background: #223450;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    touch-action: manipulation;
  }
  html.js-mobile-nav .sidebar nav, html.js-mobile-nav .sidebar .sidebar-bottom { display: none; }
  html.js-mobile-nav .sidebar.is-menu-open nav { display: grid; }
  html.js-mobile-nav .sidebar.is-menu-open .sidebar-bottom { display: flex; }
  .nav-link { min-height: 48px; padding: 10px; gap: 8px; font-size: 13px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
  .nav-link span { display: inline-block; flex: none; width: 20px; font-size: 18px; }
  .nav-heading { display: block; grid-column: 1 / -1; padding: 9px 10px 2px; }
  .sidebar-bottom { display: flex; padding: 12px 0 0; margin-top: 14px; }
  .user-meta strong { font-size: 13px; }
  .user-meta small { font-size: 12px; }
  .logout { min-width: 70px; min-height: 44px; padding: 8px; color: #d4e2f2; }
  .logout::after { content: " Sair"; font-size: 13px; font-weight: 700; }
  .sound-button { width: auto; }

  .topbar { flex-direction: column; gap: 12px; padding: 18px max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px)); }
  .topbar h1 { font-size: 23px; line-height: 1.2; overflow-wrap: anywhere; }
  .topbar-right { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; }
  .content { padding: 20px max(12px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); }
  .card { padding: 18px 14px; }
  .card-heading { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
  .card-heading h2 { font-size: 20px; }
  .badge { flex-shrink: 0; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 24px; }
  .stat { padding: 12px 10px; gap: 8px; min-width: 0; }
  .stat small { font-size: 9px; line-height: 1.35; letter-spacing: .03em; }
  .stat strong { font-size: 24px; }
  .stat strong.stat-time { font-size: 18px; }
  .section-intro, .section-intro.compact { align-items: flex-start; gap: 12px; }
  .section-intro h2, .section-intro.compact h2 { font-size: 21px; }
  .section-intro .muted, .form-card > .muted, .settings-card .muted { font-size: 14px; }

  .button, .button.small, .machine-toolbar-actions .button, .report-filter .button { min-height: 44px; padding: 11px 14px; font-size: 14px; line-height: 1.3; }
  .text-link { display: inline-flex; align-items: center; min-height: 44px; padding: 7px 2px; font-size: 14px; }
  .button, .text-link, .nav-link, .logout, .dialog-x, .machine { touch-action: manipulation; }
  .button:focus-visible, .text-link:focus-visible, .nav-link:focus-visible, .logout:focus-visible, .dialog-x:focus-visible, .mobile-menu-toggle:focus-visible { outline: 3px solid #21b4a7; outline-offset: 3px; }
  .stack { gap: 17px; }
  .stack label, .dialog-form label, .request-close-form label, .report-filter label { font-size: 14px; }
  .stack input, .stack select, .stack textarea, .dialog-form textarea, .dialog-form select, .request-close-form textarea, .report-filter input {
    min-height: 48px; font-size: 16px; line-height: 1.4; padding: 12px; max-width: 100%;
  }
  .stack input[type="checkbox"] { min-height: 24px; width: 24px; height: 24px; flex: none; }
  .stack .check { min-height: 44px; }
  .stack textarea, .dialog-form textarea, .request-close-form textarea { min-height: 120px; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .settings-card form { max-width: none; }
  .stack .button, .request-close-form .button { width: 100%; }
  .report-filter { grid-template-columns: minmax(0, 1fr); }
  .report-filter .button { width: 100%; }

  .legend { flex-wrap: wrap; gap: 10px 16px; font-size: 13px; line-height: 1.4; }
  .legend-dot { width: 11px; height: 11px; flex: none; }
  .map-panel { max-width: 100%; padding: 16px 12px; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .sector-head { position: sticky; left: 0; gap: 8px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 14px; }
  .sector-head > div { gap: 8px; }
  .sector-head h3 { font-size: 18px; }
  .sector-count { font-size: 11px; }
  .machine-grid { gap: 8px; }
  .gramp-grid { min-width: 328px; grid-template-columns: repeat(4, minmax(76px, 1fr)); }
  .production-grid { min-width: 760px; grid-template-columns: repeat(8, minmax(88px, 1fr)); }
  .machine { min-height: 72px; padding: 12px 8px; }
  .machine .machine-code { font-size: 14px; }
  .machine .machine-status { font-size: 11px; }
  .machine:hover { transform: none; }
  .map-panel:has(.production-grid)::after { content: "Deslize para os lados para ver todas as colunas →"; position: sticky; left: 0; display: block; max-width: 100%; margin-top: 14px; color: #526982; font-size: 12px; line-height: 1.5; }

  .open-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; padding: 14px 12px; }
  .open-info { min-width: 0; overflow-wrap: anywhere; }
  .open-info strong { font-size: 14px; }
  .open-info small { font-size: 13px; line-height: 1.45; }
  .open-time { grid-column: 2; font-size: 12px; }
  .open-item > .button { grid-column: 1 / -1; width: 100%; }
  .table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 540px; font-size: 13px; }
  .table-wrap th { font-size: 11px; }
  .table-wrap td { padding: 12px 10px; }
  .scroll-table { max-height: 65vh; max-height: 65dvh; }
  .machine-row-actions { gap: 10px; }
  .machine-delete-actions, .machine-toolbar-actions { align-items: stretch; }
  .machine-delete-actions { flex-wrap: wrap; }
  .machine-delete-actions .button, .machine-toolbar-actions .button { flex: 1 1 auto; }
  .team-person { flex-wrap: wrap; gap: 10px; }
  .team-person .status { font-size: 11px; }
  .team-person-info strong { font-size: 14px; }
  .team-person-info small { font-size: 12px; }
  .team-self form .button, .team-call form .button { width: 100%; }
  .team-call { padding: 14px; overflow-wrap: anywhere; }
  .team-call h3 { font-size: 17px; line-height: 1.4; }
  .team-call p, .request-description { font-size: 15px; }
  .team-call small, .request-meta { font-size: 12px; }
  .request-item { padding: 15px 12px; overflow-wrap: anywhere; }
  .request-item-top { align-items: flex-start; flex-wrap: wrap; }
  .request-category { font-size: 12px; }
  .flash { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }

  .machine-dialog { width: calc(100% - 24px); max-width: 440px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); padding: 20px 16px; overflow-y: auto; overscroll-behavior: contain; }
  .dialog-top { gap: 10px; }
  .dialog-top > div { min-width: 0; }
  .dialog-top h2 { font-size: 22px; overflow-wrap: anywhere; }
  .dialog-x { width: 44px; height: 44px; flex: none; }
  .dialog-detail { font-size: 14px; overflow-wrap: anywhere; }
  .toast-area { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); width: auto; max-height: 45vh; max-height: 45dvh; overflow-y: auto; }
  .toast strong { font-size: 15px; }
  .toast p { font-size: 13px; line-height: 1.45; }
  .toast a { display: flex; align-items: center; min-height: 44px; font-size: 14px; }

  .login-wrap { min-height: 100vh; min-height: 100dvh; }
  .login-card { min-height: 100vh; min-height: 100dvh; padding: calc(32px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); }
  .login-card .brand-mark { margin-bottom: 36px; }
  .login-card h1 { font-size: clamp(34px, 10vw, 45px); }
  .login-card .stack { max-width: none; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .nav-link, .machine { transition: none; }
}
