/* Mobile application shell and responsive workspaces */
@media (max-width: 760px) {
  :root {
    --page-x: 10px;
    --page-y: 10px;
    --control-h: 38px;
    --work-bottom-gap: 86px;
  }

  html,
  body {
    min-width: 0;
    overflow-x: hidden;
  }

  .shell,
  .shell.is-sidebar-collapsed,
  .shell.is-wide-workspace,
  .shell.is-sidebar-collapsed.is-wide-workspace,
  .shell.is-journal-shell,
  .shell.is-schedule-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    min-height: 100dvh;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .sidebar,
  .right-panel,
  .shell.is-schedule-shell .sidebar,
  .shell.is-schedule-shell .right-panel,
  .shell.is-journal-shell .sidebar,
  .shell.is-journal-shell .right-panel {
    display: none !important;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    grid-column: 1;
    grid-row: 1;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    min-height: 54px;
    padding: 8px 12px;
    background: rgba(246, 248, 251, 0.94);
    border-bottom: 1px solid var(--border-light);
    backdrop-filter: blur(14px);
  }

  .mobile-logo {
    width: 122px;
    height: 34px;
    object-fit: contain;
    object-position: left center;
  }

  .mobile-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
  }

  .mobile-topbar .icon-btn {
    width: 30px;
    height: 30px;
  }

  .mobile-topbar .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .mobile-topbar .notify-dot {
    top: 1px;
    right: 1px;
  }

  .mobile-topbar .team-notifications-popover {
    right: -2px;
    left: auto;
  }

  .mobile-branch {
    max-width: 86px;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: var(--weight-medium);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-topbar .topbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    min-width: 24px;
    height: 24px;
    font-size: 10px;
    line-height: 1;
  }

  .mobile-topbar .account-popover {
    position: fixed;
    top: 58px;
    right: 10px;
    width: min(300px, calc(100vw - 20px));
  }

  .mobile-topbar .account-popover::before {
    right: 16px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border-light);
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(16px);
  }

  .mobile-bottom-nav button {
    display: grid;
    min-width: 0;
    min-height: 48px;
    place-items: center;
    gap: 3px;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 13px;
  }

  .mobile-bottom-nav button span {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    color: currentColor;
  }

  .mobile-bottom-nav svg {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-bottom-nav svg path,
  .mobile-bottom-nav svg circle,
  .mobile-bottom-nav svg rect,
  .mobile-bottom-nav svg line,
  .mobile-bottom-nav svg polyline {
    fill: none;
    stroke: currentColor;
  }

  .mobile-bottom-nav strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 10px;
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-bottom-nav button.is-active {
    color: var(--primary);
    background: var(--primary-soft);
  }

  .workspace,
  .shell.is-wide-workspace .workspace,
  .workspace.is-journal-workspace,
  .workspace.is-schedule-workspace {
    grid-column: 1;
    grid-row: 2;
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    max-height: none;
    padding-bottom: 86px;
    overflow: visible;
  }

  .workspace > .clients-page,
  .workspace > .analytics-page,
  .workspace > .settings-page,
  .workspace > .client-card-page,
  .workspace > .schedule-page,
  .workspace > .journal-page {
    display: block;
    min-height: auto;
    height: auto;
    max-height: none;
    padding: 10px 10px 92px;
    overflow: visible;
  }

  .view-toolbar,
  .journal-toolbar,
  .client-base-toolbar,
  .page-header {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    min-height: auto;
    padding: 0 0 10px;
  }

  .toolbar-group,
  .journal-toolbar .toolbar-title-group,
  .journal-toolbar-actions,
  .page-actions {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }

  .journal-toolbar .journal-title,
  .schedule-heading,
  .page-title {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    font-size: 17px;
    line-height: 1.15;
  }

  .journal-toolbar .staff-filter,
  .staff-filter,
  .staff-filter-trigger,
  .journal-toolbar-search,
  .toolbar-search,
  .client-base-search,
  .page-actions .btn,
  .toolbar-group .btn:not(.icon-only),
  .clients-page .page-actions {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1 1 100%;
  }

  .journal-toolbar .day-nav-btn,
  .journal-toolbar .date-inline,
  .schedule-nav-btn,
  .btn.icon-only.day-nav-btn {
    width: 38px !important;
    min-width: 38px !important;
    height: 38px;
    min-height: 38px;
    flex: 0 0 38px;
  }

  .journal-toolbar .compact-primary,
  .btn.primary,
  .btn.success,
  .btn {
    min-height: 38px;
    border-radius: 10px;
  }

  .journal,
  .schedule-stage {
    display: none;
  }

  .mobile-journal-list,
  .mobile-schedule-list {
    display: grid;
    gap: 10px;
  }

  .mobile-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
  }

  .mobile-section-head > div {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .mobile-section-head strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: var(--weight-bold);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-section-head span,
  .mobile-card-meta,
  .mobile-schedule-card small {
    color: var(--text-secondary);
    font-size: 12px;
  }

  .mobile-card-list {
    display: grid;
    gap: 8px;
  }

  .mobile-appointment-card,
  .mobile-schedule-card,
  .mobile-empty-card {
    position: relative;
    display: grid;
    width: 100%;
    min-width: 0;
    gap: 5px;
    padding: 13px 14px;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
  }

  .mobile-appointment-card {
    padding-left: 18px;
  }

  .mobile-appointment-card::before {
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: 9px;
    width: 3px;
    content: "";
    background: var(--event-color, var(--primary));
    border-radius: 999px;
  }

  .mobile-card-time {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: var(--weight-semibold);
  }

  .mobile-card-title {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: var(--weight-bold);
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-appointment-card .status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  .mobile-schedule-card {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
  }

  .mobile-schedule-card .client-initial {
    width: 42px;
    height: 42px;
  }

  .mobile-schedule-card strong {
    display: block;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .mobile-schedule-card em {
    color: var(--primary);
    font-size: 11px;
    font-style: normal;
    font-weight: var(--weight-semibold);
  }

  .mobile-schedule-card.is-off {
    background: #FAFBFD;
  }

  .mobile-schedule-card.is-off em {
    color: var(--text-muted);
  }

  .clients-page > .client-base-toolbar.view-toolbar {
    padding: 0 0 10px;
  }

  .clients-page .page-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .clients-workspace.table-card,
  .table-card,
  .settings-table {
    margin: 0;
    overflow: visible;
  }

  .client-register-head {
    display: none;
  }

  .client-register-body {
    display: grid;
    gap: 8px;
  }

  .client-register-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px 10px;
    min-height: auto;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
  }

  .client-register-row > span:first-child {
    grid-row: 1 / 3;
    padding: 0;
  }

  .client-register-person {
    grid-column: 2 / 4;
    min-height: auto;
    padding: 0;
  }

  .client-register-person strong {
    font-size: 14px;
  }

  .client-phone-cell {
    grid-column: 2;
    min-height: auto;
    justify-items: start;
    padding: 0;
    font-size: 12px;
  }

  .client-register-row .client-register-cell:nth-child(4) {
    grid-column: 3;
    grid-row: 2;
    min-height: auto;
    justify-items: end;
    padding: 0;
  }

  .client-register-row .client-register-cell:nth-child(n+5) {
    display: none;
  }

  .client-card-hero,
  .client-card-main,
  .client-name-row,
  .client-card-actions,
  .profile-settings-head,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .client-card-hero {
    display: grid;
    gap: 12px;
    padding: 14px;
  }

  .client-name-row h1 {
    font-size: 22px;
    line-height: 1.15;
  }

  .client-card-meta,
  .client-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .client-card-meta::-webkit-scrollbar,
  .client-tabs::-webkit-scrollbar {
    display: none;
  }

  .client-card-actions {
    width: 100%;
  }

  .client-card-actions .btn {
    width: 100%;
  }

  .client-card-metrics,
  .form-grid.two,
  .quick-client-grid,
  .client-data-grid,
  .medical-grid,
  .analytics-kpis,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .client-tab-panel,
  .panel-section.profile-settings-card,
  .client-section-card,
  .medical-card {
    padding: 14px;
  }

  .settings-service-filters,
  .employees-filters {
    grid-template-columns: 1fr;
    padding: 0 0 10px;
    background: transparent;
    border: 0;
  }

  .settings-table-head {
    display: none;
  }

  .settings-table-body {
    display: grid;
    gap: 8px;
  }

  .settings-row,
  .employees-table .settings-row,
  .services-table .settings-row,
  .access-table .settings-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: auto;
    padding: 13px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
  }

  .settings-row > span {
    white-space: normal;
  }

  .system-admin-shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .system-admin-sidebar {
    position: static;
    width: auto;
    min-height: auto;
    padding: 18px 14px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border-light);
  }

  .system-admin-workspace {
    padding: 14px;
  }

  .system-admin-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .system-admin-header h1 {
    font-size: 28px;
  }

  .system-admin-header > strong {
    width: 42px;
    height: 42px;
  }

  .system-admin-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .system-admin-card {
    padding: 14px;
  }

  .system-org-row {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .system-org-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .modal {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }

  .modal-body {
    max-height: calc(100dvh - 178px);
  }

  .appointment-photo-inline,
  .sale-summary-grid,
  .sale-payment-grid,
  .sale-item-row,
  .block-time-fields {
    grid-template-columns: 1fr;
  }

  .appointment-service-row {
    position: relative;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding-right: 42px;
  }

  .appointment-service-row > .field:first-child {
    grid-column: 1 / -1;
  }

  .appointment-service-remove {
    position: absolute;
    right: 0;
    bottom: 0;
  }

  .appointment-services-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .appointment-services-summary {
    justify-items: start;
    text-align: left;
  }

  .sale-item-row {
    gap: 8px;
  }

  .sale-item-remove {
    width: 100%;
  }

  .sale-items-head,
  .sale-payments-history > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .sale-items-head .btn {
    width: 100%;
  }

  .appointment-cancel-confirmation-layer {
    padding: 12px;
  }

  .appointment-cancel-confirmation {
    width: min(470px, calc(100vw - 24px));
    padding: 22px 18px 18px;
  }

  .appointment-cancel-confirmation-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .appointment-cancel-confirmation-actions .btn {
    width: 100%;
  }
}
