/* Redmine Spare Parts Replaced v1.1 */
.sp-card {
  --sp-accent: #1f6fb2; --sp-accent-soft: #e9f2fb; --sp-border: #d9e2ec; --sp-muted: #6b7785;
  margin: 12px 0; padding: 12px 14px; background: #fff; border: 1px solid var(--sp-border);
  border-left: 4px solid var(--sp-accent); border-radius: 6px; box-shadow: 0 1px 2px rgba(16,42,67,.06);
}
.issue .sp-card.sp-show { background: rgba(255,255,255,.65); }
.sp-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sp-title { font-weight: 600; font-size: 1.05em; color: #243b53; }
.sp-badge { min-width: 20px; padding: 1px 7px; border-radius: 10px; background: var(--sp-accent); color: #fff; font-size: .8em; font-weight: 600; text-align: center; }

.sp-search { position: relative; max-width: 760px; margin-bottom: 10px; }
.sp-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .55; pointer-events: none; }
.sp-search .spare-parts-search-input {
  width: 100%; box-sizing: border-box; height: 34px; padding: 6px 34px 6px 32px;
  border: 1px solid var(--sp-border); border-radius: 6px; font-size: 13px; transition: border-color .15s, box-shadow .15s;
}
.sp-search .spare-parts-search-input:focus { outline: none; border-color: var(--sp-accent); box-shadow: 0 0 0 3px rgba(31,111,178,.15); }
.sp-spinner { position: absolute; right: 10px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
  border: 2px solid #c7d6e6; border-top-color: var(--sp-accent); border-radius: 50%; animation: sp-spin .7s linear infinite; }
@keyframes sp-spin { to { transform: rotate(360deg); } }

.spare-parts-results {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px 0; list-style: none;
  background: #fff; border: 1px solid var(--sp-border); border-radius: 6px; box-shadow: 0 8px 24px rgba(16,42,67,.18);
  max-height: 340px; overflow-y: auto;
}
.spare-parts-results li { display: flex; align-items: center; gap: 12px; padding: 7px 12px; cursor: pointer; }
.spare-parts-results li.active, .spare-parts-results li:hover { background: var(--sp-accent-soft); }
.spare-parts-results .sp-code { flex: 0 0 auto; min-width: 120px; font-family: Consolas, Menlo, monospace; font-weight: 600; color: #102a43; }
.spare-parts-results .sp-desc { flex: 1; color: #334e68; }
.spare-parts-results .sp-already { flex: 0 0 auto; font-size: .8em; color: #2f855a; background: #e6f6ec; padding: 1px 6px; border-radius: 8px; }
.spare-parts-results mark { background: #ffe58a; color: inherit; border-radius: 2px; padding: 0; }
.spare-parts-results .sp-msg { color: var(--sp-muted); cursor: default; }
.spare-parts-results .sp-msg:hover { background: none; }

.sp-table { width: 100%; max-width: 980px; border-collapse: separate; border-spacing: 0; border: 1px solid var(--sp-border); border-radius: 6px; overflow: hidden; }
.sp-table th { background: #f4f7fa; color: #486581; font-weight: 600; font-size: .85em; text-transform: uppercase; letter-spacing: .03em; padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--sp-border); }
.sp-table td { padding: 6px 10px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
.sp-table tbody tr:last-child td { border-bottom: 0; }
.sp-table tbody tr:hover td { background: #fafcfe; }
.sp-table .code { width: 170px; white-space: nowrap; }
.sp-table .qty { width: 120px; text-align: center; }
.sp-table .buttons { width: 36px; text-align: center; }
.sp-table tfoot td { background: #f4f7fa; border-top: 1px solid var(--sp-border); }
.sp-table tfoot .total-label { text-align: right; color: #486581; }
.sp-code-pill { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--sp-accent-soft); color: #174a7c;
  font-family: Consolas, Menlo, monospace; font-weight: 600; font-size: .92em; }

.sp-stepper { display: inline-flex; align-items: center; border: 1px solid var(--sp-border); border-radius: 6px; overflow: hidden; }
.sp-stepper .sp-step { width: 26px; height: 28px; border: 0; background: #f4f7fa; cursor: pointer; font-size: 15px; color: #334e68; padding: 0; }
.sp-stepper .sp-step:hover { background: var(--sp-accent-soft); color: var(--sp-accent); }
.sp-stepper .spare-part-qty { width: 48px; height: 28px; border: 0; text-align: center; -moz-appearance: textfield; padding: 0; }
.sp-stepper .spare-part-qty::-webkit-inner-spin-button, .sp-stepper .spare-part-qty::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.spare-part-remove { width: 26px; height: 26px; border: 0; border-radius: 50%; background: transparent; color: #c53030; font-size: 18px; line-height: 1; cursor: pointer; }
.spare-part-remove:hover { background: #fde8e8; }

.sp-empty { margin: 2px 0 0; color: var(--sp-muted); font-style: italic; }
tr.sp-flash td { animation: sp-flash 1.2s ease-out; }
@keyframes sp-flash { from { background: #fff4c2; } to { background: transparent; } }

/* Settings: selezione progetti */
.sp-project-picker { display: inline-block; width: 520px; max-width: 100%; }
.sp-project-filter { width: 100%; box-sizing: border-box; margin-bottom: 4px; }
.sp-project-actions { display: block; font-size: .9em; margin-bottom: 4px; }
.sp-project-list { display: block; max-height: 260px; overflow-y: auto; border: 1px solid #d9e2ec; border-radius: 4px; padding: 4px 8px; background: #fff; }
.tabular .sp-project-list label.sp-project-item { display: block; float: none; width: auto; margin: 0; text-align: left; font-weight: normal; line-height: 1.9; }
.tabular .sp-project-list label.sp-project-item[hidden] { display: none; }
.tabular .sp-project-list label.sp-project-item input { margin-right: 4px; }
.sp-module-off { font-size: .8em; color: #b7791f; margin-left: 6px; }

/* Tema scuro (Redmine 7 / temi con prefers-color-scheme) */
@media (prefers-color-scheme: dark) {
  html.theme-dark .sp-card, html[data-theme="dark"] .sp-card { background: #1f2933; border-color: #3e4c59; }
}

/* Componenti non a catalogo */
.sp-table tr.sp-custom td { background: #fffaf0; }
.sp-custom-badge { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 4px; background: #fbd38d; color: #7b341e;
  font-size: .75em; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; vertical-align: middle; }
.sp-table input.sp-custom-code { width: 110px; font-family: Consolas, Menlo, monospace; }
.sp-table input.sp-custom-desc { width: 100%; box-sizing: border-box; }
.sp-table input.sp-custom-code, .sp-table input.sp-custom-desc { border: 1px dashed #dd6b20; border-radius: 4px; padding: 3px 6px; background: #fff; }
.spare-parts-results li.sp-custom-option { border-top: 1px dashed #d9e2ec; color: #7b341e; }
.spare-parts-results li.sp-custom-option.active, .spare-parts-results li.sp-custom-option:hover { background: #fff4e5; }
.spare-parts-results .sp-flag { color: #dd6b20; font-size: 14px; min-width: 16px; }

/* Cataloghi multipli */
.sp-catalog-badge { padding: 1px 8px; border-radius: 10px; background: #e6fffa; color: #234e52; border: 1px solid #81e6d9; font-size: .8em; font-weight: 600; }
.sp-catalog-box legend .sp-catalog-key { color: #829ab1; font-weight: normal; }
.sp-catalog-new { border-style: dashed; }
.sp-catalog-actions .info { margin-left: 10px; }
.sp-remove-catalog { margin-left: 20px; color: #c53030; }

/* Schede database (impostazioni) */
.sp-db-card { margin: 14px 0; border: 1px solid #d9e2ec; border-left: 4px solid #1f6fb2; border-radius: 6px; background: #fff; box-shadow: 0 1px 2px rgba(16,42,67,.06); }
.sp-db-card.sp-db-new { border-left-color: #2f855a; border-style: dashed; border-left-style: solid; }
.sp-db-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #f4f7fa; border-bottom: 1px solid #d9e2ec; border-radius: 6px 6px 0 0; }
.sp-db-title { font-weight: 700; font-size: 1.1em; color: #243b53; }
.sp-db-key-label { font-family: Consolas, Menlo, monospace; font-size: .8em; color: #829ab1; background: #e4ecf4; padding: 1px 6px; border-radius: 4px; }
.sp-db-count { font-size: .8em; color: #2f855a; background: #e6f6ec; padding: 1px 8px; border-radius: 10px; }
.sp-db-spacer { flex: 1; }
.sp-remove-catalog { color: #c53030; font-size: .9em; }
.sp-remove-new { background: none; border: 0; color: #c53030; cursor: pointer; text-decoration: underline; }
.sp-db-body { padding: 4px 14px 8px; }
.sp-db-body h4 { margin: 16px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #eef2f6; color: #334e68; font-size: 1em; }
.sp-step-num { display: inline-block; width: 20px; height: 20px; line-height: 20px; margin-right: 6px; border-radius: 50%; background: #1f6fb2; color: #fff; text-align: center; font-size: .8em; }
.sp-db-foot { display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px; border-top: 1px solid #eef2f6; background: #fafcfe; border-radius: 0 0 6px 6px; }
.sp-test-result { flex: 1; line-height: 1.5; }
.sp-test-result small { display: block; margin-top: 4px; color: #627d98; font-family: Consolas, Menlo, monospace; }
.sp-test-ok { color: #276749; }
.sp-test-ko { color: #c53030; }
.sp-test-wait { color: #627d98; }
.sp-conn-fields[hidden] { display: none; }
.sp-add-wrap { margin: 6px 0 18px; }
.sp-add-catalog { padding: 7px 14px; border: 1px dashed #1f6fb2; border-radius: 6px; background: #e9f2fb; color: #174a7c; font-weight: 600; cursor: pointer; }
.sp-add-catalog:hover { background: #d6e8f8; }
