/*
  Prometheus buyer UI consistency layer.
  Loaded after the inline legacy stylesheet so order, forecast, subscription,
  account and modal surfaces share one compact rhythm.
*/

:root {
  --buyer-bg: #f6f8fc;
  --buyer-card: #ffffff;
  --buyer-soft: #f8fafc;
  --buyer-line: #dbe3ee;
  --buyer-line-strong: #cbd5e1;
  --buyer-text: #0f172a;
  --buyer-muted: #64748b;
  --buyer-primary: #1d4ed8;
  --buyer-primary-dark: #1e40af;
  --buyer-success: #166534;
  --buyer-danger: #b91c1c;
  --buyer-radius: 8px;
  --buyer-radius-sm: 6px;
  --buyer-focus: rgba(37, 99, 235, 0.18);
  --buyer-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --buyer-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

html,
body,
input,
select,
textarea,
button {
  font-family: var(--buyer-font);
  letter-spacing: 0;
}

body {
  background: var(--buyer-bg);
  color: var(--buyer-text);
  font-size: 13px;
  line-height: 1.4;
}

.wrap {
  max-width: 1280px;
  min-height: 100vh;
  padding: 16px;
  background: #fff;
}

h1,
h2,
h3,
h4 {
  color: var(--buyer-text);
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.14;
}

h2 {
  font-size: 20px;
  line-height: 1.18;
}

h3 {
  font-size: 17px;
  line-height: 1.22;
}

.sub,
.muted,
.subscription-note,
.subscription-line-sub,
.order-receipt-status-text {
  color: var(--buyer-muted);
  font-size: 12px;
  line-height: 1.4;
}

.card,
.subscription-surface,
.subscription-pending-card,
.subscription-detail-card,
.subscription-summary-grid > div,
.order-address-box,
.order-lines-wrap,
.order-receipt-wrap,
.muted-box,
.msg,
.order-empty-box,
.product-picker-empty,
.center-modal-root {
  border-color: var(--buyer-line);
  border-radius: var(--buyer-radius);
  background: var(--buyer-card);
  box-shadow: var(--buyer-shadow);
}

.card {
  padding: 12px;
  margin-bottom: 10px;
}

input,
select,
textarea,
button {
  min-height: 34px;
  border-color: var(--buyer-line-strong);
  border-radius: var(--buyer-radius);
  font-size: 13px;
}

input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
  color: var(--buyer-text);
  background: #fff;
}

button {
  font-weight: 700;
}

button.primary {
  border-color: var(--buyer-primary);
  background: var(--buyer-primary);
}

button.primary:hover:not(:disabled) {
  border-color: var(--buyer-primary-dark);
  background: var(--buyer-primary-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--buyer-focus);
}

#auth-card #auth-form,
#auth-card #auth-msg,
#auth-card .auth-action-stack,
#auth-card .auth-cta {
  width: 100%;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

#auth-card .auth-email-field input {
  width: 100%;
}

#auth-card .auth-email-field input {
  min-height: 40px;
  font-size: 14px;
}

#auth-card #auth-msg {
  margin-top: 8px;
  margin-bottom: 0;
}

#auth-card #auth-msg.warn {
  border-width: 2px;
  border-color: #f59e0b;
  background: #fffbeb;
  color: #78350f;
  box-shadow: var(--buyer-shadow);
  font-weight: 800;
}

#auth-card .auth-code-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 10px;
}

#auth-card .auth-code-button {
  width: 100%;
  min-height: 38px;
  padding: 7px 12px;
  font-size: 13px;
  line-height: 1.2;
}

#auth-card #request-link {
  grid-column: 1 / -1;
}

#auth-card #request-sms {
  display: none;
}

#auth-card .auth-code-panel {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

#auth-card .auth-code-panel label {
  margin-bottom: 0;
  text-align: center;
}

#auth-card .auth-code-panel input,
#auth-card .auth-code-panel button {
  width: 100%;
  min-height: 38px;
  text-align: center;
}

#auth-card .auth-code-panel input {
  letter-spacing: 0;
  font-weight: 700;
}

#auth-card #auth-channel-help {
  text-align: left;
}

#auth-card .auth-cta {
  margin: 10px auto 0;
  text-align: center;
}

#auth-card .auth-cta + .auth-cta {
  margin-top: 6px;
}

#auth-card .auth-cta-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--buyer-line-strong);
  border-radius: var(--buyer-radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

#auth-card .auth-cta-button:hover {
  box-shadow: 0 0 0 3px var(--buyer-focus);
}

#auth-card .auth-cta-button-primary {
  width: 100%;
  max-width: none;
  min-height: 40px;
  padding: 9px 12px;
  border-color: #bfd0ff;
  background: #f6f9ff;
  color: var(--buyer-primary);
  font-size: 12px;
  font-weight: 750;
  box-shadow: none;
}

#auth-card .auth-cta-button-primary:hover,
#auth-card .auth-cta-button-primary:focus-visible {
  border-color: #9bb4ff;
  background: #eef4ff;
  color: var(--buyer-primary-dark);
}

#auth-card .auth-cta-button-secondary {
  width: auto;
  max-width: 100%;
  min-height: 0;
  display: inline;
  border: 0;
  background: transparent;
  color: var(--buyer-muted);
  padding: 0;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

#auth-card .auth-cta-button-secondary:hover,
#auth-card .auth-cta-button-secondary:focus-visible {
  background: transparent;
  color: var(--buyer-primary);
  text-decoration: underline;
}

@media (max-width: 700px) {
  #auth-card .auth-email-field input {
    min-height: 42px;
    font-size: 16px;
  }

  #auth-card .auth-code-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  #auth-card #request-link {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  #auth-card #request-sms {
    display: none;
  }

  #auth-card.auth-code-channel-email .auth-code-panel {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #auth-card.auth-code-channel-sms .auth-code-panel {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  #auth-card .auth-code-button {
    width: 100%;
    min-height: 40px;
  }
}

.portal-top {
  margin-bottom: 8px;
}

.portal-title {
  font-size: 24px;
  line-height: 1.12;
}

.portal-title.page-title {
  font-size: 30px;
}

.portal-brand-logo {
  height: 28px;
  max-width: 160px;
}

.tabs {
  gap: 0;
  align-items: flex-end;
  overflow-x: visible;
  overflow-y: visible;
  border: 0;
  border-bottom: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  margin-bottom: -1px;
  scrollbar-width: none;
  position: relative;
  z-index: 2;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs::after {
  display: none;
}

.tab-btn {
  flex: 0 0 auto;
  min-width: 0;
  min-height: 38px;
  border: 1px solid transparent;
  border-bottom-color: transparent;
  border-radius: var(--buyer-radius) var(--buyer-radius) 0 0;
  background: transparent;
  color: #475569;
  margin-bottom: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  position: relative;
  white-space: nowrap;
}

.tab-btn.active {
  background: #fff;
  border-color: var(--buyer-line);
  border-bottom-color: #fff;
  color: var(--buyer-text);
  box-shadow: none;
  z-index: 3;
}

.tab-panel.card {
  margin-top: 0;
  border-top: 1px solid var(--buyer-line);
  border-radius: 0 0 var(--buyer-radius) var(--buyer-radius);
  position: relative;
  z-index: 1;
}

.order-lines-wrap {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  overflow: visible;
}

.order-empty-box,
.product-picker-empty,
.product-lines-empty,
.order-lines-empty,
.muted-box {
  border: 1px dashed #cbd5e1;
  border-radius: var(--buyer-radius);
  background: #fbfdff;
  color: var(--buyer-muted);
  padding: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.order-lines-empty-action,
.product-lines-empty.product-lines-add-action {
  color: var(--buyer-primary);
  font-weight: 800;
}

.subscription-line,
.order-line,
.subscription-detail-grid > *,
.subscription-summary-grid > div,
.order-totals-value,
.order-product-trigger,
.subscription-frequency-col,
.order-price-col,
.order-qty-stepper {
  border-radius: var(--buyer-radius);
}

.subscription-check-row {
  border-radius: var(--buyer-radius);
  background: #f8fbff;
}

.subscription-check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.center-modal-root {
  border-radius: var(--buyer-radius);
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}

.center-modal-title {
  font-size: 20px;
  line-height: 1.18;
}

.center-modal-icon-close,
.session-icon-btn,
.session-avatar {
  border-radius: var(--buyer-radius);
}

.toast,
.session-menu,
.date-picker-popover,
.product-picker-popover {
  border-radius: var(--buyer-radius);
}

@media (max-width: 800px) {
  .wrap {
    padding: 10px;
  }

  .portal-top {
    align-items: flex-start;
  }

  .portal-title {
    font-size: 21px;
  }

  .portal-title.page-title {
    font-size: 24px;
  }

  .card {
    padding: 10px;
  }

  .tabs {
    margin-left: 0;
    margin-right: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
  }

  .tab-btn {
    width: 100%;
    padding: 7px 6px;
    font-size: 12px;
    line-height: 1.1;
    min-height: 36px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .wrap {
    padding: 8px;
  }

  .card,
  .subscription-surface,
  .order-address-box {
    padding: 8px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  h3 {
    font-size: 16px;
  }

  button,
  input,
  select,
  textarea {
    min-height: 36px;
  }

  .center-modal-root {
    width: calc(100vw - 16px);
    padding: 12px;
  }
}

@media (max-width: 380px) {
  .tab-btn {
    padding-left: 4px;
    padding-right: 4px;
    font-size: 11px;
  }
}

.buyer-feedback-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #111827;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
}

.buyer-feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.buyer-feedback-modal.show {
  display: flex;
}

.buyer-feedback-card {
  width: min(560px, 100%);
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.22);
}

.buyer-feedback-head,
.buyer-feedback-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.buyer-feedback-head h3 {
  margin: 0;
}

.buyer-feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.buyer-feedback-card label {
  display: grid;
  gap: 5px;
  font-weight: 700;
}

.buyer-feedback-card textarea {
  min-height: 130px;
  resize: vertical;
}

.buyer-feedback-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.buyer-feedback-check input {
  width: auto;
}

@media (max-width: 560px) {
  .buyer-feedback-launcher {
    right: 12px;
    bottom: 12px;
  }

  .buyer-feedback-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 800px) {
  .wrap {
    padding:
      max(10px, env(safe-area-inset-top, 0px))
      10px
      max(18px, env(safe-area-inset-bottom, 0px));
  }

  .portal-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .portal-branding {
    min-width: 0;
  }

  .portal-title,
  .portal-title.page-title {
    overflow-wrap: anywhere;
  }

  .tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  .tab-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    max-width: none;
    padding-inline: 12px;
    overflow: visible;
    text-overflow: clip;
    scroll-snap-align: start;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .row,
  .buyer-feedback-actions {
    align-items: stretch;
  }

  .row > button,
  .row > .primary,
  .row > .danger {
    flex: 1 1 100%;
  }

  .buyer-feedback-modal {
    align-items: flex-end;
    padding: 8px;
  }

  .buyer-feedback-card {
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }

  .buyer-feedback-actions {
    flex-direction: column-reverse;
  }

  .buyer-feedback-actions > * {
    width: 100%;
  }
}
