/* Aaxis Demo ERP web application: light theme, blue primary, compact grids. No external fonts or assets. */

:root {
  --primary: #1565c0;
  --primary-dark: #0d4f9c;
  --primary-soft: #e6f0fb;
  --primary-ring: rgba(21, 101, 192, 0.28);
  --topbar: #0b3a6e;
  --topbar-text: #ffffff;
  --bg: #f1f4f8;
  --surface: #ffffff;
  --surface-alt: #f7f9fb;
  --border: #d8dee6;
  --border-strong: #b9c3cf;
  --text: #1d2733;
  --muted: #5d6a7a;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --success: #2e7d32;
  --success-soft: #e8f5e9;
  --warning: #a35f00;
  --warning-soft: #fff4e0;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 32, 56, 0.08), 0 1px 1px rgba(16, 32, 56, 0.04);
  --shadow-lg: 0 10px 30px rgba(16, 32, 56, 0.2);
  --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --topbar-height: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

.icon-lg {
  width: 26px;
  height: 26px;
}

/* ---------- top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-height);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 6px;
  background: var(--topbar);
  color: var(--topbar-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.topbar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.topbar-button:hover,
.topbar-button[aria-expanded='true'] {
  background: rgba(255, 255, 255, 0.14);
}

.topbar-button .icon {
  width: 22px;
  height: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 4px 6px;
  border-radius: var(--radius);
}

.brand:hover {
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
}

.brand img {
  border-radius: 7px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.topbar-spacer {
  flex: 1;
}

.topbar-company {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  height: 30px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.92);
}

.topbar-company strong {
  font-weight: 600;
  margin-right: 4px;
}

.user-menu {
  position: relative;
}

.user-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 8px 0 4px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.user-button:hover,
.user-button[aria-expanded='true'] {
  background: rgba(255, 255, 255, 0.14);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffb300;
  color: #1d2733;
  font-size: 12px;
  font-weight: 700;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
}

.user-dropdown-head {
  display: flex;
  flex-direction: column;
  padding: 8px 14px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.user-dropdown-head span {
  color: var(--muted);
  font-size: 12px;
}

.user-dropdown form {
  margin: 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover {
  background: var(--primary-soft);
}

/* ---------- slide-out menu ---------- */

.side-menu {
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  width: 260px;
  z-index: 35;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(-102%);
  visibility: hidden;
  transition:
    transform 0.18s ease,
    visibility 0s linear 0.18s;
  overflow-y: auto;
}

.side-menu.open {
  transform: none;
  visibility: visible;
  transition: transform 0.18s ease;
}

.side-menu ul {
  list-style: none;
  margin: 0;
  padding: 10px 0;
}

.side-menu .menu-group {
  padding: 14px 20px 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.side-menu .menu-separator {
  margin: 8px 20px;
  border-top: 1px solid var(--border);
}

.side-menu a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
  color: var(--text);
  border-left: 3px solid transparent;
}

.side-menu a:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.side-menu a.active {
  border-left-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}

.side-menu .icon {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.menu-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  z-index: 30;
  background: rgba(16, 32, 56, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.menu-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- page ---------- */

.main {
  padding: calc(var(--topbar-height) + 18px) 24px 32px;
  min-width: 0;
}

.page-loading {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

.page-header {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.page-title {
  flex: 1;
  min-width: 0;
}

.page-title h1 {
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.page-title .page-key {
  color: var(--primary-dark);
}

.page-subtitle {
  margin-top: 2px;
  color: var(--muted);
}

.breadcrumbs {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 22px 0 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  flex: 1;
  font-size: 15px;
}

.card-head .card-actions {
  display: flex;
  gap: 8px;
}

.card-body {
  padding: 14px 16px 16px;
}

.card-body.flush {
  padding: 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.cards > .card + .card {
  margin-top: 0;
}

.cards .card.wide {
  grid-column: 1 / -1;
}

.notice-card {
  padding: 18px 20px;
}

.notice-card p {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.btn:hover {
  background: var(--surface-alt);
  border-color: var(--primary);
  text-decoration: none;
}

.btn:focus-visible,
.topbar-button:focus-visible,
.user-button:focus-visible,
.icon-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-danger {
  color: var(--danger);
  border-color: #e3a5a5;
}

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

.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger-solid:hover {
  background: #a31f1f;
  border-color: #a31f1f;
}

.btn-block {
  width: 100%;
  height: 38px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.icon-button.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
}

/* ---------- alerts and badges ---------- */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.alert .icon {
  margin-top: 1px;
}

.alert-error {
  background: var(--danger-soft);
  border-color: #efb4b4;
  color: #8e1c1c;
}

.alert-info {
  background: var(--primary-soft);
  border-color: #b8d3f2;
  color: #0d3f7a;
}

.alert-success {
  background: var(--success-soft);
  border-color: #b5dbb7;
  color: #1d5a20;
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: 600;
}

.alert-meta {
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.8;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-open {
  background: var(--success-soft);
  color: var(--success);
  border-color: #b5dbb7;
}

.badge-hold {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #f0d29b;
}

.badge-void {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #efb4b4;
}

.badge-yes {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: #b8d3f2;
}

/* ---------- tiles (home) ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 148px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  border-top: 4px solid var(--primary);
  transition:
    box-shadow 0.12s ease,
    transform 0.12s ease;
}

.tile:hover {
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(16, 32, 56, 0.14);
  transform: translateY(-1px);
}

.tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}

.tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.tile-count {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--primary-dark);
}

.tile-caption {
  color: var(--muted);
  font-size: 13px;
}

.tile.tile-system {
  border-top-color: #546e7a;
}

.tile.tile-system .tile-icon {
  background: #eceff1;
  color: #455a64;
}

.tile.tile-alert .tile-count {
  color: var(--warning);
}

/* ---------- toolbar and data grid ---------- */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
}

.toolbar-title {
  font-weight: 600;
  font-size: 15px;
  margin-right: 8px;
}

.toolbar-spacer {
  flex: 1;
}

.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-box .icon {
  position: absolute;
  left: 9px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 280px;
  padding-left: 32px;
}

.toolbar-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-filter select,
.toolbar-filter input[type='date'] {
  height: 32px;
}

.toolbar-filter.checkbox {
  color: var(--text);
  gap: 6px;
  cursor: pointer;
}

.grid-wrap {
  position: relative;
  overflow-x: auto;
}

.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.grid th,
.grid td {
  padding: 0 10px;
  height: 33px;
  border-bottom: 1px solid #e7ebf0;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: none;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.grid th.sortable {
  cursor: pointer;
}

.grid th.sortable:hover {
  color: var(--text);
  background: #eef2f6;
}

.grid th .sort-icon {
  margin-left: 4px;
  color: var(--primary);
}

.grid th[aria-sort='none'] .sort-icon {
  visibility: hidden;
}

.grid td.num,
.grid th.num {
  text-align: right;
}

.grid td.center,
.grid th.center {
  text-align: center;
}

.grid tbody tr:hover td {
  background: #f5f9fe;
}

.grid tbody tr.clickable {
  cursor: pointer;
}

.grid tbody tr.editing td {
  background: #fffbea;
}

.grid tbody tr.row-error td {
  height: auto;
  padding: 6px 10px;
  white-space: pre-line;
  background: var(--danger-soft);
  color: #8e1c1c;
  border-bottom-color: #efb4b4;
}

.grid td.actions {
  width: 1%;
  text-align: right;
  padding-right: 6px;
}

.grid td.actions .icon-button + .icon-button {
  margin-left: 2px;
}

.grid td input,
.grid td select {
  height: 26px;
  width: 100%;
  min-width: 70px;
  padding: 0 6px;
  font-size: 13px;
}

.grid td input[type='checkbox'] {
  width: auto;
  min-width: 0;
  height: auto;
}

.grid-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}

.grid-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 48px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
}

.grid-error {
  margin: 10px 12px 0;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.pager-info {
  margin-right: 12px;
}

.pager-page {
  margin: 0 6px;
}

.grid-card .grid tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- tabs (Inventory) ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.tab {
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

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

.tab[aria-selected='true'] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:focus-visible {
  outline: 2px solid var(--primary-ring);
  outline-offset: -2px;
}

.qty-short {
  color: var(--danger);
  font-weight: 600;
}

/* By site: each site's pair of columns starts with a line; the headers wrap after the site ID. */
.grid th.site-start,
.grid td.site-start {
  border-left: 1px solid var(--border);
}

.by-site .grid th {
  height: auto;
  padding-top: 4px;
  padding-bottom: 4px;
  line-height: 1.3;
  white-space: normal;
  vertical-align: bottom;
}

.by-site .grid td.by-site-description {
  max-width: 260px;
}

/* ---------- Auto-refresh switch ---------- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  flex: none;
  width: 34px;
  height: 18px;
  border-radius: 9px;
  background: var(--border-strong);
  transition: background 0.15s;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 30%);
  transition: transform 0.15s;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--primary-ring);
  outline-offset: 2px;
}

.switch-note {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

/* ---------- forms and field cards ---------- */

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  height: 32px;
  padding: 0 9px;
}

textarea {
  height: auto;
  min-height: 64px;
  padding: 6px 9px;
  resize: vertical;
}

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--primary);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
}

/* A checkbox keeps its own size next to its label (the rule above would stretch it). */
.field.checkbox-field input[type='checkbox'] {
  width: 16px;
  flex: none;
}

.field.checkbox-field .checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
}

.field-value {
  min-height: 32px;
  display: flex;
  align-items: center;
  padding: 0 9px;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.field-value.empty {
  color: var(--muted);
}

.field-help {
  font-size: 12px;
  color: var(--muted);
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.15);
}

.field.invalid .field-label {
  color: var(--danger);
}

.field.changed .field-label::after {
  content: ' •';
  color: var(--primary);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
}

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

.field-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.form-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.form-cards.single {
  grid-template-columns: minmax(0, 1fr);
}

.form-cards > .card + .card {
  margin-top: 0;
}

.form-cards .card.wide {
  grid-column: 1 / -1;
}

.form-error:empty {
  display: none;
}

/* ---------- New panel ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(16, 32, 56, 0.35);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.overlay.open {
  opacity: 1;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 51;
  width: 560px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.panel.open {
  transform: none;
}

.panel.wide {
  width: 760px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 12px 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.panel-head h2 {
  flex: 1;
  font-size: 17px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

.panel-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ---------- configurable products (MINERP-21): line panel, configuration cells and cards ---------- */

/* A grid cell's text that opens something (the sales order line panel), drawn as a link. */
.link-button {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.link-button.empty {
  color: var(--muted);
}

/* The lines grid's Configuration cells wrap, so that a long configuration does not widen the grid. */
.grid td.config-cell {
  white-space: normal;
  min-width: 110px;
}

.grid td.config-cell .link-button {
  padding: 4px 0;
  line-height: 1.35;
}

.config-details {
  margin-top: 12px;
}

.link-button:focus-visible {
  outline: 2px solid var(--primary-ring);
  outline-offset: 2px;
}

.card-count {
  color: var(--muted);
  font-size: 13px;
}

.config-note {
  margin: 0 0 12px;
  color: var(--muted);
}

.config-attributes {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.config-attributes th,
.config-attributes td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.config-attributes th {
  color: var(--muted);
  font-weight: 600;
}

/* ---------- confirmation dialog ---------- */

.dialog {
  width: 440px;
  max-width: calc(100vw - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}

.dialog::backdrop {
  background: rgba(16, 32, 56, 0.4);
}

.dialog-body {
  display: flex;
  gap: 14px;
  padding: 20px 20px 8px;
}

.dialog-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.dialog.danger .dialog-icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.dialog h2 {
  font-size: 16px;
  margin-bottom: 6px;
}

.dialog p {
  margin: 0;
  color: var(--muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px 18px;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 460px;
  padding: 10px 10px 10px 14px;
  border-radius: var(--radius);
  background: #263445;
  color: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast-text {
  flex: 1;
  white-space: pre-line;
}

.toast.success .toast-icon {
  color: #81c784;
}

.toast.error {
  background: #8e1c1c;
}

.toast.error .toast-icon {
  color: #ffcdd2;
}

.toast .icon-button {
  color: rgba(255, 255, 255, 0.8);
}

.toast .icon-button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ---------- sign in ---------- */

.login-body {
  min-height: 100vh;
  background: linear-gradient(160deg, rgba(11, 58, 110, 0.96), rgba(21, 101, 192, 0.9)), var(--topbar);
}

.login-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 380px;
  max-width: 100%;
  padding: 28px 30px 30px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand h1 {
  font-size: 20px;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-card h2 {
  font-size: 17px;
  margin-bottom: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form input {
  height: 38px;
}

.login-foot {
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

/* ---------- System page ---------- */

.copy-line {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.copy-line .mono {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.data-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.grid tfoot td {
  font-weight: 600;
  background: var(--surface-alt);
  border-bottom: 0;
}

.data-note {
  margin: 0;
}

.data-error .alert {
  margin-bottom: 10px;
}

/* ---------- Sales order page ---------- */

.order-total {
  display: flex;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
}

.order-total strong {
  font-size: 18px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.order-total-lines::before {
  content: '·';
  margin-right: 8px;
}

/* ---------- Customer screens ---------- */

/* A field's link to the page of its value (the sales order's customer ID opens the customer). */
.field-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  font-size: 12px;
}

.field-link[hidden] {
  display: none;
}

.customer-sections {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

/* ---------- data import (/import) ---------- */

.import-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.import-target-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.import-target-info:empty {
  display: none;
}

.import-columns .mono {
  overflow-wrap: anywhere;
}

.import-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.import-status {
  margin-top: 12px;
  color: var(--muted);
}

.import-error:not(:empty) {
  margin-top: 12px;
}

.import-help {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.import-result > * + * {
  margin-top: 16px;
}

.import-result:not(:empty) {
  margin-top: 16px;
}

.import-summary {
  margin: 0 0 12px;
}

.import-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.import-stat {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 4px;
  background: var(--surface);
}

.import-stat-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--primary-dark);
}

.import-stat-label {
  color: var(--muted);
  font-size: 12px;
}

.import-stat.import-stat-added {
  border-top-color: #2e7d32;
}

.import-stat.import-stat-failed {
  border-top-color: var(--danger);
}

.import-stat.import-stat-failed .import-stat-value {
  color: var(--danger);
}

.import-stats + .alert {
  margin-top: 12px;
}

.import-preview-wrap .grid-wrap {
  overflow-x: auto;
}

@media (max-width: 900px) {
  .import-fields {
    grid-template-columns: minmax(0, 1fr);
  }

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

/* ---------- attachments, proofs and variable data (MINERP-20) ---------- */

.attach-upload {
  margin-bottom: 12px;
}

.attach-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.attach-upload-row select {
  width: auto;
  min-width: 150px;
}

.attach-upload-row input[type='text'] {
  flex: 1 1 180px;
  width: auto;
}

.attach-upload-row input[type='file'] {
  flex: 1 1 220px;
  width: auto;
  padding: 4px;
  font-size: 13px;
}

.attach-hint {
  margin: 6px 0 0;
  font-size: 12px;
}

.attach-errors:empty {
  display: none;
}

.attach-errors .alert {
  margin-bottom: 10px;
  white-space: pre-line;
}

.attach-empty {
  margin: 4px 0;
}

.attach-table td.actions,
.attach-table th.actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.attach-table td.actions .icon-button {
  display: inline-flex;
  vertical-align: middle;
}

.attach-latest {
  margin-left: 8px;
}

.attachments-card .card-body > .attach-list {
  margin: 0 -16px -16px;
  border-top: 1px solid var(--border);
}

.attachments-card .attach-list > .attach-empty,
.attachments-card .attach-list > .alert,
.attachments-card .attach-list > .muted {
  margin: 12px 16px;
}

.attach-group {
  margin-top: 14px;
}

.attach-group .grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.attach-group-title {
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px;
}

.proof-card {
  margin-bottom: 4px;
}

.proof-card .card-actions {
  display: flex;
  gap: 8px;
}

.dialog-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  font-size: 13px;
  cursor: pointer;
}

.dialog-check input[type='checkbox'] {
  margin-top: 2px;
  flex: none;
}

.variable-data td {
  white-space: normal;
}

/* ---------- Line panel: Releases tab (MINERP-19) ---------- */

.release-add {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.release-add h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.release-add .card {
  border: 0;
  box-shadow: none;
  background: none;
}

.release-add .card-body {
  padding: 0;
}

.release-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.releases-grid td input:not([type='checkbox']) {
  width: 100%;
  min-width: 0;
}

/* Five tabs: on a narrow window they scroll rather than wrap. */
.line-panel .tabs {
  overflow-x: auto;
}

.line-panel .tab {
  white-space: nowrap;
}

/* ---------- Jobs, Job screen and traveler (MINERP-22) ---------- */

/* A production status badge, with a Closed badge after it. */
.job-status {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  vertical-align: middle;
}

/* The Job screen's production status and actions, between the header and the cards. */
.job-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.job-actions-label {
  color: var(--muted);
  font-size: 13px;
}

.job-actions-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--border);
}

.job-tabs {
  margin-top: 20px;
}

/* An operation's one-click Complete / Reopen, in its row. */
.grid td.actions .btn-row {
  height: 26px;
  padding: 0 10px;
  margin-right: 4px;
  font-size: 12px;
  vertical-align: middle;
}

.grid td.actions .btn-row .icon {
  width: 14px;
  height: 14px;
}

/* The operations grid: headers wrap ("Hours per piece" on two lines), the description wraps, numbers stay
   narrow, so that the Complete column and the row buttons show at 1280 px. */
.job-opers .grid th {
  height: auto;
  padding-top: 4px;
  padding-bottom: 4px;
  line-height: 1.3;
  white-space: normal;
  vertical-align: bottom;
}

.job-opers .grid td.job-opers-desc {
  white-space: normal;
  min-width: 140px;
  max-width: 260px;
  line-height: 1.3;
}

.job-opers .grid td {
  padding: 0 8px;
}

.job-opers .grid td.actions {
  white-space: nowrap;
}

.job-lines {
  margin-top: 16px;
}

.job-lines > .config-note {
  margin: 4px 0;
}

.job-line-card .card-actions {
  align-items: center;
}

.job-line-card .attach-group-title:first-child {
  margin-top: 0;
}

.job-line-card .grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.job-line-card .config-note:last-child {
  margin-bottom: 0;
}

.job-proof-history {
  margin: 8px 0 0;
  font-size: 12px;
}

/* ---- Job traveler ---- */

.traveler .card + .card {
  margin-top: 16px;
}

.traveler-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 16px;
  margin: 0;
}

.traveler-fact {
  min-width: 0;
}

.traveler-fact.wide {
  grid-column: span 2;
}

.traveler-fact dt,
.traveler-label {
  font-size: 12px;
  color: var(--muted);
}

.traveler-fact dd {
  margin: 1px 0 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.traveler-notes {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.traveler-notes p {
  margin: 2px 0 0;
  white-space: pre-line;
}

.traveler-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.traveler-table th,
.traveler-table td {
  padding: 7px 8px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.traveler-table th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.traveler-table td.num {
  text-align: right;
}

.traveler-table td.traveler-done {
  text-align: center;
  color: var(--success);
}

.traveler-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
}

.traveler-table .traveler-signoff {
  width: 190px;
}

.traveler-subtitle {
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.traveler-files {
  margin: 0;
  padding-left: 18px;
}

.traveler-files li {
  margin: 2px 0;
}

.traveler-file {
  font-weight: 600;
}

.traveler-files .badge {
  margin-left: 8px;
}

.traveler-records {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.traveler-record {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.traveler-record h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

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

/* Narrow windows: the header's buttons go under the title; facts and records in fewer columns. */
@media (max-width: 700px) {
  main[data-page='job'] .page-header,
  main[data-page='job-traveler'] .page-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  main[data-page='job'] .page-title,
  main[data-page='job-traveler'] .page-title {
    flex-basis: 100%;
  }

  main[data-page='job'] .form-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  main[data-page='job'] .field-grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  main[data-page='job'] .tabs {
    overflow-x: auto;
  }

  main[data-page='job'] .tab {
    white-space: nowrap;
  }

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

  .traveler .card-body {
    overflow-x: auto;
  }
}

/* Printing the traveler: only its content, without the top bar, the menu and the buttons; a section's head,
   an operation row and a variable data record are not split across pages. */
@media print {
  body:has(main[data-page='job-traveler']) {
    background: #fff;
    font-size: 12px;
  }

  body:has(main[data-page='job-traveler']) :is(.topbar, .side-menu, .menu-backdrop, .toasts, .btn) {
    display: none !important;
  }

  main[data-page='job-traveler'] {
    padding: 0;
  }

  main[data-page='job-traveler'] .page-header {
    margin-bottom: 10px;
  }

  main[data-page='job-traveler'] .breadcrumbs,
  main[data-page='job-traveler'] .page-actions {
    display: none;
  }

  main[data-page='job-traveler'] .card {
    box-shadow: none;
    border-color: #999;
  }

  main[data-page='job-traveler'] .badge {
    print-color-adjust: exact;
  }

  .traveler-head,
  .traveler-record,
  .traveler-table tr,
  .traveler-files,
  .traveler-facts {
    break-inside: avoid;
  }

  .traveler .card-head,
  .traveler-subtitle {
    break-after: avoid;
  }

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

/* ---------- Job wizard, row selection, part operations (MINERP-22) ---------- */

/* A selectable grid's checkbox column (components/grid.js `selectable`), and its selected rows. */
.grid th.select,
.grid td.select {
  width: 1%;
  padding-right: 0;
  text-align: center;
}

.grid tbody tr.selected td {
  background: #e8f1fc;
}

.grid tbody tr.selected.editing td {
  background: #fffbea;
}

/* The Sales order lines' jobs and production statuses (one per job). */
.line-jobs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  vertical-align: middle;
}

/* Job wizard: the selection and the actions above the grid. */
.job-wizard-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.job-wizard-summary {
  font-weight: 600;
}

.job-wizard-batch {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.job-wizard-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.job-wizard-field input,
.job-wizard-field select {
  width: 180px;
}

.job-wizard-messages .alert {
  margin-bottom: 12px;
}

.job-wizard-created .card {
  margin-bottom: 12px;
}

.job-wizard-grid .grid td.job-wizard-config {
  max-width: 220px;
}

.job-wizard-grid .toolbar-filter select {
  max-width: 200px;
}

/* The Sales order lines grid, with its selection, Job and Production status columns, fits a 1280-wide window:
   the headers and the description wrap, and the cells are a little narrower. */
#sales-order-lines .grid th {
  height: auto;
  padding-top: 4px;
  padding-bottom: 4px;
  line-height: 1.3;
  white-space: normal;
  vertical-align: bottom;
}

#sales-order-lines .grid th,
#sales-order-lines .grid td {
  padding-left: 7px;
  padding-right: 7px;
}

#sales-order-lines .grid td[data-field='LineDesc'] {
  min-width: 150px;
  white-space: normal;
}

@media (max-width: 600px) {
  .job-wizard-bar .toolbar-spacer {
    display: none;
  }

  .job-wizard-summary {
    flex-basis: 100%;
  }
}

/* Shipment (MINERP-23): the note above its lines, in the flush Lines card. */
.shipment-lines-note {
  margin: 0;
  padding: 10px 14px 4px;
  color: var(--muted);
  font-size: 13px;
}

/* Narrow windows: the Shipment page's header buttons go under the title, its cards in one column (as the Job
   page's), and its lines scroll sideways. */
@media (max-width: 700px) {
  main[data-page='shipment'] .page-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  main[data-page='shipment'] .page-title {
    flex-basis: 100%;
  }

  main[data-page='shipment'] .form-cards {
    grid-template-columns: minmax(0, 1fr);
  }

  main[data-page='shipment'] #shipment-lines .grid-wrap {
    overflow-x: auto;
  }
}

/* ---------- BPM directives (MINERP-24) ---------- */

.directive-editor .checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 4px 0;
}

.directive-editor .changed-fields input[type='search'] {
  max-width: 260px;
  margin-bottom: 6px;
}

.directive-editor .changed-fields-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding: 2px;
}

.directive-editor .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  font-size: 12px;
  cursor: pointer;
}

.directive-editor .chip.checked,
.directive-editor .chip:has(input:checked) {
  border-color: #b8d3f2;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.directive-editor textarea.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.directive-editor .condition-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.directive-editor .condition-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
}

.directive-editor .condition-status:empty {
  display: none;
}

.directive-editor .condition-status.valid {
  color: var(--success);
}

.directive-editor .condition-status.invalid {
  color: var(--danger);
}

.directive-editor .action-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.directive-editor .action-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.directive-editor .action-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.directive-editor .action-head select {
  min-width: 180px;
}

.directive-editor .action-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.directive-editor .action-body .muted.wide {
  grid-column: 1 / -1;
  margin: 0;
}

main[data-page='bpm'] .switch-note,
main[data-page='bpm-directive'] .switch-note {
  min-width: 18px;
}

.grid td.nowrap {
  white-space: nowrap;
}

/* The BPM log grids: the record, actions and message wrap, so that the result stays in view. */
.bpm-log-grid .grid td[data-field='KeysText'],
.bpm-log-grid .grid td[data-field='ActionsText'],
.bpm-log-grid .grid td[data-field='Details'] {
  white-space: normal;
  height: auto;
  padding-top: 6px;
  padding-bottom: 6px;
  line-height: 1.35;
}

.bpm-log-grid .grid td[data-field='KeysText'] {
  min-width: 130px;
  max-width: 200px;
}

.bpm-log-grid .grid td[data-field='ActionsText'] {
  min-width: 160px;
  max-width: 300px;
}

.bpm-log-grid .grid td[data-field='Details'] {
  min-width: 160px;
  max-width: 320px;
}

.bpm-log-grid select[data-filter='directive'] {
  max-width: 220px;
}

.directive-editor .checkbox-row .checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Narrow windows: the BPM directive page's buttons go under its title, its fields in one column. */
@media (max-width: 700px) {
  main[data-page='bpm-directive'] .page-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  main[data-page='bpm-directive'] .page-title {
    flex-basis: 100%;
  }

  .directive-editor .field-grid.cols-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- BAQs (MINERP-25) ---------- */

.baq-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.badge-shipped {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.baq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.baq-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.baq-item select,
.baq-item input[type='text'] {
  width: auto;
  min-width: 180px;
}

.baq-number {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.baq-on {
  flex: 1;
  min-width: 0;
  font-size: 12px;
}

.baq-column-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.baq-item-actions {
  display: inline-flex;
  gap: 2px;
}

.baq-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.baq-picker select {
  max-width: 420px;
}

.baq-designer .checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.baq-designer textarea.mono,
.baq-designer input.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.baq-describe {
  margin-bottom: 8px;
}

.baq-describe td {
  white-space: normal;
  height: auto;
  padding-top: 5px;
  padding-bottom: 5px;
}

.baq-subhead {
  margin: 14px 0 6px;
  font-size: 14px;
}

.baq-shipped-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.baq-status-line {
  margin: 10px 0 8px;
  font-weight: 600;
}

.baq-status:empty::before {
  content: 'Enter the parameter values and press Test.';
  color: var(--muted);
  font-weight: 400;
}

.baq-results .grid-wrap {
  max-width: 100%;
  overflow-x: auto;
}

pre.copy-value {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.copy-buffer {
  position: fixed;
  top: -1000px;
  left: -1000px;
  opacity: 0;
}

/* ---------- Demo guide (/demo, MINERP-27) ---------- */

.demo-intro,
.demo-scenario,
.demo-mapping-table {
  padding: 14px 16px 16px;
}

.demo-scenario + .demo-scenario {
  margin-top: 12px;
}

.demo-intro p {
  margin: 0 0 10px;
}

.demo-api {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  align-items: baseline;
}

.demo-api code,
.demo-scenario code,
.demo-table code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  overflow-wrap: anywhere;
}

.demo-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 14px 0 4px;
  font-weight: 600;
}

.demo-section h2 {
  margin: 22px 0 10px;
  font-size: 18px;
}

.demo-scenario-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.demo-scenario-head h3 {
  margin: 0;
  font-size: 15px;
  flex: 1;
  min-width: 300px;
}

.demo-scenario-id {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

.demo-scenario-body > * {
  margin: 10px 0 0;
}

.demo-records {
  color: var(--muted);
}

.demo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.demo-links .field-label,
.demo-calls > .field-label {
  margin-right: 6px;
}

.demo-calls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.demo-call .copy-line {
  align-items: flex-start;
}

.demo-method {
  min-width: 52px;
  justify-content: center;
  margin-top: 6px;
  font-family: var(--mono);
}

.demo-method-get {
  background: var(--success-soft);
  color: var(--success);
}

.demo-method-post,
.demo-method-patch {
  background: var(--warning-soft);
  color: var(--warning);
}

pre.demo-body {
  margin: 6px 0 0 60px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
  max-height: 260px;
  overflow: auto;
}

.demo-note {
  margin: 4px 0 0 60px;
  color: var(--muted);
  font-size: 13px;
}

.demo-mapping-table {
  margin-top: 14px;
}

.demo-mapping-table h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.demo-table {
  width: 100%;
  border-collapse: collapse;
}

.demo-table th,
.demo-table td {
  text-align: left;
  vertical-align: top;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  max-width: none;
}

.demo-table code {
  white-space: normal;
}

.demo-table td:first-child {
  width: 24%;
  font-weight: 600;
}
