/* ============================================================
   Global responsive — tablet + mobile breakpoints
   ============================================================ */

/* ---- tablet (<=960px) ---- */
@media (max-width: 960px) {

  .grid-2,
  .grid-sidebar {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .header-search {
    max-width: none;
  }

  .chat-container {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .chat-users {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 200px;
  }
}

/* ---- mobile (<=720px) ---- */
@media (max-width: 720px) {
  :root {
    --header-h: 56px;
  }

  .app,
  html.sidebar-collapsed .app {
    grid-template-columns: 1fr;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 282px;
    z-index: 75;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(.2, .8, .2, 1);
    box-shadow: var(--shadow-lg);
    height: 100vh;
    height: 100dvh;
    padding-top: max(18px, env(safe-area-inset-top));
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Collapsed (mini) sidebar is a desktop-only feature; always show the
     full drawer on mobile regardless of the saved preference. */
  html.sidebar-collapsed .sidebar {
    padding-left: 14px;
    padding-right: 14px;
  }

  html.sidebar-collapsed .sidebar .brand-row {
    flex-direction: row;
    padding: 6px 10px 18px 6px;
  }

  html.sidebar-collapsed .sidebar .brand {
    justify-content: flex-start;
  }

  html.sidebar-collapsed .sidebar .brand-text {
    display: block;
  }

  html.sidebar-collapsed .sidebar .nav-label {
    display: block;
  }

  html.sidebar-collapsed .sidebar .nav-section + .nav-section {
    border-top: none;
    margin-top: 0;
    padding-top: 8px;
  }

  html.sidebar-collapsed .sidebar .nav-item {
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 12px;
    font-size: 13.5px;
  }

  html.sidebar-collapsed .sidebar .nav-item.active::before {
    left: -14px;
  }

  html.sidebar-collapsed .sidebar .nav-item .badge {
    position: static;
    width: auto;
    height: auto;
    min-width: 18px;
    padding: 1px 7px;
    border: 1px solid var(--line);
    font-size: 11px;
  }

  .header {
    padding: 0 14px;
    gap: 10px;
    height: var(--header-h);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .header-title {
    display: none;
  }

  .header-search {
    flex: 1;
    margin: 0;
  }

  .header-search input {
    height: 38px;
    padding-left: 34px;
    font-size: 14px;
  }

  .header-actions {
    gap: 2px;
  }

  .user-chip {
    padding: 2px;
    border: none;
    background: transparent;
  }

  .user-chip-name,
  .user-chip svg:last-child {
    display: none;
  }

  .content {
    padding: 16px 14px;
    gap: 14px;
    --pad: 14px;
    --gap: 14px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 0;
  }

  .page-title {
    font-size: 22px;
  }

  .page-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .page-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .page-actions .btn-ghost {
    flex: 0 0 auto;
  }

  .record {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "icon main"
      "side side";
    gap: 12px;
    padding: 14px;
  }

  .record>.record-icon {
    grid-area: icon;
  }

  .record>.record-main {
    grid-area: main;
    min-width: 0;
  }

  .record>.record-side {
    grid-area: side;
    justify-content: flex-start;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    gap: 10px;
    flex-wrap: wrap;
  }

  .record-stat {
    min-width: 0;
    text-align: left;
  }

  .record-stat-label {
    font-size: 10.5px;
  }

  .record-stat-value {
    font-size: 13.5px;
  }

  .ob-grid {
    grid-template-columns: 1fr;
  }

  .list-row {
    grid-template-columns: auto 1fr auto !important;
    padding: 12px 14px;
    gap: 12px;
  }

  .list-row > .col-id {
    display: none;
  }

  .list-row > *:nth-child(n+4):not(.menu-trigger):not(.list-row-status) {
    display: none;
  }

  .list-head {
    display: none;
  }

  .filter-row {
    flex-direction: column;
    gap: 8px;
  }

  .filter-group select,
  .filter-group input {
    min-width: 100%;
  }

  .page-actions {
    flex-wrap: wrap;
    gap: 6px;
  }

  .page-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .sort-select {
    flex: 1 1 auto;
  }

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    margin: -4px -14px 0;
    padding: 0 14px;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .form {
    max-width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .form-actions .btn-ghost {
    flex: 0 0 100%;
  }

  .card-header {
    padding: 14px 16px 12px;
  }

  .card-body {
    padding: 14px 16px;
  }

  .card-title {
    font-size: 14.5px;
  }

  .footer {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 16px 14px;
  }

  .grid-sidebar {
    grid-template-columns: 1fr;
  }

  .chat-container {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .chat-users {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 180px;
  }

  .action-menu {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    top: auto;
    min-width: 0;
    border-radius: var(--r-md);
    box-shadow: 0 -8px 30px oklch(0 0 0 / 0.18);
    padding: 8px;
    z-index: 81;
  }

  .action-menu.open {
    animation: sheetIn 0.18s ease;
  }

  .action-menu .menu-item {
    padding: 13px 14px;
    font-size: 15px;
  }

  .action-menu .menu-item svg {
    width: 18px;
    height: 18px;
  }

  @keyframes sheetIn {
    from {
      transform: translateY(100%);
    }

    to {
      transform: translateY(0);
    }
  }

  .dash-tiles {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .dash-tile {
    padding: 18px 10px 16px;
  }

  .dash-tile-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .dash-tile-icon svg {
    width: 20px;
    height: 20px;
  }

  .dash-tile-label {
    font-size: 12.5px;
  }

  .dash-stats {
    grid-template-columns: 1fr 1fr;
  }

  .dash-stat-value {
    font-size: 24px;
  }

  .dash-transfer-row {
    padding: 12px 16px;
  }
}

@media (max-width: 380px) {
  .header-search input {
    font-size: 13.5px;
  }
}
