/* Client dashboard only. Contract documents retain their A4 preview and print
   layout; these rules apply to the application shell, offers and status cards. */
@media screen and (max-width: 1024px) {
  html:has(> body[data-sp-layout="dashboard"]) { height: 100%; overflow: clip !important; }
  body[data-sp-layout="dashboard"] {
    position: fixed; inset: 0; width: 100%;
    height: 100dvh !important; overflow: clip !important;
  }
  body[data-sp-layout="dashboard"] .sp-header {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px !important;
    height: auto !important;
    min-height: 0 !important;
    padding: max(10px, env(safe-area-inset-top)) 16px 12px !important;
    align-items: center !important;
  }
  body[data-sp-layout="dashboard"] .sp-header > div:first-child { display: contents !important; }
  body[data-sp-layout="dashboard"] #sp-mobile-menu-btn { grid-column: 1; grid-row: 1; }
  body[data-sp-layout="dashboard"] .sp-header .sp-suche {
    grid-column: 2; grid-row: 1;
    width: 100%; max-width: none; min-width: 0;
    margin: 0; flex: none;
  }
  body[data-sp-layout="dashboard"] .sp-header .sp-suche input { min-height: 44px !important; }
  body[data-sp-layout="dashboard"] .sp-header .sp-header-actions { display: none !important; }
  body[data-sp-layout="dashboard"] #sp-header-identity {
    display: grid !important;
    grid-column: 1 / -1; grid-row: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px !important;
    width: 100%; margin: 0 !important; padding: 10px 12px;
    background: #f7f9f4; border: 1px solid #e5e9df; border-radius: 12px;
    font-size: 12px !important; font-weight: 500;
  }
  body[data-sp-layout="dashboard"] #sp-header-identity .sp-header-id-item {
    min-width: 0; max-width: none !important;
    white-space: normal; overflow: visible; overflow-wrap: anywhere;
    line-height: 1.4;
  }
  body[data-sp-layout="dashboard"] #sp-header-identity .sp-header-id-item:first-child { grid-column: 1 / -1; }
  body[data-sp-layout="dashboard"] #sp-header-identity strong {
    display: block; font-size: 14px; font-weight: 700; color: var(--text-main);
    font-variant-numeric: tabular-nums; letter-spacing: -.3px;
  }
  body[data-sp-layout="dashboard"] #sp-header-identity #sp-header-user-name { display: inline; }
  body[data-sp-layout="dashboard"] .sp-content {
    padding: 20px 16px calc(88px + env(safe-area-inset-bottom)) !important;
    scroll-padding-block: 20px 88px;
  }
  body[data-sp-layout="dashboard"] .sp-view.active { gap: 20px !important; }
  body[data-sp-layout="dashboard"] .sp-view.active > * { margin-block: 0 !important; }
  body[data-sp-layout="dashboard"] .sp-content .sp-btn { font-size: 14px !important; }
  body[data-sp-layout="dashboard"] .sp-view > div > :is(h1, h2),
  body[data-sp-layout="dashboard"] .sp-view > h2 {
    font-size: 23px !important; line-height: 1.35 !important; letter-spacing: -.4px;
  }
  body[data-sp-layout="dashboard"] .sp-view > div > p,
  body[data-sp-layout="dashboard"] .sp-view > p,
  body[data-sp-layout="dashboard"] #sp-savings-section-intro {
    font-size: 16px !important; line-height: 1.6 !important;
  }
  body[data-sp-layout="dashboard"] #fg-category-tabs {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%; gap: 10px !important;
  }
  body[data-sp-layout="dashboard"] #fg-category-tabs .sp-btn {
    width: 100%; min-width: 0 !important; min-height: 48px !important;
    padding: 12px 10px !important; font-size: 14px !important;
    line-height: 1.4; white-space: normal !important;
    border-radius: 12px;
  }
  body[data-sp-layout="dashboard"] .sp-bank-offer-grid {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important; min-width: 0;
  }
  body[data-sp-layout="dashboard"] .sp-bank-offer-grid > div { min-width: 0; padding: 20px !important; }
  body[data-sp-layout="dashboard"] .sp-bank-offer-grid h3 { font-size: 18px !important; }
  body[data-sp-layout="dashboard"] .sp-bank-offer-grid :is(p, li) { font-size: 14px !important; line-height: 1.6 !important; }
  body[data-sp-layout="dashboard"] .sp-bank-offer-grid button { white-space: normal !important; line-height: 1.4; }

  /* The ten phase labels cannot fit beside each other on a phone. Keep
     every phase in order and show the current status before the timeline. */
  body[data-sp-layout="dashboard"] .sp-fg-status-card {
    display: flex; flex-direction: column; gap: 16px; padding: 18px !important; margin: 0 !important;
  }
  body[data-sp-layout="dashboard"] .sp-fg-progress-heading { order: 0; margin: 0 !important; }
  body[data-sp-layout="dashboard"] .sp-fg-progress-heading > div { min-width: 0; }
  body[data-sp-layout="dashboard"] .sp-fg-progress-heading h3 { font-size: 16px !important; line-height: 1.5; }
  body[data-sp-layout="dashboard"] .sp-fg-current-phase { order: 1; min-width: 0; padding: 14px !important; }
  body[data-sp-layout="dashboard"] .sp-fg-current-phase > div { min-width: 0; width: 100%; }
  body[data-sp-layout="dashboard"] .sp-fg-current-phase > div:first-child > div { font-size: 14px !important; line-height: 1.5; }
  body[data-sp-layout="dashboard"] .sp-fg-current-phase button { flex: 1 1 100%; white-space: normal; }
  body[data-sp-layout="dashboard"] .sp-fg-progress {
    order: 2; display: flex !important; flex-direction: column !important;
    gap: 0; margin: 0 !important; padding: 0 !important; overflow: visible !important;
  }
  body[data-sp-layout="dashboard"] .sp-fg-progress-line { display: none; }
  body[data-sp-layout="dashboard"] .sp-fg-progress-step {
    flex: none !important; display: grid !important; grid-template-columns: 32px minmax(0, 1fr);
    align-items: center !important; gap: 12px; min-width: 0 !important; min-height: 52px;
    padding: 10px 0; text-align: left !important;
  }
  body[data-sp-layout="dashboard"] .sp-fg-progress-step:not(:last-child)::after {
    content: ""; position: absolute; width: 2px; left: 15px; top: 40px; bottom: -10px;
    background: #e2e8f0;
  }
  body[data-sp-layout="dashboard"] .sp-fg-progress-number {
    width: 32px !important; height: 32px !important; margin: 0 !important; font-size: 14px !important;
  }
  body[data-sp-layout="dashboard"] .sp-fg-progress-label {
    min-width: 0; max-width: none !important; font-size: 14px !important; line-height: 1.5 !important;
    overflow-wrap: break-word; color: #64748b !important;
  }
  body[data-sp-layout="dashboard"] .sp-fg-progress-step[data-state="completed"] .sp-fg-progress-label { color: #15803d !important; }
  body[data-sp-layout="dashboard"] .sp-fg-progress-step[aria-current="step"] .sp-fg-progress-label { color: #0f172a !important; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner > div { margin: 0 !important; gap: 16px !important; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner { margin-bottom: 20px; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner > div > div { min-width: 0 !important; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner > div > div:first-child > div:last-child > div { font-size: 14px !important; line-height: 1.5; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner button { white-space: normal; }

  /* A compact support button keeps account actions visible. Its text stays
     available to screen readers and the full support item remains in the menu. */
  body[data-sp-layout="dashboard"] #sp-chat-fab {
    width: 48px !important; min-width: 48px !important;
    height: 48px !important; min-height: 48px !important; max-height: 48px !important;
    padding: 0 !important; gap: 0 !important; border-radius: 50% !important;
    right: max(16px, env(safe-area-inset-right)) !important;
    bottom: max(16px, env(safe-area-inset-bottom)) !important; z-index: 2000 !important;
  }
  body[data-sp-layout="dashboard"] #sp-chat-fab svg { width: 22px !important; height: 22px !important; }
  body[data-sp-layout="dashboard"] #sp-chat-fab-text {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  body[data-sp-layout="dashboard"] #tab-profil .sp-prof-ornament { display: none; }
  body[data-sp-layout="dashboard"] #tab-profil .sp-user-name { color: #fff; white-space: normal; }
  body[data-sp-layout="dashboard"] #tab-profil .sp-prof-chip { max-width: 100%; min-width: 0; }
  body[data-sp-layout="dashboard"] #tab-profil #prof-user-email { white-space: normal; overflow-wrap: anywhere; }
  body[data-sp-layout="dashboard"] .sp-sidebar-header { padding-top: max(16px, env(safe-area-inset-top)) !important; }
  body[data-sp-layout="dashboard"] .sp-user-box { padding-bottom: max(16px, env(safe-area-inset-bottom)) !important; }
}
@media screen and (max-width: 600px) {
  body[data-sp-layout="dashboard"] #fg-category-tabs > :nth-child(-n+2) { grid-column: 1 / -1; }
  body[data-sp-layout="dashboard"] .sp-bank-offer-grid { grid-template-columns: minmax(0, 1fr) !important; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner > div > div { width: 100%; }
  body[data-sp-layout="dashboard"] #sp-top-action-banner button { flex: 1 1 100%; }
  body[data-sp-layout="dashboard"] #tab-vertaege > div:first-child > div:last-child,
  body[data-sp-layout="dashboard"] #tab-vertaege > div:first-child button { width: 100%; }
  body[data-sp-layout="dashboard"] .sp-filter { gap: 8px; }
  body[data-sp-layout="dashboard"] .sp-filter-chip { font-size: 14px; min-height: 44px; padding-inline: 12px !important; }
  body[data-sp-layout="dashboard"] :is(#tab-vertaege, #tab-anleihen) table.sp-table tbody td:not([colspan]) {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 5px !important; padding-block: 12px !important;
    font-size: 14px !important; line-height: 1.5;
  }
  body[data-sp-layout="dashboard"] :is(#tab-vertaege, #tab-anleihen) table.sp-table tbody td::before {
    font-size: 12px !important; line-height: 1.5; letter-spacing: .02em;
  }
  body[data-sp-layout="dashboard"] :is(#tab-vertaege, #tab-anleihen) table.sp-table tbody td .sp-btn {
    padding: 12px 14px !important; overflow-wrap: normal; word-break: normal;
  }
}
