/* NyayTrack — all-screen friendly (phone, tablet, laptop, Capacitor) */
html.nyay-screen,
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}
body.nyay-app,
body.officer-portal,
body.sp-portal,
body.nyay-auth,
body.nyay-native {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

/* Capacitor / notch */
body.nyay-native,
html.nyay-native body {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.nyay-native .sidebar {
  padding-top: env(safe-area-inset-top, 0px);
  height: 100dvh;
  max-height: 100dvh;
}
body.nyay-native .content .navbar,
body.nyay-native .nt-topbar {
  padding-top: max(8px, env(safe-area-inset-top, 0px));
}

/* Always fit content to the viewport width */
body.nyay-app .content,
body.officer-portal .content,
body.sp-portal .content,
body.officer-portal .content.od-shell {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
/* Native app + narrow phones: kill sidebar gutter even if media queries misfire */
html.nyay-native body .content,
html.nyay-native body .content.od-shell,
body.nyay-native .content,
body.nyay-native .content.od-shell {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
}
.od-hero, .od-page, .od-brand, .od-sub, .od-hero h1 {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
img, video, canvas, svg {
  max-width: 100%;
}

/* Touch targets */
.sidebar-toggler {
  min-width: 44px !important;
  min-height: 44px !important;
}
.nyay-menu-fab {
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 1100;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: #0a1628;
  box-shadow: 0 8px 20px rgba(7,17,31,.28);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}
.nyay-menu-fab .ny-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 18px;
}
.nyay-menu-fab .ny-bars span {
  display: block;
  height: 2px;
  width: 100%;
  background: #c5a028;
  border-radius: 2px;
}
@media (max-width: 991.98px) {
  .nyay-menu-fab { display: inline-flex; }
}
@media (min-width: 992px) {
  .nyay-menu-fab { display: none !important; }
}
/* Header already has the menu control — never stack a second FAB */
body:has(.content .sidebar-toggler) .nyay-menu-fab,
html.field-portal-nav .nyay-menu-fab,
body.field-portal .nyay-menu-fab,
html.field-portal-nav .nyay-tour-fab,
body.field-portal .nyay-tour-fab,
html.field-portal-nav #nyayTourRoot {
  display: none !important;
}
.btn,
.of-btn-navy,
.of-btn-gold,
.of-btn-outline,
.sp-btn-navy,
.sp-btn-gold,
.nyay-btn,
.dcr-btn,
.fdb-btn,
.fd-btn,
.sidebar-menu a {
  min-height: 44px;
  touch-action: manipulation;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="image"]):not([type="color"]),
select, textarea, .form-control, .form-select {
  font-size: 16px !important;
  max-width: 100%;
  min-height: 44px;
}
textarea.form-control { min-height: 96px; }

/* Keep checkboxes / radios normal size (not stretched into black blocks) */
input[type="checkbox"],
input[type="radio"],
.form-check-input {
  width: 1.15em !important;
  height: 1.15em !important;
  min-width: 1.15em !important;
  min-height: 1.15em !important;
  max-width: 1.15em !important;
  margin-top: 0.2em;
  flex-shrink: 0;
  vertical-align: top;
  accent-color: #0a1628;
  cursor: pointer;
}

/* Auth / guest on phones — form first, never freeze scroll */
@media (max-width: 960px) {
  html, body.nyay-auth {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
  }
  body.nyay-auth:not(.nyay-auth-app) {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    min-height: 100dvh !important;
    background: #ebe6dc !important;
  }
  body.nyay-auth.nyay-auth-app {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    min-height: 100dvh !important;
    background: #0a1628 !important;
  }
  .nyay-force-bar { order: -1; position: sticky; top: 0; z-index: 30; }
  body.nyay-auth:not(.nyay-auth-app) .nyay-auth-panel {
    order: 0 !important;
    min-height: auto !important;
    height: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: none !important;
    justify-content: flex-start !important;
  }
  body.nyay-auth:not(.nyay-auth-app) .nyay-auth-hero {
    display: none !important;
  }
  .nyay-btn {
    width: 100%;
    min-height: 48px;
  }
  .nyay-auth-foot, .na-foot {
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
  }
}

@media (max-width: 991.98px) {
  body.nyay-app .content,
  body.officer-portal .content,
  body.sp-portal .content,
  body.officer-portal .content.od-shell,
  body.nyay-app .content.open,
  body.officer-portal .content.open,
  body.sp-portal .content.open {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  .od-hero-grid {
    grid-template-columns: 1fr !important;
  }
  .od-score {
    width: 100% !important;
    justify-self: stretch !important;
  }
  .sidebar {
    width: min(86vw, 300px) !important;
    transform: translateX(-105%) !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .nyay-sidebar-backdrop {
    touch-action: manipulation;
  }
  .container-fluid,
  .nt-page {
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
  }
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }
  .row > .col-md-6,
  .row > .col-lg-4,
  .row > .col-lg-6,
  .row > .col-xl-3,
  .row > .col-xl-4,
  .row > .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  .table-responsive,
  .nt-table-wrap,
  .fdb-table,
  table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fdb-filters,
  .fd-filters,
  .nt-filter-bar,
  .dcr-toolbar,
  form.row,
  .d-flex.gap-2,
  .d-flex.gap-3 {
    flex-wrap: wrap !important;
  }
  .fdb-filters > div,
  .fd-filters > div {
    width: 100%;
    min-width: 0;
  }
  .fdb-layout,
  .fd-grid,
  .od-grid,
  .dcr-duty-panel-grid {
    grid-template-columns: 1fr !important;
  }
  .lt-stage,
  .fd-map,
  .fdb-map,
  .ny-map,
  .pro-map,
  .nt-map-stage,
  .leaflet-container {
    width: 100% !important;
    max-width: 100% !important;
    height: min(52vh, 360px) !important;
    min-height: 220px !important;
  }
  .lt-card, .lt-live {
    max-width: calc(100% - 24px);
  }
  .lt-live { font-size: 0.75rem; padding: 6px 10px; }
}

@media (max-width: 575.98px) {
  .od-kpis,
  .nt-command-bar,
  .dcr-metrics {
    grid-template-columns: 1fr !important;
  }
  h1, .fd-hero h1, .od-hero h2, .pro-hero h2 {
    font-size: 1.25rem !important;
    line-height: 1.25 !important;
  }
  .btn, .nyay-btn, .of-btn-navy, .of-btn-gold {
    width: 100%;
  }
  .btn + .btn,
  .of-btn-navy + .of-btn-outline,
  .actions .btn {
    margin-top: 8px;
  }
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Short landscape phones */
@media (max-height: 480px) and (orientation: landscape) {
  .lt-stage, .fd-map, .ny-map {
    height: 160px !important;
    min-height: 140px !important;
  }
}

/* App WebView — denser layout, working drawer, less empty scroll */
html.nyay-native body,
body.nyay-native {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
html.nyay-native .sidebar,
body.nyay-native .sidebar {
  transform: translateX(-105%) !important;
  width: min(86vw, 300px) !important;
  z-index: 1200 !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
}
html.nyay-native .sidebar.open,
body.nyay-native .sidebar.open {
  transform: translateX(0) !important;
}
html.nyay-native body.sidebar-drawer-open .nyay-sidebar-backdrop,
body.nyay-native.sidebar-drawer-open .nyay-sidebar-backdrop {
  display: block !important;
  z-index: 1190 !important;
}
html.nyay-native .nyay-menu-fab {
  display: inline-flex !important;
}
html.nyay-native .content .navbar,
html.nyay-native .nt-topbar {
  padding: 8px 10px !important;
  min-height: 52px !important;
}
html.nyay-native .container-fluid,
html.nyay-native .nt-page {
  padding-left: 10px !important;
  padding-right: 10px !important;
  padding-bottom: 12px !important;
}
html.nyay-native .od-hero,
html.nyay-native .sd-hero,
html.nyay-native .pm-hero,
html.nyay-native .dl-hero,
html.nyay-native .fd-hero,
html.nyay-native .dir-banner {
  padding: 12px !important;
  margin-bottom: 10px !important;
}
html.nyay-native .od-hero h1,
html.nyay-native .od-hero h2 {
  font-size: 1.2rem !important;
  line-height: 1.25 !important;
  margin: 0 0 6px !important;
}
html.nyay-native .od-kpis,
html.nyay-native .dcr-metrics,
html.nyay-native .nt-command-bar {
  gap: 8px !important;
  margin-bottom: 10px !important;
}
html.nyay-native .od-grid,
html.nyay-native .fd-grid,
html.nyay-native .pm-grid {
  gap: 10px !important;
}
html.nyay-native .lt-stage,
html.nyay-native .fd-map,
html.nyay-native .fdb-map,
html.nyay-native .leaflet-container {
  height: min(42vh, 280px) !important;
  min-height: 180px !important;
}
/* Keep hamburger compact — never stretch to full width */
html.nyay-native .sidebar-toggler,
html.nyay-native .nyay-menu-fab {
  width: 44px !important;
  min-width: 44px !important;
  max-width: 48px !important;
}
