/* Reliability Model — dark utility-dashboard theme.
   The criticality gradient is the only saturated color. */
:root {
  --bg: #0e1420; --bg2: #121a28; --card: #17202f; --card2: #1c2637;
  --border: #263248; --ink: #e4eaf1; --muted: #8fa0b4; --head: #f2f6fa;
  --accent: #5f9dd1; --accent-ink: #0b1826;
  --ok: #4cc38a; --warn: #d9b44a; --bad: #e5645a;
  --chip-ink: #10161c;
  --mono: Consolas, "Cascadia Mono", monospace;
}
* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
}
h1 { font-size: 22px; margin: 0 0 8px; color: var(--head); font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--head); font-weight: 650; }
.muted { color: var(--muted); }
button { font: inherit; }

/* ------------------------------------------------------------- chrome */
.chrome {
  display: flex; align-items: center; gap: 18px 28px; flex-wrap: wrap;
  padding: 12px 22px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.bolt { font-size: 22px; }
.app-name { font-weight: 700; color: var(--head); }
.app-sub { font-size: 11.5px; color: var(--muted); }
.version { margin-left: auto; color: var(--muted); font-size: 12px; }

.stepper { display: flex; gap: 6px; }
.step {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--muted); padding: 7px 14px; cursor: default;
}
.step .dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card2); border: 1px solid var(--border); font-size: 12px;
}
.step.active { color: var(--head); border-color: var(--border); background: var(--card); }
.step.active .dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.step.done { color: var(--ink); cursor: pointer; }
.step.done .dot { background: #274a68; color: var(--head); }

/* ------------------------------------------------------------- layout */
main { max-width: 1220px; margin: 0 auto; padding: 22px; }
.screen { display: none; }
.screen.visible { display: block; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
}
.screen-footer {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px;
}
.btn {
  background: var(--card2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 18px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.big { padding: 12px 28px; font-size: 15px; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.icon-btn {
  background: none; border: none; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 2px 8px;
}
.icon-btn:hover { color: var(--bad); }

/* ------------------------------------------------------------- upload */
.hero { padding: 26px 28px; }
.hero p { max-width: 70ch; }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.file-card { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.file-main { display: flex; align-items: center; gap: 12px; flex: 1; flex-wrap: wrap; }
.file-name { font-weight: 600; color: var(--head); }
.file-meta { color: var(--muted); font-size: 12.5px; }
.badge {
  font-size: 11.5px; font-weight: 650; border-radius: 999px;
  padding: 2px 10px; background: #223a53; color: #9ec7e8;
}
.badge.unrecognized { background: #4a2f16; color: var(--warn); }
.badge.errored { background: #4a1f1c; color: var(--bad); }
.badge.manual { background: #253a2c; color: var(--ok); }
.file-error { width: 100%; color: var(--bad); font-size: 12.5px; }

/* ------------------------------------------------------------- map */
.map-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; }
.target-list h2 { margin-bottom: 12px; }
.target-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 1px solid transparent; border-radius: 8px;
  color: var(--ink); padding: 8px 10px; cursor: pointer; text-align: left;
}
.target-row:hover, .target-row.selected { background: var(--card2); border-color: var(--border); }
.target-status { width: 18px; text-align: center; }
.target-status.ok { color: var(--ok); }
.target-status.warn { color: var(--warn); }
.target-label { flex: 1; }
.target-file { font-size: 12px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row {
  display: grid; grid-template-columns: 260px 1fr; gap: 10px;
  align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.map-row:last-child { border-bottom: none; }
.canon-name { font-family: var(--mono); font-size: 12.5px; }
.canon-name.required::after { content: " *"; color: var(--warn); }
select.src-select {
  background: var(--card2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; width: 100%;
}

/* ------------------------------------------------------------- review */
.summary-strip { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; }
.stat .n { font-size: 22px; font-weight: 700; color: var(--head); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
#files-review { margin-top: 16px; }
.review-file { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.review-file:last-child { border-bottom: none; }
.tablewrap { overflow-x: auto; }
#manual-card { margin-top: 4px; }
#manual-table { border-collapse: collapse; width: 100%; font-size: 13px; }
#manual-table th, #manual-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); text-align: left; }
#manual-table input {
  background: var(--card2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; width: 110px;
}
#manual-table input.invalid { border-color: var(--bad); }

/* ------------------------------------------------------------- report */
.report-head { display: flex; align-items: flex-end; gap: 22px; margin-bottom: 14px; flex-wrap: wrap; }
.report-head .btn-row { margin-left: auto; margin-top: 0; }
.report-meta { display: flex; align-items: center; gap: 20px; margin-top: 6px; flex-wrap: wrap; }
.legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.legend-bar {
  width: 140px; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, #1a9850, #fee08b, #d73027);
}
.stale-banner {
  background: #4a3a16; color: var(--warn); border: 1px solid #6b5320;
  border-radius: 8px; padding: 9px 16px; margin-bottom: 12px; font-size: 13px;
}
.report-table { border-collapse: collapse; width: 100%; }
.report-table th {
  text-align: left; color: var(--muted); font-size: 12px; letter-spacing: .04em;
  text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--border);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.report-table th:hover { color: var(--head); }
.report-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.report-table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.data-row { cursor: pointer; }
.data-row:hover { background: var(--card2); }
.c-line { font-weight: 650; color: var(--head); font-family: var(--mono); font-size: 13px; }
.c-caret { color: var(--muted); }
.chip {
  display: inline-block; min-width: 46px; text-align: center;
  border-radius: 7px; padding: 2px 10px; font-weight: 700;
  color: var(--chip-ink); font-variant-numeric: tabular-nums;
}
.chip.mini { min-width: 28px; padding: 1px 7px; font-weight: 650; font-size: 12px; }
.detail-row td { background: var(--bg2); padding: 14px 18px; }
.detail-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.detail-group h3 {
  margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
.detail-field { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 13px; }
.detail-field .fname { color: var(--muted); }
.detail-field .fval { font-variant-numeric: tabular-nums; text-align: right; }
.fbadge { font-size: 10px; color: var(--accent); margin-left: 4px; }

.issues-list { font-size: 13px; color: var(--muted); }
.issues-list div { padding: 2px 0; }

/* ------------------------------------------------------------- overlay/toast */
.overlay {
  position: fixed; inset: 0; background: rgba(8, 12, 20, .82);
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
.overlay[hidden] { display: none; }
.overlay-box { text-align: center; color: var(--head); }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 14px;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
.toasts {
  position: fixed;
  top: 84px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: var(--card2); border: 1px solid var(--border); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; max-width: 420px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
}
.toast.error { border-color: var(--bad); }
.toast.success { border-color: var(--ok); }

#issues-card {
    margin-bottom: 14px;
}

.modal {
  position: fixed; inset: 0; z-index: 35; background: rgba(8,12,20,.72);
  display: flex; align-items: center; justify-content: center; padding: 28px;
}
.modal[hidden] { display: none; }
.modal-card { width: min(760px, 100%); max-height: 84vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.modal-head h2 { margin: 0 0 7px; }
.modal-head p { margin: 0; max-width: 650px; line-height: 1.5; }

.weight-modal-card { width: min(860px, 100%); padding: 26px 28px; }
.weight-editor {
  margin-top: 24px; padding: 20px; background: var(--card2);
  border: 1px solid var(--border); border-radius: 12px;
}
.weight-editor label { display: grid; gap: 10px; color: var(--muted); font-size: 12px; }
.weight-editor label > span { font-weight: 600; }
.weight-editor select, .weight-editor input {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
}

#weight-field {
  -webkit-appearance: none;
  appearance: none;

  padding: 9px 42px 9px 18px;

  background-color: var(--card);

  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);

  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;

  background-size:
    5px 5px,
    5px 5px;

  background-repeat: no-repeat;
}
.weight-field-label { width: 100%; }
.weight-operation-row {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(160px, .7fr);
  gap: 16px; margin-top: 16px;
}
.weight-add-row {
  display: flex; align-items: center; gap: 14px; margin-top: 18px;
}
.weight-add-row .btn { min-width: 126px; min-height: 40px; }
.weight-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
}
.weight-actions .btn { min-width: 150px; min-height: 42px; }
.weight-help { line-height: 1.4; }
.weight-list-section { margin-top: 22px; }
.weight-list-section h3 { margin: 0 0 10px; color: var(--head); font-size: 13px; font-weight: 650; }
.active-weights { display: grid; gap: 9px; }
.active-weights > .muted { padding: 10px 0 2px; }
.weight-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 12px 14px; background: var(--card2);
  border: 1px solid var(--border); border-radius: 9px;
}
.weight-row-main { min-width: 0; }
.weight-row .muted { margin-left: 10px; }

.weight-slider-wrap {
  margin-top: 2px;
}

.weight-slider {
  width: 100%;
  height: 18px;
  min-height: 18px !important;
  padding: 0 !important;
  margin: 0;
  border: 0 !important;
  background: transparent !important;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

/* Track */
.weight-slider::-webkit-slider-runnable-track {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
}

/* Thumb */
.weight-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  cursor: grab;
}

.weight-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
}

.weight-slider-scale {
  display: flex;
  justify-content: space-between;
  margin-top: -1px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

@media (max-width: 760px) {
  .modal { padding: 14px; align-items: flex-start; }
  .weight-modal-card { padding: 20px; }
  .weight-operation-row { grid-template-columns: 1fr; }
  .weight-add-row, .weight-actions { align-items: stretch; flex-direction: column; }
  .weight-add-row .btn, .weight-actions .btn { width: 100%; }
}
