/* Responsive layout hardening for Dialog Feedback System. */
html,
body,
#app {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  grid-template-columns: 184px minmax(0, 1fr) minmax(320px, 390px);
}

.main,
.content,
.panel,
.right-rail,
.drawer,
.drawer-body {
  min-width: 0;
}

.panel,
.summary-table,
.report-preview {
  max-width: 100%;
}

.panel > table,
.drawer-body > table,
.summary-table table {
  min-width: 760px;
}

.panel,
.drawer-body,
.summary-table {
  overflow-x: auto;
}

.toolbar,
.topbar,
.drawer-head,
.drawer-foot,
.top-actions,
.inline-actions,
.filters,
.tabs,
.pill-row {
  min-width: 0;
  flex-wrap: wrap;
}

.topbar {
  height: auto;
  min-height: 74px;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}

.topbar h1 {
  overflow-wrap: anywhere;
}

.filters .input,
.filters .select,
.top-actions .select {
  width: auto;
  max-width: 100%;
}

.input,
.select,
.textarea,
.btn {
  max-width: 100%;
}

.metric-strip {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.metric {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-strip .metric:last-child {
  border-right: 1px solid var(--line);
}

.lower-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.checkbox-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.check-row {
  grid-template-columns: 22px minmax(0, 1fr);
}

.check-row .select {
  width: 100%;
  grid-column: 2;
}

.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.template-item {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.45fr) auto;
}

.criteria-row {
  grid-template-columns: minmax(180px, 1fr) minmax(210px, 250px) minmax(70px, 92px);
}

.report-meta,
.report-stats,
.profile-facts,
.rail-tabs {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.report-page {
  overflow-wrap: anywhere;
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 184px minmax(0, 1fr);
  }

  .right-rail {
    display: none;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .sidebar {
    width: 72px;
    overflow: hidden;
  }

  .brand {
    height: 82px;
    padding: 12px;
    justify-content: center;
  }

  .brand img {
    width: 48px;
    max-height: 48px;
    object-fit: contain;
  }

  .nav-title,
  .nav-button span:last-child,
  .identity-card div:not(.avatar) {
    display: none;
  }

  .nav-section {
    padding: 12px 8px 0;
  }

  .nav-button {
    justify-content: center;
    padding: 10px 0;
  }

  .identity-card {
    justify-content: center;
    padding: 8px 0;
    border: 0;
    background: transparent;
  }

  .sidebar-footer {
    padding: 12px 8px;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 13px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    display: block;
  }

  .brand,
  .sidebar-footer {
    display: none;
  }

  .nav-section {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
  }

  .nav-button {
    width: auto;
    min-width: 44px;
    flex: 0 0 auto;
  }

  .topbar,
  .content,
  .drawer-head,
  .drawer-body,
  .drawer-foot {
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-actions,
  .inline-actions,
  .filters {
    align-items: stretch;
  }

  .filters,
  .top-actions {
    width: 100%;
  }

  .filters .input,
  .filters .select,
  .top-actions .select,
  .top-actions .btn {
    width: 100%;
    max-width: none;
  }

  .drawer {
    width: 100vw;
  }

  .drawer-foot {
    position: sticky;
    bottom: 0;
  }

  .drawer-foot .inline-actions,
  .drawer-foot .btn {
    width: 100%;
  }

  .panel > table,
  .drawer-body > table,
  .summary-table table {
    min-width: 680px;
  }
}

@media (max-width: 520px) {
  .form-grid,
  .checkbox-grid,
  .lower-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .template-item,
  .criteria-row {
    grid-template-columns: 1fr;
  }

  .score-set {
    width: 100%;
  }

  .panel > table,
  .drawer-body > table,
  .summary-table table {
    min-width: 600px;
  }
}
