/* The legacy fallback is an inline <a>, whereas
 * recognized clients receive a <button>; give both the same complete hit area.
 * Scoped !important declarations override the old theme's mobile margin/basis
 * patches without changing its brand colours, typography or other screens.
 */
#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
  padding-top: 16px;
}

/* Give the mobile navigation a little more room while keeping it on screen. */
@media (max-width: 989px) {
  #dashboard .workplace #sidebar {
    width: min(250px, calc(100vw - 20px));
  }

  #dashboard .workplace #sidebar .sidebar-content {
    width: 100%;
  }
}

#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer .btn {
  box-sizing: border-box;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  height: 44px !important;
  min-height: 44px;
  max-width: 100%;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 9px 18px;
  line-height: 1.4;
  vertical-align: middle;
  text-align: center;
  white-space: nowrap;
  text-decoration: none;
  transition-property: background-color, border-color, color, box-shadow;
}

#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .btn,
#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .hover-options {
  flex: 0 1 160px !important;
  width: 160px;
  margin: 0 !important;
}

#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer .hover-options {
  display: flex;
  align-items: stretch;
  min-height: 44px;
  min-width: 0;
  margin: 0 !important;
}

#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer .hover-options > .btn {
  flex: 1 1 auto;
  width: 100% !important;
}

/* The original hover bridge can otherwise cover the next row of actions.
 * The current component opens Ant Design's own click-triggered popup.
 */
#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer .hover-options::after {
  display: none !important;
  content: none !important;
}

#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .subscription-actions {
  display: flex;
  align-items: stretch;
  flex: 0 0 100%;
  gap: 12px;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0 !important;
}

#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .subscription-actions > .btn,
#dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .subscription-actions > .hover-options {
  flex: 0 1 248px !important;
  width: 248px;
  max-width: calc((100% - 12px) / 2);
  min-width: 0;
  margin: 0 !important;
}

/* The direct Shadowrocket action has a longer label than the old menu. */
#dashboard .workplace .work-container .container section.my-subscription .panel.my-subscription > .footer > .hover-options {
  flex: 0 1 220px !important;
  width: 220px;
}

@media (max-width: 590px) {
  #dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer {
    gap: 10px;
  }

  #dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .subscription-actions {
    flex-wrap: wrap;
    gap: 10px;
  }

  #dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .btn,
  #dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .hover-options,
  #dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .subscription-actions > .btn,
  #dashboard .workplace .work-container .container section:is(.dashboard, .my-subscription) .panel.my-subscription > .footer > .subscription-actions > .hover-options {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    margin: 0 !important;
  }
}

#dashboard .client-downloads {
  --client-accent: #274cdb;
  --client-tint: #eef2ff;
}

#dashboard .client-downloads--jgjs {
  --client-accent: #4e3db2;
  --client-tint: #f1eefc;
}

#dashboard .client-downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#dashboard .client-downloads-device {
  display: flex;
  width: 100%;
  min-height: 78px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 4px;
  border: 1px solid #dce2eb;
  border-radius: 8px;
  background: #fff;
  color: #202838;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
}

#dashboard .client-downloads-device i {
  color: var(--client-accent);
  font-size: 21px;
  line-height: 24px;
}

#dashboard .client-downloads-device:not(:disabled):hover,
#dashboard .client-downloads-device[aria-expanded="true"] {
  border-color: var(--client-accent);
  background: var(--client-tint);
  color: var(--client-accent);
}

#dashboard .client-downloads-device:disabled {
  background: #f7f8fa;
  color: #526074;
  cursor: not-allowed;
}

#dashboard .client-downloads-device:disabled i,
#dashboard .client-downloads-status {
  color: #526074;
}

#dashboard .client-downloads-status {
  margin: 10px 0 0;
}

#dashboard .client-downloads-details .client-downloads-status {
  margin: 8px 0;
}

#dashboard .client-downloads-device:focus-visible {
  outline: 2px solid var(--client-accent);
  outline-offset: 2px;
}

#dashboard .client-downloads-details {
  margin-top: 12px;
  padding: 2px 12px;
  border: 1px solid #dce2eb;
  border-radius: 8px;
}

#dashboard .client-downloads-release {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 0;
}

#dashboard .client-downloads-release + .client-downloads-release {
  border-top: 1px solid #e5e9f0;
}

#dashboard .client-downloads-release small {
  margin-left: 8px;
  color: #526074;
}

#dashboard .client-downloads-release a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--client-accent);
  text-decoration: underline;
}

#dashboard .client-downloads-type {
  display: inline-block;
  width: fit-content;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--client-tint);
  color: var(--client-accent);
  font-size: 12px;
  font-weight: 600;
}

#dashboard .tutorial-downloads-release-name .client-downloads-type {
  margin-left: 0;
}

#dashboard .client-downloads-notice:not(:empty) {
  position: fixed;
  z-index: 1100;
  top: 20px;
  left: 50%;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid #dce2eb;
  border-radius: 6px;
  background: #fff;
  color: #273345;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
  transform: translateX(-50%);
  pointer-events: none;
}

#dashboard .tutorial-downloads {
  --tutorial-action: #2f5cfc;
  --tutorial-heading: #263661;
  --tutorial-header-border: #dce5fb;
  padding: 0;
  overflow: hidden;
  border: 1px solid #e1e6ef;
  border-radius: 10px;
}

#dashboard .tutorial-downloads.client-downloads--jgjs {
  --tutorial-action: #2e3c53;
  --tutorial-heading: #2e3c53;
  --tutorial-header-border: #e1def4;
}

#dashboard .tutorial-downloads-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--tutorial-header-border);
  background: linear-gradient(105deg, var(--client-tint), #fff);
  color: var(--tutorial-heading);
}

#dashboard .tutorial-downloads-heading h2 {
  margin: 0;
  color: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}

#dashboard .tutorial-downloads-detected {
  padding: 5px 9px;
  border: 1px solid var(--tutorial-header-border);
  border-radius: 5px;
  background: #fff;
  color: var(--tutorial-heading);
  font-size: 12px;
  font-weight: 600;
}

#dashboard .tutorial-downloads-body {
  padding: 16px 20px 20px;
}

#dashboard .tutorial-downloads-devices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
}

#dashboard .tutorial-downloads-device {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  border: 1px solid #e0e5ed;
  border-radius: 6px;
  background: #fff;
  color: #455167;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#dashboard .tutorial-downloads-device:hover,
#dashboard .tutorial-downloads-device[aria-pressed="true"] {
  border-color: var(--client-accent);
  background: var(--client-tint);
  color: var(--client-accent);
}

#dashboard .tutorial-downloads-device:focus-visible,
#dashboard .tutorial-downloads-actions a:focus-visible,
#dashboard .tutorial-downloads-qr button:focus-visible,
#dashboard .tutorial-downloads-actions button:focus-visible {
  outline: 2px solid var(--client-accent);
  outline-offset: 2px;
}

#dashboard .tutorial-downloads-options {
  margin-top: 14px;
  padding: 0 14px;
  border: 1px solid #e2e7ef;
  border-radius: 7px;
  background: #f8f9fc;
}

#dashboard .tutorial-downloads-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 11px 0;
}

#dashboard .tutorial-downloads-option + .tutorial-downloads-option {
  border-top: 1px solid #e2e7ef;
}

#dashboard .tutorial-downloads-release-name {
  display: grid;
  flex: 1 1 170px;
  min-width: 0;
  gap: 2px;
  color: #273345;
  overflow-wrap: anywhere;
}

#dashboard .tutorial-downloads-release-name small,
#dashboard .tutorial-downloads-message {
  color: #526074;
}

#dashboard .tutorial-downloads-message {
  margin: 0;
  padding: 14px 0;
}

#dashboard .tutorial-downloads-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#dashboard .tutorial-downloads-actions a,
#dashboard .tutorial-downloads-qr-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid var(--tutorial-action);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}

#dashboard .tutorial-downloads-qr-button {
  background: #fff;
  color: var(--tutorial-action);
  cursor: pointer;
}

#dashboard .tutorial-downloads-qr-button:hover {
  background: var(--client-tint);
}

#dashboard .tutorial-downloads-qr {
  position: fixed;
  z-index: 1100;
  top: 50%;
  left: 50%;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 40px rgba(19, 35, 56, .25);
  padding: 14px;
  border: 1px solid #d9e2ef;
  border-radius: 7px;
  background: #fff;
  color: #273345;
  overflow-wrap: anywhere;
}

#dashboard .tutorial-downloads-qr-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

#dashboard .tutorial-downloads-qr button {
  min-height: 40px;
  padding: 6px 12px;
  border: 1px solid var(--tutorial-action);
  border-radius: 5px;
  color: var(--tutorial-action);
  background: #fff;
  cursor: pointer;
}

#dashboard .tutorial-downloads-qr-code {
  margin-top: 12px;
  text-align: center;
}

#dashboard .tutorial-downloads-qr-code canvas,
#dashboard .tutorial-downloads-qr-code svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  image-rendering: pixelated;
}

#dashboard .tutorial-downloads-qr p {
  margin: 8px 0;
  color: #526074;
}

#dashboard .tutorial-downloads-main {
  background: var(--tutorial-action);
  color: #fff;
}

#dashboard .tutorial-downloads-main:hover {
  background: var(--tutorial-heading);
  color: #fff;
}

#dashboard .tutorial-downloads-backup {
  background: #fff;
  color: var(--tutorial-action);
}

#dashboard .tutorial-downloads-backup:hover {
  background: var(--client-tint);
  color: var(--client-accent);
}

.payment-cashier-fallback > .payment-cashier-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 24px;
  border-radius: 6px;
  background: #1677ff;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}

.payment-cashier-fallback > .payment-cashier-link:hover {
  background: #0c61cf;
  color: #fff;
}

.payment-cashier-fallback > .payment-cashier-link:focus-visible {
  outline: 2px solid #0c61cf;
  outline-offset: 2px;
}

@media (max-width: 590px) {
  #dashboard .client-downloads-grid {
    grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
    gap: 8px;
  }

  #dashboard .client-downloads-device {
    min-height: 66px;
  }

  #dashboard .tutorial-downloads-heading {
    padding: 13px 12px;
  }

  #dashboard .tutorial-downloads-body {
    padding: 12px;
  }

  #dashboard .tutorial-downloads-actions {
    width: 100%;
  }

  #dashboard .tutorial-downloads-actions a {
    flex: 1 1 0;
    padding-inline: 6px;
  }

  #dashboard .tutorial-downloads-qr-button,
  #dashboard .tutorial-downloads-qr {
    display: none;
  }
}
