/**
 * VeriDux GateKeeper — Apple HIG mobile chrome
 * Activated when html has .gk-mobile (phones / compact widths).
 * Uses SF system stack, grouped backgrounds, 44pt targets, safe-area insets.
 */

html.gk-mobile {
  /* Tint = brand (HIG: apps may replace systemBlue with brand tint) */
  --ios-tint: #0f766e;
  --ios-tint-press: #0d9488;
  --ios-blue: #007aff;
  --ios-green: #34c759;
  --ios-red: #ff3b30;
  --ios-orange: #ff9500;
  --ios-bg: #f2f2f7;
  --ios-elevated: #ffffff;
  --ios-fill: rgba(120, 120, 128, 0.12);
  --ios-fill-2: rgba(120, 120, 128, 0.2);
  --ios-label: #000000;
  --ios-secondary: rgba(60, 60, 67, 0.6);
  --ios-tertiary: rgba(60, 60, 67, 0.3);
  --ios-separator: rgba(60, 60, 67, 0.29);
  --ios-nav: rgba(249, 249, 249, 0.94);
  --ios-radius: 12px;
  --ios-radius-lg: 16px;
  --ios-radius-xl: 20px;
  --touch: 44px;
  --page-pad-x: max(16px, env(safe-area-inset-left, 0px));
  --page-pad-r: max(16px, env(safe-area-inset-right, 0px));
  --page-pad-b: max(20px, env(safe-area-inset-bottom, 0px));

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

html.gk-mobile,
html.gk-mobile body {
  background: var(--ios-bg) !important;
  color: var(--ios-label);
  overflow-x: clip;
  max-width: 100vw;
}

html.gk-mobile[data-theme="light"] {
  --bg-deep: var(--ios-bg);
  --bg-base: var(--ios-bg);
  --bg-elevated: var(--ios-elevated);
  --bg-surface: #ffffff;
  --bg-hover: var(--ios-fill);
  --text: var(--ios-label);
  --text-muted: var(--ios-secondary);
  --muted: var(--ios-secondary);
  --border: rgba(60, 60, 67, 0.18);
  --border-strong: var(--ios-separator);
  --accent: var(--ios-tint);
  --accent-dim: var(--ios-tint-press);
  --gk-bg: var(--ios-bg);
  --gk-surface: var(--ios-elevated);
  --gk-surface-muted: var(--ios-bg);
  --gk-text: var(--ios-label);
  --gk-text-muted: var(--ios-secondary);
  --gk-accent: var(--ios-tint);
  --bg-primary: var(--ios-bg);
  --bg-secondary: var(--ios-bg);
  --bg-card: var(--ios-elevated);
  --bg-header: var(--ios-nav);
  --bg-sidebar: rgba(242, 242, 247, 0.96);
  --text-primary: var(--ios-label);
  --text-secondary: var(--ios-secondary);
  --border-default: rgba(60, 60, 67, 0.18);
  --accent-primary: var(--ios-tint);
}

html.gk-mobile[data-theme="dark"] {
  --ios-bg: #000000;
  --ios-elevated: #1c1c1e;
  --ios-fill: rgba(120, 120, 128, 0.24);
  --ios-fill-2: rgba(120, 120, 128, 0.36);
  --ios-label: #ffffff;
  --ios-secondary: rgba(235, 235, 245, 0.6);
  --ios-tertiary: rgba(235, 235, 245, 0.3);
  --ios-separator: rgba(84, 84, 88, 0.65);
  --ios-nav: rgba(28, 28, 30, 0.94);
  --ios-tint: #2dd4bf;
  --bg-deep: #000000;
  --bg-base: #000000;
  --bg-elevated: #1c1c1e;
  --bg-surface: #2c2c2e;
  --text: #ffffff;
  --muted: rgba(235, 235, 245, 0.6);
  --border: rgba(84, 84, 88, 0.65);
  --accent: #2dd4bf;
}

/* —— Shell / navigation bar —— */
html.gk-mobile .app-shell {
  min-height: 100dvh;
  background: var(--ios-bg);
}

html.gk-mobile .app-content {
  min-height: 100dvh;
  background: var(--ios-bg);
}

html.gk-mobile .content-topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: calc(52px + env(safe-area-inset-top, 0px));
  padding:
    max(8px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    8px
    max(8px, env(safe-area-inset-left, 0px));
  background: var(--ios-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
  box-shadow: none;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
}

/* Apple HIG: leading control (menu) on the left, trailing actions on the right */
html.gk-mobile .sidebar-toggle {
  order: 0 !important;
  margin-right: 2px;
  flex-shrink: 0;
}
html.gk-mobile .content-topbar-titles {
  order: 1 !important;
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 0;
}
html.gk-mobile .content-topbar-right {
  order: 2 !important;
  flex-shrink: 0;
  max-width: none;
  margin-left: 0 !important;
  gap: 6px;
}

html.gk-mobile .content-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.gk-mobile .content-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--ios-secondary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.gk-mobile .topbar-brand {
  display: none; /* declutter phone chrome — brand lives in sidebar */
}

html.gk-mobile .sidebar-toggle,
html.gk-mobile .btn-icon,
html.gk-mobile .user-avatar-btn,
html.gk-mobile .theme-toggle {
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  min-height: var(--touch);
  border-radius: 999px;
  border: 0;
  background: var(--ios-fill);
  color: var(--ios-tint);
}

html.gk-mobile .sidebar-toggle:active,
html.gk-mobile .btn-icon:active,
html.gk-mobile .user-avatar-btn:active {
  background: var(--ios-fill-2);
}

html.gk-mobile .main {
  padding:
    12px
    var(--page-pad-r)
    calc(24px + env(safe-area-inset-bottom, 0px))
    var(--page-pad-x) !important;
  max-width: none !important;
  width: 100%;
  box-sizing: border-box;
}

html.gk-mobile .page-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

html.gk-mobile .page-body section {
  margin-top: 0;
}

/* —— iOS drawer sidebar —— */
html.gk-mobile .sidebar {
  width: min(86vw, 320px) !important;
  max-width: 320px;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--ios-elevated) !important;
  border-right: 0.5px solid var(--ios-separator) !important;
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.18);
  color: var(--ios-label) !important;
}

html.gk-mobile .sidebar-brand {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--ios-separator);
}

html.gk-mobile .sidebar-logo {
  width: 44px !important;
  height: 44px !important;
  border-width: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

html.gk-mobile .sidebar-title {
  color: var(--ios-label) !important;
  font-size: 17px;
  font-weight: 600;
}

html.gk-mobile .sidebar-user,
html.gk-mobile .sidebar-role {
  color: var(--ios-secondary) !important;
}

html.gk-mobile .nav-section {
  color: var(--ios-secondary) !important;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  padding: 18px 16px 6px;
}

html.gk-mobile .nav-link {
  min-height: var(--touch);
  border-radius: 10px;
  margin: 1px 8px;
  padding: 10px 12px;
  color: var(--ios-label) !important;
  font-size: 17px;
  font-weight: 400;
}

html.gk-mobile .nav-link:hover,
html.gk-mobile .nav-link:active {
  background: var(--ios-fill) !important;
}

html.gk-mobile .nav-link.active {
  background: rgba(15, 118, 110, 0.14) !important;
  background: color-mix(in srgb, var(--ios-tint) 14%, transparent) !important;
  color: var(--ios-tint) !important;
  box-shadow: none !important;
  font-weight: 600;
}

html.gk-mobile .nav-link.active .nav-icon {
  color: var(--ios-tint) !important;
  opacity: 1;
}

html.gk-mobile .btn-icon-dark {
  border: 0;
  background: var(--ios-fill);
  color: var(--ios-tint);
  border-radius: 999px;
  width: 36px;
  height: 36px;
}

html.gk-mobile .sidebar-backdrop:not([hidden]) {
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

html.gk-mobile .sidebar-footer {
  border-top: 0.5px solid var(--ios-separator);
}

/* —— Grouped cards / lists —— */
html.gk-mobile .card,
html.gk-mobile .settings-section,
html.gk-mobile .home-section-actions,
html.gk-mobile .approvals-list-panel,
html.gk-mobile .approvals-detail-panel,
html.gk-mobile .reports-sidebar,
html.gk-mobile .reports-content {
  background: var(--ios-elevated) !important;
  border: 0 !important;
  border-radius: var(--ios-radius-lg) !important;
  box-shadow: none !important;
  padding: 14px 16px !important;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

html.gk-mobile .card + .card,
html.gk-mobile .page-body > .card {
  margin: 0;
}

html.gk-mobile h1,
html.gk-mobile h2,
html.gk-mobile .settings-subhead,
html.gk-mobile .home-section-title {
  letter-spacing: -0.02em;
  font-weight: 700;
}

html.gk-mobile .muted {
  color: var(--ios-secondary) !important;
}

/* —— Controls —— */
html.gk-mobile .btn-primary,
html.gk-mobile .btn-outline,
html.gk-mobile a.btn-outline,
html.gk-mobile .lobby-kiosk-cta,
html.gk-mobile .lobby-kiosk-exit {
  min-height: var(--touch);
  border-radius: 12px !important;
  font-size: 17px !important;
  font-weight: 600;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-appearance: none;
  appearance: none;
}

html.gk-mobile .btn-primary {
  background: #fff !important;
  color: #334155 !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
}

html.gk-mobile .btn-primary:active {
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
  color: #0f766e !important;
  opacity: 1;
}

html.gk-mobile .btn-outline,
html.gk-mobile a.btn-outline {
  background: #fff !important;
  border: 1px solid #cbd5e1 !important;
  color: #334155 !important;
}

html.gk-mobile .btn-outline:active,
html.gk-mobile a.btn-outline:active {
  background: #f8fafc !important;
  border-color: #94a3b8 !important;
  color: #0f766e !important;
}

html.gk-mobile input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="range"]),
html.gk-mobile select,
html.gk-mobile textarea,
html.gk-mobile .luxe-input,
html.gk-mobile .login-card input,
html.gk-mobile .public-form input,
html.gk-mobile .public-form select,
html.gk-mobile .public-form textarea,
html.gk-mobile .settings-form input,
html.gk-mobile .settings-form select,
html.gk-mobile .settings-form textarea {
  font-size: 16px !important; /* prevent iOS zoom */
  min-height: var(--touch);
  border-radius: 10px !important;
  border: 0.5px solid var(--ios-separator) !important;
  background: var(--ios-elevated) !important;
  color: var(--ios-label) !important;
  padding: 10px 12px !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

html.gk-mobile textarea {
  min-height: 96px;
}

html.gk-mobile label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ios-secondary);
}

/* —— Tables → horizontal cards —— */
html.gk-mobile .table,
html.gk-mobile .approvals-table,
html.gk-mobile .settings-table,
html.gk-mobile .dept-approvals-table,
html.gk-mobile .approvals-history-table,
html.gk-mobile .approvals-visitors-table,
html.gk-mobile .reports-table {
  min-width: 0 !important;
  width: 100%;
  font-size: 14px;
  background: transparent;
}

html.gk-mobile .page-body .card:has(.table),
html.gk-mobile .settings-section:has(.table),
html.gk-mobile .table-scroll,
html.gk-mobile .agency-table-wrap,
html.gk-mobile .settings-page .settings-panel .settings-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin-inline: -4px;
  padding-bottom: 4px;
  border-radius: 12px;
}

html.gk-mobile .table th,
html.gk-mobile .table td {
  border-color: var(--ios-separator);
  padding: 12px 10px;
  white-space: nowrap;
}

html.gk-mobile .table th {
  background: var(--ios-bg);
  color: var(--ios-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* —— Home —— */
html.gk-mobile .home-page,
html.gk-mobile .home-section-actions {
  width: 100%;
}

html.gk-mobile .home-actions,
html.gk-mobile .home-stats,
html.gk-mobile .stats {
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
}

html.gk-mobile .home-action-card {
  min-height: 112px;
  border-radius: var(--ios-radius-lg);
  padding: 14px 12px;
}

html.gk-mobile .home-action-title {
  font-size: 14px;
}

html.gk-mobile .home-action-icon-wrap {
  width: 48px;
  height: 48px;
}

html.gk-mobile .home-stat,
html.gk-mobile .stat,
html.gk-mobile .approvals-stat {
  border-radius: var(--ios-radius) !important;
  background: var(--ios-elevated) !important;
  border: 0.5px solid var(--ios-separator) !important;
  box-shadow: none !important;
}

html.gk-mobile .urgent-approvals-banner {
  max-width: 100%;
  width: 100%;
  justify-content: space-between;
  border-radius: 14px;
  padding: 10px 12px;
}

html.gk-mobile .urgent-approvals-copy {
  white-space: normal;
}

/* —— Approvals —— */
html.gk-mobile .approvals-page,
html.gk-mobile .dept-approvals-page {
  gap: 12px;
}

html.gk-mobile .dept-filter-search,
html.gk-mobile .dept-filter-date,
html.gk-mobile .dept-filter-presets {
  width: 100%;
}

html.gk-mobile .dept-row {
  flex-direction: column;
  align-items: stretch;
}

html.gk-mobile .dept-row-action {
  width: 100%;
  justify-content: stretch;
}

html.gk-mobile .dept-card-list,
html.gk-mobile .dept-row-list {
  max-height: none;
}

html.gk-mobile .dept-pane-tabs {
  flex-direction: column;
}

html.gk-mobile .dept-card-list {
  max-height: none;
}

html.gk-mobile .approvals-split {
  grid-template-columns: 1fr !important;
  gap: 12px;
}

html.gk-mobile .approvals-toolbar {
  flex-direction: column;
  align-items: stretch;
}

html.gk-mobile .approvals-filters {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 10px;
  background: var(--ios-fill);
  border: 0;
  padding: 3px;
}

html.gk-mobile .approvals-filter {
  min-height: 36px;
  border-radius: 8px;
  font-size: 14px;
}

html.gk-mobile .approvals-filter.is-active {
  background: var(--ios-elevated) !important;
  color: var(--ios-label) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

html.gk-mobile .approvals-list {
  max-height: none;
  gap: 10px;
}

html.gk-mobile .approvals-card {
  border-radius: var(--ios-radius-lg);
  border: 0.5px solid var(--ios-separator);
  background: var(--ios-elevated);
  padding: 14px;
}

html.gk-mobile .approvals-card-facts > div {
  grid-template-columns: 1fr;
  gap: 2px;
}

html.gk-mobile .approvals-detail-row {
  grid-template-columns: 1fr !important;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--ios-separator);
}

html.gk-mobile .approvals-detail-label {
  font-size: 12px;
  color: var(--ios-secondary);
}

html.gk-mobile .approvals-detail-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, var(--ios-bg) 28%);
}

html.gk-mobile .approvals-detail-actions .btn-primary,
html.gk-mobile .approvals-detail-actions .btn-outline {
  width: 100%;
}

/* —— Settings —— */
html.gk-mobile .settings-tabs {
  display: flex;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 6px;
  padding: 4px 2px 10px;
  margin: 0 -4px 8px;
  scrollbar-width: none;
}

html.gk-mobile .settings-tabs::-webkit-scrollbar { display: none; }

html.gk-mobile .settings-tab {
  flex: 0 0 auto;
  min-height: 36px;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--ios-fill);
  border: 0;
  font-size: 14px;
  font-weight: 600;
}

html.gk-mobile .settings-tab.active,
html.gk-mobile .settings-tab[aria-selected="true"] {
  background: var(--ios-tint);
  color: #fff;
}

html.gk-mobile .settings-form-grid {
  grid-template-columns: 1fr !important;
}

html.gk-mobile .settings-form-actions,
html.gk-mobile .settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

html.gk-mobile .settings-actions .btn-outline,
html.gk-mobile .settings-form-actions .btn-primary,
html.gk-mobile .settings-form-actions .btn-outline {
  flex: 1 1 auto;
}

/* —— Login —— */
html.gk-mobile .login-wrap,
html.gk-mobile .login-wrap-split {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch;
  justify-content: flex-start;
  min-height: 100dvh;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(20px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px)) !important;
  background: var(--ios-bg) !important;
  gap: 0;
}

html.gk-mobile .login-theme-bar {
  position: fixed !important;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 20;
}

html.gk-mobile .login-wrap-split .login-hero,
html.gk-mobile .login-hero,
html.gk-mobile .login-image-pane {
  display: none !important; /* phone: form-first, HIG-style focused sign-in */
}

html.gk-mobile .login-split {
  display: block !important;
  min-height: 0 !important;
  width: 100%;
}

html.gk-mobile .login-form-pane {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 52px 0 12px !important;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  flex: 1;
  background: transparent !important;
  overflow: visible !important;
}

html.gk-mobile .login-form-inner {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

html.gk-mobile .login-eyebrow-compact {
  font-size: 13px !important;
  font-weight: 600;
  color: var(--ios-secondary) !important;
  text-align: center;
  margin: 0 0 6px !important;
}

html.gk-mobile .login-lead-compact {
  display: none !important; /* reduce chrome on phone login */
}

html.gk-mobile .login-wrap-split .login-panel,
html.gk-mobile .login-panel {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 48px 0 0 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  background: transparent !important;
}

html.gk-mobile .login-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  border-radius: var(--ios-radius-xl) !important;
  padding: 22px 18px !important;
  background: var(--ios-elevated) !important;
  border: 0 !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08) !important;
}

html.gk-mobile .login-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.35rem 0 0.5rem;
}

html.gk-mobile .login-logo,
html.gk-mobile .login-card img {
  width: 72px !important;
  height: 72px !important;
}

html.gk-mobile .login-biometric,
html.gk-mobile .login-microsoft,
html.gk-mobile .login-card .btn-primary {
  width: 100%;
  min-height: var(--touch);
}

/* —— Public request forms —— */
html.gk-mobile .public-header {
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    12px
    max(16px, env(safe-area-inset-left, 0px));
  background: var(--ios-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
}

html.gk-mobile .public-header-row {
  gap: 12px;
}

html.gk-mobile .public-form-logo {
  width: 56px !important;
  height: 56px !important;
}

html.gk-mobile .public-main,
html.gk-mobile .company-pack-page,
html.gk-mobile .team-wrap {
  max-width: none;
  width: 100%;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: max(28px, env(safe-area-inset-bottom, 0px));
}

html.gk-mobile .public-form .card,
html.gk-mobile .visitors-block,
html.gk-mobile .risk-section {
  border-radius: var(--ios-radius-lg);
  border: 0.5px solid var(--ios-separator);
  background: var(--ios-elevated);
}

/* —— Modules launcher —— */
html.gk-mobile .modules-page {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

html.gk-mobile .modules-grid {
  grid-template-columns: 1fr !important;
  gap: 12px;
}

html.gk-mobile .module-tile {
  min-height: 132px;
  border-radius: var(--ios-radius-xl);
}

/* —— Reports / agency —— */
html.gk-mobile .reports-page {
  grid-template-columns: 1fr !important;
}

html.gk-mobile .reports-sidebar {
  position: static !important;
  max-height: none !important;
}

html.gk-mobile .agency-inline-form,
html.gk-mobile .agency-detail-grid,
html.gk-mobile .ag-layout,
html.gk-mobile .ag-form-top {
  grid-template-columns: 1fr !important;
}

/* —— Modals / sheets —— */
html.gk-mobile .modal-backdrop,
html.gk-mobile .staff-msg-modal {
  padding: 0 !important;
  align-items: flex-end !important;
}

html.gk-mobile .modal-panel,
html.gk-mobile .ui-dialog,
html.gk-mobile .staff-msg-sheet,
html.gk-mobile .staff-msg-sheet-luxury {
  width: 100% !important;
  max-width: 100% !important;
  border-radius: 14px 14px 0 0 !important;
  max-height: min(92dvh, 100%) !important;
  margin: 0 !important;
}

html.gk-mobile .user-menu-panel {
  right: 0;
  left: auto;
  min-width: min(280px, calc(100vw - 24px));
  border-radius: 14px;
  border: 0.5px solid var(--ios-separator);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

html.gk-mobile .user-menu-item {
  min-height: var(--touch);
  font-size: 17px;
}

/* —— Lobby / public kiosk —— */
html.gk-mobile .lobby-kiosk {
  min-height: 100dvh;
  background: var(--ios-bg);
}

html.gk-mobile .lobby-kiosk-top {
  padding:
    max(10px, env(safe-area-inset-top, 0px))
    max(14px, env(safe-area-inset-right, 0px))
    10px
    max(14px, env(safe-area-inset-left, 0px));
  background: var(--ios-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
}

html.gk-mobile .lobby-kiosk-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

html.gk-mobile .lobby-kiosk-brand h1 {
  font-size: 17px;
  font-weight: 600;
}

html.gk-mobile .lobby-kiosk-body {
  padding:
    12px
    max(14px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(14px, env(safe-area-inset-left, 0px));
  justify-content: flex-start;
}

html.gk-mobile .lobby-kiosk-hero,
html.gk-mobile .lobby-kiosk-panel {
  width: 100%;
  border-radius: var(--ios-radius-xl);
  box-shadow: none;
  border: 0.5px solid var(--ios-separator);
  padding: 18px 16px;
}

html.gk-mobile .lobby-kiosk-hero h2,
html.gk-mobile .lobby-kiosk-panel h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

html.gk-mobile .lobby-kiosk-steps {
  width: 100%;
  gap: 4px;
}

html.gk-mobile .lobby-kiosk-steps li {
  font-size: 10px;
  padding: 6px 4px;
  text-transform: capitalize;
}

html.gk-mobile .lobby-kiosk-search {
  flex-direction: column;
  gap: 8px;
}

html.gk-mobile .lobby-kiosk-actions {
  flex-direction: column;
  position: sticky;
  bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.gk-mobile .lobby-kiosk-actions .btn-primary,
html.gk-mobile .lobby-kiosk-actions .btn-outline,
html.gk-mobile .lobby-kiosk-cta {
  width: 100%;
}

html.gk-mobile .lobby-kiosk-video {
  width: 100%;
  max-height: 48vh;
  border-radius: 16px;
  background: #000;
}

html.gk-mobile .lobby-kiosk-arrival {
  min-height: var(--touch);
  border-radius: 14px;
}

/* —— Badge reader —— */
html.gk-mobile .badge-read-page {
  max-width: none;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.gk-mobile .badge-read-video-wrap {
  max-height: 46vh;
  border-radius: 16px;
}

html.gk-mobile .badge-read-actions {
  display: grid;
  grid-template-columns: 1fr;
}

/* —— Gatekeeper / calendars —— */
html.gk-mobile .gk-layout,
html.gk-mobile .week-grid {
  grid-template-columns: 1fr !important;
}

html.gk-mobile .create-link-actions,
html.gk-mobile .token-manage-actions,
html.gk-mobile .token-link-actions {
  flex-direction: column;
  align-items: stretch;
}

html.gk-mobile .create-link-actions > *,
html.gk-mobile .token-manage-actions > *,
html.gk-mobile .token-link-actions > * {
  width: 100%;
}

/* —— Narrow phones —— */
@media (max-width: 390px) {
  html.gk-mobile .home-actions,
  html.gk-mobile .home-stats,
  html.gk-mobile .stats {
    grid-template-columns: 1fr !important;
  }

  html.gk-mobile .approvals-filters {
    grid-template-columns: 1fr;
  }

  html.gk-mobile .approvals-detail-actions {
    grid-template-columns: 1fr;
  }
}

/* —— Landscape phones —— */
@media (max-width: 900px) and (orientation: landscape) {
  html.gk-mobile .content-topbar {
    min-height: 48px;
  }

  html.gk-mobile .lobby-kiosk-video {
    max-height: 36vh;
  }
}

/* —— Reduce motion —— */
@media (prefers-reduced-motion: reduce) {
  html.gk-mobile * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* —— iOS standalone (Add to Home Screen) —— */
html.gk-ios.gk-mobile.gk-standalone .content-topbar {
  padding-top: max(12px, env(safe-area-inset-top, 0px));
}

/* —— Fit any phone width: contain, stack, scroll inside —— */
html.gk-mobile #app,
html.gk-mobile .app-shell,
html.gk-mobile .app-content,
html.gk-mobile .main,
html.gk-mobile .page-body,
html.gk-mobile .settings-page,
html.gk-mobile .settings-main,
html.gk-mobile .settings-panel,
html.gk-mobile .su-layout,
html.gk-mobile .su-panel,
html.gk-mobile .chain-hub,
html.gk-mobile .chain-view,
html.gk-mobile .modules-shell,
html.gk-mobile .login-form-inner,
html.gk-mobile .public-main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

html.gk-mobile img:not(.modules-logo):not(.sidebar-logo):not(.login-logo) {
  max-width: 100%;
  height: auto;
}

html.gk-mobile .su-hero,
html.gk-mobile .su-toolbar,
html.gk-mobile .chain-subnav-wrap,
html.gk-mobile .chain-subnav,
html.gk-mobile .su-filters {
  max-width: 100%;
  min-width: 0;
}

html.gk-mobile .su-hero {
  flex-direction: column;
  align-items: stretch;
  padding: 0.9rem 1rem;
}

html.gk-mobile .su-stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html.gk-mobile .su-stat {
  min-width: 0;
  width: 100%;
}

html.gk-mobile .su-filters,
html.gk-mobile .chain-subnav {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

html.gk-mobile .su-filter,
html.gk-mobile .chain-tab {
  flex: 1 1 auto;
}

html.gk-mobile .su-fieldset-grid,
html.gk-mobile .settings-form-grid,
html.gk-mobile .su-form,
html.gk-mobile .chain-group-form,
html.gk-mobile .chain-split,
html.gk-mobile .staff-edit-summary,
html.gk-mobile .staff-edit-form .su-fieldset-grid {
  grid-template-columns: 1fr !important;
  max-width: 100% !important;
}

html.gk-mobile .settings-form,
html.gk-mobile .settings-form-wide,
html.gk-mobile .su-search,
html.gk-mobile .su-search-wrap {
  width: 100%;
  max-width: 100% !important;
}

html.gk-mobile .su-toolbar {
  flex-direction: column;
  align-items: stretch;
}

html.gk-mobile .su-toolbar .btn-outline,
html.gk-mobile .su-toolbar .btn-primary,
html.gk-mobile .chain-card .btn-outline {
  width: 100%;
}

html.gk-mobile .su-table-wrap,
html.gk-mobile .table-scroll,
html.gk-mobile .agency-table-wrap,
html.gk-mobile .lf-settings-table-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

html.gk-mobile .su-table,
html.gk-mobile .settings-table,
html.gk-mobile .gk-table {
  min-width: 32rem;
}

html.gk-mobile .chain-toggle {
  flex-direction: column;
  align-items: stretch;
}

html.gk-mobile .chain-toggle select {
  width: 100%;
  min-width: 0;
}

html.gk-mobile .chain-save-bar {
  position: sticky;
  bottom: env(safe-area-inset-bottom, 0px);
  justify-content: stretch;
}

html.gk-mobile .chain-save-bar .btn-primary {
  width: 100%;
}

html.gk-mobile .modal-backdrop,
html.gk-mobile .chain-dialog-backdrop {
  padding:
    max(8px, env(safe-area-inset-top, 0px))
    max(8px, env(safe-area-inset-right, 0px))
    env(safe-area-inset-bottom, 0px)
    max(8px, env(safe-area-inset-left, 0px)) !important;
}

html.gk-mobile .modal-panel,
html.gk-mobile .ui-dialog,
html.gk-mobile .staff-edit-dialog,
html.gk-mobile .chain-form-dialog {
  width: 100% !important;
  max-width: 100% !important;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 12px) !important;
  overflow-y: auto;
  box-sizing: border-box;
}

html.gk-mobile .modules-hub .modules-grid,
html.gk-mobile .modules-hub .modules-grid-unified,
html.gk-mobile .modules-hub .modules-grid-workspaces,
html.gk-mobile .modules-page .modules-grid {
  grid-template-columns: 1fr !important;
}

html.gk-mobile .modules-hub .modules-grid-system {
  max-width: 100%;
}

html.gk-mobile .modules-hub-top,
html.gk-mobile .modules-hub-brand {
  flex-direction: column;
  align-items: stretch;
}

html.gk-mobile .public-form,
html.gk-mobile .public-main,
html.gk-mobile .login-card,
html.gk-mobile .login-panel {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

html.gk-mobile .gk-layout,
html.gk-mobile .approvals-page,
html.gk-mobile .reports-page,
html.gk-mobile .lf-page,
html.gk-mobile .fin-att-page,
html.gk-mobile .login-layout,
html.gk-mobile .ag-layout,
html.gk-mobile .agency-req-hero,
html.gk-mobile .agency-req-split,
html.gk-mobile .agency-req-filters,
html.gk-mobile .agency-req-grid,
html.gk-mobile .agency-req-grid-2,
html.gk-mobile .agency-req-grid-3,
html.gk-mobile .agency-req-card-grid,
html.gk-mobile .agency-inline-form,
html.gk-mobile .reports-dashboard-grid,
html.gk-mobile .create-link-work-grid {
  grid-template-columns: 1fr !important;
  width: 100%;
  min-width: 0;
}

html.gk-mobile input,
html.gk-mobile select,
html.gk-mobile textarea {
  max-width: 100%;
}

html.gk-mobile .gk-luxe,
html.gk-mobile .gk-body,
html.gk-mobile .gk-topbar,
html.gk-mobile .gk-table-wrap {
  max-width: 100%;
  min-width: 0;
}

html.gk-mobile .public-header-row,
html.gk-mobile .fin-pay-toolbar,
html.gk-mobile .content-topbar-right {
  flex-wrap: wrap;
  max-width: 100%;
}

@media (max-width: 390px) {
  html.gk-mobile .su-stats {
    grid-template-columns: 1fr;
  }
  html.gk-mobile .home-actions,
  html.gk-mobile .home-stats,
  html.gk-mobile .stats {
    grid-template-columns: 1fr !important;
  }
}
