/* Instrument panel (js/ui/instrumentPanel.js), Instruments page and spec sheet
   (js/calculators/instruments.js), plus the Pro job-details block. Meant to be
   appended to www/css/styles.css once this moves out of prototype — the
   --success/--success-bg tokens would fold into styles.css's :root and dark-mode
   blocks alongside --warning. */

:root {
  --success: #2a7a3d;
  --success-bg: #e3f1e5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --success: #6fce85;
    --success-bg: #1c3322;
  }
}

.link-btn {
  background: none;
  border: none;
  padding: 6px 0;
  min-height: 32px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.link-btn:disabled {
  color: var(--muted);
  cursor: not-allowed;
  text-decoration: none;
}

/* ---- per-tool panel ---- */

.instrument-panel {
  max-width: 640px;
}

.ip-select-field {
  flex: 1 1 260px;
  max-width: 100%;
}

.ip-select {
  width: 100%;
  min-width: 0;
}

.ip-status {
  margin: 4px 0 10px;
}

.ip-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.ip-save,
.inst-create,
.ip-create {
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  height: fit-content;
}

.ip-save.ip-confirming {
  background: var(--warning);
  color: var(--accent-contrast);
}

.ip-load {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.ip-spec-pull,
.ip-spec-push {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}

.ip-spec-push.ip-confirming {
  background: var(--warning);
  color: var(--accent-contrast);
}

.ip-spec-pull:disabled,
.ip-spec-push:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ip-specs {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ip-specs[hidden] {
  display: none;
}

.ip-specs-title {
  margin: 0 0 6px;
  font-weight: 600;
}

.ip-spec-list {
  margin: 0 0 10px;
  padding-left: 18px;
  overflow-wrap: anywhere;
}

.ip-spec-list li[data-state="differs"] {
  color: var(--warning);
  font-weight: 600;
}

.inst-specs {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.inst-specs .field {
  max-width: none;
  flex: 1 1 140px;
}

.inst-spec-line {
  margin: 4px 0 0;
}

.ip-save:disabled,
.ip-load:disabled,
.inst-create:disabled,
.ip-create:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ip-new-row,
.inst-create-row {
  align-items: flex-end;
  margin-top: 6px;
}

.ip-new-field,
.inst-create-field {
  flex: 1 1 240px;
}

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

.instruments-page {
  max-width: 640px;
}

.inst-filter-row .field {
  max-width: 220px;
  margin-bottom: 10px;
}

.inst-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.inst-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
}

.inst-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}

.inst-name {
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.inst-count {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: auto;
}

/* Inline rename — same flex-shrink gotcha as the Bridge/Compensation cards. */
.inst-rename-input {
  min-width: 0;
  flex: 1 1 160px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.inst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
}

.inst-chip {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.inst-chip[data-has="1"] {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.inst-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.inst-actions button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 6px 12px;
  min-height: 32px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
}

.inst-actions .inst-open {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.inst-actions .inst-confirming {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
}

.inst-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.inst-status-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
}

.inst-status-pill[data-status="in-progress"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

.inst-status-pill[data-status="on-hold"] {
  background: var(--warning-bg);
  color: var(--warning);
}

.inst-status-pill[data-status="done"] {
  background: var(--success-bg);
  color: var(--success);
}

.inst-details-wrap {
  position: relative;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.inst-details .field {
  max-width: none;
}

.inst-notes-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
  box-sizing: border-box;
}

.inst-details-wrap.pro-lock-wrap .pro-lock-overlay {
  position: absolute;
  padding: 16px;
}

/* ---- spec sheet ---- */

.spec-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.spec-title {
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.spec-heading {
  font-size: 1.05rem;
  margin: 22px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.spec-table td:first-child {
  font-weight: 600;
}

.spec-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spec-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: var(--surface);
}

.spec-card-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.spec-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  margin: 0;
}

.spec-card-cell dt {
  color: var(--muted);
  font-size: 0.74rem;
}

.spec-card-cell dd {
  margin: 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.spec-missing .preset-buttons {
  margin-top: 8px;
}

/* The spec list is secondary text, like the other notes in the panel. */
.ip-spec-list {
  font-size: 0.9rem;
}

/* A number the tool refused (out of range or not a number); it reverts when you leave the field. */
input[aria-invalid="true"] {
  border-color: var(--warning);
  outline: 2px solid var(--warning);
  outline-offset: 0;
}
