/* Shared user-cabinet layout and interaction polish. */
.app-shell .screen { min-width: 0; }
.app-shell .page-head { margin-bottom: 2px; }
.app-shell .page-head p,
.app-shell .home-welcome > p { max-width: 58ch; line-height: 1.55; }
.app-shell .btn { min-height: 44px; border-radius: 10px !important; font-weight: 650; }
.app-shell .btn-primary { background: #84d6a0 !important; color: #08110b !important; box-shadow: none !important; }
.app-shell .btn-secondary { border: 1px solid #303638 !important; background: #141719 !important; color: #e8ecea !important; }
.app-shell button:disabled,
.app-shell [aria-disabled="true"] { cursor: not-allowed; opacity: .58; }
.app-shell :focus-visible { outline: 2px solid #84d6a0 !important; outline-offset: 3px; }

.screen[data-screen="home"] .home-plan-card { overflow: hidden; }
.screen[data-screen="home"] .home-plan-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px !important; padding: 0 12px 12px; }
.screen[data-screen="home"] .home-plan-actions[hidden] { display: none !important; }
.screen[data-screen="home"] .home-plan-actions > .btn { width: 100%; min-width: 0; justify-content: center; margin: 0 !important; }
.screen[data-screen="home"] .wizard-dashboard-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.screen[data-screen="home"] .wizard-dashboard-link { min-height: 64px; }
.screen[data-screen="home"] .wizard-dashboard-link:first-child { grid-column: 1 / -1; }
.screen[data-screen="home"] .wizard-subscription-stat > strong,
.screen[data-screen="home"] .wizard-subscription-stat > span { line-height: 1.4; }
.home-progress { width: 100%; max-width: 180px; height: 5px; overflow: hidden; border-radius: 5px; background: #303638; }
.home-progress > span { display: block; width: var(--remaining-percent, 0%); height: 100%; border-radius: inherit; background: #84d6a0; }

.pending-payment-card { display: grid; gap: 12px; margin: 0 auto 16px; padding: 16px !important; border-color: #76523a !important; background: #171411 !important; }
.pending-payment-card.is-pending { border-color: #765b35 !important; }
.pending-payment-card .pending-payment-main { display: grid; min-width: 0; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.pending-payment-card .pending-payment-copy { display: grid; min-width: 0; gap: 4px; }
.pending-payment-card .pending-payment-copy strong,
.pending-payment-card .pending-payment-copy small { overflow-wrap: anywhere; }
.pending-payment-card .pending-payment-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pending-payment-card .pending-payment-actions .btn { flex: 1 1 180px; }
.pending-payment-card .pending-payment-feedback { color: #b4aaa0; line-height: 1.45; }

.screen[data-screen="subscription"] .detail-card { display: grid; gap: 14px; }
.screen[data-screen="subscription"] .detail-card > .btn,
.screen[data-screen="subscription"] .detail-card > button { width: 100% !important; min-width: 0; margin: 0 !important; }
.screen[data-screen="subscription"] .info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.screen[data-screen="subscription"] .info-cell { min-width: 0; padding: 12px 10px; }
.screen[data-screen="subscription"] .info-cell strong { overflow-wrap: anywhere; }
.subscription-stack { display: grid; min-width: 0; gap: 12px; padding: 16px; border: 1px solid #2c3234; border-radius: 12px; background: #101315; }
.subscription-stack-head { align-items: center; }
.subscription-stack-head h3 { margin: 0 0 4px; }
.subscription-stack-head small,
.subscription-picker-detail { line-height: 1.45; }
.subscription-picker-trigger { border-radius: 10px; }
.subscription-link-warning { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid #76523a; border-radius: 10px; background: #171411; color: #e2c09a; font-size: 12px; line-height: 1.45; }
.subscription-link-warning button { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #76523a; border-radius: 8px; background: transparent; color: #f0d1ad; font: inherit; cursor: pointer; }

.screen[data-screen="payments"] .payment-filters { display: flex; width: 100%; min-width: 0; gap: 6px; overflow-x: auto; }
.screen[data-screen="payments"] .payment-filters .chip { flex: 1 0 auto; min-height: 38px; }
.payment-history-card { display: grid; gap: 12px; padding: 14px !important; }
.payment-history-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; }
.payment-history-head > div { display: grid; min-width: 0; gap: 4px; }
.payment-history-head small { color: #929a9d; }
.payment-month-group { display: grid; min-width: 0; gap: 8px; }
.payment-month-group + .payment-month-group { margin-top: 16px; }
.payment-month-group > h3 { margin: 4px 0 0; color: #aab1ae; font-size: 12px; font-weight: 650; text-transform: capitalize; }
.payment-history-row { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); gap: 14px; padding: 13px 0; border-bottom: 1px solid #292f31; }
.payment-history-row:last-child { border-bottom: 0; }
.payment-history-row > div { display: grid; min-width: 0; align-content: start; gap: 5px; }
.payment-history-row strong { font-size: 15px; }
.payment-history-row small { color: #929a9d; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.payment-status-label { width: fit-content; padding: 4px 8px; border: 1px solid #34483b; border-radius: 999px; background: #152019; color: #a9e0ba; font-size: 11px; }
.payment-history-row.pending .payment-status-label,
.payment-history-row.created .payment-status-label,
.payment-history-row.processing .payment-status-label { border-color: #765b35; background: #211b12; color: #e2c09a; }
.payment-history-row.expired .payment-status-label,
.payment-history-row.failed .payment-status-label,
.payment-history-row.cancelled .payment-status-label,
.payment-history-row.canceled .payment-status-label { border-color: #583234; background: #241517; color: #e4a2a5; }
.payment-expired-note { margin-top: 2px; }
.payment-history-action { min-height: 38px; width: fit-content; align-items: center; }

.screen[data-screen="devices"] .stats-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.screen[data-screen="devices"] .stats-strip > div { min-width: 0; padding: 11px 8px; text-align: center; }
.screen[data-screen="devices"] .device-list { display: grid; gap: 8px; }
.screen[data-screen="devices"] .device-card { border-radius: 10px !important; }
.screen[data-screen="devices"] .device-card > div strong { font-size: 13px; line-height: 1.35; }
.screen[data-screen="devices"] .device-card > div small { color: #929a9d; font-size: 11px; line-height: 1.4; }
.screen[data-screen="devices"] .device-active { width: fit-content; padding: 4px 7px; border: 1px solid #34483b; border-radius: 999px; background: #152019; color: #a9e0ba; font-size: 10px; }
.screen[data-screen="devices"] .device-active:not(:empty) { line-height: 1.2; }

.screen[data-screen="family"] .family-hero,
.screen[data-screen="referral"] [data-referral-hero] { display: grid; min-width: 0; gap: 14px; }
.screen[data-screen="family"] .family-hero h2,
.screen[data-screen="family"] .family-hero p,
.screen[data-screen="referral"] [data-referral-hero] h2,
.screen[data-screen="referral"] [data-referral-hero] p { overflow-wrap: anywhere; }
.screen[data-screen="family"] .family-code-box,
.screen[data-screen="referral"] .invite-code { min-width: 0; }
.screen[data-screen="family"] .family-code-box code,
.screen[data-screen="referral"] .invite-code code { min-width: 0; overflow-wrap: anywhere; }
.screen[data-screen="referral"] .referral-rule-note { font-size: 12px; line-height: 1.55; }
.screen[data-screen="referral"] .referral-invite-row { min-width: 0; }
.screen[data-screen="referral"] .referral-invite-row > div { min-width: 0; }
.screen[data-screen="referral"] .referral-invite-row small { overflow-wrap: anywhere; line-height: 1.45; }

.screen[data-screen="profile"] .profile-data-row { grid-template-columns: 36px minmax(0, 1fr) minmax(0, auto) 34px; gap: 10px; }
.screen[data-screen="profile"] .profile-data-row > span:nth-of-type(2) { min-width: 0; }
.screen[data-screen="profile"] .profile-data-row > .profile-value { max-width: 100%; overflow: visible; overflow-wrap: anywhere; text-overflow: clip; white-space: normal; }
.profile-copy,
.profile-copy-placeholder { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border: 1px solid #303638; border-radius: 9px; background: #141719; color: #aeb6b2; }
.profile-copy { padding: 0; cursor: pointer; }
.profile-copy svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.profile-copy:hover { border-color: #476f52; color: #a9e0ba; }

.screen.active[data-screen="support"] { gap: 14px; }
.support-status { line-height: 1.45; }
.support-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.support-topic { min-height: 72px; }
.support-panel,
.support-chat { min-height: 420px; border-radius: 12px !important; }
.support-panel { grid-template-rows: auto auto auto minmax(0, 1fr); }
.support-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.support-tabs button { min-width: 0; min-height: 38px; }
.support-ticket { width: 100%; min-width: 0; padding: 12px !important; }
.support-ticket > span { min-width: 0; }
.support-ticket strong,
.support-ticket small { overflow-wrap: anywhere; }
.support-chat { grid-template-rows: auto minmax(120px, 1fr) auto auto; }
.support-feed { display: flex; flex-direction: column; gap: 9px; padding: 4px 2px; overscroll-behavior: contain; }
.support-bubble { width: fit-content; max-width: min(88%, 620px) !important; padding: 12px !important; border: 1px solid #303638 !important; border-radius: 12px !important; overflow-wrap: anywhere; line-height: 1.5; }
.support-bubble.user { align-self: flex-end; background: #17221b !important; }
.support-bubble.admin { align-self: flex-start; background: #171b1d !important; }
.support-compose { gap: 9px; }
.support-compose input,
.support-compose textarea { min-height: 44px; border: 1px solid #303638 !important; border-radius: 10px !important; background: #141719 !important; color: #f1f3f2 !important; }
.support-compose textarea { min-height: 82px; resize: vertical; }
.support-compose-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.support-compose-actions .btn { min-width: 0; justify-content: center; }
.support-compose-actions [data-action="send-ticket-message"] { grid-column: 1 / -1; }
.support-back-to-list { width: fit-content; min-height: 36px; align-items: center; margin-bottom: 7px; padding: 0 10px; border: 1px solid #303638; border-radius: 8px; background: #141719; color: #a9e0ba; }

.screen[data-screen="notifications"] .notification-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.screen[data-screen="notifications"] .notification-filters {
  gap: 4px; margin: 0 0 14px; padding: 4px; overflow: hidden;
  border: 1px solid #292f30; border-radius: 12px; background: #101314;
}
.screen[data-screen="notifications"] .notification-filters .chip {
  min-width: 0; min-height: 38px; padding: 0 10px; border: 0 !important;
  border-radius: 9px; background: transparent !important; box-shadow: none !important;
  color: #929a9d !important; font-size: 13px; font-weight: 650;
}
.screen[data-screen="notifications"] .notification-filters .chip.active {
  background: #1b2921 !important; color: #a9e0ba !important;
}
.screen[data-screen="notifications"] .notification-filters .chip:focus-visible {
  outline: 2px solid #80d5a0; outline-offset: -2px;
}
.screen[data-screen="notifications"] .notification-list { display: grid; gap: 9px; }
.screen[data-screen="notifications"] .notification-card {
  display: grid !important; grid-template-columns: 40px minmax(0, 1fr) 12px; align-items: center;
  gap: 12px; width: 100%; min-width: 0; min-height: 0; margin: 0 !important; padding: 14px !important;
  border: 1px solid #292f30 !important; border-radius: 14px !important; background: #101314 !important;
  color: #f1f3f2 !important; box-shadow: none !important; text-align: left; cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease;
}
.screen[data-screen="notifications"] .notification-card:hover { border-color: #46534a !important; background: #131816 !important; }
.screen[data-screen="notifications"] .notification-card.unread { border-color: #42634d !important; }
.screen[data-screen="notifications"] .notification-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #303839;
  border-radius: 11px; background: #171c1d; color: #aab4b4;
}
.screen[data-screen="notifications"] .notification-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.screen[data-screen="notifications"] .notification-card.is-payment .notification-icon { color: #a9e0ba; }
.screen[data-screen="notifications"] .notification-copy { display: grid; min-width: 0; gap: 5px; }
.screen[data-screen="notifications"] .notification-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; min-width: 0; }
.screen[data-screen="notifications"] .notification-card .notification-heading strong {
  display: block !important; flex: 1 1 180px; min-width: 0; color: #f1f3f2; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere;
}
.screen[data-screen="notifications"] .notification-type {
  display: inline-flex !important; align-items: center; width: fit-content; margin: 0 !important; padding: 4px 8px;
  border: 1px solid #2b3d32; border-radius: 999px; background: #17221b; color: #a9e0ba;
  font-size: 10px; font-weight: 700; line-height: 1.2; white-space: nowrap;
}
.screen[data-screen="notifications"] .notification-card.is-news .notification-type { border-color: #2b3a3d; background: #151f20; color: #9ac8c0; }
.screen[data-screen="notifications"] .notification-card.is-support .notification-type { border-color: #30393a; background: #181e1f; color: #bac7c6; }
.screen[data-screen="notifications"] .notification-card .notification-text { display: block; min-width: 0; color: #aab1b0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.screen[data-screen="notifications"] .notification-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.screen[data-screen="notifications"] .notification-meta small { color: #778180; font-size: 11px; line-height: 1.3; }
.screen[data-screen="notifications"] .notification-new { color: #a9e0ba; font-size: 10px; font-weight: 700; }
.screen[data-screen="notifications"] .notification-arrow { color: #778180; font-size: 21px; line-height: 1; text-align: right; }

/* Support uses four distinct rows; keeping them explicit prevents filters from stretching. */
@media (min-width: 900px) {
  .screen.active[data-screen="support"] {
    grid-template-columns: minmax(260px, .78fr) minmax(0, 1.22fr) !important;
    align-items: start;
  }
  .screen[data-screen="support"] > .page-head,
  .screen[data-screen="support"] > .support-status,
  .screen[data-screen="support"] > .support-topics-section { grid-column: 1 / -1; }
  .screen[data-screen="support"] > .support-panel,
  .screen[data-screen="support"] > .support-chat {
    align-self: start;
    height: auto !important;
    min-height: 0 !important;
  }
  .screen[data-screen="support"] > .support-panel {
    display: grid !important;
    grid-template-rows: auto auto auto minmax(0, 1fr) !important;
    gap: 12px !important;
    overflow: visible !important;
  }
  .screen[data-screen="support"] .support-section-heading { min-width: 0; }
  .screen[data-screen="support"] .support-tabs { align-self: start; }
  .screen[data-screen="support"] .support-tabs button {
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 8px !important;
  }
  .screen[data-screen="support"] .support-new-ticket { width: 100%; margin: 0 !important; }
  .screen[data-screen="support"] .support-list {
    min-height: 92px !important;
    max-height: 360px !important;
    overflow: auto !important;
    padding: 0 3px 0 0 !important;
  }
  .screen[data-screen="support"] > .support-chat {
    grid-template-rows: auto auto auto !important;
    overflow: hidden !important;
    background: #101314 !important;
  }
  .screen[data-screen="support"] .support-chat-head {
    min-height: 0 !important;
    padding: 16px 18px !important;
    background: #141819 !important;
  }
  .screen[data-screen="support"] .support-feed {
    min-height: 0 !important;
    max-height: 380px !important;
    padding: 14px 16px !important;
    background: #0c1011 !important;
  }
  .screen[data-screen="support"] .support-feed:has(.support-empty) {
    min-height: 112px !important;
    display: grid !important;
    place-items: center;
  }
  .screen[data-screen="support"] .support-feed .support-empty {
    max-width: 38ch;
    margin: 0 auto;
    padding: 14px 18px;
    border: 1px dashed #303638;
    border-radius: 10px;
    color: #929a9d;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
  }
  .screen[data-screen="support"] .support-compose {
    padding: 14px 16px 16px !important;
    background: #141819 !important;
  }
}

.screen[data-screen="connect"] .connect-wizard-card { gap: 14px; }
.screen[data-screen="connect"] .connect-wizard-copy { min-width: 0; }
.screen[data-screen="connect"] .connect-wizard-copy h2,
.screen[data-screen="connect"] .connect-wizard-copy p { overflow-wrap: anywhere; }
.screen[data-screen="connect"] .connect-primary,
.screen[data-screen="connect"] .connect-wizard-next { width: 100%; justify-content: center; }

@media (max-width: 680px) {
  .app-shell, .app-shell.app--ultima { padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
  .app-content { width: 100% !important; }
  .screen[data-screen="subscription"] .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen[data-screen="subscription"] .detail-topline { flex-wrap: wrap; }
  .screen[data-screen="payments"] .payment-history-row { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .screen[data-screen="payments"] .payment-history-row > div + div { padding-top: 2px; }
  .screen[data-screen="devices"] .device-card { grid-template-columns: 40px minmax(0, 1fr) 36px !important; align-items: center; }
  .screen[data-screen="devices"] .device-card > div { grid-column: 2; grid-row: 1; }
  .screen[data-screen="devices"] .device-active { grid-column: 2; grid-row: 2; display: block !important; }
  .screen[data-screen="devices"] .remove-device { grid-column: 3; grid-row: 1 / span 2; }
  .screen[data-screen="profile"] .profile-data-row { grid-template-columns: 36px minmax(0, 1fr) minmax(0, auto) 32px; gap: 8px; padding-inline: 10px; }
  .screen[data-screen="profile"] .profile-data-row > span:nth-of-type(2) { font-size: 11px; }
  .screen[data-screen="profile"] .profile-data-row > .profile-value { font-size: 11px; }
  .profile-copy, .profile-copy-placeholder { width: 32px; height: 32px; flex-basis: 32px; }
  .screen.active[data-screen="support"] { grid-template-columns: minmax(0, 1fr); }
  .screen[data-screen="support"] > .page-head,
  .screen[data-screen="support"] > .support-status,
  .screen[data-screen="support"] > .support-topics-section { grid-column: 1; }
  .screen[data-screen="support"] .support-panel { grid-row: 4; }
  .screen[data-screen="support"] .support-chat { display: none; }
  .screen[data-screen="support"].support-screen--conversation > .page-head,
  .screen[data-screen="support"].support-screen--conversation > .support-status,
  .screen[data-screen="support"].support-screen--conversation > .support-topics-section,
  .screen[data-screen="support"].support-screen--conversation > .support-panel { display: none; }
  .screen[data-screen="support"].support-screen--conversation .support-chat { display: grid; grid-column: 1; min-height: calc(100dvh - 150px); grid-template-rows: auto minmax(120px, 1fr) auto auto; }
  .screen[data-screen="support"].support-screen--conversation .support-feed { max-height: none; min-height: 120px; }
  .support-back-to-list { display: inline-flex; }
  .screen[data-screen="support"] .support-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen[data-screen="notifications"] .notification-card { grid-template-columns: 36px minmax(0, 1fr) 10px; gap: 10px; padding: 12px !important; }
  .screen[data-screen="notifications"] .notification-icon { width: 36px; height: 36px; }
  .screen[data-screen="notifications"] .notification-card .notification-heading strong { flex-basis: 150px; font-size: 14px; }
  .screen[data-screen="home"] .wizard-dashboard-links { grid-template-columns: minmax(0, 1fr); }
  .screen[data-screen="home"] .wizard-dashboard-link:first-child { grid-column: auto; }
  .pending-payment-card .pending-payment-main { grid-template-columns: 38px minmax(0, 1fr); }
  .pending-payment-card .pending-payment-amount { grid-column: 2; justify-self: start; }
}

@media (max-width: 380px) {
  .screen[data-screen="home"] .wizard-subscription-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .screen[data-screen="home"] .wizard-subscription-stat:last-child { grid-column: 1 / -1; border-top: 1px solid #272d2f; border-left: 0; }
  .screen[data-screen="home"] .wizard-subscription-stat { padding-inline: 7px; }
  .screen[data-screen="devices"] .device-card { grid-template-columns: 36px minmax(0, 1fr) 34px !important; gap: 8px; }
  .screen[data-screen="devices"] .device-icon { width: 36px !important; height: 36px !important; flex-basis: 36px; }
  .screen[data-screen="devices"] .remove-device { width: 34px !important; height: 34px !important; flex-basis: 34px; }
  .screen[data-screen="support"] .support-topics { grid-template-columns: minmax(0, 1fr); }
  .screen[data-screen="notifications"] .notification-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subscription-link-warning { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell *, .app-shell *::before, .app-shell *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
