﻿:root {
  color-scheme: dark;
  --bg: #0f1720;
  --panel: #15202b;
  --panel-2: #101820;
  --line: #2c3d4f;
  --text: #e8eef5;
  --muted: #8ea0b4;
  --accent: #4cc9f0;
  --accent-2: #7ae582;
  --warn: #f59f00;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: linear-gradient(180deg, #0b1118, #0f1720 35%, #0f1720); color: var(--text); font: 14px/1.45 "Segoe UI", system-ui, sans-serif; }
body { padding: 20px; }
h1, h2, h3, p { margin: 0; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 18px; }
.topbar-side { display: grid; gap: 10px; justify-items: end; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; margin-bottom: 4px; }
h1 { font-size: 24px; }
.topbar-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.cloud-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.session-user { padding: 9px 12px; border: 1px solid rgba(76, 201, 240, .22); border-radius: 999px; color: #d8ebf5; background: rgba(10, 20, 31, .84); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 4px rgba(245,159,0,.12); }
.shell { display: grid; grid-template-columns: 360px 1fr 420px; gap: 16px; align-items: start; }
.panel { background: rgba(21, 32, 43, .94); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.preview { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.section-title { margin-top: 18px; }
.coef-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; padding: 10px; background: rgba(16, 24, 32, .65); border: 1px solid rgba(44, 61, 79, .8); border-radius: 10px; }
.coef-grid input { padding: 7px 8px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input, select, button { font: inherit; }
input, select { width: 100%; padding: 9px 10px; background: var(--panel-2); color: var(--text); border: 1px solid #304355; border-radius: 8px; outline: none; }
input:focus, select:focus, button:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(76, 201, 240, .18); }
input[readonly] { color: var(--accent-2); background: rgba(122, 229, 130, .08); }
input:disabled { opacity: .72; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
button { border: 1px solid var(--line); background: #1b2633; color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer; }
button.primary { background: linear-gradient(180deg, #1d6fa3, #155d8b); border-color: #2d7db0; }
button.active { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .55; cursor: not-allowed; }
.hint { color: var(--muted); margin-top: 10px; }
.message { min-height: 20px; margin-top: 10px; color: var(--muted); }
.message[data-kind="error"] { color: var(--danger); }
.message[data-kind="warn"] { color: var(--warn); }
.message[data-kind="ok"] { color: var(--accent-2); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; color: var(--muted); font-size: 12px; margin-top: 12px; }
.stat-card { min-height: 72px; padding: 10px; border: 1px solid rgba(76, 201, 240, .18); border-radius: 8px; background: rgba(9, 17, 26, .62); display: grid; gap: 4px; }
.stat-card b { color: #cfe0ef; font-size: 12px; font-weight: 600; }
.stat-card span { color: #8ea0b4; }
.stat-card strong { color: var(--accent-2); font-size: 14px; font-weight: 700; }
.stat-card.highlight { border-color: rgba(122, 229, 130, .45); background: rgba(122, 229, 130, .09); }
.swatch { width: 12px; height: 3px; border-radius: 999px; display: inline-block; }
.rough { background: #f59f00; }
.blank { background: #f59f00; }
.target { background: #4cc9f0; }
.allow { background: #7ae582; }
.leadin { background: #ffd166; }
.cut { background: #ff8fab; }
.retract { background: #ff6b6b; }
.rapid { background: #64748b; }
#plot { width: 100%; aspect-ratio: 3 / 2; background: #09111a; border: 1px solid var(--line); border-radius: 10px; display: block; cursor: zoom-in; }
.table-wrap { overflow: auto; max-height: 650px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th { position: sticky; top: 0; background: #13202b; z-index: 1; text-align: left; padding: 10px 8px; color: #cfe0ef; border-bottom: 1px solid var(--line); }
tbody td { padding: 8px; border-bottom: 1px solid rgba(44, 61, 79, .7); color: #dce7f1; vertical-align: top; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.toggle button { border: 0; border-radius: 0; padding: 8px 10px; }
body.cloud-locked { overflow: hidden; background: #06101a; }
body.cloud-locked > .topbar,
body.cloud-locked > .workbench,
body.cloud-locked > .shell { visibility: hidden; pointer-events: none; }
.workbench { margin-bottom: 16px; display: grid; gap: 14px; }
.workbench-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.workbench-note { color: var(--muted); margin-top: 4px; }
.workbench-toolbar, .workbench-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.workbench-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.workbench-card { min-height: 86px; padding: 12px; border: 1px solid rgba(76, 201, 240, .16); border-radius: 8px; background: rgba(9, 17, 26, .55); display: grid; gap: 6px; }
.workbench-card span { color: var(--muted); font-size: 12px; }
.workbench-card strong { color: #dce7f1; font-size: 16px; }
.workbench-card small { color: #8ea0b4; font-size: 12px; }
.workbench-card.highlight { border-color: rgba(122, 229, 130, .45); background: rgba(122, 229, 130, .08); }
.workbench-card.highlight strong { color: var(--accent-2); }
.simulation-bar { display: grid; grid-template-columns: auto auto 34px 34px 44px 112px 112px minmax(180px, 1fr) 170px; gap: 8px; align-items: center; margin-top: 10px; color: var(--muted); }
.simulation-bar label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.simulation-bar select { padding: 7px 8px; }
.simulation-bar button { padding: 7px 10px; }
#plotZoomOutBtn, #plotZoomInBtn, #plotZoomResetBtn { min-width: 0; padding: 7px 0; }
.simulation-bar input[type="range"] { padding: 0; accent-color: var(--accent); }
.simulation-bar span { text-align: right; font-size: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); }
.check-row input { width: auto; min-height: auto; padding: 0; accent-color: var(--accent); }
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; overflow: hidden; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 6, 12, .72); }
.tool-dialog { position: relative; z-index: 1; width: min(1280px, calc(100vw - 32px)); height: min(760px, calc(100vh - 32px)); display: grid; grid-template-columns: 400px 1fr; overflow: hidden; border: 1px solid #3a4d61; border-radius: 10px; background: #101820; box-shadow: 0 24px 80px rgba(0,0,0,.45); }
.tool-form { min-height: 0; padding: 16px; overflow-y: auto; overflow-x: visible; background: #f0f2f4; color: #17202a; display: grid; grid-auto-rows: max-content; gap: 10px; scrollbar-gutter: stable; }
.tool-form label { color: #17202a; grid-template-columns: 1fr; font-size: 14px; }
.tool-form input, .tool-form select { background: #fff; color: #111827; border-color: #9aa4af; border-radius: 2px; padding: 7px 8px; }
.modal-head { position: sticky; top: -16px; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 0 10px; background: #f0f2f4; }
.modal-head h2 { color: #101820; font-size: 18px; }
.icon-btn { width: 34px; height: 30px; display: grid; place-items: center; padding: 0; border-radius: 4px; color: #101820; background: #e4e7eb; border-color: #b7c0ca; }
.tool-note { color: #111827; font-weight: 600; }
.modal-actions { position: sticky; bottom: -16px; z-index: 2; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; padding: 10px 0 16px; background: #f0f2f4; }
.tool-preview { position: relative; min-height: 0; overflow: hidden; background: #020406; }
#toolCanvas { width: 100%; height: 100%; min-height: 0; display: block; background: #020406; cursor: grab; }
#toolCanvas:active { cursor: grabbing; }
.tool-view-controls { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #cbd5e1; font-size: 12px; pointer-events: none; }
.tool-view-controls button { pointer-events: auto; padding: 7px 10px; background: rgba(15, 23, 32, .86); border-color: rgba(148, 163, 184, .45); }
.tool-view-controls span { padding: 6px 9px; border-radius: 6px; background: rgba(15, 23, 32, .68); }
.cloud-modal[hidden] { display: none; }
.cloud-modal { position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 12, .72); display: grid; place-items: center; padding: 18px; }
.cloud-card { width: min(980px, calc(100vw - 36px)); max-height: 86vh; overflow: auto; background: #121d28; border: 1px solid #34516b; border-radius: 12px; padding: 18px; color: #eef6ff; box-shadow: 0 24px 80px rgba(0, 0, 0, .42); }
.cloud-modal.wide .cloud-card { width: min(1180px, calc(100vw - 36px)); }
.cloud-modal.admin-mode .cloud-card { width: min(1340px, calc(100vw - 36px)); }
.cloud-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.cloud-head h2 { font-size: 24px; }
.cloud-head button { min-width: 42px; }
.cloud-stack { display: grid; gap: 14px; }
.cloud-note { padding: 12px 14px; border: 1px solid rgba(76, 201, 240, .14); border-radius: 10px; background: rgba(8, 19, 31, .8); color: #b3c8d9; }
.cloud-note.error-note { border-color: rgba(255, 107, 107, .28); color: #ffd2d2; background: rgba(56, 16, 18, .82); }
.cloud-note.ok-note { border-color: rgba(122, 229, 130, .28); color: #d8f6dd; background: rgba(18, 40, 26, .78); }
.cloud-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.cloud-search { min-width: min(320px, 100%); flex: 1 1 280px; }
.cloud-search span { color: var(--muted); font-size: 12px; }
.cloud-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.cloud-stat { min-height: 86px; padding: 12px; border: 1px solid rgba(76, 201, 240, .16); border-radius: 10px; background: rgba(8, 17, 27, .72); display: grid; gap: 6px; }
.cloud-stat span { color: #90a8bc; font-size: 12px; }
.cloud-stat strong { color: #eef6ff; font-size: 18px; }
.cloud-stat small { color: #7f99ae; font-size: 12px; }
.cloud-list { display: grid; gap: 10px; }
.project-list, .records-list, .user-list { max-height: 56vh; overflow: auto; padding-right: 2px; }
.cloud-item { border: 1px solid #28425a; border-radius: 10px; padding: 12px; background: #08131f; display: grid; gap: 10px; }
.cloud-item.active { border-color: rgba(122, 229, 130, .48); background: rgba(18, 40, 26, .35); }
.cloud-item-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.cloud-item-head b { display: block; font-size: 15px; }
.cloud-item-head small { color: #8fb0c9; display: block; margin-top: 4px; }
.cloud-item-meta { display: flex; flex-wrap: wrap; gap: 14px; color: #96adc0; font-size: 12px; }
.cloud-item-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cloud-badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(76, 201, 240, .24); color: #d8edf8; background: rgba(12, 26, 40, .86); font-size: 12px; }
.cloud-badge.ok { border-color: rgba(122, 229, 130, .35); color: #d8f6dd; background: rgba(18, 40, 26, .75); }
.cloud-badge.warn { border-color: rgba(245, 159, 0, .38); color: #ffe5a7; background: rgba(58, 42, 9, .8); }
.cloud-empty { padding: 22px 16px; border: 1px dashed rgba(76, 201, 240, .2); border-radius: 10px; color: #8fb0c9; text-align: center; background: rgba(8, 17, 27, .55); }
.cloud-admin-grid { display: grid; grid-template-columns: 1.05fr 1.35fr; gap: 14px; }
.cloud-section { padding: 14px; border: 1px solid rgba(76, 201, 240, .14); border-radius: 10px; background: rgba(8, 17, 27, .68); display: grid; gap: 12px; }
.cloud-section-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.cloud-section-head h3 { font-size: 16px; }
.cloud-section-head p { color: #8ca7bc; font-size: 12px; }
.cloud-log-list { max-height: 34vh; overflow: auto; display: grid; gap: 8px; }
.cloud-log-item { padding: 10px 12px; border-radius: 8px; background: rgba(4, 12, 20, .7); border: 1px solid rgba(44, 61, 79, .76); display: grid; gap: 4px; }
.cloud-log-item b { font-size: 13px; }
.cloud-log-item small { color: #8fb0c9; }
.cloud-modal.login-mode { background: #06101a; place-items: center; }
.cloud-modal.login-mode::before { content: ""; position: fixed; inset: 0; background: radial-gradient(circle at 50% 18%, rgba(44, 166, 219, .12), transparent 34%); pointer-events: none; }
.cloud-modal.login-mode .cloud-card { width: min(460px, calc(100vw - 36px)); max-height: none; overflow: visible; padding: 26px; border-color: #2f5f7d; }
.cloud-modal.login-mode .cloud-head { margin-bottom: 18px; }
.cloud-modal.login-mode .cloud-head h2 { font-size: 26px; }
.cloud-modal.login-mode #cloudBody { display: grid; gap: 14px; }
.cloud-modal.login-mode label { display: grid; gap: 7px; color: #a8c6dc; }
.cloud-modal.login-mode input { min-height: 44px; }
.cloud-modal.mandatory .cloud-head button { display: none; }
.login-brand { border: 1px solid rgba(77, 185, 227, .22); border-radius: 8px; padding: 14px; background: rgba(6, 20, 32, .72); }
.login-brand p { color: var(--accent); font-size: 12px; letter-spacing: .08em; }
.login-brand h3 { margin: 5px 0; font-size: 20px; }
.login-brand span { color: #8fb0c9; font-size: 13px; }
.login-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }

@media (max-width: 1400px) {
  .shell { grid-template-columns: 1fr; }
  .workbench-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .cloud-stat-grid, .cloud-admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .tool-dialog { grid-template-columns: 1fr; grid-template-rows: minmax(360px, 55vh) minmax(260px, 45vh); }
  .tool-preview { min-height: 260px; }
  #toolCanvas { min-height: 260px; }
  .simulation-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .simulation-bar input[type="range"], .simulation-bar span { grid-column: 1 / -1; }
  .cloud-card .grid, .grid, .workbench-grid, .cloud-toolbar { grid-template-columns: 1fr; }
  .topbar { align-items: start; }
  .topbar-meta { flex-wrap: wrap; }
  .workbench-head { flex-direction: column; }
}

/* 2026 CAM workstation visual system */
:root {
  --bg: #1b2630;
  --panel: #273540;
  --panel-2: #1c2832;
  --panel-raised: #31414d;
  --line: #50616e;
  --line-strong: #657887;
  --text: #edf2f6;
  --muted: #8d9aa6;
  --accent: #42d8bd;
  --accent-strong: #20bda2;
  --accent-2: #76e39a;
  --warn: #f4b740;
  --danger: #ff6f7d;
  --focus: rgba(66, 216, 189, .2);
}

html, body {
  background: var(--bg);
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  letter-spacing: 0;
}

body {
  min-width: 1180px;
  padding: 12px;
  background-image: linear-gradient(180deg, #263540 0, #1a252e 58%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

.topbar {
  position: relative;
  z-index: 2;
  min-height: 58px;
  margin: 0 0 8px;
  padding: 8px 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
  background: #2b3a46;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

.brand-block { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(66,216,189,.55); border-radius: 4px; background: rgba(66,216,189,.1); color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.eyebrow { margin-bottom: 2px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .12em; }
h1 { font-size: 19px; line-height: 1.2; font-weight: 650; }
h2 { font-size: 17px; line-height: 1.25; font-weight: 650; }
h3 { font-size: 14px; }

.topbar-side { display: flex; align-items: center; gap: 14px; }
.topbar-meta { min-height: 30px; padding: 0 11px; border-left: 1px solid var(--line); color: #aeb9c3; }
.status-dot { width: 8px; height: 8px; box-shadow: 0 0 0 3px rgba(244,183,64,.12); }
.cloud-actions { flex-wrap: nowrap; }
.session-user { padding: 6px 10px; border-radius: 4px; background: #202d37; }

button {
  min-height: 34px;
  padding: 7px 11px;
  border-color: var(--line-strong);
  border-radius: 5px;
  background: #33434f;
  color: #dde6ed;
  font-weight: 600;
  transition: background-color .14s ease, border-color .14s ease, color .14s ease, transform .14s ease;
}
button:hover:not(:disabled) { border-color: #8195a4; background: #40525f; color: #fff; }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary {
  border-color: #2bc8ae;
  background: #1aa98f;
  color: #041511;
  box-shadow: none;
}
button.primary:hover:not(:disabled) { border-color: #65ead2; background: #36cfb4; color: #03100d; }
button.active { border-color: var(--accent); background: rgba(66,216,189,.1); color: #73ead5; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--focus);
}

.workbench {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  padding: 10px 12px;
  gap: 10px;
  border-radius: 0 0 6px 6px;
  background: #25333e;
}
.workbench-head { align-items: center; }
.workbench-head .eyebrow, .workbench-note { display: none; }
.workbench-head h2::before { content: "项目 · "; color: var(--muted); font-weight: 500; }
.workbench-toolbar, .workbench-actions { gap: 7px; }
.workbench-grid { grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 7px; }
.workbench-card {
  min-height: 66px;
  padding: 9px 11px;
  gap: 2px;
  border-radius: 4px;
  background: #1d2a34;
}
.workbench-card strong { overflow: hidden; color: #e6edf2; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.workbench-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workbench-card.highlight { border-color: rgba(66,216,189,.38); background: rgba(35,116,103,.12); }
.workbench-card.highlight strong { color: #71e3cf; }
.workbench-actions { border-top: 1px solid var(--line); padding-top: 8px; }

.shell {
  position: relative;
  z-index: 1;
  grid-template-columns: 344px minmax(620px, 1fr) 390px;
  gap: 8px;
  align-items: stretch;
  height: calc(100vh - 304px);
  min-height: 430px;
}

.panel {
  padding: 13px;
  border-color: var(--line);
  border-radius: 5px;
  background: rgba(38, 52, 63, .98);
  box-shadow: 0 7px 24px rgba(0,0,0,.14);
}
.inputs, .table-panel { height: 100%; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
.inputs { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: 0; overflow: hidden; }
.parameter-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--line); background: #2d3d49; }
.parameter-tabs button { min-width: 0; min-height: 40px; padding: 6px 3px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; color: #adbac4; font-size: 12px; }
.parameter-tabs button:last-child { border-right: 0; }
.parameter-tabs button.active { box-shadow: inset 0 -3px var(--accent); background: rgba(66,216,189,.1); color: #7aead6; }
.parameter-body { min-height: 0; padding: 13px; overflow: auto; scrollbar-gutter: stable; }
.parameter-page[hidden] { display: none; }
.parameter-page > h2 { position: relative; margin: 0 0 10px; padding: 7px 9px; border-left: 3px solid var(--accent); background: #344550; color: #e9eff4; font-size: 14px; }
.parameter-actions { margin: 0; padding: 10px; border-top: 1px solid var(--line); background: #2a3944; }
.parameter-actions #generateBtn { flex: 1 1 100%; }
.coefficient-details { margin-top: 9px; border: 1px solid var(--line); border-radius: 4px; background: #202d37; }
.coefficient-details summary { padding: 9px 10px; color: #dbe5eb; font-size: 12px; font-weight: 700; cursor: pointer; }
.coefficient-details summary:hover { color: var(--accent); }
.coefficient-details .coef-grid { margin: 0 8px 8px; }
.sag-page { min-height: 100%; }
.sag-controls { margin-bottom: 9px; }
.sag-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 9px; }
.sag-summary > div { min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 4px; background: #202d37; }
.sag-summary span { display: block; color: var(--muted); font-size: 10px; }
.sag-summary strong { display: block; margin-top: 3px; overflow: hidden; color: var(--accent-2); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.sag-table-wrap { max-height: 310px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
.sag-table { font-size: 11px; }
.sag-table th, .sag-table td { padding: 6px; }
.inputs > h2:first-child, .section-title {
  position: relative;
  margin: 16px 0 9px;
  padding: 7px 9px;
  border-left: 3px solid var(--accent);
  background: #344550;
  color: #e9eff4;
  font-size: 14px;
}
.inputs > h2:first-child { margin-top: 0; }
.grid { gap: 8px; }
label { gap: 4px; color: #99a7b3; font-size: 11px; font-weight: 600; }
input, select {
  min-height: 35px;
  padding: 7px 9px;
  border-color: #344451;
  border-radius: 4px;
  background: #1b2731;
  color: #eef3f7;
}
input:hover, select:hover { border-color: #4b5d6b; }
input[readonly] { color: #76e39a; background: rgba(59,125,80,.13); }
.coef-grid { gap: 7px; margin-top: 8px; padding: 8px; border-radius: 4px; background: #202d37; }
.actions { margin: 14px -13px 0; padding: 10px 13px; border-top: 1px solid var(--line); background: rgba(34,48,58,.98); }
.message { margin-top: 12px; font-size: 12px; }
.hint { font-size: 11px; }
.check-row { min-height: 34px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #202d37; }

.preview {
  position: sticky;
  top: 12px;
  height: 100%;
  max-height: none;
  padding: 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(210px, 1fr) auto auto;
}
.panel-head { min-height: 34px; margin-bottom: 8px; }
.legend { justify-content: flex-end; gap: 9px; font-size: 11px; }
.swatch { width: 14px; height: 2px; border-radius: 0; }
#plot {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border-color: #263744;
  border-radius: 3px;
  background-color: #111c25;
  background-image: linear-gradient(rgba(55,75,91,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(55,75,91,.14) 1px, transparent 1px);
  background-size: 28px 28px;
}
.simulation-bar {
  grid-template-columns: auto auto 32px 32px 42px 104px 102px minmax(130px, 1fr) 150px;
  gap: 6px;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #202d37;
}
.simulation-bar button { min-height: 31px; padding: 5px 8px; }
.simulation-bar select { min-height: 31px; padding: 5px 7px; }
.stats { gap: 7px; margin-top: 8px; }
.stat-card { min-height: 65px; padding: 8px 9px; border-radius: 4px; background: #202d37; }
.stat-card.highlight { background: rgba(35,116,103,.12); }

.table-panel { padding: 12px; }
.toggle { border-radius: 4px; }
.toggle button { min-height: 31px; padding: 5px 8px; }
.table-wrap { max-height: calc(100vh - 126px); border-radius: 3px; }
table { font-variant-numeric: tabular-nums; }
thead th { padding: 8px 7px; background: #394b57; color: #e2e9ee; }
tbody td { padding: 7px; }
tbody tr:hover { background: rgba(66,216,189,.055); }

.cloud-card, .cloud-item, .cloud-section, .cloud-stat, .cloud-note, .cloud-empty { border-radius: 5px; }
.cloud-card { background: #283741; border-color: #58707e; }
.cloud-item { background: #1f2c35; }
.cloud-modal.login-mode { background: #25323c; }
.cloud-modal.login-mode::before { display: none; }
.cloud-modal.login-mode .cloud-card { border-radius: 6px; border-color: #647d8b; background: #31414d; }
.login-brand { border-radius: 4px; background: #24323c; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #141d25; }
::-webkit-scrollbar-thumb { border: 2px solid #141d25; border-radius: 6px; background: #52616d; }
::-webkit-scrollbar-thumb:hover { background: #50616e; }

@media (max-width: 1560px) {
  .shell { grid-template-columns: 320px minmax(580px, 1fr) 360px; }
}

@media (max-width: 1280px) {
  body { min-width: 0; }
  .shell { grid-template-columns: 310px minmax(0, 1fr); height: auto; min-height: 0; }
  .inputs, .preview { height: max(430px, calc(100vh - 304px)); }
  .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .stat-card { min-height: 56px; padding: 6px 7px; }
  .table-panel { grid-column: 1 / -1; height: auto; min-height: 420px; }
  .table-wrap { max-height: 520px; }
  .workbench-grid { grid-template-columns: repeat(4, minmax(140px,1fr)); }
}

@media (max-width: 900px) {
  body { padding: 7px; }
  .topbar, .topbar-side, .workbench-head { align-items: stretch; }
  .topbar { flex-direction: column; }
  .topbar-side { flex-direction: column; gap: 7px; }
  .topbar-meta { border-left: 0; padding-left: 0; }
  .cloud-actions { justify-content: flex-start; }
  .shell { grid-template-columns: 1fr; }
  .inputs, .preview, .table-panel { position: relative; top: auto; width: 100%; height: auto; min-height: 0; max-height: none; }
  .inputs { grid-template-rows: auto minmax(420px, auto) auto; }
  .workbench-grid, .grid { grid-template-columns: 1fr 1fr; }
  .preview { display: block; overflow: visible; }
  #plot { height: auto; aspect-ratio: 16 / 10; }
}
