/* Billing page — extends dashboard shell */

:root {
  --bill-purple: var(--color-cosmos-accent);
  --bill-plan-cosmos-deep: var(--color-cosmos-deep);
  --bill-plan-cosmos-mid: var(--color-cosmos-stellar);
  --bill-plan-cosmos-light: var(--color-cosmos-mist);
  --bill-purple-soft: var(--dash-surface-hover);
  --bill-card-elevated: var(--dash-elevated);
  --bill-border: var(--color-border-secondary);
  --bill-text: var(--dash-text, #f4f4f5);
  --bill-danger: var(--color-error);
  --bill-danger-soft: var(--color-error-soft);
  --bill-right-w: 376px;
}

body.bill-page {
  --dash-purple: var(--bill-purple);
  --dash-purple-soft: var(--bill-purple-soft);
}

.bill-page .dash-pro {
  display: none;
}

.bill-page .dash-new-btn {
  background: var(--bill-purple);
}

.bill-page .dash-pro__btn {
  background: var(--bill-purple);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.bill-page .dash-search input:focus {
  border-color: var(--dash-border-strong);
  box-shadow: 0 0 0 3px var(--dash-surface-hover);
}

.bill-content {
  padding: var(--dash-content-y, 32px) var(--dash-page-x, 32px);
  padding-left: calc(var(--dash-page-x, 32px) + var(--dash-mobile-nav-gutter, 0px));
  padding-bottom: calc(var(--dash-content-y, 32px) + var(--dash-content-pad-bottom, 0px));
  flex: 1;
  min-width: 0;
  container: bill-content / inline-size;
}

.bill-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, var(--bill-right-w));
  gap: var(--dash-gap, 24px);
  align-items: start;
}

.bill-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  container: bill-main / inline-size;
}

.bill-checkout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 15rem);
  align-items: center;
  gap: 24px;
  padding: 24px;
  border: 0;
  border-radius: 24px;
  background: var(--dash-page-island-bg, var(--dash-card));
  color: var(--bill-text);
  outline: none;
}

.bill-checkout[hidden] {
  display: none !important;
}

/* Checkout is off: the summary becomes the coming-soon card (DS: shared/plan-gate.js soonMarkup). */
.bill-checkout.is-soon { grid-template-columns: minmax(0, 1fr); }
.bill-checkout.is-soon > .bill-checkout__copy,
.bill-checkout.is-soon > .bill-checkout__plan { display: none; }
.bill-checkout__soon[hidden] { display: none; }

.bill-checkout__copy,
.bill-checkout__plan {
  min-width: 0;
}

.bill-checkout h2 {
  margin: 0;
  color: var(--bill-text);
  font-size: 22px;
  line-height: 1.2;
}

.bill-checkout__copy p,
.bill-checkout__status {
  margin: 7px 0 0;
  color: var(--dash-text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.bill-checkout__plan {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  text-align: right;
}

.bill-checkout__plan strong,
.bill-checkout__plan span {
  display: block;
}

.bill-checkout__plan strong {
  font-size: 16px;
  font-weight: 650;
}

.bill-checkout__plan span {
  margin-top: 3px;
  color: var(--dash-text-muted);
  font-size: 13px;
}

.bill-checkout__status {
  max-width: 22rem;
  color: var(--bill-danger);
}

.bill-checkout__status:empty {
  display: none;
}

.bill-checkout__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.bill-checkout__actions .bill-btn {
  text-decoration: none;
}

.bill-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: var(--dash-gap, 24px);
  min-width: 0;
  margin-top: 0;
}

/* Breadcrumb */
.bill-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dash-text-muted);
}

.bill-crumb a {
  color: var(--dash-text-muted);
  text-decoration: none;
  transition: color 150ms ease;
}

.bill-crumb a:hover {
  color: var(--bill-purple);
}

.bill-crumb__sep {
  opacity: 0.5;
}

.bill-crumb [aria-current="page"] {
  color: var(--bill-text);
}

.bill-head {
  margin-bottom: 4px;
}

.bill-head .settings-crumb {
  margin-bottom: 10px;
}

.bill-title {
  margin: 0;
  font-family: "Instrument Serif", ui-serif, Georgia, "Times New Roman", serif;
  font-size: 40px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
  color: var(--bill-text);
}

.bill-subtitle {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--dash-text-muted);
  line-height: 1.45;
}

/* Hero plan card */
.bill-hero {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 24px;
  min-height: 0;
  padding: 28px;
  background: var(--dash-page-island-bg, var(--dash-card));
  border: 0;
  border-radius: 28px;
  box-shadow: none;
  transition: background 150ms ease;
  container: bill-plan-card / inline-size;
}

html.bill-has-plan-request .bill-hero {
  display: none;
}

.bill-hero__head {
  min-width: 0;
}

.bill-hero__name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 26px;
}

.bill-hero__name {
  margin: 0;
  font-size: clamp(21px, 2vw, 26px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--bill-text);
}

.bill-hero__note {
  min-height: 20px;
  margin: 15px 0 0;
  font-size: 14px;
  color: var(--dash-text-muted);
  line-height: 1.45;
}

.bill-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 14px 20px;
}

.bill-features li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1.4;
  color: color-mix(in srgb, var(--dash-text, #f4f4f5) 66%, transparent);
}

.bill-features svg {
  color: currentColor;
  flex-shrink: 0;
}

.bill-hero__amount {
  display: flex;
  align-items: baseline;
  white-space: nowrap;
  margin: 26px 0 0;
  font-size: clamp(48px, 4vw, 58px);
  font-weight: 600;
  letter-spacing: -0.06em;
  color: var(--bill-text);
  line-height: 0.94;
  font-variant-numeric: tabular-nums;
}

.bill-hero__currency {
  align-self: flex-start;
  margin-block-start: 4px;
  font-size: 20px;
  font-weight: 600;
}

.bill-hero__period {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--dash-text-muted);
}

.bill-hero__actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.bill-hero__actions > .bill-link-btn {
  margin-top: 0;
}

.bill-hero__upgrade {
  font-weight: 600;
  text-decoration: none;
}

.bill-hero__upgrade[hidden] {
  display: none;
}

.bill-hero__plans {
  width: 100%;
  min-height: 46px;
  margin-top: 0;
  text-decoration: none;
  font-weight: 600;
}

/* Shared card */
.bill-card {
  background: var(--dash-page-island-bg, var(--dash-card));
  border: 0;
  border-radius: 28px;
  padding: 24px;
  box-shadow: none;
  transition: background 150ms ease;
}

.bill-card__head {
  margin-bottom: 16px;
}

.bill-card__title {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  color: var(--bill-text);
}

.bill-card__head .bill-card__title {
  margin-bottom: 6px;
}

.bill-card__subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--dash-text-muted);
  line-height: 1.45;
}

/* Detail rows */
.bill-detail-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 32px;
}

.bill-detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.bill-detail-row:last-child {
  min-height: 0;
  padding-bottom: 0;
}

.bill-detail-row + .bill-detail-row { border-top: 0; }

.bill-detail-row__label {
  font-size: 14px;
  color: var(--dash-text-muted);
  flex-shrink: 0;
}

.bill-detail-row__value {
  font-size: 14px;
  font-weight: 500;
  color: var(--bill-text);
  text-align: start;
}

.bill-detail-row__right {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
  gap: 12px;
}

.bill-detail-row[hidden],
.bill-action-card[hidden],
.bill-panel[hidden],
.bill-card[hidden],
.bill-badge[hidden],
.bill-btn[hidden] {
  display: none !important;
}

html[data-navorina-plan="free"] .bill-detail-row[data-bill-payment-row],
html[data-navorina-plan="free"] .bill-action-card[data-bill-paid-only],
html[data-navorina-plan="free"] .bill-card[data-bill-controls] {
  display: none !important;
}

.bill-pay-method {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--bill-text);
}

.bill-pay-method__brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 18px;
  flex: 0 0 auto;
}

.bill-pay-method__brand--mastercard {
  position: relative;
  width: 32px;
}

.bill-pay-method__brand--mastercard::before,
.bill-pay-method__brand--mastercard::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.bill-pay-method__brand--mastercard::before {
  left: 6px;
  background: #ef4444;
}

.bill-pay-method__brand--mastercard::after {
  left: 15px;
  background: rgba(245, 158, 11, 0.9);
  mix-blend-mode: screen;
}

.bill-update-link {
  border: none;
  background: var(--color-well);
  color: var(--bill-text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  transition: background 150ms ease;
}

.bill-update-link:hover {
  background: var(--color-well-hover);
}

/* Action cards */
.bill-action-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bill-action-card {
  display: grid;
  grid-template-columns: 40px 1fr 20px;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 16px;
  background: color-mix(in srgb, var(--dash-text, #f4f4f5) 4%, transparent);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease;
}

.bill-action-card + .bill-action-card { border-top: 0; }

.bill-action-card:hover {
  background: color-mix(in srgb, var(--dash-text, #f4f4f5) 8%, transparent);
}

.bill-action-card--danger:hover {
  background: var(--bill-danger-soft);
}

.bill-action-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--color-well);
  color: var(--bill-text);
}

.bill-action-card__icon--danger {
  background: var(--bill-danger-soft);
  color: var(--bill-danger);
}

.bill-action-card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bill-action-card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--bill-text);
}

.bill-action-card--danger .bill-action-card__title {
  color: var(--bill-danger);
}

.bill-action-card__desc {
  font-size: 13px;
  color: var(--dash-text-muted);
  line-height: 1.4;
}

.bill-action-card__chev {
  color: var(--dash-text-muted);
  opacity: 0.6;
}

/* Badges */
.bill-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.bill-badge--success {
  background: var(--dash-green-soft);
  color: var(--dash-green);
}

.bill-badge--muted {
  background: var(--color-well-hover);
  color: var(--dash-text-muted);
}

.bill-badge--warning {
  background: var(--dash-orange-soft);
  color: var(--dash-orange);
}

/* Right panel */
.bill-panel {
  background: var(--dash-page-island-bg, var(--dash-card));
  border: 0;
  border-radius: 28px;
  padding: 24px;
  box-shadow: none;
  transition: background 150ms ease;
}

.bill-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.bill-panel__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  color: var(--bill-text);
}

.bill-panel__meta {
  font-size: 12px;
  color: var(--dash-text-muted);
}

.bill-panel__link {
  border: none;
  background: transparent;
  color: var(--dash-text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  transition: color 150ms ease;
}

.bill-panel__link:hover {
  color: var(--bill-text);
}

.bill-readiness__copy {
  margin: 0;
  color: var(--dash-text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.bill-readiness__link {
  text-decoration: none;
}

.bill-link-btn {
  display: inline-flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 0 14px;
  border: none;
  border-radius: 999px;
  background: var(--color-well);
  color: var(--bill-text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.bill-link-btn:hover {
  background: var(--color-well-hover);
  color: var(--bill-text);
}

/* Usage */
.bill-usage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bill-usage__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.bill-usage__label {
  font-size: 13px;
  color: var(--dash-text-muted);
}

.bill-usage__val {
  font-size: 12px;
  font-weight: 500;
  color: var(--bill-text);
}

/* Invoices */
.bill-history-empty {
  margin: 0;
  color: var(--dash-text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.bill-invoice {
  display: grid;
  grid-template-columns: 1fr auto 32px;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 0;
  border: none;
}

.bill-invoice:last-child {
  min-height: 0;
  padding-bottom: 0;
}

.bill-invoice__date {
  margin: 0;
  font-size: 13px;
  color: var(--dash-text-muted);
}

.bill-invoice__amount {
  margin: 2px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--bill-text);
}

.bill-invoice__dl {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--dash-text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}

.bill-invoice + .bill-invoice {
  border-top: 1px solid var(--color-border-secondary);
}

.bill-invoice__dl:hover {
  background: var(--color-well);
  color: var(--bill-text);
}

/* Support */
.bill-support {
  text-align: left;
}

.bill-support__icon {
  width: 40px;
  height: 40px;
  margin: 0 0 12px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--color-well);
  color: var(--dash-text-muted);
}

.bill-support__title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--bill-text);
}

.bill-support__desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--dash-text-muted);
  line-height: 1.45;
}

.bill-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.bill-btn--primary {
  background: var(--bill-purple);
  color: var(--dash-accent-text, #0a0a0a);
}

.bill-btn--primary:hover {
  background: color-mix(in srgb, var(--bill-purple) 90%, white);
}

.bill-btn--secondary {
  background: var(--color-well);
  color: var(--bill-text);
}

.bill-btn--secondary:hover {
  background: var(--color-well-hover);
}

.bill-btn--danger {
  background: var(--bill-danger-soft);
  border: none;
  color: var(--bill-danger);
}

.bill-btn--danger:hover {
  background: color-mix(in srgb, var(--bill-danger) 20%, transparent);
}

.bill-btn--block {
  width: 100%;
}

.bill-btn:disabled,
.bill-action-card:disabled,
.bill-update-link:disabled,
.bill-link-btn:disabled,
.bill-panel__link:disabled,
.bill-invoice__dl:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

/* Dialogs */
.bill-dialog {
  color-scheme: inherit;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 32px));
  max-height: min(42rem, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: var(--dash-island-border);
  border-radius: var(--dash-radius-card, 20px);
  background: var(--dash-card);
  color: var(--bill-text);
  box-shadow: var(--shadow-xl, 0 24px 80px rgba(0, 0, 0, 0.4));
}

html:not(.light):not(.light-theme) .bill-dialog {
  border: none;
}

.bill-dialog::backdrop {
  background: var(--color-overlay);
  backdrop-filter: blur(8px);
}

.bill-dialog__panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.bill-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.bill-dialog__head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  color: var(--bill-text);
}

.bill-dialog__close {
  display: grid;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--color-well);
  color: var(--dash-text-muted);
  cursor: pointer;
  padding: 0;
}

.bill-dialog__close:hover {
  background: var(--color-well-hover);
  color: var(--bill-text);
}

.bill-dialog__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--dash-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.bill-dialog__field label {
  color: var(--dash-text-muted);
}

.bill-dialog__input,
.bill-dialog .form-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: var(--control-height-md);
  min-height: var(--control-height-md);
  border: var(--color-input-border, none);
  border-radius: var(--control-radius-input);
  background-color: var(--color-input-bg, var(--color-well));
  color: var(--color-input-text, var(--bill-text));
  font: inherit;
  padding: 0 var(--control-padding-x);
  outline: none;
}

.bill-dialog__input:hover,
.bill-dialog .form-input:hover {
  background-color: var(--color-input-bg-hover, var(--color-well-hover));
}

.bill-dialog__input:focus-visible,
.bill-dialog__close:focus-visible,
.bill-btn:focus-visible,
.bill-update-link:focus-visible,
.bill-action-card:focus-visible,
.bill-link-btn:focus-visible,
.bill-panel__link:focus-visible,
.bill-invoice__dl:focus-visible {
  outline: 2px solid var(--dash-accent-focus);
  outline-offset: 2px;
}

.bill-dialog .set-btn--ghost,
.bill-dialog .bill-btn--secondary {
  background: var(--color-well);
  color: var(--bill-text);
}

.bill-dialog__error {
  margin: 0;
  color: var(--bill-danger);
  font-size: 13px;
}

.bill-dialog__copy {
  margin: 0;
  color: var(--dash-text-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}

.bill-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.bill-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-tooltip, 80);
  max-width: min(340px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--dash-popover-bg-solid, var(--dash-card));
  color: var(--bill-text);
  box-shadow: var(--dash-popover-shadow, var(--shadow-xl));
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.bill-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@container bill-content (max-width: 900px) {
  .bill-layout {
    grid-template-columns: 1fr;
  }

  .bill-aside {
    position: static;
    margin-top: 0;
  }
}

@container bill-main (max-width: 560px) {
  .bill-features {
    grid-template-columns: 1fr;
  }

  .bill-detail-rows {
    grid-template-columns: 1fr;
  }

  .bill-detail-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .bill-detail-row__value,
  .bill-detail-row__right {
    width: 100%;
    text-align: left;
  }

  .bill-detail-row__right {
    justify-content: space-between;
  }

  .bill-action-card {
    grid-template-columns: 40px 1fr 18px;
    padding: 12px 4px;
  }

  .bill-action-card__icon {
    width: 40px;
    height: 40px;
  }

  .bill-checkout {
    grid-template-columns: 1fr;
  }

  .bill-checkout__plan {
    align-items: flex-start;
    text-align: left;
  }

  .bill-checkout__actions {
    justify-content: flex-start;
  }
}

@media (max-width: 800px) {
  .bill-content {
    padding-right: var(--dash-page-x, 20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bill-dialog::backdrop {
    backdrop-filter: none;
  }
}
