/* Medical broker — simple test UI */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --accent: #0b6e4f;
  --accent-hover: #095c42;
  --border: #d5dde5;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --radius: 8px;
  --font: "Segoe UI", system-ui, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 1px 2px rgba(26, 35, 50, 0.06);
}

.card--wide {
  max-width: 560px;
}

.brand {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.brand-row .subtitle {
  margin-bottom: 0;
}

.brand-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: block;
}

.topbar .brand-row {
  margin-bottom: 0;
  min-width: 0;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.field {
  margin-bottom: 1rem;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 12rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.8rem;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(11, 110, 79, 0.35);
  border-color: var(--accent);
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn--secondary {
  width: auto;
  margin-top: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--bg);
}

.form-actions {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
}

.form-actions .btn {
  width: auto;
  flex: 1 1 0;
}

.error {
  display: none;
  margin-bottom: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.9rem;
}

.error.is-visible {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.status-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.status-list li:last-child {
  border-bottom: none;
}

.status-list .label {
  color: var(--muted);
}

.status-list .value {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  text-align: right;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  background: #e6f4ef;
  color: var(--accent);
}

.placeholder {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
}

.placeholder strong {
  color: var(--text);
}

.page--top {
  align-items: flex-start;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.card--xl {
  max-width: 820px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.field--full {
  grid-column: 1 / -1;
}

input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.progress-panel {
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafb;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e4e9ee;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.result-panel {
  margin-top: 1.25rem;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.result-title {
  margin: 0;
  font-size: 1.1rem;
}

.badge--ok {
  background: #e6f4ef;
  color: var(--accent);
}

.badge--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.failure-reason {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 650;
}

.provider-errors-panel {
  margin: 0 0 1rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #f1b5ad;
  border-radius: 6px;
  background: var(--danger-bg);
}

.provider-errors-panel h3 {
  margin: 0 0 0.5rem;
  color: var(--danger);
  font-size: 0.9rem;
}

.result-hint {
  margin: 0 0 0.85rem;
}

.products-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.product-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.product-card--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(11, 110, 79, 0.15);
}

.product-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.product-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.product-name-ar {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.product-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.product-price {
  margin: 0.65rem 0 0;
  font-size: 1.05rem;
  font-weight: 650;
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.85rem;
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
}

.detail-list--compact {
  margin-top: 0.5rem;
}

.detail-list dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
  word-break: break-word;
}

.price-table {
  width: 100%;
  margin-top: 0.35rem;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.price-table td {
  padding: 0.3rem 0;
  border-bottom: 1px solid #eef2f5;
}

.price-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.price-table__muted {
  color: var(--muted);
  text-align: right;
}

.member-options {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.member-option {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}

.member-option:hover {
  background: #f8fafb;
}

.member-option input {
  margin-top: 0.2rem;
}

.document-list {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.document-list a {
  color: var(--accent);
}

.selection-panel {
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafb;
}

.selection-heading {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.selection-actions {
  margin-top: 0.85rem;
}

.selection-actions .btn {
  width: auto;
  margin-top: 0;
}

.btn--compact {
  width: auto;
  margin-top: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

.member-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.raw-details {
  margin-top: 0.5rem;
}

.raw-details .raw-title {
  cursor: pointer;
  font-weight: 650;
}

.product-errors {
  margin: 0.65rem 0 0;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.75rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.product-detail-title {
  margin: 0.65rem 0 0.25rem;
  font-size: 0.8rem;
}

.product-raw-details {
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.product-raw-details summary {
  cursor: pointer;
  font-weight: 650;
}

.product-data {
  margin: 0.4rem 0 0;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: #f4f7fa;
  color: var(--text);
  font-size: 0.75rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.raw-title {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.json-block {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0f1720;
  color: #e8eef5;
  font-size: 0.75rem;
  line-height: 1.4;
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-block {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0f1720;
  color: #e8eef5;
  font-size: 0.75rem;
  line-height: 1.4;
  overflow: auto;
  max-height: 480px;
  white-space: pre-wrap;
  word-break: break-word;
}

.section-title {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
}

.panel {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

input[readonly] {
  background: #eef2f6;
  color: #334155;
  cursor: default;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
    gap: 0.25rem;
  }
}
