/* Global responsive enhancements — preserves existing desktop appearance */

body.nav-open {
  overflow: hidden;
}

#layout-wrapper,
.main-content {
  width: 100%;
  max-width: 100%;
}

/* ── NAVBAR ── */
@media (max-width: 1100px) {
  nav {
    width: calc(100% - 24px);
    max-width: none;
    margin-left: 12px;
    margin-right: 12px;
    padding: 0 16px;
    height: auto;
    min-height: 72px;
    flex-wrap: wrap;
    gap: 10px;
    border-radius: 24px;
  }

  .nav-logo img {
    width: 160px !important;
    height: auto !important;
    top: auto !important;
    left: auto !important;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    display: none;
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    border-radius: 16px;
    padding: 10px;
    max-height: 60vh;
    overflow-y: auto;
  }

  body.nav-open .nav-links {
    display: flex;
  }

  .nav-links a {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
  }

  .nav-right {
    margin-left: auto;
  }

  .user-info .role {
    display: none;
  }
}

@media (max-width: 640px) {
  nav {
    width: calc(100% - 16px);
    margin-left: 8px;
    margin-right: 8px;
    padding: 10px 12px;
    border-radius: 18px;
  }

  .nav-logo img {
    width: 130px !important;
  }

  .nav-icon-btn {
    display: none;
  }

  .user-chip {
    padding-right: 10px;
  }

  .user-info .name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
    padding: 16px;
  }
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border, #dde1e7);
  background: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  background: #334155;
  border-radius: 2px;
  position: relative;
}

.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }

/* ── SHARED LAYOUT ── */
main,
.cdash,
.txn-page {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 900px) {
  main,
  .cdash {
    padding-left: 16px;
    padding-right: 16px;
  }

  .card {
    flex-direction: column;
    max-width: 100%;
  }

  .card-sidebar,
  .card-body {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    padding: 24px 20px;
  }

  .card-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border, #dde1e7);
    min-height: auto;
  }

  .form-grid,
  .form-grid-two {
    grid-template-columns: 1fr;
  }

  .form-group.span-two {
    grid-column: span 1;
  }

  .btn-row {
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .btn-row .btn {
    flex: 1 1 auto;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modules-table,
  .section-table,
  .generic-table {
    min-width: 640px;
  }
}

@media (max-width: 600px) {
  mains {
    flex-direction: column;
    padding: 16px;
  }

  .sidebar-title {
    white-space: normal;
  }

  .logo-upload-row {
    flex-wrap: wrap;
  }

  .btn-choose {
    width: 100%;
  }
}

/* ── CLICKABLE DASHBOARD CARDS ── */
.stat-card--link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.stat-card--link:hover {
  box-shadow: 0 4px 16px rgba(13, 27, 75, 0.08);
}

.stat-card--link .stat-view-btn {
  pointer-events: none;
}

.cdash-card--link {
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.cdash-card--link:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.cdash-card--link:focus-visible {
  outline: 2px solid #0d1b4b;
  outline-offset: 2px;
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .charts-row,
  .bottom-split,
  .cdash-row--2 {
    grid-template-columns: 1fr !important;
  }

  .cdash-metrics {
    grid-template-columns: 1fr;
  }

  .cdash-health-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .cdash-book-btn {
    width: 100%;
    justify-content: center;
  }

  .cdash-legend {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .donut-wrapper {
    width: 170px;
    height: 170px;
  }
}

/* Diagnostics admin pages */
@media (max-width: 1024px) {
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    width: 100%;
  }
}
