/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-out);
  }

  #sidebarToggle:checked ~ .sidebar {
    transform: translateX(0);
  }

  #sidebarToggle:checked ~ .sidebar-overlay {
    display: block;
  }

  .main {
    margin-left: 0;
    padding-top: 56px;
  }

  .main-inner {
    padding: 20px 16px;
  }

  .page-header {
    flex-direction: column;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  #metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .health-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-shortcut {
    display: none;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  /* Card-mode tables */
  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tbody tr {
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
    transition: background var(--duration-fast);
  }

  tbody tr:hover {
    background: rgba(99,102,241,0.03);
  }

  tbody td {
    border: none;
    padding: 5px 14px;
    position: relative;
    padding-left: 45%;
    text-align: right;
    font-size: 13px;
  }

  tbody td::before {
    content: attr(data-label);
    position: absolute;
    left: 14px;
    width: 40%;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
  }

  .table-wrap table {
    min-width: unset;
  }

  .table-wrap {
    overflow-x: hidden;
  }

  .routes-table tbody tr {
    margin-bottom: 12px;
    padding: 12px 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02);
    box-shadow: var(--shadow-sm);
  }

  .routes-table tbody td {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .routes-table tbody td::before {
    width: calc(42% - 8px);
  }

  .routes-table .cell-long,
  .routes-table .cell-mono {
    text-align: left;
    padding-left: 14px;
    padding-top: 26px;
  }

  .routes-table .cell-long::before,
  .routes-table .cell-mono::before {
    position: static;
    display: block;
    width: auto;
    margin-bottom: 6px;
  }

  .routes-table .domain-copy {
    display: block;
    width: 100%;
    padding: 8px 10px;
  }

  .routes-table .domain-copy-name {
    justify-content: flex-start;
  }

  .routes-table .cell-actions {
    padding-left: 14px;
    padding-top: 28px;
    text-align: left;
  }

  .routes-table .cell-actions::before {
    position: static;
    display: block;
    width: auto;
    margin-bottom: 8px;
  }

  .routes-table .route-actions {
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .routes-table .route-actions .btn {
    width: 100%;
    min-height: 38px;
  }

  /* Command palette responsive */
  .cmd-palette-overlay {
    padding: 8px;
    padding-top: 10vh;
  }

  .cmd-palette {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  #metrics {
    grid-template-columns: 1fr;
  }

  .health-kpis {
    grid-template-columns: 1fr 1fr;
  }

  .logs-realtime {
    flex-direction: column;
  }

  .logs-stat {
    min-width: unset;
  }

  .page-header-text h1 {
    font-size: 22px;
  }

  #toastContainer {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }

  tbody td {
    padding-left: 50%;
  }

  tbody td::before {
    width: calc(45% - 8px);
  }

  .routes-table tbody tr {
    margin-bottom: 10px;
  }

  .routes-table .route-actions {
    grid-template-columns: 1fr;
  }
}
