:root { color-scheme: light; font-family: Mulish, Arial, sans-serif; color: #1f2b21; background: #f5f5f5; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; height: 100vh; overflow: hidden; background: #f5f5f5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { height: 100vh; min-height: 0; display: grid; grid-template-columns: 344px minmax(0, 1fr); grid-template-rows: 88px minmax(0, 1fr); overflow: hidden; }
.app-header { grid-column: 1 / -1; min-height: 88px; padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid #d6e0d3; background: #fff; }
.eyebrow { margin: 0 0 3px; color: #417033; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0; }
h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: 0; }
h2 { margin: 0 0 10px; font-size: 15px; }
.file-state { max-width: 48%; overflow: hidden; color: #536154; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.tool-panel { min-height: 0; overflow-y: auto; padding: 16px; border-right: 1px solid #d6e0d3; background: #fff; }
.panel-section { padding: 16px 0; border-bottom: 1px solid #e6ece5; }
.panel-section:first-child { padding-top: 0; }
.panel-section:last-child { border-bottom: 0; }
.upload-control, .tool-button, .secondary-button, .button-grid button { border: 1px solid #b6d8ab; border-radius: 6px; transition: background .15s ease, border-color .15s ease; }
.upload-control { display: flex; align-items: center; gap: 11px; padding: 13px; color: #fff; background: #417033; border-color: #417033; }
.upload-control strong, .upload-control small { display: block; }
.upload-control strong { font-size: 14px; }
.upload-control small { margin-top: 3px; color: #e7f2e3; font-size: 11px; }
.upload-icon { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #b6d8ab; border-radius: 50%; font-weight: 800; }
#fbxInput { position: absolute; width: 1px; height: 1px; opacity: 0; }
.status-text, .hint { margin: 9px 0 0; color: #667568; font-size: 12px; line-height: 1.45; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.button-grid button, .secondary-button, .tool-button { width: 100%; padding: 9px 10px; color: #314833; background: #fff; font-size: 13px; font-weight: 700; }
.button-grid button:hover, .secondary-button:hover { border-color: #417033; background: #e7f2e3; }
.tool-button { margin-top: 10px; color: #fff; background: #417033; border-color: #417033; }
.tool-button.is-active { color: #fff; background: #cc2841; border-color: #cc2841; }
.secondary-button { margin-top: 8px; }
.measurement-result { display: block; margin-top: 9px; color: #417033; font-size: 13px; font-weight: 800; }
.dimension-inputs { display: grid; gap: 7px; margin-top: 10px; }
.dimension-inputs label { display: grid; grid-template-columns: 1fr 72px 22px; align-items: center; gap: 5px; color: #536154; font-size: 12px; }
.dimension-inputs input { width: 100%; padding: 6px; border: 1px solid #cbd7c9; border-radius: 4px; color: #1f2b21; }
.calibration-details { margin-top: 10px; padding-top: 9px; border-top: 1px solid #e1e9df; }
.calibration-details summary { color: #417033; font-size: 12px; font-weight: 800; cursor: pointer; }
.object-name { min-height: 20px; margin: 0 0 8px; font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.object-dimensions { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; gap: 6px; }
.object-dimensions div { padding: 8px 6px; border: 1px solid #e1e9df; border-radius: 5px; background: #fbfdfb; }
.object-dimensions dt { color: #667568; font-size: 10px; }.object-dimensions dd { margin: 4px 0 0; color: #417033; font-size: 12px; font-weight: 800; }
.note-label { display: block; margin-top: 12px; font-size: 12px; font-weight: 700; }.selection-section textarea { width: 100%; resize: vertical; margin-top: 6px; padding: 8px; border: 1px solid #cbd7c9; border-radius: 5px; line-height: 1.35; }
.viewer-panel { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #eef1ed; }.viewer { width: 100%; height: 100%; }.viewer canvas { display: block; width: 100%; height: 100%; outline: none; }.viewer-toolbar { position: absolute; z-index: 2; top: 14px; right: 16px; left: 16px; display: flex; justify-content: space-between; gap: 12px; pointer-events: none; }.tool-hint, .mode-badge { padding: 8px 10px; border: 1px solid #d6e0d3; border-radius: 5px; color: #536154; background: rgba(255,255,255,.92); font-size: 12px; }.mode-badge { color: #417033; font-weight: 800; white-space: nowrap; }.empty-state { position: absolute; top: 50%; left: 50%; width: min(420px, calc(100% - 40px)); padding: 24px; text-align: center; transform: translate(-50%, -50%); border: 1px solid #d6e0d3; border-radius: 8px; background: rgba(255,255,255,.95); }.empty-state.is-hidden { display: none; }.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 6px; color: #fff; background: #417033; font-weight: 800; }.empty-state h2 { font-size: 17px; }.empty-state p { margin: 0; color: #536154; font-size: 13px; line-height: 1.5; }
@media (max-width: 760px) { body { height: auto; overflow: auto; } .app-shell { height: auto; min-height: 100vh; overflow: visible; display: block; }.app-header { min-height: 76px; padding: 14px 16px; }.app-header h1 { font-size: 18px; }.file-state { max-width: 46%; }.tool-panel { overflow: visible; border-right: 0; border-bottom: 1px solid #d6e0d3; }.viewer { height: 62vh; min-height: 430px; }.viewer-toolbar { display: block; }.tool-hint, .mode-badge { display: table; margin-bottom: 6px; }.empty-state { padding: 18px; }.object-dimensions { max-width: 330px; } }

.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.plan-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.segmented-control button, .plan-tools button { min-height: 36px; padding: 8px; border: 1px solid #b6d8ab; border-radius: 6px; color: #314833; background: #fff; font-size: 13px; font-weight: 800; }
.segmented-control button.is-active, .plan-tools button.is-active { color: #fff; background: #417033; border-color: #417033; }
.plan-banner { margin: 10px 0 0; padding: 8px; border-left: 3px solid #cc8a1f; color: #684c12; background: #fff8e8; font-size: 12px; line-height: 1.4; }
.cut-height { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: #536154; font-size: 12px; font-weight: 800; }
.cut-height output { color: #417033; }
#cutHeight { width: 100%; accent-color: #417033; }
.plan-section button:disabled { cursor: not-allowed; opacity: .45; }
.product-panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e6ece5; }
.product-status { margin: 0; color: #314833; font-size: 12px; font-weight: 800; }
.product-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.product-actions .tool-button, .product-actions .secondary-button { margin-top: 0; }
.plan-selection-panel { margin-top: 10px; }
.plan-selection-heading { margin: 0 0 6px; color: #536154; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.plan-selection-list { display: grid; max-height: 180px; gap: 5px; overflow-y: auto; }
.plan-selection-empty { margin: 0; color: #667568; font-size: 12px; line-height: 1.4; }
.plan-selection-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 6px 7px; border: 1px solid #b6d8ab; border-radius: 5px; background: #f4f9f2; }
.plan-selection-title { overflow: hidden; padding: 0; border: 0; color: #314833; background: transparent; font-size: 12px; font-weight: 700; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.plan-selection-row .icon-button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; color: #536154; background: transparent; font-size: 17px; line-height: 1; }
.plan-selection-row .icon-button:hover { color: #cc2841; background: #f8dde1; }
.product-list { display: grid; gap: 6px; margin-top: 10px; }
.product-empty { margin: 0; color: #667568; font-size: 12px; }
.product-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; padding: 7px; border: 1px solid #e1e9df; border-radius: 6px; background: #fbfdfb; }
.product-row.is-active { border-color: #417033; background: #e7f2e3; }
.product-title { overflow: hidden; padding: 0; border: 0; color: #314833; background: transparent; font-size: 12px; font-weight: 800; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.product-count { color: #417033; font-size: 11px; font-weight: 800; white-space: nowrap; }
.product-row .icon-button { width: 25px; height: 25px; padding: 0; border: 0; border-radius: 4px; color: #667568; background: transparent; font-size: 17px; line-height: 1; }
.product-row .icon-button:hover { color: #cc2841; background: #f8dde1; }
.import-drawing { display: block; width: 100%; margin-top: 8px; padding: 9px 10px; border: 1px solid #b6d8ab; border-radius: 6px; color: #314833; font-size: 13px; font-weight: 700; text-align: center; cursor: pointer; }
#importDrawing { position: absolute; width: 1px; height: 1px; opacity: 0; }
.annotation-list { display: grid; gap: 7px; }
.annotation-empty { margin: 0; color: #667568; font-size: 12px; line-height: 1.45; }
.annotation-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 7px; align-items: center; padding: 8px; border: 1px solid #e1e9df; border-radius: 6px; background: #fbfdfb; }
.annotation-row.is-selected { border-color: #cc2841; background: #fff5f6; }
.annotation-title { overflow: hidden; padding: 0; border: 0; color: #314833; background: transparent; font-size: 12px; font-weight: 800; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.annotation-value { color: #417033; font-size: 12px; font-weight: 800; white-space: nowrap; }
.annotation-actions { display: flex; gap: 2px; }
.annotation-actions button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 4px; color: #536154; background: transparent; font-size: 15px; }
.annotation-actions button:hover { color: #cc2841; background: #f8dde1; }
.plan-overlay { position: absolute; z-index: 3; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.plan-overlay rect { vector-effect: non-scaling-stroke; }
.viewer-toolbar { z-index: 4; }
.empty-state { z-index: 5; }

.plan-overlay[hidden] { display: none; }

.sheet-controls { display: grid; gap: 10px; margin-top: 12px; }
.sheet-target { margin: 0; color: #536154; font-size: 12px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.sheet-view-buttons button.is-active { color: #fff; background: #417033; border-color: #417033; }
.sheet-controls[hidden] { display: none; }
.export-views { display: grid; gap: 6px; margin-top: 9px; }
.export-views label { display: flex; align-items: center; gap: 7px; color: #536154; font-size: 12px; font-weight: 700; }
.export-views input { accent-color: #417033; }
.secondary-button.is-active { color: #fff; background: #cc2841; border-color: #cc2841; }
.annotation-list { max-height: 300px; overflow-y: auto; }
.panel-details > summary { color: #1f2b21; font-size: 15px; font-weight: 800; cursor: pointer; }
.panel-details[open] > summary { margin-bottom: 10px; }
.summary-count { color: #667568; font-size: 13px; font-weight: 700; }
.calibration-details textarea { width: 100%; resize: vertical; margin-top: 8px; padding: 8px; border: 1px solid #cbd7c9; border-radius: 5px; line-height: 1.35; }

.toolbar-actions { display: flex; align-items: flex-start; gap: 8px; pointer-events: none; }
.toolbar-toggle { pointer-events: auto; padding: 8px 10px; border: 1px solid #b6d8ab; border-radius: 5px; color: #314833; background: rgba(255,255,255,.92); font-size: 12px; font-weight: 800; white-space: nowrap; }
.toolbar-toggle.is-off { color: #8a6d1f; border-color: #e2c98a; background: #fff8e8; }
.toolbar-toggle[hidden] { display: none; }
.load-progress { margin-top: 16px; }
.load-progress[hidden] { display: none; }
.load-progress-track { height: 8px; overflow: hidden; border-radius: 4px; background: #e6ece5; }
.load-progress-bar { width: 0%; height: 100%; border-radius: 4px; background: #417033; transition: width .2s ease; }
.load-progress-text { margin: 8px 0 0; color: #536154; font-size: 12px; font-weight: 700; }

/* Клиентский режим (?p=токен): только просмотр и экспорт, инструменты редактирования скрыты. */
.is-client .panel-upload,
.is-client .plan-tools,
.is-client #addObjectBounds, .is-client #addProjectBounds,
.is-client #addSheetDimensions, .is-client #sheetDimensionTool,
.is-client .plan-selection-panel, .is-client #addToSheet, .is-client .product-actions,
.is-client .product-row .icon-button,
.is-client .annotation-actions [data-action="edit"], .is-client .annotation-actions [data-action="delete"],
.is-client .calibration-section .calibration-details,
.is-client .selection-section .calibration-details,
.is-client .document-section { display: none; }
