:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #d5dee8;
  --text: #172033;
  --muted: #64748b;
  --blue: #4386ee;
  --green: #34aa58;
  --yellow: #ffbf00;
  --gray-button: #6d7985;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Arial, sans-serif; font-size: 13px; letter-spacing: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-rows: 76px 64px minmax(0, 1fr) 34px; }

.topbar { background: #fff; border-bottom: 1px solid #e0e6ee; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; }
.brand-line { display: flex; align-items: center; gap: 10px; }
.brand-line h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; color: #172033; }
.brand-copy p { margin: 5px 0 0; font-size: 12px; color: #64748b; }
.version { padding: 7px 9px; border-radius: 6px; background: #eaf3fc; color: #2771b8; font-size: 12px; font-weight: 700; }
.account-area { text-align: right; color: #64748b; }
.account-area div { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.account-area button, .toolbar button { min-height: 38px; padding: 6px 16px; border: 1px solid #d5dee8; border-radius: 7px; background: #fff; color: #172033; }
.account-area button { min-height: 32px; padding: 4px 13px; }
.account-area button:hover, .toolbar button:hover { background: #f4f9ff; border-color: #8bb8e8; }
.account-area small { display: block; margin-top: 5px; font-size: 11px; color: #2566a8; }

.toolbar { background: #f9fbfd; border-bottom: 1px solid #e0e6ee; padding: 12px 24px; display: flex; align-items: center; gap: 8px; }
.toolbar input { width: 360px; height: 38px; border: 1px solid #d5dee8; border-radius: 7px; background: #fff; padding: 0 12px; outline: none; }
.toolbar input:focus { border-color: #4d8fd6; }
.stats { margin-left: 8px; color: #466989; font-size: 12px; white-space: nowrap; }

.main-area { min-height: 0; margin: 16px 16px 0; border: 1px solid #dce4ed; display: grid; grid-template-rows: 35px minmax(0, 1fr); background: #f5f7fa; }
.tabs { display: flex; align-items: end; overflow-x: auto; background: #f5f7fa; }
.tab { height: 35px; padding: 7px 18px; margin-right: 4px; border: 1px solid #b8c1cb; border-bottom-color: #dce4ed; border-radius: 0; background: #ededed; color: #475569; white-space: nowrap; }
.tab.active { background: #fff; color: #172033; border-bottom-color: #fff; }
.workspace { min-width: 0; min-height: 0; overflow: auto; background: #f5f7fa; }
.module-grid { display: flex; flex-wrap: wrap; align-content: flex-start; padding: 14px 14px 18px; }
.module-card { width: 264px; height: 226px; margin: 8px; padding: 15px; border: 1px solid #e0e6ee; border-radius: 8px; background: #fff; box-shadow: 0 2px 13px rgba(15, 23, 42, .10); display: grid; grid-template-rows: auto 1fr auto; gap: 7px; text-align: left; color: inherit; }
.module-card:hover { background: #f8fbff; border-color: #8bb8e8; }
.module-card:active { background: #eaf3fc; border-color: #4d8fd6; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.module-title { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 700; color: #0f172a; }
.badge { flex: 0 0 auto; max-width: 94px; padding: 3px 7px; border: 1px solid currentColor; border-radius: 6px; font-size: 10.5px; line-height: 1.25; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body { min-width: 0; overflow: hidden; }
.summary { margin: 0 0 8px; color: #475569; font-size: 11.5px; line-height: 17px; min-height: 34px; max-height: 38px; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; }
.tag { margin: 0 5px 5px 0; padding: 2px 6px; border: 1px solid currentColor; border-radius: 5px; font-size: 10.5px; line-height: 16px; }
.next-step { margin: 4px 0 0; color: #64748b; font-size: 10.5px; line-height: 16px; max-height: 34px; overflow: hidden; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.action-pill { padding: 4px 7px; border-radius: 6px; font-size: 11px; line-height: 18px; font-weight: 700; }
.maturity { color: #64748b; font-size: 10.5px; text-align: right; white-space: nowrap; }

.resource-view { padding: 16px 20px; }
.resource-toolbar { min-height: 48px; margin: -16px -20px 16px; padding: 8px 12px; border-bottom: 1px solid #d5dee8; background: #fff; display: flex; align-items: center; gap: 8px; }
.resource-toolbar strong { margin-right: auto; }
.resource-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.resource-item { width: 264px; min-height: 138px; padding: 14px; border: 1px solid #dce4ed; border-radius: 4px; background: #fff; }
.resource-item h3 { margin: 0 0 8px; font-size: 15px; }
.resource-item p { margin: 0; color: #64748b; line-height: 1.65; }
.resource-meta { margin-top: 10px; color: #2566a8; font-size: 12px; }

.tool-open .app-shell { grid-template-rows: minmax(0, 1fr) 34px; }
.tool-open .launcher-only { display: none !important; }
.tool-open .main-area { margin: 0; border: 0; display: block; min-height: 0; }
.tool-open .workspace { height: calc(100vh - 34px); padding: 8px; overflow: auto; background: #edf1f7; }
.tool-panel { min-height: calc(100vh - 50px); border: 1px solid #87929e; background: #f1f4f9; }
.tool-header { height: 56px; padding: 0 20px; background: #4386ee; color: #fff; display: flex; align-items: center; justify-content: space-between; }
.tool-title h2 { margin: 0; font-size: 18px; font-weight: 700; }
.tool-title p { margin: 3px 0 0; font-size: 11px; color: #e8f2ff; }
.tool-header-actions { display: flex; gap: 6px; }
.desktop-btn { min-width: 96px; height: 33px; padding: 0 16px; border: 0; border-radius: 0; color: #fff; font-weight: 700; }
.desktop-btn.recommend { background: #ffbf00; }
.desktop-btn.export { background: #6d7985; }
.desktop-btn.back { min-width: 72px; background: #2c6fcf; }
.tool-tabs { height: 34px; border-bottom: 1px solid #aab2bc; background: #eee; display: flex; align-items: end; padding-left: 5px; }
.tool-tab { height: 30px; padding: 5px 14px; border: 1px solid #9fa7b1; border-bottom: 0; border-radius: 0; background: #eee; color: #111827; }
.tool-tab.active { background: #fff; }
.tool-content { min-height: calc(100vh - 146px); padding: 9px; display: grid; grid-template-columns: minmax(330px, 38%) minmax(420px, 1fr); gap: 9px; }
.tool-content.single-column { grid-template-columns: 1fr; }
.form-area, .result-area { min-width: 0; }
.desktop-group { position: relative; margin: 3px 0 10px; padding: 18px 10px 10px; border: 1px solid #a9a9a9; background: #f8f9fb; }
.desktop-group > legend, .group-title { position: absolute; top: -9px; left: 9px; padding: 0 3px; background: #f8f9fb; color: #172033; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(135px, 1fr)); gap: 9px 14px; }
.field { min-width: 0; display: grid; grid-template-columns: minmax(76px, auto) minmax(72px, 1fr); align-items: center; gap: 7px; }
.field.wide { grid-column: 1 / -1; }
.field label { color: #22324a; white-space: nowrap; }
.field input, .field select { width: 100%; height: 27px; border: 1px solid #8e97a1; border-radius: 0; background: #fff; padding: 2px 6px; outline: none; }
.field input:focus, .field select:focus { border-color: #4386ee; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px 13px 8px; }
.form-actions button { min-width: 110px; height: 35px; border: 0; border-radius: 0; color: #fff; font-weight: 700; }
.form-actions .calculate { background: #34aa58; }
.form-actions .reset { background: #ffbf00; }
.form-actions .checklist { background: #4386ee; }
.form-actions .report { background: #6d7985; }
.result-area { display: grid; grid-template-rows: auto minmax(230px, 1fr) auto; gap: 10px; }
.result-table { width: 100%; border-collapse: collapse; background: #fff; }
.result-table th, .result-table td { height: 29px; padding: 5px 8px; border: 1px solid #aeb7c2; text-align: left; }
.result-table th { background: #edf1f7; text-align: center; color: #172033; }
.result-table td:nth-child(2) { color: #145a9c; font-weight: 700; }
.result-scroll { min-height: 230px; border: 1px solid #a9a9a9; background: #fff; overflow: auto; }
.note-list { margin: 0; padding: 10px 16px 10px 28px; border: 1px solid #a9a9a9; background: #fff; color: #334155; line-height: 1.75; }
.result-status { float: right; color: #17743a; font-weight: 400; }
.chart { width: 100%; height: 190px; border: 1px solid #aeb7c2; background: #fff; margin-top: 10px; }
.statusbar { height: 34px; padding: 0 10px; border-top: 1px solid #d5dee8; background: #fff; color: #466989; display: flex; align-items: center; font-size: 11px; }
.compat-elements { display: none; }
.hidden { display: none !important; }
.empty-state { margin: 20px; padding: 40px; border: 1px dashed #aeb7c2; background: #fff; text-align: center; color: #64748b; }
.status-ok { color: #15803d; }
.status-warn { color: #b45309; }
.status-bad { color: #b91c1c; }

@media (max-width: 900px) {
  .brand-line h1 { font-size: 22px; }
  .account-area { display: none; }
  .stats { display: none; }
  .toolbar input { width: min(44vw, 360px); }
  .tool-content { grid-template-columns: 1fr; }
  .tool-header { height: auto; min-height: 66px; padding: 8px 12px; gap: 10px; }
  .desktop-btn { min-width: 72px; padding: 0 9px; }
}

@media (max-width: 620px) {
  .app-shell { grid-template-rows: 76px auto minmax(0, 1fr) 34px; }
  .topbar { padding: 0 14px; }
  .brand-line h1 { font-size: 19px; }
  .toolbar { padding: 9px 12px; flex-wrap: wrap; }
  .toolbar input { width: 100%; }
  .toolbar button { flex: 1; padding: 5px 7px; }
  .main-area { margin: 8px 8px 0; }
  .module-grid { justify-content: center; padding: 8px 0 14px; }
  .module-card { width: min(264px, calc(100vw - 34px)); }
  .tool-header { align-items: flex-start; flex-direction: column; }
  .tool-header-actions { width: 100%; overflow-x: auto; }
  .tool-title h2 { font-size: 16px; }
  .tool-tabs { overflow-x: auto; }
  .tool-tab { white-space: nowrap; }
  .tool-content { padding: 7px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
  .form-actions button { flex: 1 1 42%; min-width: 100px; }
}


/* Module-specific WinForms layouts */
.trunnion-workspace { min-height: calc(100vh - 146px); display: grid; grid-template-columns: 38% 62%; background: #f1f4f9; }
.legacy-shaft { min-width: 0; border-right: 1px solid #c7cdd5; background: #f7f7f7; }
.shaft-tabs { padding-left: 4px; }
.shaft-legacy-body { position: relative; min-height: 520px; padding: 12px 10px; }
.choice-row { width: 235px; min-height: 62px; padding: 25px 12px 10px; border: 1px solid #cfd3d8; background: #fff; display: flex; gap: 15px; }
.choice-row label, .keyway-box label { white-space: nowrap; }
.shaft-type-row { position: absolute; top: 12px; right: 8px; width: 100px; min-height: 74px; padding: 22px 10px 8px; border: 1px solid #cfd3d8; background: #fff; }
.shaft-type-row label { display: block; margin-bottom: 8px; }
.legacy-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 12px; }
.legacy-inline label { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.legacy-inline input, .legacy-output input { width: 64px; height: 24px; border: 1px solid #8e97a1; border-radius: 0; }
.keyway-box { margin: 0 0 8px; padding-top: 24px; display: flex; gap: 14px; }
.inner-tabs { display: flex; align-items: end; height: 38px; }
.inner-tabs button { height: 35px; padding: 5px 10px; border: 1px solid #b0b5bb; border-radius: 0; background: #eee; }
.inner-tabs button.active { background: #fff; border-bottom-color: #fff; }
.legacy-value { height: 43px; padding: 14px 8px; border: 1px solid #d3d7dc; background: #fff; }
.legacy-output { display: flex; align-items: center; gap: 28px; margin-top: 15px; padding: 0 10px; }
.legacy-output label { display: flex; align-items: center; gap: 10px; }
.shaft-assistant { min-width: 0; padding: 10px 14px; }
.assistant-group { height: 510px; margin: 0; padding: 28px 14px 12px; }
.assistant-grid { display: grid; grid-template-columns: 185px minmax(260px,1fr); align-items: center; gap: 8px 0; }
.assistant-grid label { color: #172033; }
.assistant-grid input, .assistant-grid select { width: 100%; height: 25px; border: 1px solid #b9bec5; border-radius: 0; padding: 2px 5px; background: #fff; }
.assistant-grid input:disabled { background: #eef1f5; color: #65758a; }
.assistant-calculate { width: 100%; height: 36px; margin-top: 14px; border: 1px solid #b9bec5; border-radius: 3px; background: #fff; color: #111; }
.assistant-result { min-height: 62px; padding: 22px 3px 8px; color: #1e508c; font-size: 14px; font-weight: 700; line-height: 1.6; }
.assistant-help { padding-top: 10px; color: #6b7280; line-height: 1.65; }
.engineering-bar { height: 48px; padding: 7px 10px; border-top: 1px solid #d5dee8; background: #f5f8fc; display: flex; align-items: center; gap: 6px; }
.engineering-bar span { margin-right: auto; color: #555; }
.engineering-bar button { width: 96px; height: 30px; border: 1px solid #c8cdd3; border-radius: 4px; background: #fff; }

.layout-stacked { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
.layout-stacked .form-grid { grid-template-columns: repeat(4,minmax(150px,1fr)); }
.layout-stacked .result-area { min-height: 360px; }
.layout-stacked .result-scroll { min-height: 190px; }
.layout-drive { grid-template-columns: 34% 66%; }
.layout-drive .form-grid { grid-template-columns: 1fr; padding: 10px 34px; }
.layout-drive .field { grid-template-columns: 125px minmax(90px,1fr); }
.layout-drive .form-actions { justify-content: center; }
.layout-drive .result-scroll { min-height: 430px; }
.layout-gear { grid-template-columns: 35% 65%; }
.layout-shaft { grid-template-columns: 40% 60%; }
.layout-bolt { grid-template-columns: 38% 62%; }
.layout-bolt .form-grid { grid-template-columns: 1fr; padding: 0 24px; }
.layout-bolt .field { grid-template-columns: 105px minmax(90px,1fr); }
.layout-parameter { grid-template-columns: 52% 48%; }
.layout-parameter .form-grid { grid-template-columns: repeat(2,minmax(145px,1fr)); }
.layout-parameter .result-scroll { min-height: 330px; }
.layout-mechanics { grid-template-columns: 68% 32%; }
.layout-mechanics .result-area { display: flex; flex-direction: column; }
.layout-mechanics .report-group { order: -1; flex: 1; }
.layout-mechanics .result-group { min-height: 190px; }
.layout-profile { grid-template-columns: 38% 62%; }
.layout-profile .form-grid { grid-template-columns: 1fr; }
.layout-profile .result-scroll { min-height: 320px; background: repeating-linear-gradient(0deg,#fff,#fff 23px,#e5edf7 24px),repeating-linear-gradient(90deg,transparent,transparent 23px,#e5edf7 24px); }
.layout-treatment { grid-template-columns: 32% 68%; }
.layout-treatment .form-grid { grid-template-columns: 1fr; padding: 12px; }
.layout-treatment .field { grid-template-columns: 110px minmax(100px,1fr); }
.layout-treatment .result-scroll { min-height: 300px; }
.layout-treatment .note-list { min-height: 250px; }
.layout-cam { grid-template-columns: 38% 62%; }
.layout-cam .result-scroll { min-height: 250px; }
.layout-cam .chart { height: 230px; }
.tool-content:not(.single-column) .form-area { border-right: 1px solid #b9c0c9; }

@media (max-width: 900px) {
  .trunnion-workspace { grid-template-columns: 1fr; }
  .legacy-shaft { border-right: 0; border-bottom: 1px solid #c7cdd5; }
  .shaft-legacy-body { min-height: 430px; }
  .assistant-grid { grid-template-columns: 145px minmax(140px,1fr); }
  .layout-drive,.layout-gear,.layout-shaft,.layout-bolt,.layout-parameter,.layout-mechanics,.layout-profile,.layout-treatment,.layout-cam { grid-template-columns: 1fr; }
  .layout-stacked .form-grid { grid-template-columns: repeat(2,minmax(135px,1fr)); }
}

@media (max-width: 620px) {
  .choice-row { width: 100%; }
  .shaft-type-row { position: static; width: 100%; margin-top: 8px; }
  .legacy-inline { grid-template-columns: 1fr; }
  .keyway-box { flex-direction: column; gap: 7px; }
  .legacy-output { align-items: flex-start; flex-direction: column; gap: 8px; }
  .assistant-group { height: auto; min-height: 510px; }
  .assistant-grid { grid-template-columns: 1fr; gap: 4px; }
  .engineering-bar span { display: none; }
  .engineering-bar button { flex: 1; }
  .layout-stacked .form-grid { grid-template-columns: 1fr; }
}

.compact-table { margin-top: 12px; }
.compact-table .result-table th,.compact-table .result-table td { height: 25px; padding: 3px 6px; }
.small-actions { display: flex; gap: 6px; margin-top: 10px; }
.small-actions button { min-width: 62px; height: 30px; border: 0; border-radius: 0; background: #4386ee; color: #fff; }
.beam-summary { padding: 12px 16px; background: #fff; border: 1px solid #d5dee8; }
.beam-preview { position: relative; height: 220px; border: 1px solid #d5dee8; background-color: #f7fbff; background-image: linear-gradient(#e2eaf3 1px,transparent 1px),linear-gradient(90deg,#e2eaf3 1px,transparent 1px); background-size: 24px 24px; }
.beam-line { position: absolute; left: 9%; right: 9%; top: 52%; height: 12px; border-radius: 6px; background: #0d78df; }
.support { position: absolute; top: 32%; width: 38px; height: 95px; border: 1px solid #888; background: repeating-linear-gradient(135deg,#eee,#eee 5px,#aaa 6px,#aaa 7px); }
.support.left { left: 2%; }.support.right { right: 2%; }
.load-mark { position: absolute; left: 46%; top: 47%; padding: 7px 15px; border-radius: 8px; background: #ff3b30; color: #fff; font-weight: 700; }
.profile-kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin: 12px 0; }
.profile-kpis div { min-height: 74px; padding: 14px; background: #fff; text-align: center; color: #64748b; }
.profile-kpis strong { display: block; margin-top: 12px; color: #172033; }
.cam-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; min-height: 190px; padding: 18px; border: 1px solid #d5dee8; background: #fff; }
.cam-shape { width: 150px; height: 150px; margin: auto; border: 3px solid #144cff; border-radius: 48% 52% 42% 58%; transform: rotate(-18deg); }
.cam-preview p { margin: 12px 0; }
.layout-profile .result-group { display: none; }
.layout-profile .report-group { min-height: 180px; }
.layout-cam .result-group { min-height: 250px; }
@media(max-width:620px){.profile-kpis{grid-template-columns:1fr 1fr}.cam-preview{grid-template-columns:1fr}.beam-preview{height:170px}}
