/* ============================================================================
 *  BearingDesigner — UI styles (light theme)
 * ==========================================================================*/
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #66708a;
  --line: #dce1ea;
  --accent: #1f6feb;
  --accent-soft: #e7f0ff;
  --steel: #9aa3ad;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 6px 18px rgba(20, 30, 50, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px;
}
button, input, select { font-family: inherit; font-size: 13px; }

/* ---- top utility bar ---- */
.topbar {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 18px;
  background: #11223d; color: #cdd7e6; font-size: 12px;
}
.topbar .tb-home { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .2px; }
.topbar .tb-spacer { flex: 1; }
.topbar .tb-link {
  color: #cdd7e6; text-decoration: none; padding: 3px 9px; border-radius: 6px; border: 1px solid #2c3f5e;
}
.topbar .tb-link:hover { background: #1f6feb; color: #fff; border-color: #1f6feb; }

/* ---- header ---- */
header {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
header .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #1f6feb, #13b0c6);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
header h1 { font-size: 17px; margin: 0; }
header .tag { color: var(--muted); font-size: 12px; }
header .spacer { flex: 1; }
header label { color: var(--muted); font-size: 12px; }
header select {
  padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 270px 1fr 320px; gap: 12px; padding: 12px; height: calc(100vh - 84px); }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-height: 0; display: flex; flex-direction: column; }
.col > .head { padding: 9px 12px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.col > .body { padding: 10px 12px; overflow: auto; flex: 1; }

/* ---- left: types ---- */
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cat-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 4px 9px; border-radius: 20px; cursor: pointer; font-size: 12px;
}
.cat-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#searchInput { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.type-list { display: flex; flex-direction: column; gap: 4px; }
.type-item {
  padding: 8px 10px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; line-height: 1.25;
}
.type-item:hover { background: var(--accent-soft); }
.type-item.active { background: var(--accent-soft); border-color: #bcd4fb; font-weight: 600; }
.type-item .sub { color: var(--muted); font-size: 11px; }

/* ---- middle: view ---- */
.view-wrap { display: flex; flex-direction: column; height: 100%; }
.tabs { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tabs .spacer { flex: 1; }
.ctrl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.ctrl input[type=range] { width: 90px; }
.stage { position: relative; flex: 1; min-height: 0; }
#canvas3d { width: 100%; height: 100%; display: block; background: radial-gradient(circle at 50% 40%, #fbfdff, #e9eef6); }
#svg2d { width: 100%; height: 100%; display: none; overflow: auto; background: #fff; }
#svg2d.show { display: block; }
.hint { position: absolute; left: 12px; bottom: 10px; color: var(--muted); font-size: 11px; background: rgba(255,255,255,.8); padding: 3px 7px; border-radius: 6px; }

/* ---- right: params + results + export ---- */
.field { margin-bottom: 9px; }
.field label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.field label .badge { font-size: 10px; background: #eef1f6; color: #8a93a6; padding: 1px 6px; border-radius: 10px; }
.field label .auto-btn { cursor: pointer; color: var(--accent); border: none; background: none; font-size: 12px; }
.field label .snap-btn { cursor: pointer; border: 1px solid var(--line); background: #f3f6fb; color: var(--accent);
  font-size: 10.5px; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.field label .snap-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.field input, .field select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink);
}
.field input:disabled { background: #f3f6fb; color: #55607a; }
.field.auto label { color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 10px; border-radius: 8px; cursor: pointer; text-align: center;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #1a5fcc; color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-style: dashed; font-size: 11px; padding: 5px 10px; }
.btn-ghost:hover { border-color: var(--muted); color: var(--ink); }

.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 6px; }
.group-subtitle { font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--accent); font-weight: 600; margin: 10px 0 3px; }

table.results { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.results td { padding: 5px 7px; border-bottom: 1px solid var(--line); }
table.results td.k { color: var(--muted); width: 60%; }
table.results td.v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
table.results td.sec { background: var(--accent-soft); color: var(--accent); font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; font-size: 11px; width: auto; }
.warn { color: #c0392b; }
table.results td.apply-cell { padding-top: 6px; }
table.results td.apply-cell .btn { width: 100%; }
table.results tr.reverse-row { cursor: pointer; }
table.results tr.reverse-row:hover { background: var(--accent-soft); }
table.results tr.reverse-current { background: var(--accent-soft); }
table.results tr.reverse-current td.k { color: var(--accent); font-weight: 700; }

.result-cards { display: flex; gap: 6px; margin: 8px 0 6px; }
.rcard { flex: 1 1 0; min-width: 0; background: var(--accent-soft); border: 1px solid var(--line);
         border-radius: 8px; padding: 7px 6px; text-align: center; }
.rcard .rt { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.rcard .rv { font-size: 15px; font-weight: 700; line-height: 1.15; margin-top: 2px;
             font-variant-numeric: tabular-nums; word-break: break-word; }
.rcard .rs { font-size: 10px; color: var(--muted); margin-top: 1px; }
.sec-rating { color: var(--accent); }
table.results td.v svg { display: block; width: 100%; max-width: 320px; height: auto; }

/* feasibility verdict colors */
.feas-ok { color: #1e8e3e; }
.feas-warn { color: #b06a00; }
.feas-fail { color: #c0392b; }
.feas-banner { font-weight: 700; text-align: center; letter-spacing: .5px;
  background: #eafaf0; border-radius: 5px; margin-bottom: 4px; }
.feas-banner.feas-conditional { background: #fdf3e3; }
.feas-banner.feas-fail { background: #fdecec; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .col { max-height: none; }
  .stage { height: 420px; }
}

/* ---- ⑬ catalogue table ---- */
.cat-table-wrap { overflow-x: auto; margin: 2px 0 4px; }
table.cat-table { border-collapse: collapse; width: 100%; font-size: 12px;
  font-variant-numeric: tabular-nums; }
table.cat-table th, table.cat-table td { padding: 3px 7px; text-align: right;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
table.cat-table th { color: var(--muted); font-weight: 600; text-transform: uppercase;
  font-size: 10px; letter-spacing: .03em; background: var(--bg); }
table.cat-table td:first-child, table.cat-table th:first-child { text-align: left; }
table.cat-table td.pn { font-weight: 700; color: var(--ink); }
table.cat-table td.pn.exact { color: var(--accent); }
table.cat-table tr.ok td:nth-child(7) { color: #1e8e3e; }
table.cat-table tr.bad td:nth-child(7) { color: #c0392b; }
table.cat-table tr.bad.spd td:nth-child(7) { color: #b06a00; }

/* ---- duty-cycle editor (multi-condition) ---- */
.duty-wrap { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 6px; }
.duty-wrap .subhead { font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.duty-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.duty-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end;
  padding: 4px; background: var(--bg); border-radius: 4px; }
.duty-row .dfield { display: flex; flex-direction: column; }
.duty-row .dfield label { font-size: 10px; color: var(--muted); }
.duty-row .dfield input { width: 62px; }
.btn-add { background: var(--accent); color: #fff; border: none; border-radius: 4px;
  padding: 3px 8px; cursor: pointer; font-size: 12px; margin-top: 2px; }
.btn-rm { background: #c0392b; color: #fff; border: none; border-radius: 4px;
  width: 22px; height: 22px; cursor: pointer; font-size: 13px; line-height: 1; }
