/* Shared phone/tablet layout. Loaded after page styles; desktop keeps its layout. */
.mobile-disclosure {
  min-width: 0;
}
.compact-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.compact-action > svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.compact-action-context {
  display: none;
}
.compact-action-tooltip {
  position: fixed;
  z-index: 1300;
  max-width: min(280px, calc(100vw - 16px));
  padding: 8px 12px;
  border: 1px solid var(--border-glass-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.compact-action-tooltip[hidden] {
  display: none;
}
.mobile-disclosure > summary {
  display: none;
}
.mobile-disclosure:not(.mobile-active) {
  display: contents;
}
.reveal-immediate [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
  transition: none !important;
}

@media (max-width: 900px) {
  :root {
    --mobile-bar: calc(60px + env(safe-area-inset-top));
    --mobile-gap: 16px;
  }
  html {
    min-height: 100dvh;
    scroll-padding-top: calc(var(--mobile-bar) + 16px);
  }
  body {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: auto;
    overflow-x: clip;
    background-attachment: scroll;
  }
  body:has(.sidebar) {
    padding-top: var(--mobile-bar);
  }
  body:not(:has(.sidebar)) {
    padding-top: 0;
  }
  body.theme-dark,
  body.theme-light {
    background: var(--bg);
  }
  body:has(.sidebar) > main {
    flex: 1 0 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    min-height: calc(100dvh - var(--mobile-bar));
    padding: 20px max(var(--mobile-gap), env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(var(--mobile-gap), env(safe-area-inset-left));
    margin: 0;
    overflow: visible;
    align-content: start;
    border-radius: 0;
    animation: none;
  }
  body::before,
  .aurora-orb {
    display: none;
  }
  body.mobile-nav-open {
    overflow: hidden;
  }
  .mobile-topbar {
    position: fixed;
    inset: 0 0 auto;
    height: var(--mobile-bar);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0
      max(16px, env(safe-area-inset-left));
    background: #101221;
    border-bottom: 1px solid var(--border-glass);
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .mobile-topbar-logo {
    display: flex;
    align-items: center;
    height: 100%;
  }
  .mobile-topbar-logo img {
    width: 70px;
    height: 46px;
    object-fit: contain;
  }
  .mobile-menu-btn {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 22px;
    box-shadow: none;
    border-radius: 10px;
  }
  .sidebar {
    position: fixed;
    top: var(--mobile-bar);
    left: 0;
    width: min(100vw, 100%);
    max-width: 100%;
    height: calc(100dvh - var(--mobile-bar));
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
    transform: translateX(-105%);
    visibility: hidden;
    pointer-events: none;
    transition:
      transform var(--t-sheet) var(--ease-ios),
      visibility var(--t-sheet);
    z-index: 1100;
    border-radius: 0;
    background: #101221;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .sidebar.show {
    transform: none;
    visibility: visible;
    pointer-events: auto;
  }
  .sidebar-logo {
    display: none;
  }
  .sidebar-nav {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .sidebar-nav a,
  .sidebar-user-profile-btn,
  .sidebar-user-menu-item {
    min-height: 44px;
    font-size: 14px;
  }
  .sidebar-user-name {
    font-size: 14px;
  }
  .sidebar-user-role {
    font-size: 12px;
  }
  .sidebar-footer {
    flex-shrink: 0;
  }
  .sidebar-overlay {
    position: fixed;
    inset: var(--mobile-bar) 0 0;
    /* Always rendered so it can fade; visibility keeps it from catching taps while closed. */
    display: block;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity var(--t-sheet) var(--ease-ios),
      visibility var(--t-sheet);
    background: rgb(0 0 0 / 0.55);
    z-index: 1000;
  }
  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* One reading column and restrained surfaces, without nested page scrolling. */
  main > *,
  main :is(section, form, header, fieldset, article),
  main :is([class$="-grid"], [class$="-layout"]) > * {
    min-width: 0;
  }
  main > header,
  .dashboard-header,
  .dev-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
    padding: 0;
    margin: 0 0 16px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  main > header > div {
    min-width: 0;
    max-width: 100%;
  }
  main > header h1,
  .dev-page-header h1 {
    font-size: clamp(21px, 5vw, 27px);
    line-height: 1.2;
    overflow-wrap: anywhere;
    margin-bottom: 6px;
  }
  main
    :is(
      .page-eyebrow,
      .dashboard-eyebrow,
      .management-eyebrow,
      .dev-page-eyebrow,
      .access-kicker
    ) {
    display: none;
  }
  main
    :is(
      .card,
      .panel,
      .user-form,
      .users-panel,
      .settings-section,
      .time-form,
      .time-list-panel,
      .location-form,
      .locations-panel,
      .mail-section,
      .performance-panel
    ) {
    border-radius: 12px;
    box-shadow: none;
    backdrop-filter: none;
    padding: 16px;
  }
  main :is(.card, .panel, header, form)::before,
  main :is(.card, .panel, header, form)::after {
    display: none;
  }
  main :is(h1, h2) {
    -webkit-text-fill-color: currentColor;
    background-clip: border-box;
  }
  main h1 {
    background-image: none;
  }
  main :is(h2, h3) {
    overflow-wrap: anywhere;
  }
  main h2 {
    font-size: 18px;
    line-height: 1.3;
  }
  main p {
    line-height: 1.5;
  }
  main label {
    text-transform: none;
    letter-spacing: normal;
  }
  main label > span {
    text-transform: none;
    letter-spacing: normal;
  }
  main
    :is(
      input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not(
          [type="color"]
        ),
      select,
      textarea
    ) {
    font-size: 16px;
    max-width: 100%;
    min-height: 44px;
    scroll-margin-block: 90px 24px;
  }
  main :is(button, .button, .btn, .panel-link, .c-select__trigger) {
    min-height: 44px;
    white-space: normal;
  }
  main :is(.icon-btn, .icon-button, .btn-icon-sm) {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    flex-shrink: 0;
  }
  main button::after {
    display: none;
  }
  .studio-selector {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  .studio-switch-btn {
    width: 100%;
    min-height: 44px;
    font-size: 14px;
  }
  #studio-switch-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .studio-menu {
    width: 100%;
    left: 0;
    right: 0;
    max-height: min(420px, 60dvh);
    overflow-y: auto;
  }
  .studio-menu-item {
    min-height: 44px;
  }
  main
    :is(
      .users-panel,
      .user-form,
      .time-panel-scroll,
      .inventory-list,
      .mail-list
    ) {
    max-height: none;
    height: auto;
  }
  .table-scroll,
  .table-wrapper,
  .table-container,
  .time-panel-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  /* Use the phone's native picker; no tiny custom popover or offscreen menu. */
  .c-select > .c-select__trigger {
    display: none;
  }
  .c-select > select {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    opacity: 1 !important;
    overflow: visible !important;
    pointer-events: auto !important;
  }
  .c-select {
    min-width: 0;
    max-width: 100%;
  }

  .mobile-disclosure.mobile-active {
    display: block;
    border: 1px solid var(--border-glass-mid);
    border-radius: 12px;
    background: var(--glass-4);
    min-width: 0;
  }
  .mobile-disclosure.mobile-active > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    min-height: 48px;
    font-size: 14px;
    font-weight: 650;
    cursor: pointer;
    list-style: none;
  }
  .mobile-disclosure > summary::-webkit-details-marker {
    display: none;
  }
  .mobile-disclosure.mobile-active > summary::after {
    content: "+";
    flex: none;
    font-size: 20px;
  }
  .mobile-disclosure.mobile-active[open] > summary::after {
    content: "−";
  }
  .mobile-disclosure.mobile-active > :not(summary) {
    margin: 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
  }
  .mobile-disclosure.mobile-active > p {
    padding: 0 16px 14px;
  }
  .mobile-disclosure .mobile-section-heading {
    display: none;
  }
  .mobile-disclosure.mobile-help {
    background: transparent;
    border: 0;
  }
  .mobile-disclosure.mobile-help > summary {
    padding: 8px 0;
    color: var(--text-secondary);
    min-height: 44px;
    font-size: 13px;
  }
  .mobile-disclosure.mobile-help > p {
    padding: 0 0 12px;
  }

  /* Dialogs scroll inside the available viewport instead of clipping their actions. */
  :is(.modal, .modal-overlay) {
    padding: max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  :is(
    .modal-content,
    .modal-box,
    .contact-detail-modal,
    .ac-modal-card
  ) {
    max-width: 100%;
    max-height: calc(
      100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .live-audio-toggle {
    bottom: max(12px, env(safe-area-inset-bottom));
    right: max(12px, env(safe-area-inset-right));
    max-width: calc(100% - 24px);
  }
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }

  /* Mobile has no scroll-reveal (content must never start hidden), so sections cascade in once
     with a pure-CSS animation instead: backwards-fill only, nothing lingers after it ends. */
  @media (prefers-reduced-motion: no-preference) {
    main > :not(.modal):not(dialog):not([role="dialog"]):not([hidden]) {
      animation: mobile-rise 0.65s var(--ease-ios) backwards;
    }
    main > :nth-child(2) { animation-delay: 0.05s; }
    main > :nth-child(3) { animation-delay: 0.1s; }
    main > :nth-child(4) { animation-delay: 0.15s; }
    main > :nth-child(5) { animation-delay: 0.2s; }
    main > :nth-child(6) { animation-delay: 0.25s; }
    main > :nth-child(n+7) { animation-delay: 0.3s; }
  }

  /* Dashboard: brief overview first; detailed reports stay one tap away. */
  .dashboard {
    gap: 16px;
  }
  .dashboard-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .dashboard-kpis .kpi-card {
    min-height: 120px;
    padding: 14px;
  }
  .kpi-card .kpi-icon {
    display: none;
  }
  .dashboard-kpis .number {
    font-size: 28px;
    margin: 8px 0;
  }
  .dashboard-kpis h3 {
    font-size: 13px;
    min-height: 0;
    text-transform: none;
    letter-spacing: normal;
  }
  .dashboard-kpis small {
    font-size: 12px;
    text-transform: none;
    letter-spacing: normal;
  }
  .dashboard-kpis .kpi-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    min-height: 84px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 12px;
  }
  .dashboard-kpis .kpi-card:last-child:nth-child(odd) .number {
    grid-column: 2;
    grid-row: 1 / 3;
  }
  .dashboard-kpis .kpi-card:last-child:nth-child(odd) small {
    grid-column: 1;
    grid-row: 2;
  }
  .performance-chart {
    min-width: 0;
    width: 100%;
    height: auto;
  }
  .dashboard-top-grid,
  .dashboard-content,
  .dashboard-cockpit {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  /* Management becomes a compact directory rather than ten oversized tiles. */
  .management-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .management-grid .management-tile {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 4px 12px;
    min-height: 84px;
    padding: 14px;
    border-radius: 12px;
    box-shadow: none;
    backdrop-filter: none;
  }
  .management-tile .management-tile-icon {
    grid-row: 1 / 3;
    width: 36px;
    height: 36px;
    margin: 0;
    border-radius: 9px;
  }
  .management-tile h3 {
    margin: 0;
    font-size: 15px;
  }
  .management-groups { gap: 24px; }
  .management-tile p {
    margin: 0;
    font-size: 12px;
  }
  .management-tile:hover {
    transform: none;
  }

  .dev-page-header-left {
    min-width: 0;
    width: 100%;
    gap: 12px;
  }
  .dev-page-header-left > div {
    min-width: 0;
  }
  .dev-page-header-icon {
    display: none;
  }
  .dev-status-pills {
    flex-wrap: wrap;
    max-width: 100%;
  }
  .dev-page :is(.dev-grid, .dev-two-col, .dev-stats-grid) {
    grid-template-columns: minmax(0, 1fr);
  }
  .dev-page :is(input, pre, code) {
    overflow-wrap: anywhere;
    min-width: 0;
    max-width: 100%;
  }
  .dev-page pre {
    overflow-x: auto;
  }
  .dev-page .dev-card {
    padding: 16px;
    border-radius: 12px;
    box-shadow: none;
    backdrop-filter: none;
  }
  .dev-card-icon {
    display: none;
  }
  .dev-card::before,
  .dev-card::after {
    display: none;
  }
  .mail-page .mail-grid {
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
  }
  .mail-page .mail-section {
    padding: 16px;
  }
  .mail-page .mail-section-header {
    gap: 12px;
    flex-wrap: wrap;
  }
  .time-summary {
    gap: 10px;
  }
  .tasks .date-panel {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 12px;
    box-shadow: none;
  }
  .tasks .task-header-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    width: 100%;
  }
  .tasks .task-header-info > div {
    min-width: 0;
  }
  .tasks .employee-name {
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .tasks .weekly-progress-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }
  .tasks .weekly-progress-card {
    padding: 14px;
    border-radius: 12px;
    box-shadow: none;
  }
  .tasks .weekly-progress-icon {
    display: none;
  }
  .tasks .weekly-progress-info {
    min-width: 0;
    width: 100%;
  }
  .tasks .weekly-progress-label {
    font-size: 12px;
    text-transform: none;
    letter-spacing: normal;
  }
  .panel-header {
    flex-wrap: wrap;
  }
  .panel-header h2 {
    flex: 1 1 160px;
    overflow-wrap: normal;
  }
  .status-strip,
  .live-stage {
    border-radius: 12px;
    box-shadow: none;
  }
  .status-strip > div {
    padding: 12px;
  }
  .status-strip span {
    font-size: 12px;
    text-transform: none;
    white-space: normal;
    letter-spacing: normal;
  }
  .live-stage {
    padding: 16px;
  }
  .admin-time-controls {
    flex-wrap: wrap;
  }
  .month-nav {
    padding: 8px;
    gap: 6px;
    max-width: 100%;
    flex-wrap: wrap;
  }
  .month-nav-label {
    min-width: 0;
  }
  .cal-day {
    min-width: 0;
    width: 100%;
    aspect-ratio: auto;
    padding: 4px 0;
  }
  .login-page {
    min-height: 100dvh;
    padding: max(20px, env(safe-area-inset-top)) 16px
      max(20px, env(safe-area-inset-bottom));
  }
  .login-card {
    padding: 24px;
    border-radius: 16px;
  }
  .login-logo {
    margin-bottom: 20px;
  }
  .login-logo img {
    width: 90px;
  }
  .login-form input {
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  main .compact-action {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    gap: 0;
  }
  .compact-action > .compact-action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .inventory .order-tab-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 8px 0;
    overflow: visible;
  }
  .inventory .order-tab {
    min-width: 0;
  }
  .compact-action-context {
    display: block;
    padding: 16px 16px 0;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
  }
}

@media (max-width: 480px) {
  main > header {
    flex-direction: column;
  }
  .time-summary,
  .time-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .settings-profile-head {
    flex-wrap: wrap;
  }
  .modal-content,
  .modal-box {
    padding: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
/* Individual transform properties compose with the element's own `transform`, so children that
   centre themselves with translate(-50%, -50%) keep their position while they animate. */
@keyframes mobile-rise {
  from { opacity: 0; translate: 0 18px; scale: 0.985; }
}
