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

.table-wrap {
  -webkit-overflow-scrolling: touch;
}

button,
.nav-link,
select,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.install-button[hidden] {
  display: none !important;
}

@media (display-mode: standalone) {
  .install-button {
    display: none !important;
  }
}

@media (max-width: 680px) {
  .app-shell {
    font-size: 12px;
    overflow-x: hidden;
  }

  .app-shell,
  .app-shell * {
    box-sizing: border-box;
  }

  .app-shell .site-header {
    top: 0 !important;
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: max(10px, env(safe-area-inset-top)) 10px 8px !important;
    border-right: 0 !important;
    border-left: 0 !important;
    border-radius: 0 !important;
  }

  .app-shell .brand {
    width: 120px !important;
    height: 28px !important;
  }

  .app-shell .brand img {
    width: 118px !important;
    height: 40px !important;
  }

  .app-shell h1,
  .app-shell .topline h1 {
    font-size: 15px !important;
  }

  .app-shell h2 {
    font-size: 16px !important;
  }

  .app-shell h3 {
    font-size: 13px !important;
  }

  .app-shell .topline .muted {
    font-size: 10px !important;
  }

  .app-shell .header-actions {
    width: 100%;
    max-width: 100%;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px !important;
    justify-content: stretch !important;
  }

  .app-shell .header-actions .nav-link,
  .app-shell .header-actions button {
    min-height: 34px !important;
    justify-content: center;
    padding: 6px 7px !important;
    overflow: hidden;
    font-size: 10px !important;
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100% !important;
  }

  .app-shell #install-app-button {
    grid-column: span 2;
  }

  .app-shell main {
    width: calc(100vw - 16px) !important;
    margin: 12px auto 24px !important;
  }

  .app-shell .hero-strip {
    min-height: 0 !important;
    margin: 12px 0 !important;
    padding: 0 !important;
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  .app-shell .eyebrow {
    min-height: 22px !important;
    padding: 3px 8px !important;
    font-size: 9px !important;
  }

  .app-shell .hero-strip h2 {
    margin-top: 8px !important;
    font-size: 24px !important;
    line-height: 1.02 !important;
  }

  .app-shell .hero-strip p {
    display: none !important;
  }

  .app-shell .bar,
  .app-shell .name-bar,
  .app-shell .panel {
    margin-bottom: 10px !important;
    padding: 10px !important;
    box-shadow: 0 10px 28px rgba(29, 53, 50, 0.1) !important;
  }

  .app-shell .bar,
  .app-shell .name-bar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
  }

  .app-shell .bar-controls,
  .app-shell .name-controls,
  .app-shell .alert-head,
  .app-shell .alert-actions,
  .app-shell .form-actions,
  .app-shell .secret-row,
  .app-shell .profile-actions {
    display: grid !important;
    width: 100%;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .app-shell label {
    width: 100%;
    font-size: 10px !important;
  }

  .app-shell select,
  .app-shell input,
  .app-shell textarea,
  .app-shell button,
  .app-shell .nav-link {
    max-width: 100%;
    min-width: 0 !important;
  }

  .app-shell select,
  .app-shell input {
    display: block;
    width: 100% !important;
    margin: 6px 0 0 !important;
  }

  .app-shell .field input,
  .app-shell .field select,
  .app-shell .field textarea {
    margin: 0 !important;
  }

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

  .app-shell .metric,
  .app-shell .tile {
    min-height: 62px !important;
    padding: 8px !important;
  }

  .app-shell .metric span,
  .app-shell .tile span {
    font-size: 9px !important;
  }

  .app-shell .metric strong,
  .app-shell .tile strong {
    margin-top: 4px !important;
    font-size: 15px !important;
    line-height: 1.08 !important;
  }

  .app-shell .analysis-grid,
  .app-shell .analysis-insights,
  .app-shell .chart-grid,
  .app-shell .register-grid,
  .app-shell .calculation-grid,
  .app-shell .command-grid,
  .app-shell .status-grid,
  .app-shell .profile-form,
  .app-shell .embed-grid,
  .app-shell .user-form {
    grid-template-columns: 1fr !important;
  }

  .app-shell .dossier-title {
    grid-template-columns: 1fr !important;
  }

  .app-shell .table-wrap {
    margin-right: -10px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
    overflow-x: auto;
  }

  .app-shell table {
    font-size: 11px !important;
  }

  .app-shell th,
  .app-shell td {
    padding: 7px 5px !important;
  }

  .app-shell .detail-backdrop {
    align-items: stretch !important;
    padding: max(10px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom)) !important;
  }

  .app-shell .metric-detail {
    width: 100% !important;
    max-height: 100dvh !important;
    padding: 10px !important;
  }

  .app-shell .metric-detail-head {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .app-shell .detail-chart svg {
    height: 150px !important;
  }

  .app-shell .detail-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 420px) {
  .app-shell #install-app-button {
    grid-column: auto;
  }

  .app-shell .metric strong,
  .app-shell .tile strong {
    font-size: 14px !important;
  }
}
