/* Tanshar Home — final phone alignment layer. Desktop layout is unchanged. */
@media (max-width: 768px) {
  body[data-signed="1"] {
    padding-top: env(safe-area-inset-top) !important;
  }

  body[data-signed="1"] .topbar {
    position: relative;
    min-height: 64px;
    padding-top: 10px !important;
  }

  body[data-signed="1"] .content {
    padding: 14px 14px calc(104px + env(safe-area-inset-bottom)) !important;
  }

  /* Page heading and primary action always occupy clean, full-width rows. */
  body[data-signed="1"] .rent-compact-head,
  body[data-signed="1"] .schedule-compact-head,
  body[data-signed="1"] .pantry-pro-heading {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    align-items: start !important;
  }

  body[data-signed="1"] .rent-compact-head > .btn,
  body[data-signed="1"] .schedule-compact-head > .btn {
    width: 100% !important;
    min-height: 48px !important;
    justify-content: center !important;
  }

  /* Do not retain the desktop Settings-card fixed height on phone. */
  body[data-signed="1"] .rent-compact-grid > .cardx,
  body[data-signed="1"] .schedule-compact-grid > .cardx,
  body[data-signed="1"] .bill-compact-grid > .cardx {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
  }

  body[data-signed="1"] .rent-compact-grid .section-head,
  body[data-signed="1"] .schedule-compact-grid .section-head,
  body[data-signed="1"] .bill-compact-grid .section-head {
    min-height: 58px;
    margin: 0 !important;
    padding: 14px 16px 10px !important;
  }

  body[data-signed="1"] .tenant-compact-list,
  body[data-signed="1"] .schedule-directory,
  body[data-signed="1"] .bill-compact-list {
    width: 100%;
    max-height: 430px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 0 14px 8px !important;
  }

  /* Rent and schedule directory rows: icon, copy and actions stay aligned. */
  body[data-signed="1"] .tenant-compact-row,
  body[data-signed="1"] .schedule-directory-row {
    display: grid !important;
    grid-template-columns: 46px minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto !important;
    column-gap: 11px !important;
    row-gap: 2px !important;
    align-items: center !important;
    min-height: 72px !important;
    padding: 10px 0 !important;
  }

  body[data-signed="1"] .tenant-compact-row > .bill-logo,
  body[data-signed="1"] .schedule-directory-row > .bill-logo {
    grid-column: 1 !important;
    grid-row: 1 / 3 !important;
    align-self: center !important;
    justify-self: start !important;
    width: 42px !important;
    height: 42px !important;
    margin: 0 !important;
  }

  body[data-signed="1"] .tenant-compact-row > strong,
  body[data-signed="1"] .schedule-directory-row > strong {
    grid-column: 2 !important;
    grid-row: 1 !important;
    align-self: end !important;
    min-width: 0;
    margin: 0 !important;
    text-align: left !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body[data-signed="1"] .tenant-compact-row > span,
  body[data-signed="1"] .schedule-directory-row > span {
    grid-column: 2 !important;
    grid-row: 2 !important;
    align-self: start !important;
    margin: 0 !important;
    text-align: left !important;
  }

  body[data-signed="1"] .tenant-icon-actions,
  body[data-signed="1"] .schedule-icon-actions {
    grid-column: 3 !important;
    grid-row: 1 / 3 !important;
    display: flex !important;
    align-items: center !important;
    align-self: center !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
  }

  /* Due rows remain compact and readable. */
  body[data-signed="1"] .rent-due-card > #rentDue,
  body[data-signed="1"] .schedule-compact-grid > .cardx > #recurringPending,
  body[data-signed="1"] .schedule-compact-grid > .cardx > #subscriptionPending {
    min-height: 0 !important;
    max-height: 430px !important;
    overflow-y: auto !important;
    padding: 0 14px 8px !important;
  }

  body[data-signed="1"] .rent-due-row,
  body[data-signed="1"] .schedule-due-row {
    grid-template-columns: 46px minmax(0, 1fr) auto !important;
    min-height: 72px !important;
    padding: 10px 0 !important;
    gap: 10px !important;
  }

  body[data-signed="1"] .rent-due-row .btn,
  body[data-signed="1"] .schedule-due-row .btn {
    min-width: 76px !important;
    min-height: 44px !important;
  }

  body[data-signed="1"] .rent-due-card .empty,
  body[data-signed="1"] .schedule-compact-grid .empty {
    min-height: 150px !important;
    padding: 22px 14px !important;
  }

  /* Pantry stock: compact two-column cards instead of tall scattered rows. */
  body[data-signed="1"] .pantry-stock-main .pantry-pro-row {
    display: grid !important;
    grid-template-columns: 46px minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto !important;
    gap: 4px 10px !important;
    min-height: 118px !important;
    padding: 12px 14px !important;
    align-items: center !important;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-row > .product-picture {
    grid-column: 1 !important;
    grid-row: 1 / 3 !important;
    align-self: start !important;
    justify-self: start !important;
    margin: 0 !important;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-row > div:nth-child(2) {
    grid-column: 2 !important;
    grid-row: 1 !important;
    min-width: 0;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-row > b {
    grid-column: 2 !important;
    grid-row: 2 !important;
    justify-self: start !important;
    margin: 0 !important;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-row > em {
    grid-column: 1 !important;
    grid-row: 3 !important;
    justify-self: start !important;
    margin-top: 5px !important;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-actions {
    grid-column: 2 !important;
    grid-row: 3 !important;
    display: flex !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin-top: 5px !important;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-actions button {
    min-height: 40px !important;
  }

  body[data-signed="1"] .pantry-stock-main .pantry-pro-list {
    overflow: visible !important;
  }
}

@media (max-width: 390px) {
  body[data-signed="1"] .content { padding-inline: 10px !important; }
  body[data-signed="1"] .tenant-action,
  body[data-signed="1"] .schedule-action { width: 36px; height: 36px; }
  body[data-signed="1"] .tenant-icon-actions,
  body[data-signed="1"] .schedule-icon-actions { gap: 4px !important; }
}
