:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #1d2433;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 247, 249, 0.98)), #f6f7f9;
}

button,
input,
select {
  font: inherit;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 48px;
}

.page-content {
  width: min(100%, 720px);
}

.page-content--narrow {
  width: min(100%, 520px);
}

.page-content--wide {
  width: min(100%, 1180px);
}

.eyebrow {
  margin: 0 0 12px;
  color: #1f6feb;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.page h1 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 1.02;
  letter-spacing: 0;
}

.page p:not(.eyebrow) {
  max-width: 580px;
  margin: 22px 0 0;
  color: #4d596d;
  font-size: 18px;
  line-height: 1.55;
}

.test-order-panel,
.order-meta {
  width: min(100%, 560px);
  margin-top: 28px;
  padding: 16px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  background: #ffffff;
}

.bridge-dashboard {
  width: 100%;
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.bridge-panel {
  width: 100%;
  margin-top: 0;
}

.bridge-panel__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.bridge-panel__header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.bridge-panel__header p {
  margin: 3px 0 0;
  color: #647084;
  font-size: 12px;
  line-height: 1.35;
}

.bridge-step {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: #1f6feb;
  color: #ffffff;
  font-weight: 800;
}

.test-order-panel label {
  display: block;
  margin: 12px 0 8px;
  color: #364154;
  font-size: 14px;
  font-weight: 700;
}

.test-order-panel__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.test-order-panel input,
.test-order-panel select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 0 12px;
}

.test-order-panel select {
  background: #ffffff;
  color: #1d2433;
}

.test-order-panel button {
  width: 100%;
  margin-top: 14px;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: #1f6feb;
  color: #ffffff;
  cursor: pointer;
}

.admin-login {
  margin-top: 28px;
}

.admin-login .admin-error {
  max-width: none;
  margin: 12px 0 0;
  color: #c51f46;
  font-size: 14px;
  line-height: 1.4;
}

.admin-topbar {
  width: 100%;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #d9dee7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #647084;
  font-size: 14px;
  font-weight: 700;
}

.admin-topbar form {
  margin: 0;
}

.admin-topbar button {
  min-height: 38px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 0 14px;
  background: #ffffff;
  color: #364154;
  cursor: pointer;
}

.admin-topbar button:hover {
  background: #eef2f7;
}

.copy-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.copy-input .copy-input__button {
  width: 42px;
  min-height: 42px;
  margin-top: 0;
  padding: 0;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #364154;
  font-size: 18px;
  line-height: 1;
}

.copy-input .copy-input__button:hover {
  background: #eef2f7;
}

.bridge-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.bridge-actions .bridge-link {
  min-height: 42px;
  margin-top: 14px;
  padding: 0 12px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #1f6feb;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.bridge-output {
  min-height: 20px;
  display: block;
  margin-top: 12px;
  color: #364154;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.bridge-json {
  min-height: 180px;
  max-height: 380px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #d9dee7;
  border-radius: 6px;
  background: #f8fafc;
  color: #1d2433;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.order-meta p {
  margin: 10px 0 0;
  color: #647084;
  font-size: 13px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.receipt-upload {
  width: min(100%, 560px);
  margin-top: 20px;
  padding: 16px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  background: #ffffff;
}

.receipt-upload label:not(.receipt-upload__confirm) {
  display: block;
  margin: 0 0 8px;
  color: #364154;
  font-size: 14px;
  font-weight: 700;
}

.receipt-upload input[type="file"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 9px 12px;
  background: #ffffff;
}

.receipt-upload__confirm {
  margin: 14px 0 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #4d596d;
  font-size: 14px;
  line-height: 1.4;
}

.receipt-upload__confirm input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: 0 0 auto;
}

.receipt-upload button {
  width: 100%;
  min-height: 42px;
  margin-top: 16px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: #1f6feb;
  color: #ffffff;
  cursor: pointer;
}

.receipt-upload button:disabled {
  cursor: not-allowed;
  background: #aeb7c6;
}

.page a {
  color: #1f6feb;
}

.chat-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  width: auto;
}

.chat-launcher {
  position: relative;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #302829;
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 14px 28px rgba(29, 24, 25, 0.24);
  cursor: pointer;
}

.chat-launcher__dot {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: block;
}

.chat-widget.has-unread .chat-launcher::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 38px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ff3b30;
  box-shadow: 0 0 0 2px #302829;
}

.chat-shell {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(400px, calc(100vw - 48px));
  height: min(620px, calc(100vh - 116px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(29, 36, 51, 0.12);
}

.chat-shell[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid #e4e8ef;
  background: #ffffff;
}

.chat-header h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.chat-header p {
  margin: 4px 0 0;
  color: #647084;
  font-size: 13px;
}

.chat-close-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: #eef2f7;
  color: #364154;
  cursor: pointer;
  font-size: 18px;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

.message {
  width: fit-content;
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #e1e6ee;
}

.message.is-me {
  align-self: flex-end;
  background: #e8f1ff;
  border-color: #cfe0ff;
}

.message__author {
  display: block;
  margin-bottom: 4px;
  color: #647084;
  font-size: 12px;
}

.message__content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message__attachment {
  display: block;
  margin-top: 8px;
  color: #1f6feb;
  overflow-wrap: anywhere;
}

.message__attachment img {
  display: block;
  width: min(220px, 100%);
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
}

.composer {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 64px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid #e4e8ef;
  background: #ffffff;
}

.composer-file {
  display: none;
}

.composer button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: #1f6feb;
  color: #ffffff;
  cursor: pointer;
}

.composer button:disabled {
  cursor: not-allowed;
  background: #aeb7c6;
}

.composer-attach {
  width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  background: #eef2f7 !important;
  color: #364154 !important;
}

.composer input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 0 12px;
}

.composer-file-name {
  grid-column: 2 / 4;
  margin: -2px 0 0;
  color: #647084;
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (max-width: 520px) {
  .page {
    align-items: flex-start;
    padding: 36px 20px 120px;
  }

  .page h1 {
    font-size: 38px;
  }

  .test-order-panel__row {
    grid-template-columns: 1fr;
  }

  .bridge-dashboard {
    grid-template-columns: 1fr;
  }

  .bridge-actions {
    grid-template-columns: 1fr;
  }

  .chat-widget {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .chat-widget.is-open {
    inset: 0;
    overflow: hidden;
  }

  .chat-widget.is-open .chat-launcher {
    display: none;
  }

  .chat-launcher {
    width: 100%;
    justify-content: center;
  }

  .chat-shell {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .chat-header {
    padding: calc(14px + env(safe-area-inset-top)) 14px 12px;
  }

  .messages {
    padding: 16px 14px;
  }

  .composer {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }
}
