:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #172033;
  background: #f2f5fa;
  --brand: #1257d5;
  --brand-dark: #0b3f9e;
  --focus: #0b3f9e;
  --focus-gap: #ffffff;
  --surface: #ffffff;
  --border: #c7d1e2;
  --muted: #526078;
  --danger: #9e1c27;
  --pilot: #7a4a00;
  --pilot-surface: #fff6df;
  --pilot-border: #d9a94e;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  overflow-x: hidden;
  scroll-padding-bottom: calc(7.5rem + var(--safe-bottom));
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: #f2f5fa;
}

button,
input,
select,
a {
  font: inherit;
}

button,
a {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

a {
  color: var(--brand-dark);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--focus-gap);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: max(0.5rem, var(--safe-top));
  left: 0.5rem;
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  transform: translateY(-180%);
  border-radius: 0.5rem;
  color: #ffffff;
  background: #172033;
}

.skip-link:focus {
  transform: translateY(0);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  font-size: 1.125rem;
  font-weight: 750;
  color: #172033;
}

.brand-link {
  text-decoration: none;
}

.brand-name,
.session-status-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand-mark {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 44px;
  border-radius: 0.875rem;
  color: #ffffff;
  background: var(--brand);
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--brand-dark);
  font-size: 0.8125rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-layout {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: max(1rem, var(--safe-top)) 1rem max(1rem, var(--safe-bottom));
}

.login-card {
  width: min(100%, 30rem);
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: 0 1rem 3rem rgba(23, 32, 51, 0.09);
}

.login-heading {
  margin: 2rem 0 1.25rem;
}

.login-heading h1,
.welcome-card h1,
.placeholder-card h2 {
  margin: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.supporting-text,
.security-note,
.welcome-card p,
.placeholder-card p {
  color: var(--muted);
}

.welcome-card .pilot-user {
  margin: 0.625rem 0;
  font-weight: 700;
}

.pilot-warning {
  display: grid;
  gap: 0.25rem;
  margin: 1rem 0;
  padding: 0.875rem;
  border: 1px solid var(--pilot-border);
  border-radius: 0.75rem;
  color: var(--pilot);
  background: var(--pilot-surface);
}

.pilot-warning span {
  color: #5f4b23;
}

.placeholder-card .pilot-disabled-label {
  font-weight: 700;
  color: var(--pilot);
}

.status-message {
  min-height: 44px;
  margin-bottom: 1rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid #b8c8e5;
  border-radius: 0.75rem;
  color: #173a74;
  background: #eef5ff;
  overflow-wrap: anywhere;
}

.status-message-error {
  border-color: #df9aa0;
  color: #7a1019;
  background: #fff1f2;
}

.status-message-placeholder {
  border-color: transparent;
  background: transparent;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  min-width: 0;
  gap: 0.375rem;
}

.field label {
  font-weight: 700;
}

.field input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.75rem;
  border: 1px solid #71809a;
  border-radius: 0.75rem;
  color: #172033;
  background: #ffffff;
}

.field select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.75rem;
  border: 1px solid #71809a;
  border-radius: 0.75rem;
  color: #172033;
  background: #ffffff;
}

.primary-button,
.secondary-button,
.danger-button,
.placeholder-card button,
.desktop-navigation button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  font-weight: 750;
}

.primary-button {
  width: 100%;
  color: #ffffff;
  background: var(--brand);
}

.secondary-button,
.danger-button {
  width: 100%;
  margin-top: 0.5rem;
}

.secondary-button {
  border: 1px solid var(--brand);
  color: var(--brand-dark);
  background: #eef5ff;
}

.danger-button {
  border: 1px solid #c56c75;
  color: #7a1019;
  background: #fff1f2;
}

.secondary-link {
  display: inline-flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--brand);
  border-radius: 0.75rem;
  text-align: center;
  text-decoration: none;
}

button:disabled {
  color: #5d6879;
  background: #dce2eb;
  cursor: not-allowed;
}

.security-note {
  margin: 1.25rem 0 0;
  font-size: 0.875rem;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
}

.header-inner {
  display: flex;
  width: min(100%, 72rem);
  min-width: 0;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

.session-status {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.5rem;
  color: #22522f;
  font-size: 0.8125rem;
  font-weight: 700;
}

.session-status-text {
  display: block;
}

.status-dot {
  width: 0.75rem;
  height: 0.75rem;
  flex: 0 0 0.75rem;
  border-radius: 50%;
  background: #24833e;
}

.shell-layout {
  width: min(100%, 72rem);
  min-width: 0;
  margin: 0 auto;
}

.desktop-navigation {
  display: none;
}

.app-content {
  min-width: 0;
  padding: 1rem 1rem calc(7.5rem + var(--safe-bottom));
}

.welcome-card,
.placeholder-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
}

.welcome-card {
  padding: 1.25rem;
}

.section-grid {
  display: grid;
  align-items: start;
  min-width: 0;
  gap: 1rem;
  margin-top: 1rem;
}

.placeholder-card {
  scroll-margin-top: calc(5.5rem + var(--safe-top));
  padding: 1rem;
}

.placeholder-card button {
  width: 100%;
}

.wizard-step,
.selected-branch,
.branch-choice,
.file-prepared,
.file-summary,
.order-detail {
  display: grid;
  min-width: 0;
  gap: 0.375rem;
}

.wizard-step {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(7.5rem + var(--safe-top));
  scroll-margin-bottom: calc(7.5rem + var(--safe-bottom));
}

.wizard-step:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.wizard-step h3,
.order-detail h3 {
  margin: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.step-label {
  margin: 0;
  color: var(--brand-dark) !important;
  font-size: 0.8125rem;
  font-weight: 750;
  text-transform: uppercase;
}

.selected-branch,
.branch-choice,
.file-prepared {
  padding: 0.75rem;
  border: 1px solid #b8c8e5;
  border-radius: 0.75rem;
  background: #f5f8ff;
  overflow-wrap: anywhere;
}

.selected-branch {
  margin-top: 1rem;
}

.branch-form,
.branch-list {
  display: grid;
  min-width: 0;
  gap: 0.75rem;
}

.branch-list {
  padding: 0;
  border: 0;
}

.branch-option {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  min-width: 0;
  min-height: 56px;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
}

.branch-option input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
}

.branch-option input[type="radio"]:checked + .branch-choice {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(18, 87, 213, 0.16);
}

.upload-form,
.options-form,
.status-search {
  display: grid;
  min-width: 0;
  gap: 0.75rem;
}

.upload-form input[type="file"] {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.625rem;
  border: 1px dashed #71809a;
  border-radius: 0.75rem;
  background: #ffffff;
}

.upload-progress {
  margin: 0;
  font-weight: 700;
  color: var(--brand-dark) !important;
}

[hidden] {
  display: none !important;
}

.file-list,
.quote-list,
.summary-list,
.order-list {
  display: grid;
  min-width: 0;
  gap: 0.75rem;
  padding: 0;
  list-style: none;
}

.file-card,
.quote-list li,
.summary-list li,
.order-list li {
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.file-card > form + form {
  margin-top: 0.5rem;
}

.file-card > strong,
.file-card > span,
.file-card > small {
  display: block;
  margin-block: 0.2rem;
}

.order-detail > p {
  margin-block: 0.35rem;
}

.order-files-target,
.order-detail,
.order-actions {
  min-width: 0;
  scroll-margin-top: calc(7.5rem + var(--safe-top));
  scroll-margin-bottom: calc(7.5rem + var(--safe-bottom));
}

.quote-list li,
.summary-list li {
  display: grid;
  gap: 0.25rem;
}

.quote-total {
  color: #172033 !important;
  font-size: 1.125rem;
}

.cart-card {
  scroll-margin-top: calc(7.5rem + var(--safe-top));
}

.order-list a {
  display: grid;
  min-width: 0;
  min-height: 44px;
  gap: 0.25rem;
  color: #172033;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.order-card {
  display: grid;
  min-width: 0;
  gap: 0.625rem;
}

.order-code {
  display: inline-block;
  max-width: 100%;
  user-select: text;
  -webkit-user-select: text;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.copy-order-code-button {
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--brand);
  border-radius: 0.75rem;
  color: var(--brand-dark);
  background: #eef5ff;
}

.copy-feedback {
  min-width: 0;
  min-height: 1.5rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.order-actions {
  display: grid;
  gap: 0.625rem;
  padding-bottom: 0.5rem;
}

.order-actions .secondary-link {
  margin: 0;
}

.quantity-summary,
.payment-review-meta {
  display: grid;
  min-width: 0;
  gap: 0.5rem;
  margin: 1rem 0;
}

.quantity-summary > div,
.payment-review-meta > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

.quantity-summary dt,
.quantity-summary dd,
.payment-review-meta dt,
.payment-review-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.quantity-summary dd,
.payment-review-meta dd {
  font-weight: 750;
  text-align: right;
}

.payment-review-card {
  min-width: 0;
  grid-column: 1 / -1;
  scroll-margin-top: calc(7.5rem + var(--safe-top));
  scroll-margin-bottom: calc(8.5rem + var(--safe-bottom));
}

.payment-review-warning,
.payment-review-identity,
.payment-review-items,
.payment-review-note {
  min-width: 0;
  overflow-wrap: anywhere;
}

.payment-review-identity {
  display: grid;
  gap: 0.25rem;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #ffffff;
}

.payment-review-identity > span {
  color: var(--muted);
}

.payment-review-items {
  display: grid;
  gap: 0.75rem;
  padding: 0;
  list-style: none;
}

.payment-review-items li {
  display: grid;
  min-width: 0;
  gap: 0.35rem;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #ffffff;
  overflow-wrap: anywhere;
}

.payment-review-amount {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
  padding: 1rem;
  border: 2px solid var(--brand);
  border-radius: 0.875rem;
  background: #eef5ff;
}

.payment-review-amount span {
  color: var(--muted);
}

.payment-review-amount strong {
  color: var(--brand-dark);
  font-size: clamp(1.5rem, 8vw, 2.25rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.quote-list li > span,
.summary-list li > span,
.status-search input,
.order-detail,
.order-card {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.test-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 28px;
  margin: 0;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  color: #5a3600 !important;
  background: #ffe7ad;
  font-size: 0.8125rem;
  font-weight: 750;
}

.pagination {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pagination a {
  display: inline-flex;
  align-items: center;
}

.timeline {
  padding-left: 1.5rem;
}

form[aria-busy="true"] {
  opacity: 0.75;
}

.mobile-navigation {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-width: 0;
  padding: 0.375rem 0.25rem max(0.375rem, var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 -0.5rem 1.5rem rgba(23, 32, 51, 0.08);
}

.mobile-navigation a,
.mobile-navigation button {
  display: flex;
  min-width: 44px;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.25rem;
  border-radius: 0.625rem;
  color: #334159;
  font-size: 0.6875rem;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.mobile-navigation form {
  min-width: 0;
  margin: 0;
}

.mobile-navigation button {
  width: 100%;
  border: 0;
  background: transparent;
}

.mobile-navigation button:disabled {
  color: #647087;
  background: transparent;
}

.mobile-navigation a[aria-current="location"] {
  color: #ffffff;
  background: var(--brand-dark);
}

@media (max-width: 26.875rem) {
  .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "status";
    align-items: start;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
  }

  .header-inner .brand {
    grid-area: brand;
    max-width: 100%;
  }

  .session-status {
    grid-area: status;
    width: 100%;
    max-width: 100%;
    align-items: flex-start;
  }

  .session-status-text {
    flex: 1 1 auto;
    white-space: normal;
    word-break: normal;
    overflow-wrap: anywhere;
  }
}

@media (min-width: 48rem) {
  .login-card {
    padding: 2rem;
  }

  .shell-layout {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
  }

  .desktop-navigation {
    position: sticky;
    top: calc(6rem + var(--safe-top));
    display: grid;
    align-content: start;
    align-self: start;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--surface);
  }

  .desktop-navigation a,
  .desktop-navigation button {
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    padding: 0.625rem 0.75rem;
    border-radius: 0.625rem;
    color: #26344b;
    text-decoration: none;
  }

  .desktop-navigation form {
    margin: 0;
  }

  .app-content {
    padding: 0 0 2rem;
  }

  .section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-flow-card {
    grid-column: 1 / -1;
  }

  .mobile-navigation {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
