/* SpellOS — camada responsiva para celular. Desktop permanece preservado. */
.mobile-menu-button,
.mobile-nav-overlay {
  display: none;
}

@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .app:not(.hidden):not([hidden]) {
    display: block;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed !important;
    z-index: 1200;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    height: 100dvh !important;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: rgba(11, 8, 14, .985);
    box-shadow: 24px 0 70px rgba(0, 0, 0, .62);
    transform: translateX(-105%);
    transition: transform .22s ease;
    overscroll-behavior: contain;
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-nav-overlay {
    position: fixed;
    z-index: 1150;
    inset: 0;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(0, 0, 0, .68);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  body.mobile-nav-open .mobile-nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .brand {
    justify-content: center;
    margin: 0 0 12px !important;
    padding: 2px 0 12px;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-logo {
    display: block;
    width: 164px !important;
    max-width: 75vw !important;
    height: auto !important;
    margin: 0 auto;
  }

  .sidebar nav {
    display: block !important;
    overflow: visible !important;
    flex: 1;
  }

  .sidebar details {
    display: block;
    margin: 4px 0;
  }

  .nav,
  summary {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 11px 13px !important;
    border-radius: 10px;
    font-size: 15px !important;
    line-height: 1.25;
    white-space: normal !important;
    text-align: left;
  }

  .nav.sub {
    padding-left: 28px !important;
    font-size: 14px !important;
  }

  .sidebar #logoutBtn {
    width: 100%;
    min-height: 46px;
    margin-top: 12px;
  }

  .main {
    width: 100%;
    min-width: 0;
    padding: 0 12px 28px !important;
  }

  .topbar {
    position: sticky;
    z-index: 900;
    top: 0;
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center !important;
    gap: 10px;
    margin: 0 -12px 14px !important;
    padding: calc(9px + env(safe-area-inset-top)) 12px 9px;
    border-bottom: 1px solid rgba(61, 45, 71, .92);
    background: rgba(13, 10, 16, .94);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-menu-button {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #17121b;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
  }

  .topbar > div:first-of-type {
    min-width: 0;
  }

  .topbar .eyebrow {
    margin: 0 0 2px;
    font-size: 8px;
    white-space: nowrap;
  }

  .topbar h1 {
    overflow: hidden;
    margin: 0 !important;
    font-size: 22px !important;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .userbox {
    gap: 5px !important;
  }

  .userbox #userName {
    display: none;
  }

  .userbox .pill {
    padding: 5px 8px;
    font-size: 10px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .metrics article {
    min-height: 88px;
    padding: 13px !important;
    border-radius: 13px !important;
  }

  .metrics span {
    font-size: 11px !important;
    line-height: 1.25;
  }

  .metrics strong {
    margin-top: 6px !important;
    font-size: 25px !important;
  }

  .panel {
    min-width: 0;
    margin-top: 11px !important;
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .panel h2 {
    font-size: 22px;
  }

  .panel p {
    line-height: 1.45;
  }

  .panel-head {
    display: flex !important;
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px !important;
  }

  .panel-head .row-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100%;
  }

  .panel-head .row-actions .btn:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .btn {
    min-height: 44px;
    touch-action: manipulation;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  dialog {
    width: calc(100vw - 18px) !important;
    max-width: none !important;
    max-height: 92dvh;
    margin: auto;
    overflow-y: auto;
    border-radius: 15px;
  }

  dialog form {
    padding: 14px !important;
  }

  .grid2,
  .employee-form-grid {
    grid-template-columns: 1fr !important;
  }

  .actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 14px -14px -14px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(27, 21, 33, .96);
  }

  .actions .btn {
    flex: 1;
  }

  .toolbar,
  .employees-toolbar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    margin: 12px 0 !important;
  }

  .employee-card {
    grid-template-columns: 42px minmax(0, 1fr) !important;
    gap: 10px !important;
    padding: 12px !important;
  }

  .employee-avatar {
    width: 42px !important;
    height: 42px !important;
  }

  .employee-title-row {
    align-items: flex-start !important;
  }

  .employee-title-row h3 {
    font-size: 15px;
  }

  .employee-meta {
    gap: 5px !important;
  }

  .employee-actions {
    grid-column: 1 / -1;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .employee-actions .btn {
    width: 100%;
  }

  .checklist-module-tabs {
    position: sticky;
    z-index: 850;
    top: calc(62px + env(safe-area-inset-top));
    display: flex !important;
    gap: 7px;
    margin: 0 -12px 10px;
    padding: 8px 12px;
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(13, 10, 16, .94);
    scrollbar-width: none;
  }

  .checklist-module-tabs::-webkit-scrollbar {
    display: none;
  }

  .checklist-module-tab {
    flex: 0 0 auto !important;
    min-width: 138px;
    min-height: 42px;
    white-space: nowrap;
  }

  .checklist-operational-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .checklist-operational-summary article {
    min-height: 82px;
    padding: 12px !important;
  }

  .checklist-tasks-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .checklist-tasks-grid > * {
    min-width: 0;
    border-radius: 14px !important;
  }

  .checklist-tasks-grid .btn {
    width: 100%;
    min-height: 48px;
    margin-top: 7px;
    font-weight: 700;
  }

  .checklist-camera-modal {
    align-items: end !important;
    padding: 0 !important;
  }

  .checklist-camera-card {
    width: 100% !important;
    max-height: 94dvh !important;
    border-radius: 18px 18px 0 0 !important;
    padding-bottom: calc(14px + env(safe-area-inset-bottom)) !important;
  }

  .checklist-camera-stage {
    aspect-ratio: 3 / 4 !important;
    max-height: 58dvh;
  }

  .checklist-camera-actions {
    position: static;
    display: grid !important;
    grid-template-columns: 1fr !important;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .mobile-card-table,
  .mobile-card-table tbody {
    display: block;
    width: 100%;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table tr {
    display: block;
    width: 100%;
    margin: 0 0 11px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(24, 17, 30, .75);
  }

  .mobile-card-table td {
    display: grid;
    grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
    align-items: start;
    gap: 9px;
    width: 100%;
    padding: 7px 0 !important;
    border: 0 !important;
    overflow-wrap: anywhere;
  }

  .mobile-card-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
  }

  .mobile-card-table td:first-child {
    display: block;
    padding-top: 0 !important;
    font-size: 15px;
  }

  .mobile-card-table td:first-child::before {
    display: none;
  }

  .mobile-card-table td:last-child {
    display: block;
    padding-bottom: 0 !important;
  }

  .mobile-card-table td:last-child::before {
    display: none;
  }

  .mobile-card-table td:last-child .btn,
  .mobile-card-table td:last-child .row-actions {
    width: 100%;
  }

  .mobile-card-table td:last-child .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-card-table td:last-child .btn {
    min-height: 43px;
  }

  #schedulePage .metrics {
    margin-bottom: 10px;
  }

  #schedulePage .panel-head .row-actions {
    grid-template-columns: 1fr 1fr !important;
  }

  #scheduleMonth {
    width: 100%;
  }

  .schedule-mobile-note {
    margin: 9px 0 12px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
    background: rgba(17, 13, 21, .75);
    font-size: 12px;
    line-height: 1.4;
  }

  .schedule-mobile-list {
    display: grid;
    gap: 12px;
  }

  .schedule-mobile-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(36, 27, 44, .96), rgba(27, 21, 33, .96));
  }

  .schedule-mobile-card-head {
    padding: 12px 13px 10px;
    border-bottom: 1px solid var(--line);
  }

  .schedule-mobile-card-head strong,
  .schedule-mobile-card-head span {
    display: block;
  }

  .schedule-mobile-card-head strong {
    font-size: 15px;
  }

  .schedule-mobile-card-head span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
  }

  .schedule-mobile-weekdays,
  .schedule-mobile-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
  }

  .schedule-mobile-weekdays {
    padding: 9px 10px 3px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    text-align: center;
  }

  .schedule-mobile-grid {
    padding: 5px 10px 12px;
  }

  .schedule-mobile-grid .schedule-cell {
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 52px;
    height: auto;
    place-items: center;
    gap: 1px;
    padding: 5px 2px;
    border-radius: 9px;
  }

  .schedule-mobile-grid .schedule-cell .mobile-day-number {
    font-size: 11px;
    font-weight: 700;
  }

  .schedule-mobile-grid .schedule-cell .mobile-day-status {
    font-size: 13px;
    font-weight: 900;
  }

  .schedule-mobile-grid .schedule-cell:disabled {
    opacity: .92;
  }

  .schedule-table-wrap {
    max-width: 100%;
  }

  .toast {
    right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    left: 12px;
    text-align: center;
  }
}

@media (max-width: 370px) {
  .metrics {
    grid-template-columns: 1fr 1fr !important;
  }

  .main {
    padding-right: 9px !important;
    padding-left: 9px !important;
  }

  .topbar {
    margin-right: -9px !important;
    margin-left: -9px !important;
    padding-right: 9px;
    padding-left: 9px;
  }

  .schedule-mobile-weekdays,
  .schedule-mobile-grid {
    gap: 3px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .schedule-mobile-grid .schedule-cell {
    min-height: 49px;
  }
}
