/* Mobile workbench shell
 * A compact execution-first layout inspired by native mobile workbenches.
 * Desktop navigation and page composition remain untouched.
 */

.mobile-workbench-dock,
.mobile-quick-actions {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --mobile-dock-height: 72px;
    --mobile-dock-offset: max(8px, env(safe-area-inset-bottom));
  }

  body {
    background:
      radial-gradient(circle at 12% 5%, rgb(91 92 226 / 7%), transparent 32%),
      #f5f7fb;
  }

  .app-main,
  body.nav-collapsed .app-main {
    padding-bottom: calc(var(--mobile-dock-height) + var(--mobile-dock-offset) + 18px);
  }

  .workspace-topbar {
    position: sticky;
    top: 0;
    z-index: 45;
    border-bottom: 1px solid rgb(216 222 235 / 88%);
    background: rgb(250 251 254 / 94%);
    box-shadow: 0 4px 18px rgb(35 46 75 / 5%);
  }

  body[data-active-page="home"] .workspace-tools > span:first-child {
    display: block;
    color: var(--ds-text-muted, #68738a);
    font-size: 11px;
    line-height: 1.25;
    text-align: right;
  }

  .mobile-workbench-dock {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: var(--mobile-dock-offset);
    left: max(8px, env(safe-area-inset-left));
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: end;
    min-height: var(--mobile-dock-height);
    overflow: hidden;
    border: 1px solid rgb(213 219 233 / 92%);
    border-radius: 20px;
    background: rgb(255 255 255 / 97%);
    padding: 6px 5px 5px;
    box-shadow: 0 14px 34px rgb(35 46 75 / 16%);
  }

  .mobile-workbench-dock .nav-btn,
  body.nav-collapsed .mobile-workbench-dock .nav-btn {
    position: relative;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 36px 18px;
    justify-items: center;
    align-content: center;
    gap: 0;
    width: 100%;
    min-width: 0;
    min-height: 58px;
    margin: 0;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #747e93;
    padding: 1px 2px 0;
    box-shadow: none;
    transform: none;
  }

  .mobile-workbench-dock .nav-btn::before {
    position: absolute;
    top: 1px;
    left: 50%;
    width: 24px;
    height: 3px;
    border-radius: 999px;
    background: transparent;
    content: "";
    transform: translateX(-50%);
  }

  .mobile-workbench-dock .nav-btn:hover {
    border: 0;
    background: rgb(91 92 226 / 5%);
    color: #4f5870;
    transform: none;
  }

  .mobile-workbench-dock .nav-btn.active {
    border: 0;
    background: transparent;
    color: var(--ds-brand-strong, #4d4fd5);
    box-shadow: none;
  }

  .mobile-workbench-dock .nav-btn.active::before {
    background: var(--ds-brand, #5b5ce2);
  }

  .mobile-dock-icon {
    display: grid;
    place-items: center;
    align-self: center;
    width: 32px;
    height: 32px;
    border-radius: 11px;
    transition: background 160ms ease, transform 160ms ease;
  }

  .mobile-workbench-dock .nav-btn.active .mobile-dock-icon {
    background: rgb(91 92 226 / 11%);
    transform: translateY(-2px);
  }

  .mobile-dock-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-dock-label,
  body.nav-collapsed .mobile-workbench-dock .nav-btn > .mobile-dock-label {
    display: block !important;
    overflow: visible;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: .01em;
    line-height: 18px;
    white-space: nowrap;
  }

  #page-home {
    padding-top: 12px;
  }

  #page-home .home-overview {
    gap: 12px;
  }

  #page-home .home-profile-stage {
    border-radius: 18px;
    box-shadow: 0 9px 28px rgb(35 46 75 / 8%);
  }

  #page-home .home-profile-stage .carousel-shell,
  #page-home .carousel-shell {
    height: clamp(212px, 60vw, 286px);
    border-radius: 0;
  }

  #page-home .home-profile-stage .carousel-caption,
  #page-home .carousel-caption {
    max-width: 86%;
    padding: 44px 16px 34px;
  }

  #page-home .home-profile-stage .home-profile-panel {
    margin: -18px 10px 10px;
    border: 1px solid rgb(221 226 237 / 84%);
    border-radius: 16px;
    padding: 13px;
    box-shadow: 0 9px 22px rgb(35 46 75 / 10%);
  }

  #page-home .home-profile-panel .metric-grid {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(116px, 42%);
    gap: 8px;
    overflow-x: auto;
    padding: 3px 1px 6px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  #page-home .home-profile-panel .metric-grid::-webkit-scrollbar,
  .mobile-quick-actions-grid::-webkit-scrollbar {
    display: none;
  }

  #page-home .home-profile-panel .metric,
  #page-home .home-profile-panel .metric:nth-child(even),
  #page-home .home-profile-panel .metric:nth-child(n + 3) {
    min-height: 72px;
    border: 1px solid rgb(221 226 237 / 92%);
    border-radius: 13px;
    background: #f8f9fd;
    padding: 9px 10px;
    scroll-snap-align: start;
  }

  .mobile-quick-actions {
    display: grid;
    gap: 10px;
    border: 1px solid rgb(220 225 237 / 92%);
    border-radius: 18px;
    background: rgb(255 255 255 / 96%);
    padding: 14px;
    box-shadow: 0 7px 22px rgb(35 46 75 / 6%);
  }

  .mobile-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-section-heading > div {
    display: flex;
    align-items: center;
    gap: 7px;
  }

  .mobile-section-heading h2 {
    margin: 0;
    color: var(--ds-text, #20283a);
    font-size: 17px;
    letter-spacing: -.01em;
  }

  .mobile-section-heading small {
    color: var(--ds-text-muted, #758097);
    font-size: 12px;
  }

  .mobile-quick-actions-grid {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(116px, 38%);
    gap: 9px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .mobile-quick-actions-grid button {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
    min-height: 52px;
    border: 1px solid rgb(218 223 236 / 96%);
    border-radius: 14px;
    background: #fafbfe;
    color: #303a50;
    padding: 8px 10px;
    scroll-snap-align: start;
    box-shadow: none;
  }

  .mobile-quick-actions-grid button > span {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: rgb(91 92 226 / 10%);
    color: var(--ds-brand-strong, #4d4fd5);
    font-size: 17px;
  }

  .mobile-quick-actions-grid button strong {
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #page-home .home-dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 0;
  }

  #page-home .home-dashboard-main {
    order: 1;
    gap: 12px;
  }

  #page-home .home-dashboard-sidebar {
    order: 2;
  }

  #page-home .home-dashboard-main > .panel,
  #page-home .home-dashboard-sidebar > .panel {
    border-radius: 18px;
  }

  #page-home .home-command-bar {
    border: 1px solid rgb(220 225 237 / 92%);
    border-radius: 18px;
    background: rgb(255 255 255 / 96%);
    padding: 14px;
    box-shadow: 0 7px 22px rgb(35 46 75 / 6%);
  }

  #page-home .home-command-actions {
    gap: 8px;
  }

  #page-home .home-command-actions button {
    min-height: 42px;
    border-radius: 12px;
  }
}

@media (max-width: 380px) {
  :root {
    --mobile-dock-height: 68px;
  }

  .mobile-workbench-dock {
    right: max(5px, env(safe-area-inset-right));
    left: max(5px, env(safe-area-inset-left));
    border-radius: 17px;
    padding-inline: 2px;
  }

  .mobile-workbench-dock .nav-btn,
  body.nav-collapsed .mobile-workbench-dock .nav-btn {
    grid-template-rows: 34px 17px;
    min-height: 55px;
    padding-inline: 0;
  }

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

  .mobile-dock-label,
  body.nav-collapsed .mobile-workbench-dock .nav-btn > .mobile-dock-label {
    font-size: 10px;
  }

  #page-home .home-profile-identity {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  #page-home .profile-avatar-shell {
    width: 68px;
    height: 88px;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  :root {
    --mobile-dock-height: 62px;
  }

  .mobile-workbench-dock .nav-btn,
  body.nav-collapsed .mobile-workbench-dock .nav-btn {
    grid-template-rows: 31px 16px;
    min-height: 49px;
  }

  .mobile-dock-icon {
    width: 29px;
    height: 29px;
  }
}

@media print {
  .mobile-workbench-dock,
  .mobile-quick-actions {
    display: none !important;
  }
}
