.mobile-nav {
  display: none;
}

.account-menu {
  position: relative;
  flex: none;
}

.account-menu summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 5px 8px;
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
  font-size: .88rem;
  font-weight: 650;
}

.account-menu summary::-webkit-details-marker {
  display: none;
}

.account-menu summary:hover,
.account-menu[open] summary {
  background: var(--brand-soft);
}

.account-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
}

.account-avatar .ui-icon {
  width: 19px;
  height: 19px;
}

.account-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 230px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(23, 32, 51, .16);
}

.account-popover strong {
  overflow: hidden;
  padding: 9px 10px 12px;
  border-bottom: 1px solid var(--line);
  text-overflow: ellipsis;
}

.account-popover a,
.account-popover .link-button {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 11px 10px;
  border-radius: 8px;
  color: #344054;
  text-align: left;
}

.account-popover a:hover,
.account-popover .link-button:hover {
  background: #f4f7f8;
}

@media (max-width: 760px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
    background: var(--canvas);
  }

  .topbar {
    height: 60px;
    min-height: 60px;
    padding: 0 14px;
    flex-wrap: nowrap;
  }

  .brand {
    gap: 9px;
    font-size: .95rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .main-nav {
    display: none;
  }

  .account-name {
    display: none;
  }

  .account-menu summary {
    padding: 4px;
  }

  .account-popover {
    position: fixed;
    top: 66px;
    right: 12px;
    left: 12px;
    min-width: 0;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -8px 24px rgba(23, 32, 51, .08);
    backdrop-filter: blur(16px);
  }

  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 54px;
    border-radius: 11px;
    color: #667085;
    font-size: .68rem;
    font-weight: 700;
  }

  .mobile-nav a[aria-current="page"] {
    color: var(--brand-dark);
    background: var(--brand-soft);
  }

  .mobile-nav .ui-icon {
    width: 22px;
    height: 22px;
  }

  .page-shell {
    width: calc(100% - 24px);
    margin: 24px auto 32px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    margin-bottom: 20px;
  }

  .page-header h1 {
    margin-top: 7px;
    font-size: clamp(1.8rem, 9vw, 2.5rem);
    line-height: 1.08;
  }

  .page-header > .button,
  .page-header > .actions {
    width: 100%;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .actions .button,
  .actions form,
  .actions form .button {
    width: 100%;
  }

  .button {
    min-height: 46px;
    padding: 11px 15px;
  }

  .card {
    padding: 16px;
    border-radius: 15px;
    box-shadow: 0 8px 22px rgba(23, 32, 51, .055);
  }

  .filters,
  .filters-compact,
  .form-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .filter-actions,
  .full-span {
    grid-column: auto;
  }

  .filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .field input,
  .field select,
  .field textarea,
  .form-stack input {
    min-height: 48px;
    padding: 12px;
    border-radius: 10px;
    font-size: 16px;
  }

  .field textarea {
    min-height: 112px;
  }

  .field label {
    font-size: .84rem;
  }

  .table-wrap {
    overflow: visible;
    margin: 0 -4px;
  }

  .data-table,
  .data-table tbody {
    display: block;
    width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tr {
    display: block;
    margin-bottom: 12px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
  }

  .data-table tr:last-child {
    margin-bottom: 0;
  }

  .data-table td,
  .data-table td:nth-child(3),
  .data-table td:nth-child(4) {
    display: grid;
    grid-template-columns: minmax(88px, 35%) minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    padding: 7px 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .data-table td:first-child {
    display: block;
    margin-bottom: 5px;
    padding: 0 0 10px;
    border-bottom: 1px solid var(--line);
  }

  .data-table td:first-child::before {
    content: none;
  }

  .data-table td:first-child .table-identity-link {
    width: 100%;
    min-height: 38px;
  }

  .pagination {
    justify-content: flex-start;
    overflow-x: auto;
    margin: 4px -4px 0;
    padding: 18px 4px 2px;
  }

  .pagination a,
  .pagination .current {
    min-width: 44px;
    min-height: 44px;
    text-align: center;
  }

  .detail-grid,
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .full-detail {
    grid-column: auto;
  }

  .details div {
    padding: 11px 0;
  }

  .nested-form {
    margin: 0 -4px;
    padding: 18px 4px;
  }

  .field ul[id$="_roles"] {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field ul[id$="_roles"] label {
    min-height: 46px;
  }

  .sticky-actions {
    bottom: calc(76px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px;
  }

  .danger-zone {
    padding: 8px 0;
    text-align: center;
  }

  .link-danger {
    min-height: 44px;
    padding: 10px;
  }

  .auth-layout {
    display: block;
    min-height: auto;
  }

  .auth-card {
    max-width: none;
    padding: 22px 18px;
  }

  .table-icon {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 380px) {
  .filter-actions,
  .actions,
  .sticky-actions {
    grid-template-columns: 1fr;
  }

  .data-table td {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}
