/* Phone and tablet presentation used by the Android shell and mobile web app. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.launch-splash { display: none; }

.launch-splash-active {
  overflow: hidden;
}

.launch-splash-active .launch-splash {
  position: fixed;
  z-index: 2147483647;
  inset: 0;
  display: block;
  overflow: hidden;
  background: #020914;
  opacity: 1;
  transition: opacity .4s ease;
}

.launch-splash-active .launch-splash img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.launch-splash-active.launch-splash-fading .launch-splash {
  opacity: 0;
}

button,
a,
input,
select,
textarea,
label {
  touch-action: manipulation;
}

.android-app .auth-choice { display:none; }

/* The installed Android experience should read as an app screen, not a web
   dialog sitting over the dashboard. */
.android-app:has(.auth-modal[open]) .shell > :not(.auth-modal) {
  visibility: hidden;
}

@media (max-width: 760px) {
  :root { --mobile-nav-height: 72px; }

  body,
  body.dark,
  body:not(.dark) {
    min-width: 0;
    overflow-x: hidden;
    background-color: #020914;
    background-image: linear-gradient(rgba(1, 8, 21, .08), rgba(1, 8, 21, .2)), url("assets/dropsquid-mobile-background.jpg");
    background-position: center top;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }

  .auth-modal::backdrop,
  body:not(.dark) .auth-modal::backdrop {
    background-color: #020914;
    background-image: linear-gradient(rgba(1, 8, 21, .12), rgba(1, 8, 21, .24)), url("assets/dropsquid-mobile-background.jpg");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
  }

  body.android-app .auth-modal::backdrop,
  body.android-app:not(.dark) .auth-modal::backdrop {
    background: transparent;
  }

  body.android-app,
  body.android-app.dark,
  body.android-app:not(.dark) {
    background-color: #020914;
    background-image:
      linear-gradient(180deg, rgba(1, 7, 18, .08) 0%, rgba(1, 7, 18, .18) 54%, rgba(1, 7, 18, .38) 100%),
      url("assets/dropsquid-mobile-background.jpg");
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
  }

  body.android-app .auth-modal {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
    border-radius: 0;
    overflow-y: auto;
    background-color: #020914;
    background-image:
      linear-gradient(180deg, rgba(1, 7, 18, .08) 0%, rgba(1, 7, 18, .18) 54%, rgba(1, 7, 18, .38) 100%),
      url("assets/dropsquid-mobile-background.jpg");
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
  }

  body.android-app .auth-brand {
    margin: 2vh auto 14px;
  }

  body.android-app .auth-brand-logo {
    width: 92px;
    height: 92px;
  }

  body.android-app .auth-brand-wordmark {
    width: min(280px, 76vw);
    height: 52px;
    margin-top: -10px;
  }

  body.android-app .auth-brand > span {
    margin-top: -8px;
    font-size: 10px;
    letter-spacing: 3.2px;
  }

  body.android-app .auth-modal form {
    width: min(100%, 430px);
    margin: 0 auto;
    padding: 24px 24px 22px;
    border-color: rgba(64, 183, 255, .58);
    background: linear-gradient(155deg, rgba(7, 27, 54, .88), rgba(2, 14, 31, .82));
    box-shadow: 0 18px 50px rgba(0, 4, 16, .38), inset 0 1px 0 rgba(255, 255, 255, .08);
  }
  .shell { display: block; min-height: 100dvh; }

  /* The primary destinations stay within thumb reach. */
  .sidebar {
    position: fixed;
    z-index: 100;
    inset: auto 0 0;
    width: 100%;
    height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    border: 0;
    border-top: 1px solid rgba(65, 160, 245, .28);
    box-shadow: 0 -10px 30px rgba(0, 5, 18, .28);
    overflow: visible;
  }

  .sidebar > .brand { display: none; }
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(7, minmax(48px, 1fr));
    gap: 0;
    width: 100%;
    height: var(--mobile-nav-height);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .sidebar nav [data-view="connections"] { display: none!important; }
  .sidebar .mobile-more { display: flex!important; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav .nav-link:not(.settings) {
    min-width: 48px;
    min-height: 56px;
    padding: 8px 3px 6px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    color: #a9bfd6;
    font-size: 9px;
    line-height: 1.05;
    text-align: center;
    white-space: nowrap;
  }
  .sidebar nav .nav-link:not(.settings) > span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    font-size: 21px;
  }
  .sidebar .nav-symbol { width: 21px; height: 21px; }
  .sidebar .nav-link.active { color: #fff; }

  /* Put account and appearance controls in the far-right More menu. */
  .sidebar-bottom {
    position: static;
  }
  .sidebar-bottom .connection,
  .sidebar-bottom .theme-toggle,
  .sidebar-bottom .settings { display: none; }
  .sidebar-bottom .profile {
    position: static;width:0;height:0;padding:0;border:0;
  }
  .sidebar-bottom .profile-copy,.profile .profile-avatar-button,.profile .profile-menu-button { display:none; }
  .profile-menu {
    position: fixed;
    top: auto;
    right: 10px;
    bottom: calc(var(--mobile-nav-height) + 10px + env(safe-area-inset-bottom));
    left: auto;
    width: min(300px,calc(100vw - 20px));
    padding: 8px;
    border-radius: 16px;
    box-shadow:0 18px 45px rgba(0,0,0,.5);
  }
  .profile-menu button { min-height: 46px; width: 100%; text-align: left; font-size:13px; }

  main {
    width: 100%;
    margin: 0;
    padding: calc(72px + env(safe-area-inset-top)) 14px calc(var(--mobile-nav-height) + 26px + env(safe-area-inset-bottom));
  }
  main > header { min-height: 38px; margin-bottom: 18px; padding-right: 0; }
  main > header h1 { font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; }

  .section-heading,
  .panel-head,
  .tool-row { align-items: stretch; flex-direction: column; }
  .section-heading { gap: 14px; margin-bottom: 18px; }
  .section-heading h2 { font-size: 22px; }
  .section-heading p { line-height: 1.55; }
  .header-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .header-actions > button:only-child { grid-column: 1 / -1; }
  .header-actions button { width: 100%; min-height: 46px; white-space: normal; }

  .primary,
  .secondary,
  .danger-button,
  .text-button,
  .row-action,
  .icon-button { min-height: 44px; padding: 11px 14px; }
  input,
  select,
  textarea,
  .search { font-size: 16px !important; }
  input,
  select { min-height: 46px; }
  textarea { min-height: 96px; }

  .panel { padding: 16px; border-radius: 13px; }
  .stats,
  .health-list,
  .monitor-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stat, .monitor-summary div { padding: 14px 12px; }
  .stat strong { font-size: 19px; }
  .dashboard-grid,
  .fulfillment-layout,
  .fulfillment-explainer,
  .create-layout { grid-template-columns: minmax(0, 1fr); }
  .notice { align-items: flex-start; padding: 13px; }
  .notice .notice-icon { flex: 0 0 29px; }

  .tool-row { gap: 9px; }
  .search { width: 100%; min-height: 46px; }
  .tool-row select { width: 100%; min-height: 46px; }

  /* Product tables become readable cards instead of requiring horizontal swipes. */
  .table-panel {
    max-width: 100%;
    overflow: visible;
    border-radius: 13px;
  }
  .table-panel table { min-width: 0; display: block; }
  .table-panel thead { display: none; }
  .table-panel tbody { display: grid; gap: 12px; padding: 12px; }
  .table-panel tr { display: block; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
  .table-panel td { display: grid; grid-template-columns:minmax(92px, .7fr) minmax(0, 1fr); align-items:center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); text-align:right; }
  .table-panel td:first-child { display:block; border-top:0; padding:14px 12px; text-align:left; }
  .table-panel td:not(:first-child)::before { color:var(--muted); font:500 10px "DM Mono",monospace; letter-spacing:.3px; text-align:left; }
  #productTable td:nth-child(2)::before,#listedItems td:nth-child(2)::before { content:"SUPPLIER COST"; }
  #productTable td:nth-child(3)::before,#listedItems td:nth-child(3)::before { content:"SELL PRICE"; }
  #productTable td:nth-child(4)::before,#listedItems td:nth-child(4)::before { content:"PROFIT"; }
  #productTable td:nth-child(5)::before,#listedItems td:nth-child(5)::before { content:"MARGIN"; }
  #productTable td:nth-child(6)::before { content:"STATUS"; }
  #listedItems td:nth-child(6)::before { content:"MARKETPLACE"; }
  #listedItems td:nth-child(7)::before { content:"STATUS"; }
  .table-panel td:last-child { display:flex; justify-content:flex-end; }
  .table-panel td:last-child::before { content:none; }
  .table-panel .product-cell { align-items:center; }
  .table-panel .thumb { width:52px; height:52px; }
  .row-actions { gap: 4px; }
  .row-actions button { min-height: 40px; }

  .listing-grid { grid-template-columns: 1fr; }
  .listing-card .card-img { height: 190px; object-fit:contain; }
  .listing-card footer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .listing-card footer button { min-height: 44px; }

  .create-product { grid-template-columns: 1fr; }
  .create-product > * { grid-column: 1 !important; }
  .create-preview { min-height: 300px; }
  .create-artwork-empty { min-height: 220px; }
  .create-preview img { max-height: 320px; }
  .create-mode { display: grid; grid-template-columns: 1fr 1fr; }
  .create-mode label { min-height: 46px; display: flex; align-items: center; }
  .create-variants { grid-template-columns: 1fr 1fr; max-height: 330px; }
  .create-variant { min-height: 52px; }

  .fulfillment-rules,
  .supplier-row,
  .fulfillment-order { align-items: stretch; flex-direction: column; }
  .fulfillment-order-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .order-sync-actions { display: grid; grid-template-columns: 1fr; }
  .order-sync-actions button { width: 100%; }
  .settings-save { align-items: stretch; }
  .settings-save .primary { width: 100%; }

  /* Android-style bottom sheets avoid tiny, vertically clipped dialogs. */
  dialog:not(.auth-modal) {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: calc(94dvh - env(safe-area-inset-top));
    margin: 0;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  dialog:not(.auth-modal) form,
  dialog:not(.auth-modal) .details-dialog {
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
  }
  dialog::backdrop { background: rgba(0, 6, 18, .72); }
  .modal-head { position: sticky; top: -20px; z-index: 2; padding: 7px 0 10px; }
  .dark .modal-head { background: #101c2e; }
  body:not(.dark) .modal-head { background: #f5f8fc; }
  .close { width: 44px; height: 44px; flex: 0 0 44px; font-size: 26px; }
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }
  .modal-actions > * { width: 100%; min-height: 46px; }
  .form-grid,
  .details-grid { grid-template-columns: 1fr; }
  .details-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .details-gallery img { height: 140px; }
  .image-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-item img { height: 100px; }
  .image-add { align-items: stretch; flex-direction: column; }

  #toast {
    right: 12px;
    bottom: calc(var(--mobile-nav-height) + 12px + env(safe-area-inset-bottom));
    left: 12px;
    max-height: 35dvh;
    overflow-y: auto;
    padding: 13px 15px;
    font-size: 13px;
    line-height: 1.45;
  }
}

@media (max-width: 390px) {
  main { padding-inline: 10px; }
  .stats, .monitor-summary { grid-template-columns: 1fr 1fr; }
  .create-variants { grid-template-columns: 1fr; }
  .modal-actions { grid-template-columns: 1fr; }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root { --mobile-nav-height: 58px; }
  .sidebar nav { height: var(--mobile-nav-height); }
  .sidebar nav .nav-link:not(.settings) { min-height: 50px; padding-block: 4px; }
  main { padding-top: calc(58px + env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
