/* Starkwood ONE mobile/tablet responsive layer.
   Desktop layout (1024px and wider) is intentionally untouched. */
.sw-mobile-menu-button,
.sw-mobile-sidebar-head,
.sw-mobile-nav-backdrop,
.sw-mobile-table-hint {
  display: none;
}

@media (max-width: 1023px) {
  :root {
    --sw-mobile-header-height: 64px;
    --sw-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  html,
  body,
  #root {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    height: 100dvh !important;
    overflow: hidden !important;
  }

  body.sw-mobile-nav-open {
    overscroll-behavior: none;
    touch-action: none;
  }

  .sw-mobile-topbar {
    position: relative;
    z-index: 140;
    min-width: 0;
    padding-left: 10px !important;
    padding-right: 10px !important;
    gap: 8px;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .sw-mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #0b1739;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
    -webkit-tap-highlight-color: transparent;
  }

  .sw-mobile-menu-button:active {
    transform: scale(.97);
    background: #f8fafc;
  }

  .sw-mobile-brand {
    min-width: 0;
    max-width: min(42vw, 230px);
    flex: 0 1 auto;
  }

  .sw-mobile-brand > div:last-child {
    min-width: 0;
  }

  .sw-mobile-actions {
    margin-left: auto;
    min-width: 0;
    gap: 6px !important;
  }

  .sw-mobile-profile-button {
    min-width: 0 !important;
    width: auto !important;
    max-width: 170px;
    padding: 6px 8px !important;
  }

  .sw-mobile-profile-menu {
    right: 12px !important;
    left: auto !important;
    width: min(320px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
  }

  .sw-mobile-content-row {
    min-width: 0;
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .sw-app-sidebar {
    position: fixed !important;
    z-index: 150 !important;
    top: var(--sw-mobile-header-height) !important;
    left: 0 !important;
    bottom: 0 !important;
    width: min(86vw, 320px) !important;
    max-width: 320px !important;
    height: auto !important;
    min-height: 0 !important;
    transform: translate3d(-104%, 0, 0);
    transition: transform .24s ease;
    box-shadow: 18px 0 45px rgba(2, 8, 23, .25);
    will-change: transform;
    padding-bottom: var(--sw-mobile-safe-bottom);
  }

  body.sw-mobile-nav-open .sw-app-sidebar {
    transform: translate3d(0, 0, 0);
  }

  .sw-mobile-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    min-height: 52px;
    padding: 10px 12px 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
    color: rgba(255, 255, 255, .78);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .sw-mobile-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 11px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    font-size: 24px;
    line-height: 1;
  }

  .sw-sidebar-item {
    min-height: 46px !important;
    padding-top: 11px !important;
    padding-bottom: 11px !important;
  }

  .sw-mobile-nav-backdrop {
    display: block;
    position: fixed;
    z-index: 145;
    inset: var(--sw-mobile-header-height) 0 0 0;
    border: 0;
    padding: 0;
    background: rgba(2, 8, 23, .50);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
    backdrop-filter: blur(2px);
  }

  body.sw-mobile-nav-open .sw-mobile-nav-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .sw-mobile-main {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sw-mobile-main > .flex-1,
  .sw-mobile-main > .flex-1 > * {
    min-width: 0;
    max-width: 100%;
  }

  .sw-mobile-main .p-6 { padding: 1rem !important; }
  .sw-mobile-main .px-6 { padding-left: 1rem !important; padding-right: 1rem !important; }
  .sw-mobile-main .py-6 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
  .sw-mobile-main .gap-6 { gap: 1rem !important; }
  .sw-mobile-main .gap-5 { gap: .875rem !important; }

  .sw-mobile-main .grid-cols-7,
  .sw-mobile-main .grid-cols-5,
  .sw-mobile-main .grid-cols-4,
  .sw-mobile-main .grid-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .sw-mobile-overflow-flex {
    flex-wrap: wrap !important;
    align-items: stretch !important;
  }

  .sw-mobile-overflow-flex > input,
  .sw-mobile-overflow-flex > select,
  .sw-mobile-overflow-flex > .relative,
  .sw-mobile-overflow-flex > [class*="min-w-"] {
    min-width: min(100%, 220px) !important;
    flex: 1 1 220px !important;
  }

  .sw-mobile-main input,
  .sw-mobile-main select,
  .sw-mobile-main textarea,
  .sw-mobile-modal-card input,
  .sw-mobile-modal-card select,
  .sw-mobile-modal-card textarea {
    max-width: 100%;
  }

  .sw-mobile-main button,
  .sw-mobile-modal-card button {
    touch-action: manipulation;
  }

  .sw-mobile-table-shell {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #eef2f7;
  }

  .sw-mobile-table-shell::-webkit-scrollbar { height: 9px; }
  .sw-mobile-table-shell::-webkit-scrollbar-track { background: #eef2f7; border-radius: 999px; }
  .sw-mobile-table-shell::-webkit-scrollbar-thumb { background: #94a3b8; border: 2px solid #eef2f7; border-radius: 999px; }

  .sw-mobile-table-wide {
    min-width: 760px !important;
    width: max-content !important;
  }

  .sw-manage-access-table-scroll .sw-mobile-table-wide {
    min-width: 1180px !important;
  }

  .sw-mobile-table th,
  .sw-mobile-table td {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .sw-mobile-table-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    max-width: 100%;
    margin: 0 0 7px;
    padding: 5px 9px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    font-size: 10px;
    font-weight: 700;
  }

  .sw-floating-scrollbar {
    display: none !important;
  }

  .sw-mobile-modal-overlay {
    padding: 12px !important;
    align-items: center !important;
  }

  .sw-mobile-modal-card {
    width: min(680px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
  }

  .sw-map-tools {
    align-items: stretch !important;
  }

  .sw-map-search-wrap,
  .sw-map-tools input,
  .sw-map-tools select,
  .sw-map-tools .sw-map-btn {
    min-width: 0 !important;
  }

  .sw-map-search-wrap {
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .sw-map-tools select,
  .sw-map-tools .sw-map-btn {
    flex: 1 1 150px;
  }

  .sw-map-editbar .push {
    display: none !important;
  }

  .sw-map-modal {
    padding: 12px !important;
  }

  .sw-map-modal-card {
    width: min(480px, 100%) !important;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .sw-mobile-main .recharts-responsive-container,
  .sw-mobile-main .recharts-wrapper {
    max-width: 100% !important;
  }

  .sw-mobile-main footer,
  .sw-mobile-main [data-sw-app-footer] {
    flex-wrap: wrap;
    gap: 6px 12px;
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 767px) {
  :root { --sw-mobile-header-height: 60px; }

  .sw-mobile-topbar {
    min-height: 60px !important;
    height: 60px !important;
  }

  .sw-mobile-menu-button {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
  }

  .sw-mobile-brand {
    max-width: 43vw;
  }

  .sw-mobile-brand > div:last-child > div:first-child {
    font-size: 12px !important;
  }

  .sw-mobile-brand > div:last-child > div:last-child {
    display: none;
  }

  .sw-mobile-profile-button {
    max-width: 46px;
    width: 42px !important;
    min-height: 42px;
    justify-content: center;
    padding: 4px !important;
    border-radius: 12px !important;
  }

  .sw-mobile-profile-button > div:not(:first-child),
  .sw-mobile-profile-button > svg {
    display: none !important;
  }

  .sw-mobile-main .p-5,
  .sw-mobile-main .p-6 { padding: .875rem !important; }
  .sw-mobile-main .px-5,
  .sw-mobile-main .px-6 { padding-left: .875rem !important; padding-right: .875rem !important; }

  .sw-mobile-main .grid-cols-7,
  .sw-mobile-main .grid-cols-5,
  .sw-mobile-main .grid-cols-4,
  .sw-mobile-main .grid-cols-3,
  .sw-mobile-main .grid-cols-2 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .sw-mobile-main h1 { font-size: 1.35rem !important; line-height: 1.3 !important; }
  .sw-mobile-main h2 { line-height: 1.35 !important; }

  .sw-mobile-main input,
  .sw-mobile-main select,
  .sw-mobile-main textarea,
  .sw-mobile-modal-card input,
  .sw-mobile-modal-card select,
  .sw-mobile-modal-card textarea {
    font-size: 16px !important;
  }

  .sw-mobile-main button:not(.sw-mobile-compact-button),
  .sw-mobile-modal-card button:not(.sw-mobile-compact-button) {
    min-height: 42px;
  }

  .sw-mobile-table-wide {
    min-width: 700px !important;
  }

  .sw-mobile-modal-overlay {
    padding: 0 !important;
    align-items: stretch !important;
  }

  .sw-mobile-modal-card {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
  }

  .sw-map-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .sw-map-modal-card {
    width: 100% !important;
    max-height: 88dvh !important;
    border-radius: 18px 18px 0 0 !important;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sw-map-detail-grid {
    grid-template-columns: 1fr !important;
  }

  .sw-map-detail.wide {
    grid-column: auto !important;
  }

  .sw-map-tools select,
  .sw-map-tools .sw-map-btn {
    flex-basis: calc(50% - 4px);
  }
}

@media (max-width: 390px) {
  .sw-mobile-brand {
    max-width: 40vw;
  }

  .sw-mobile-brand > div:first-child {
    width: 32px !important;
    height: 32px !important;
  }

  .sw-mobile-topbar {
    padding-left: 7px !important;
    padding-right: 7px !important;
    gap: 5px;
  }

  .sw-mobile-actions { gap: 3px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .sw-app-sidebar,
  .sw-mobile-nav-backdrop,
  .sw-mobile-menu-button {
    transition: none !important;
  }
}
