:root {
  --bg: #071327;
  --panel: #0b1a33;
  --panel-2: #0f223f;
  --muted: #8ea1bf;
  --text: #e5edf8;
  --line: #243f63;
  --accent: #22c55e;
  --accent-2: #16a34a;
  --danger: #ef4444;
  --surface: #09172d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top right, #17335e, #060f22 55%);
  color: var(--text);
}

.page {
  height: 100%;
}

.auth-card {
  max-width: 420px;
  margin: 10vh auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  background: rgba(9, 23, 45, 0.94);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

input,
button,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px;
  margin-top: 6px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #071327;
  color: var(--text);
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
}

button {
  border: 1px solid var(--line);
  background: #112545;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

button:hover {
  background: #17335f;
  border-color: #2d4f78;
}

button.primary {
  background: var(--accent);
  color: #052e16;
  border-color: var(--accent-2);
  font-weight: 700;
}

button.danger {
  background: #7f1d1d;
  border-color: #b91c1c;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.remember-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.auth-actions #login {
  margin: 0;
}

.layout {
  display: grid;
  grid-template-rows: 56px 40px 1fr;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: linear-gradient(180deg, #0a1b35 0%, #08152b 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 175px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid #3f6a36;
  background: linear-gradient(145deg, #7cbc48, #2a8f4d);
  color: #edf8d8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.brand-text strong {
  font-size: 20px;
  letter-spacing: 0.2px;
}

.brand-text span {
  color: #8fd1ff;
  font-size: 11px;
  font-family: Consolas, monospace;
}

.top-project {
  flex: 1;
  min-width: 0;
}

.top-project input {
  margin: 0;
  height: 30px;
  padding: 6px 10px;
  border-radius: 6px;
  border-color: #264a72;
  background: #07182f;
  font-size: 13px;
}

.top-actions-bar {
  display: flex;
  gap: 2px;
  align-items: center;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.context-toolbar {
  border-bottom: 1px solid #1d3353;
  background: linear-gradient(180deg, #091a32 0%, #081529 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 3px 10px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}

.context-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.context-label {
  color: #9ec4ef;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.context-note {
  color: #9bb2cf;
  font-size: 12px;
}

.context-btn {
  margin: 0;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #294162;
  background: #0f223f;
  color: #dce9fb;
  font-size: 12px;
  font-weight: 600;
}

.context-btn.active {
  border-color: #2dd58d;
  background: #15364d;
  color: #e8fff3;
}

.context-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.context-input-wrap input {
  margin: 0;
  width: 92px;
  height: 32px;
  padding: 4px 8px;
  border-radius: 6px;
}

.context-group-tools {
  gap: 10px;
}

.context-group-bg {
  gap: 6px;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid #1f3555;
}

.context-tool-strip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.context-measure-strip {
  padding-right: 8px;
  border-right: 1px solid #1f3555;
}

.context-tool-btn {
  margin: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #294162;
  background: #0f223f;
  color: #dce9fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.context-tool-btn:hover {
  background: #15304f;
}

.context-tool-btn.active {
  border-color: #2dd58d;
  background: #15364d;
  color: #e8fff3;
}

.context-tool-btn .tool-icon {
  width: 22px;
  height: 22px;
}

.context-tool-btn .tool-icon svg {
  width: 22px;
  height: 22px;
}

.context-system-group {
  gap: 6px;
  padding-left: 10px;
  margin-left: 2px;
  border-left: 1px solid #1f3555;
  min-width: 0;
}

.context-system-palette {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 0;
}

.context-system-section {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.context-system-section.split {
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid #1f3555;
}

.context-system-section-label {
  color: #8cb4df;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.context-system-icons {
  max-width: none;
  overflow: visible;
  padding-bottom: 0;
}

.context-system-extra {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid #1f3555;
}

.context-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.context-compact-select {
  margin: 0;
  width: auto;
  min-width: 78px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid #294162;
  background: #0f223f;
  color: #dce9fb;
}

#contextPipeSize {
  min-width: 84px;
}

#contextPipeSchedule {
  min-width: 140px;
}

.top-action {
  margin: 0;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #eef4ff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.top-action:hover {
  background: #112644;
  border-color: transparent;
}

.top-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.top-action-icon {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.top-action-icon svg {
  width: 15px;
  height: 15px;
}

.top-action.action-accent {
  color: #18d18e;
}

.top-action.action-warn {
  color: #f97316;
}

.top-action.action-link {
  color: #3b82f6;
}

.top-action.action-danger {
  color: #ef4444;
}

.top-action.sep-left {
  border-left: 1px solid #1e3658;
  margin-left: 8px;
  padding-left: 12px;
}

.top-action.top-action-icon-only {
  width: 34px;
  justify-content: center;
  padding: 0;
}

.scale-inline {
  margin: 0 0 0 8px;
  width: 120px;
  min-width: 120px;
  height: 28px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.body-grid {
  display: grid;
  grid-template-columns: 62px 1fr 300px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel {
  position: relative;
  z-index: 20;
  border-right: 1px solid var(--line);
  padding: 10px 7px;
  background: linear-gradient(180deg, #091a35 0%, #07142a 100%);
  min-height: 0;
}

.panel-right {
  border-left: 1px solid var(--line);
  padding: 10px;
  background: linear-gradient(180deg, #091a35 0%, #07142a 100%);
  min-height: 0;
  overflow-y: auto;
}

.panel-right h3 {
  margin: 8px 0 10px;
  font-size: 15px;
}

.properties-panel {
  padding: 12px 10px;
}

.prop-system-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.prop-system-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid #2ea970;
  background: rgba(30, 163, 109, 0.14);
  color: #43d693;
  font-size: 11px;
  font-weight: 700;
}

.prop-tool-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid #27558a;
  background: rgba(39, 85, 138, 0.2);
  color: #9fc4ee;
  font-size: 11px;
  font-weight: 700;
}

.prop-group {
  margin-bottom: 14px;
}

.prop-label {
  display: block;
  margin-bottom: 6px;
  color: #9eb7d8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.prop-input-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

.prop-input-wrap input {
  margin: 0;
  height: 32px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.prop-input-wrap span {
  font-size: 10px;
  color: #93a8c4;
}

.prop-value {
  margin: 0;
  font-size: 12px;
  color: #d8e6fa;
  font-weight: 600;
}

.pipe-field {
  margin-bottom: 12px;
}

.draw-color-palette-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.draw-color-row {
  border: 1px solid #2a3f5f;
  border-radius: 8px;
  padding: 8px;
  background: #111f38;
}

.draw-color-row .pipe-sub-label {
  margin-bottom: 6px;
}

.draw-color-slot-inline {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 1fr;
  gap: 6px;
  align-items: center;
}

.draw-color-slot-inline input[type="color"] {
  margin: 0;
  width: 44px;
  min-width: 44px;
  height: 30px;
  padding: 0;
  border-radius: 6px;
}

.draw-color-slot-inline .ghost {
  margin: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 11px;
}

.pump-spec-card {
  margin-bottom: 10px;
  padding: 8px;
  border: 1px solid #2a3f5f;
  border-radius: 8px;
  background: #16243c;
}

.pump-spec-card .check-wrap {
  margin-bottom: 8px;
}

.pump-spec-card input[type="number"] {
  margin: 0;
  height: 32px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.coverage-group .note {
  margin-top: 8px;
}

.coverage-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.coverage-toggle-row .pipe-sub-label {
  margin: 0;
}

.coverage-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
}

.coverage-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.coverage-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border-radius: 999px;
  background: #162742;
  border: 1px solid #2f4d74;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.coverage-slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #93a8c4;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.coverage-switch input:checked + .coverage-slider {
  background: rgba(16, 185, 129, 0.22);
  border-color: #10b981;
}

.coverage-switch input:checked + .coverage-slider::before {
  transform: translateX(22px);
  background: #10b981;
}

#bgScalePercent,
#bgOffsetX,
#bgOffsetY,
#bgKnownDistance,
#bgRotationDeg {
  margin: 0;
  height: 32px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.prop-group input:disabled,
.prop-group select:disabled,
.prop-group button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.history-controls-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.history-btn {
  width: 100%;
  height: 32px;
  font-size: 12px;
  font-weight: 700;
}

.bg-offset-row {
  margin-bottom: 12px;
}

.bg-rotate-row {
  align-items: end;
  margin-bottom: 12px;
}

.bg-rotate-reset {
  height: 32px;
  min-width: 100px;
}

#bgOpacity {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#bgResetTransform {
  width: 100%;
  margin: 2px 0 0;
  height: 32px;
  font-size: 12px;
  font-weight: 600;
}

#bgCalibrateStart,
#bgCalibCancel,
#bgApplySuggestedScale {
  width: 100%;
  margin: 0 0 8px;
  height: 32px;
  font-size: 12px;
  font-weight: 600;
}

.diag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

.diag-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #2f4d74;
  background: #1a2233;
  color: #d2e3fb;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.diag-badge.ok {
  border-color: #1fa56d;
  background: rgba(31, 165, 109, 0.15);
  color: #39d58f;
}

.diag-badge.warn {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.diag-badge.bad {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.13);
  color: #f87171;
}

.diag-badge.muted {
  border-color: #385375;
  background: rgba(56, 83, 117, 0.18);
  color: #9db7d8;
}

.diag-value {
  font-size: 11px;
  color: #b9ccea;
}

.bg-calib-row {
  align-items: center;
}

.bg-calib-row #bgCalibUnit {
  flex: 0 0 88px;
  width: 88px;
  min-width: 88px;
}

.pipe-sub-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #e7effc;
}

.pipe-select {
  margin: 0;
  height: 36px;
  border-radius: 10px;
  border-color: #2f4d74;
  background: #1a2233;
  font-size: 12px;
  font-weight: 600;
  color: #f1f6ff;
}

.pipe-size-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.pipe-size-btn {
  margin: 0;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #2a3f5f;
  background: #1a2233;
  color: #9fc3ee;
  font-size: 11px;
  font-weight: 600;
  padding: 0 4px;
}

.pipe-size-btn:hover {
  background: #24324b;
}

.pipe-size-btn.active {
  border-color: var(--pipe-size-color, #22c55e);
  color: var(--pipe-size-color, #22c55e);
  box-shadow: inset 0 0 0 1px var(--pipe-size-color, #22c55e);
}

.pipe-legend {
  margin-top: 10px;
  height: 32px;
  border: 1px solid #2a3f5f;
  border-radius: 6px;
  background: #1a2233;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #b9ccea;
  font-size: 11px;
  font-weight: 700;
}

.pipe-legend-swatch {
  width: 32px;
  height: 14px;
  border-radius: 4px;
  display: inline-block;
}

.unit-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.unit-btn {
  margin: 0;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #2a3f5f;
  background: #1a2233;
  color: #dce9fb;
  font-size: 12px;
  text-transform: lowercase;
}

.unit-btn.active {
  border-color: #ffffff;
  color: #ffffff;
  background: #2e3441;
}

.tool-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-panel {
  overflow: visible;
}

.system-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
  padding: 4px;
  border: 1px solid #1e3658;
  border-radius: 10px;
  background: #101f3a;
}

.tool-system-switch {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.system-tab {
  width: 100%;
  margin: 0;
  min-height: 34px;
  font-weight: 600;
  font-size: 11px;
  padding: 0;
  border-radius: 8px;
  background: #111f38;
  border-color: #273f60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.system-tab.active {
  border-color: #2dd58d;
  box-shadow: inset 0 0 0 1px rgba(45, 213, 141, 0.56);
  background: #1f9f67;
  color: #e8fff3;
}

.system-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
}

.system-icon svg {
  width: 20px;
  height: 20px;
}

.tool-section {
  margin-bottom: 14px;
}

.tool-section h4 {
  margin: 0 0 8px;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: pre-line;
  color: #93c5fd;
}

.section-tools h4 {
  display: none;
}

.section-detectors h4 {
  color: #ff7d3a;
}

.section-devices h4 {
  color: #ff7d3a;
}

.section-cables h4 {
  color: #ff7d3a;
}

.section-equipment h4 {
  color: #19d5a4;
}

.section-sprinkler h4 {
  color: #19d5a4;
}

.section-valves h4 {
  color: #19d5a4;
}

.section-pipes h4 {
  color: #19d5a4;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.section-tools .tool-grid {
  grid-template-columns: 1fr;
  justify-items: center;
}

.section-tools .tool-btn,
.section-tools .tool-group-wrap,
.section-tools .tool-system-switch {
  width: 50%;
  min-width: 42px;
}

.tool-group-wrap {
  position: relative;
  min-width: 0;
  overflow: visible;
}

.tool-group-btn {
  position: relative;
  justify-content: center;
}

.tool-group-caret {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 9px;
  color: #9cb3d1;
}

.tool-group-popover {
  position: absolute;
  top: 0;
  left: calc(100% + 6px);
  z-index: 100;
  min-width: 150px;
  max-width: 220px;
  width: auto;
  padding: 6px 4px;
  border: 1px solid #2a3f5f;
  border-radius: 8px;
  background: #0b1a33;
  box-shadow: 0 12px 28px rgba(3, 10, 20, 0.45);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.tool-group-popover[hidden] {
  display: none;
}

.tool-group-opt {
  margin: 0;
  width: 100%;
  min-height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: #10233f;
  color: #d7e4f7;
}

.tool-group-opt.active {
  border-color: #2dd58d;
  background: #14344d;
}

.tool-group-opt-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #dbe9fb;
  line-height: 1;
  white-space: nowrap;
}

.tool-grid .tool-btn:only-child {
  grid-column: 1 / -1;
}

.tool-btn {
  width: 100%;
  margin: 0;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #111f38;
  border-color: #273f60;
  padding: 0;
}

.tool-btn.icon-only {
  min-height: 34px;
}

.tool-btn:hover {
  background: #162b48;
}

.tool-btn.active {
  border-color: #2dd58d;
  box-shadow: inset 0 0 0 1px rgba(45, 213, 141, 0.56);
  background: #1f9f67;
  color: #e8fff3;
}

.tool-glyph {
  min-width: 28px;
  height: 20px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  background: #0b1830;
  border: 1px solid #2f4d74;
  padding: 0 4px;
}

.tool-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-icon svg {
  width: 20px;
  height: 20px;
}

.tool-icon svg * {
  vector-effect: non-scaling-stroke;
}

.tool-name {
  display: none;
}

.tool-section + .tool-section {
  border-top: 1px solid #1d3353;
  padding-top: 8px;
}

.hint-note {
  margin: 8px 2px 0;
  font-size: 10px;
  line-height: 1.35;
}

.canvas-wrap {
  position: relative;
  z-index: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #dde5f0;
  min-height: 0;
}

.canvas-stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.canvas-stage {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  box-shadow: none;
  background-color: #dde5f0;
  background-image:
    linear-gradient(to right, rgba(62, 84, 123, 0.13) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(62, 84, 123, 0.13) 1px, transparent 1px);
  background-size: 24px 24px;
}

#cad {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

.worksheet-bar {
  height: 38px;
  border-top: 1px solid #244566;
  background: linear-gradient(180deg, #0b1a34 0%, #09162b 100%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  flex-shrink: 0;
}

.ws-tabs-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1;
}

.ws-tab {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid #274469;
  border-radius: 8px;
  background: #0d223f;
  padding: 2px;
}

.ws-tab.active {
  border-color: #20c585;
  background: #0f2f4a;
  box-shadow: inset 0 0 0 1px rgba(32, 197, 133, 0.35);
}

.ws-tab-btn {
  height: 28px;
  min-width: 88px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d8e6fb;
  font-size: 12px;
  font-weight: 600;
  padding: 0 10px;
}

.ws-tab-btn:hover {
  background: #123252;
}

.ws-tab.active .ws-tab-btn {
  color: #e7fff4;
}

.ws-tab-close {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b3c6e1;
  padding: 0;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

.ws-tab:hover .ws-tab-close,
.ws-tab.active .ws-tab-close {
  opacity: 1;
  pointer-events: auto;
}

.ws-tab-close:hover {
  background: #17395a;
  color: #f5fbff;
}

.ws-add-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #2c4a70;
  background: #102945;
  color: #e1f0ff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.ws-add-btn:hover {
  background: #173a5c;
}

.note {
  color: var(--muted);
  font-size: 12px;
}

.hint-note {
  margin: 8px 2px 0;
}

.row {
  display: flex;
  gap: 8px;
}

.row-tight {
  margin: 0 0 8px;
}

.row > * {
  flex: 1;
}

.check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #d8e6fa;
}

.check-wrap input {
  margin: 0;
  width: 14px;
  height: 14px;
}

.cloud-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}

.cloud-item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cloud-item-title {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.cloud-item-meta {
  margin: 0 2px;
  font-size: 11px;
  color: var(--muted);
}

.cloud-item-actions {
  display: flex;
  gap: 6px;
}

.cloud-item-actions > button {
  min-width: 60px;
}

.ghost {
  background: #0d1f3a;
  border-color: #2a486f;
}

.hidden {
  display: none;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 10, 22, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid #2b4d76;
  border-radius: 10px;
  background: #0a1b34;
  padding: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.modal-form input,
.modal-form select {
  margin-bottom: 8px;
}

.modal-form label {
  display: block;
  font-size: 11px;
  color: #9eb4d1;
  margin-bottom: 4px;
}

.page-setup-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 12px;
}

.page-setup-tab {
  min-height: 38px;
  background: #081a33;
  border-color: #21405f;
  color: #d8e6fb;
  font-weight: 700;
}

.page-setup-tab.active {
  background: rgba(16, 185, 129, 0.14);
  border-color: #10b981;
  color: #d6fff2;
}

.page-setup-pane {
  border-top: 1px solid #244466;
  padding-top: 12px;
}

.page-bg-group {
  margin-top: 0;
}

.scale-modal-card {
  width: min(560px, calc(100vw - 24px));
}

.scale-modal-card .note {
  margin: 0 0 10px;
  font-size: 13px;
}

.scale-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scale-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 64px;
  background: #081a33;
  border-color: #21405f;
  color: #d8e6fb;
}

.scale-mode-btn strong {
  font-size: 15px;
}

.scale-mode-btn span {
  color: #9cb5d6;
  font-size: 12px;
}

.scale-mode-btn.active {
  background: rgba(16, 185, 129, 0.14);
  border-color: #10b981;
}

.scale-pane {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #244466;
}

.scale-pane label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #dbe9ff;
  font-weight: 600;
}

.scale-pane input {
  margin: 0;
}

.scale-pane .prop-input-wrap {
  margin-bottom: 8px;
}

.scale-pane .ghost {
  background: #0a1d38;
  border-color: #2a496e;
  color: #e6eefb;
}

.scale-ref-info,
.scale-ref-result {
  margin-top: 10px;
  border: 1px solid #26486d;
  border-radius: 9px;
  padding: 10px 12px;
  background: rgba(8, 24, 46, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scale-ref-info strong,
.scale-ref-result strong {
  color: #10d7a0;
}

.scale-ref-card {
  margin-top: 10px;
  border: 1px solid #10b981;
  border-radius: 10px;
  padding: 10px 12px 12px;
  background: rgba(16, 185, 129, 0.08);
}

.scale-unit-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 170px;
  flex: 0 0 auto;
}

.scale-unit-btn {
  min-height: 40px;
  background: #0a1b35;
  border-color: #2b4668;
  color: #c5d7f1;
  font-weight: 700;
}

.scale-unit-btn.active {
  background: #10b981;
  border-color: #10b981;
  color: #042b1f;
}

.scale-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

.scale-scope-row {
  margin-top: 12px;
  border-top: 1px solid #244466;
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.scale-scope-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #ceddf4;
}

.scale-scope-opt input {
  margin: 0;
  width: auto;
}

.bq-modal-card {
  width: min(760px, calc(100vw - 24px));
}

.bq-tabs {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.bq-tab {
  margin: 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #2a486d;
  border-radius: 8px;
  background: #0d203b;
  color: #c9d9f0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.bq-tab.active {
  border-color: #21c986;
  background: rgba(33, 201, 134, 0.14);
  color: #dffcef;
}

.bq-tab-content {
  min-height: 160px;
}

.bq-section {
  margin-top: 12px;
}

.bq-section h4 {
  margin: 0 0 8px;
  color: #19d5a4;
  font-size: 20px;
}

.bq-table {
  width: 100%;
  border-collapse: collapse;
  background: #1b2435;
  border-radius: 10px;
  overflow: hidden;
}

.bq-table th,
.bq-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #2b3f5f;
  text-align: left;
  font-size: 15px;
}

.bq-table th {
  color: #9cb3d1;
  font-weight: 700;
}

.bq-table .num {
  font-weight: 700;
}

.bq-table tbody tr:last-child td {
  border-bottom: 0;
}

.bq-modal-footer {
  justify-content: space-between;
  align-items: center;
}

.bq-total-section {
  border-top: 1px solid #284868;
  padding-top: 10px;
}

@media (max-width: 1280px) {
  .top-action {
    font-size: 12px;
    padding: 0 8px;
  }

  .top-project input {
    font-size: 12px;
  }

  .body-grid {
    grid-template-columns: 60px 1fr 270px;
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-rows: auto auto 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 8px;
  }

  .brand {
    min-width: 0;
  }

  .top-project {
    order: 2;
    width: 100%;
  }

  .top-actions-bar {
    margin-left: auto;
    max-width: 100%;
    order: 3;
    width: 100%;
  }

  .body-grid {
    grid-template-columns: 58px 1fr;
  }

  .panel-right {
    display: none;
  }
}
