:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --text: #18202c;
  --muted: #687386;
  --line: #e3e8ef;
  --primary: #3273dc;
  --primary-dark: #255eb8;
  --primary-soft: #edf4ff;
  --green: #2b8a66;
  --green-soft: #eaf7f1;
  --amber: #a76312;
  --amber-soft: #fff6e7;
  --red: #b54444;
  --red-soft: #fff0f0;
  --shadow: 0 12px 32px rgba(25, 45, 75, .07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.hidden { display: none !important; }

.app-sidebar { width: 248px; position: fixed; inset: 0 auto 0 0; z-index: 25; display: flex; flex-direction: column; padding: 22px 16px; background: #fff; border-right: 1px solid var(--line); }
.app-sidebar .brand { padding: 0 8px 24px; }
.app-sidebar nav { display: grid; gap: 5px; }
.app-sidebar nav a { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 0 12px; border-radius: 9px; color: #4f5d70; text-decoration: none; font-weight: 650; }
.app-sidebar nav a:hover, .app-sidebar nav a.active { color: var(--primary-dark); background: var(--primary-soft); }
.app-sidebar nav a span { width: 20px; font-size: 18px; text-align: center; }
.sidebar-foot { margin-top: auto; }
.topbar { height: 68px; margin-left: 248px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.breadcrumbs { color: var(--muted); font-size: 13px; }
.engineer-profile { display: flex; align-items: center; gap: 9px; }
.engineer-profile > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #e8eef7; color: #42566f; font-size: 11px; font-weight: 750; }
.engineer-profile b, .engineer-profile small { display: block; }
.engineer-profile small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.engineer-profile .icon-button { margin-left: 5px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; background: radial-gradient(circle at 20% 10%, #edf4ff, transparent 34%), #f6f8fb; }
.auth-card { width: min(100%, 440px); display: grid; gap: 25px; padding: 34px; background: #fff; border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 24px 70px rgba(35, 54, 78, .12); }
.auth-card h1 { margin: 6px 0 8px; font-size: 30px; }
.auth-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.auth-form { display: grid; gap: 15px; }
.auth-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; }
.auth-form label small { color: var(--muted); font-weight: 400; }
.auth-form input { width: 100%; min-height: 45px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; }
.auth-form input:focus { outline: 2px solid #cbdcf4; border-color: #809bc0; }
.auth-form .button { width: 100%; min-height: 45px; margin-top: 4px; }
.auth-switch { text-align: center; font-size: 13px; }
.auth-switch a { color: var(--primary); font-weight: 700; }
.auth-inline-link { justify-self: end; margin-top: -7px; color: var(--primary); font-size: 12px; font-weight: 700; }
.local-mail-link { text-align: center; text-decoration: none; }
.mailbox-card { width: min(100%, 760px); }
.mailbox-list { display: grid; gap: 14px; max-height: 56vh; overflow: auto; }
.mailbox-message { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #f8fafc; }
.mailbox-message small { color: var(--muted); }
.mailbox-message h2 { margin: 8px 0; font-size: 17px; }
.mailbox-message p { white-space: pre-wrap; font-size: 13px; }
.mailbox-message .button { display: inline-block; width: auto; margin-top: 14px; text-decoration: none; }
.mailbox-empty { padding: 28px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }
.field-error { color: #b74242 !important; font-size: 12px; }
.mobile-menu { display: none; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: var(--primary); color: white; font-weight: 750; letter-spacing: -.03em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.local-badge { color: #50705f; background: var(--green-soft); border: 1px solid #d8eee4; border-radius: 999px; padding: 7px 11px; font-size: 12px; }
.local-badge span { display: inline-block; width: 7px; height: 7px; background: #43a77e; border-radius: 50%; margin-right: 6px; }

.page-shell, .shell-content { width: min(1440px, calc(100% - 312px)); margin: 0 32px 0 auto; padding: 38px 0 64px; }
.shell-page { width: 100%; }
.shell-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.shell-page-head h1 { margin: 8px 0 7px; font-size: 34px; letter-spacing: -.04em; }
.shell-page-head p { margin: 0; color: var(--muted); }
.back-link { display: block; margin-bottom: 22px; color: var(--muted); text-decoration: none; }
.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.project-card { display: block; min-height: 190px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: inherit; text-decoration: none; box-shadow: 0 4px 14px rgba(31,50,76,.035); }
.project-card:hover { border-color: #b9cbe3; box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card .project-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: var(--primary-soft); color: var(--primary); font-size: 20px; }
.project-card h2 { margin: 17px 0 7px; font-size: 18px; }
.project-card p { min-height: 36px; margin: 0; color: var(--muted); line-height: 1.45; }
.project-card footer { display: flex; justify-content: space-between; margin-top: 18px; color: var(--muted); font-size: 11px; }
.empty-projects, .development-card { padding: 72px 24px; border: 1px dashed #cad4e2; border-radius: 16px; background: #fff; text-align: center; }
.empty-projects > span, .development-card > span { display: block; color: var(--primary); font-size: 38px; }
.empty-projects h2, .development-card h1 { margin: 15px 0 8px; }
.empty-projects p, .development-card p { max-width: 570px; margin: 0 auto 22px; color: var(--muted); line-height: 1.6; }
.module-groups { display: grid; gap: 28px; }
.module-group h2 { margin-bottom: 12px; font-size: 17px; }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.module-card { min-height: 164px; padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: #fff; color: inherit; text-decoration: none; }
.module-card.available { border-top: 3px solid var(--primary); }
.module-card h3 { margin: 14px 0 6px; }
.module-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.module-status { display: inline-flex; padding: 4px 8px; border-radius: 20px; background: #eef1f5; color: var(--muted); font-size: 10px; font-weight: 700; }
.module-card.available .module-status { color: var(--green); background: var(--green-soft); }
.knowledge-landing { padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.knowledge-landing p { color: var(--muted); }
.knowledge-base-link { width: 100%; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.knowledge-base-link:hover { border-color: #b5c8e2; box-shadow: var(--shadow); }
.knowledge-base-link small { color: var(--muted); }
.project-dialog { width: min(620px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 70px rgba(20,35,55,.22); }
.project-dialog::backdrop { background: rgba(22,31,44,.38); backdrop-filter: blur(2px); }
.project-dialog form { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; }
.dialog-head h2 { margin: 7px 0 0; }
.project-dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 24px; }
.project-dialog-actions > div, .confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.danger-text { padding: 8px 0; border: 0; background: transparent; color: var(--red); cursor: pointer; }
.danger-text:hover { text-decoration: underline; }
.button.danger { background: var(--red); color: white; }
.button.danger:hover { background: #963737; }
.danger-label { color: var(--red); }
.confirm-dialog { width: min(510px, calc(100% - 28px)); padding: 24px; border: 0; border-radius: 16px; box-shadow: 0 24px 70px rgba(20,35,55,.24); }
.confirm-dialog::backdrop { background: rgba(22,31,44,.45); backdrop-filter: blur(2px); }
.confirm-dialog > p { margin: 20px 0 24px; color: var(--muted); line-height: 1.55; }
.knowledge-inline-link { min-height: 40px; padding: 0 5px; border: 0; background: transparent; color: var(--primary-dark); cursor: pointer; text-align: left; }
.knowledge-inline-link:hover strong, .text-link:hover { text-decoration: underline; }
.knowledge-inline-link small { display: block; color: var(--muted); font-size: 10px; }
.text-link { padding: 0; border: 0; background: transparent; color: var(--primary-dark); cursor: pointer; font: inherit; }
.upload-view { width: min(820px, 100%); margin: 12px auto 0; }
.intro { max-width: 690px; margin: 0 auto 38px; text-align: center; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.intro h1 { margin: 12px 0 14px; font-size: clamp(34px, 5vw, 50px); line-height: 1.08; letter-spacing: -.045em; }
.intro p { color: var(--muted); font-size: 17px; line-height: 1.6; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 24px; }
.step { display: flex; align-items: center; gap: 11px; position: relative; color: var(--muted); }
.step:not(:last-child)::after { content: ""; height: 1px; background: var(--line); position: absolute; left: 48px; right: 12px; top: 17px; z-index: -1; }
.step > span { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 50%; font-weight: 700; }
.step.active > span { color: white; background: var(--primary); border-color: var(--primary); }
.step b, .step small { display: block; background: var(--bg); padding-right: 7px; }
.step b { color: var(--text); font-size: 13px; }
.step small { margin-top: 3px; font-size: 11px; }

.upload-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px; box-shadow: var(--shadow); }
.drop-zone { width: 100%; min-height: 270px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1.5px dashed #b9c9dd; border-radius: 14px; background: #fbfdff; cursor: pointer; transition: .2s ease; }
.drop-zone:hover, .drop-zone.dragging { background: var(--primary-soft); border-color: var(--primary); transform: translateY(-1px); }
.upload-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 18px; border-radius: 15px; background: var(--primary-soft); color: var(--primary); font-size: 26px; font-weight: 400; }
.drop-zone strong { font-size: 17px; }
.drop-zone > span:not(.upload-icon) { color: var(--muted); margin-top: 7px; }
.drop-zone em { color: #98a1af; font-style: normal; font-size: 12px; margin-top: 22px; }
.template-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 18px 10px 7px; }
.template-row b, .template-row span { display: block; }
.template-row span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.privacy-note { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }
.privacy-note span { color: var(--green); margin-right: 4px; }
.import-errors { margin-top: 18px; padding: 20px; border: 1px solid #efcccc; border-radius: var(--radius); background: var(--red-soft); }
.import-error-list { display: grid; gap: 8px; margin-top: 15px; }
.import-error-item { display: flex; gap: 11px; padding: 12px 13px; border-radius: 10px; background: rgba(255,255,255,.7); }
.import-error-item > span { width: 22px; height: 22px; display: grid; place-items: center; flex: 0 0 22px; border-radius: 50%; background: #efcece; color: var(--red); font-weight: 800; }
.import-error-item b { font-size: 12px; }
.import-error-item p { margin: 3px 0 0; color: #7e4747; font-size: 12px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 17px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-weight: 650; cursor: pointer; transition: .16s ease; white-space: nowrap; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: var(--surface); border-color: var(--line); color: #334054; }
.button.secondary:hover { border-color: #b9c5d4; background: var(--surface-soft); }
.button:disabled { opacity: .55; cursor: wait; }

.loading-view { min-height: calc(100vh - 190px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.loader { width: 54px; height: 54px; border: 4px solid #dce8f8; border-top-color: var(--primary); border-radius: 50%; animation: spin .9s linear infinite; }
.loading-view h2 { margin: 24px 0 8px; font-size: 24px; }
.loading-view p { color: var(--muted); }
.loading-line { width: 300px; height: 4px; overflow: hidden; background: #e5eaf1; border-radius: 99px; margin-top: 20px; }
.loading-line span { display: block; width: 38%; height: 100%; background: var(--primary); border-radius: inherit; animation: progress 1.3s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progress { from { transform: translateX(-110%); } to { transform: translateX(360%); } }

.workspace { width: 100%; }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.workspace-head h1 { margin: 7px 0 6px; font-size: 30px; letter-spacing: -.035em; }
.workspace-head p { margin: 0; color: var(--muted); }
.dot { margin: 0 8px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 0; margin-bottom: 22px; cursor: pointer; }
.text-button:hover { color: var(--primary); }
.head-actions { display: flex; gap: 10px; }

.status-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 18px; margin-bottom: 18px; border: 1px solid; border-radius: 12px; }
.status-banner > div { display: flex; align-items: center; gap: 10px; }
.status-banner .status-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; border-radius: 50%; font-weight: 800; }
.status-banner p { margin: 2px 0 0; font-size: 12px; }
.status-banner.ready { color: #236e52; background: var(--green-soft); border-color: #d0ebdf; }
.status-banner.ready .status-icon { background: #d3ede2; }
.status-banner.attention { color: #875412; background: var(--amber-soft); border-color: #f2dfbd; }
.status-banner.attention .status-icon { background: #f5dfb7; }
.status-banner.blocked { color: #974040; background: var(--red-soft); border-color: #f0d0d0; }
.status-banner.blocked .status-icon { background: #f1d1d1; }
.banner-action { border: 0; background: transparent; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 650; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metrics article { min-height: 128px; padding: 19px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.metrics span, .metrics small { display: block; color: var(--muted); }
.metrics strong { display: block; margin: 10px 0 4px; font-size: 27px; letter-spacing: -.035em; }
.metrics small { font-size: 11px; }
.metrics .attention { background: #fffcf7; }
.metrics .attention strong { color: var(--amber); }

.findings-panel, .table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.findings-panel { margin-bottom: 18px; padding: 20px; }
.section-title { display: flex; justify-content: space-between; gap: 18px; }
.section-title h2, .table-tools h2 { margin-bottom: 5px; font-size: 18px; }
.section-title p, .table-tools p { margin: 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 25px; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); color: var(--text); }
.findings-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 16px; }
.finding-item { width: 100%; display: flex; gap: 11px; padding: 14px; border-radius: 10px; background: var(--surface-soft); border: 1px solid #edf0f4; cursor: pointer; text-align: left; color: inherit; }
.finding-item:hover { border-color: #cad4e1; }
.finding-dot { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 6px; border-radius: 50%; background: var(--amber); }
.finding-item.error .finding-dot { background: var(--red); }
.finding-item b, .finding-item span { display: block; }
.finding-item b { font-size: 13px; }
.finding-content { min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.finding-content ul, .room-finding-box ul { margin: 7px 0 0; padding-left: 17px; }
.finding-content li + li, .room-finding-box li + li { margin-top: 5px; }
.finding-content em { display: block; margin-top: 9px; color: var(--primary); font-style: normal; font-weight: 650; }

.table-card { overflow: hidden; }
.table-tools { min-height: 82px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.selection-bar { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 20px; border-bottom: 1px solid #cfe0f7; background: var(--primary-soft); }
.selection-bar > div { display: flex; align-items: center; gap: 10px; }
.selection-bar > div:first-child { align-items: flex-start; flex-direction: column; gap: 3px; }
.selection-bar span { color: var(--muted); font-size: 12px; }
.tools-right { display: flex; align-items: center; gap: 10px; }
.search { width: 230px; height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--muted); }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.filter { display: flex; padding: 3px; background: #f0f3f7; border-radius: 9px; }
.filter-button { min-height: 32px; padding: 0 12px; border: 0; background: transparent; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 12px; }
.filter-button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(20,30,45,.08); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th { padding: 11px 12px; background: #fafbfc; color: #7e8795; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 14px 12px; border-bottom: 1px solid #edf0f4; vertical-align: middle; }
tbody tr { transition: background .13s; }
tbody tr:hover { background: #fbfcfe; }
tbody tr[data-room-row] { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
.check-cell { width: 42px; text-align: center; }
.check-cell input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.room-cell b, .room-cell span, .system-cell span { display: block; }
.room-cell b { max-width: 240px; }
.room-cell span, .system-cell span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.auto-filled-badge { display: inline-flex !important; width: fit-content; margin-top: 5px !important; padding: 3px 7px; border-radius: 99px; background: var(--green-soft); color: var(--green) !important; font-size: 10px !important; font-weight: 700; line-height: 1.2; }
.auto-filled-badge.hidden { display: none !important; }
.table-badge { margin-top: 5px; }
.user-defined-badge { display: inline-flex !important; width: fit-content; margin-top: 5px; padding: 3px 7px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 10px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.user-defined-badge.hidden { display: none !important; }
.manual-airflow-fieldset { padding: 16px; border: 1px solid #cfe0f7; border-radius: 12px; background: var(--primary-soft); }
.manual-airflow-fieldset legend { display: flex; align-items: center; gap: 8px; }
.attribute-line { display: block; margin-top: 5px; color: var(--muted); }
.system-cell > span { display: block; min-width: 150px; }
.system-cell > span + span { margin-top: 9px; }
.system-cell b, .system-origin { display: block; }
.system-origin { margin-top: 2px; font-size: 10px; }
.system-origin.manual { color: var(--primary-dark); }
.system-origin.suggested { color: var(--green); }
.system-origin.empty { color: var(--muted); }
.attribute-line .auto-filled-badge { display: inline-flex !important; margin-left: 4px !important; }
.number-cell { font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow-value { font-weight: 650; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 99px; font-size: 11px; white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.ok { color: var(--green); background: var(--green-soft); }
.status-pill.warn { color: var(--amber); background: var(--amber-soft); }
.status-pill.error { color: var(--red); background: var(--red-soft); }
.edit-button { min-width: 36px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.edit-button:hover { color: var(--primary); border-color: #aac4eb; background: var(--primary-soft); }
.empty-rows { padding: 44px; text-align: center; color: var(--muted); }
.result-note { margin: 14px 4px 0; color: var(--muted); font-size: 11px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: var(--bg); }
.drawer { width: 100%; position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: var(--bg); visibility: hidden; opacity: 0; transform: translateY(18px); pointer-events: none; transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s; }
.drawer.open { visibility: visible; opacity: 1; transform: translateY(0); pointer-events: auto; transition-delay: 0s; }
#editDrawer { width: min(440px, 42vw); inset: 0 0 0 auto; background: var(--bg); box-shadow: -16px 0 42px #26364d26; transform: translateX(24px); }
#editDrawer.open { transform: translateX(0); }
#editDrawer .drawer-head { padding: 16px 20px; }
#editDrawer .form-scroll { padding: 8px 20px 30px; }
#editDrawer .drawer-actions { padding: 14px 20px; }
#editDrawer .form-grid { grid-template-columns: 1fr; }
#editDrawer .form-grid label.wide { grid-column: auto; }
body:has(#editDrawer.open) .drawer-backdrop { background: #18263b20; }
.drawer-head-actions { display: flex; gap: 8px; }
.drawer-head { min-height: 94px; display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 18px max(28px, calc((100vw - 1180px) / 2)); border-bottom: 1px solid var(--line); background: var(--surface); }
.drawer-head h2 { margin: 7px 0 4px; font-size: 23px; }
.drawer-head p { margin: 0; color: var(--muted); }
#roomForm, #bulkForm, #roomTypeForm { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.form-scroll { width: min(1180px, 100%); min-height: 0; overflow-y: auto; flex: 1; margin: 0 auto; padding: 8px 28px 36px; }
fieldset { border: 0; padding: 0; margin: 24px 0 0; }
legend { width: 100%; padding: 0 0 12px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.field-help { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 15px; }
.form-grid label { display: block; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label > span { display: block; margin-bottom: 6px; color: #4e596a; font-size: 12px; font-weight: 600; }
.form-grid input, .form-grid textarea, .form-grid select { width: 100%; border: 1px solid #d9e0e9; border-radius: 8px; background: var(--surface); color: var(--text); outline: 0; }
.form-grid input, .form-grid select { height: 40px; padding: 0 11px; }
.adjacent-room-field { grid-column: 1 / -1; }
.adjacent-room-field > span { display: block; margin-bottom: 6px; color: #4e596a; font-size: 12px; font-weight: 600; }
.adjacent-picker { position: relative; margin-top: 10px; }
.adjacent-search span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.adjacent-search input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid #d9e0e9; border-radius: 8px; }
.adjacent-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: 0; }
.adjacent-dropdown { position: absolute; z-index: 5; top: calc(100% + 5px); right: 0; left: 0; padding: 5px; border: 1px solid #cbd6e4; border-radius: 9px; background: var(--surface); box-shadow: 0 14px 34px #26364d2b; }
.adjacent-dropdown.hidden { display: none; }
.adjacent-room-list { display: grid; gap: 4px; max-height: 240px; overflow-y: auto; padding: 1px; overscroll-behavior: contain; }
.adjacent-room-list label { display: flex; align-items: center; gap: 7px; min-height: 34px; padding: 5px 8px; border-radius: 7px; background: #f5f7fa; cursor: pointer; }
.adjacent-room-list input { width: auto; height: auto; margin: 0; }
.adjacent-room-list:empty::after { content: "В проекте нет других помещений"; grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.selected-adjacent-rooms { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; }
.selected-adjacent-rooms:empty::after { content: "Помещения ещё не выбраны"; color: var(--muted); font-size: 12px; }
.adjacent-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 8px; border: 1px solid #c7d7ec; border-radius: 999px; background: var(--primary-soft); color: #36577f; font-size: 11px; }
.adjacent-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adjacent-chip button { border: 0; padding: 0; background: transparent; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; }
.adjacent-balance-result { margin-top: 10px; padding: 10px 11px; border-radius: 8px; background: #eef4fb; color: #36577f; font-size: 12px; line-height: 1.45; }
.adjacent-balance-result:empty { display: none; }
.form-grid textarea { padding: 10px 11px; resize: vertical; }
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-grid label.required-for-calculation { padding: 10px; margin: -10px; border: 1px solid #e6bd75; border-radius: 10px; background: var(--amber-soft); }
.form-grid label.required-for-calculation > span::after { content: " · нужно для расчёта"; color: var(--amber); font-weight: 700; }
.form-grid label.required-for-calculation input { border-color: #d9a955; background: #fffefa; }
.room-finding-box { margin-top: 18px; padding: 13px 14px; border: 1px solid #f0dcb9; border-radius: 10px; background: var(--amber-soft); color: #815417; font-size: 12px; line-height: 1.5; }
.room-finding-box b { display: block; margin-bottom: 3px; }
.applicable-method-groups { display: grid; gap: 7px; margin-top: 18px; }
.applicable-method-groups:empty { display: none; }
.applicable-method-groups h3 { margin: 0 0 3px; font-size: 14px; }
.method-summary { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.method-summary b { font-size: 12px; }
.method-summary span { color: var(--muted); font-size: 11px; }
.method-summary.needs-input { border-color: #e6bd75; background: var(--amber-soft); }
.classification-box { margin-top: 18px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.classification-box.unresolved { border-color: #e2ba72; background: var(--amber-soft); }
.classification-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.classification-head span, .classification-head strong { display: block; }
.classification-head span { color: var(--muted); font-size: 11px; }
.classification-head strong { margin-top: 3px; font-size: 14px; }
.type-picker { margin-top: 15px; padding-top: 14px; border-top: 1px solid var(--line); }
.type-picker > p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.type-search { display: block; }
.type-search > span { display: block; margin-bottom: 6px; color: #4e596a; font-size: 12px; font-weight: 650; }
.type-search input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #d9e0e9; border-radius: 8px; outline: 0; }
.type-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.room-type-options { display: grid; gap: 7px; max-height: 235px; overflow-y: auto; margin: 10px 0; }
.type-option { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); text-align: left; cursor: pointer; }
.type-option:hover { border-color: #adc5e7; }
.type-option.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.type-option b, .type-option span { display: block; }
.type-option span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.type-option em { color: var(--primary); font-style: normal; font-size: 11px; }
.remember-alias { display: flex; align-items: flex-start; gap: 9px; padding: 10px 0 13px; cursor: pointer; }
.remember-alias input { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--primary); }
.remember-alias b, .remember-alias small { display: block; }
.remember-alias b { font-size: 12px; }
.remember-alias small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.remember-alias #aliasPreview { display: inline; }
.type-picker > .button { width: 100%; }
.bulk-summary { margin-top: 18px; padding: 13px 14px; border-radius: 10px; background: var(--primary-soft); color: #36577f; }
.bulk-summary div { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.bulk-fields { display: grid; gap: 9px; margin-top: 14px; }
.bulk-field { display: grid; grid-template-columns: 18px minmax(150px, 1fr) 130px; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; }
.bulk-field > input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.bulk-field > span { font-size: 12px; font-weight: 600; }
.bulk-field > input:last-child { width: 100%; height: 36px; padding: 0 9px; border: 1px solid #d9e0e9; border-radius: 7px; }
.bulk-field > input:last-child:disabled { background: #f1f3f6; opacity: .6; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px max(28px, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--line); background: var(--surface); }
.knowledge-body { width: min(1180px, 100%); min-height: 0; flex: 1; overflow-y: auto; margin: 0 auto; padding: 24px 28px 36px; }
.knowledge-tabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 10px; background: #eef2f7; }
.knowledge-tabs button { flex: 1; padding: 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; }
.knowledge-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px #22344f1a; }
.knowledge-filters { display: grid; grid-template-columns: 1fr 210px; gap: 10px; }
.knowledge-filters select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #d9e0e9; border-radius: 8px; background: white; }
.knowledge-note { padding: 13px 14px; margin-bottom: 16px; border-radius: 10px; background: var(--primary-soft); color: #36577f; }
.knowledge-note b, .knowledge-note span { display: block; }
.knowledge-note span { margin-top: 4px; color: #567293; font-size: 12px; line-height: 1.45; }
.knowledge-type-list { display: grid; gap: 8px; margin-top: 13px; }
.knowledge-type-card { padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; }
.knowledge-type-card:hover { border-color: #adc5e7; }
.knowledge-type-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.knowledge-type-card b, .knowledge-type-card span { display: block; }
.knowledge-type-card span { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.knowledge-type-card .alias-list { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); color: #46566b; }
.room-card-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.room-card-toolbar p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.room-card-group { margin-top: 18px; }
.room-card-group h3 { margin: 0 0 8px; font-size: 14px; }
.room-card-summary { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 13px; margin-bottom: 7px; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: left; cursor: pointer; }
.room-card-summary span, .room-card-summary small { display: block; }
.room-card-summary small { margin-top: 4px; color: var(--muted); }
.completeness { align-self: center; padding: 5px 8px; border-radius: 20px; background: #fff1d6; color: #815b18; font-size: 11px; }
.completeness.complete { background: #e4f5ea; color: #27713e; }
.method-editor { display: grid; gap: 10px; margin-top: 12px; }
.method-card { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.method-card-head { display: grid; grid-template-columns: 20px 1fr; align-items: center; gap: 8px; }
.method-card-head select { height: 34px; border: 1px solid #d9e0e9; border-radius: 7px; }
.method-parameters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.method-parameters label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.method-parameters input { width: 100%; height: 36px; padding: 0 8px; border: 1px solid #d9e0e9; border-radius: 7px; }
.method-source { grid-column: 1 / -1; margin-top: 6px; }
.alias-detail-drawer { z-index: 42; }
.alias-detail-body { width: min(900px, 100%); margin: 0 auto; }
.alias-detail-list { display: grid; gap: 8px; }
.alias-detail-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.alias-detail-row button.alias-name { border: 0; background: transparent; text-align: left; color: var(--text); cursor: pointer; }
.alias-detail-row button.alias-delete { width: 30px; height: 30px; border: 0; border-radius: 50%; background: #fbe7e7; color: var(--red); cursor: pointer; font-size: 18px; }
.alias-form { width: 100%; padding: 16px max(28px, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--line); background: var(--surface); }
.alias-form > div, .alias-form > label, .alias-form > button { max-width: 760px; margin-left: auto; margin-right: auto; }
.alias-form > div span, .alias-form label span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.alias-form > div strong { display: block; margin-bottom: 12px; }
.alias-form label input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid #d9e0e9; border-radius: 8px; outline: 0; }
.alias-form .button { width: 100%; margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 60; max-width: min(500px, calc(100% - 32px)); padding: 12px 17px; border-radius: 10px; background: #263142; color: white; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 20px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9b3d3d; }
.systems-panel { margin-top: 22px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.systems-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 16px; }
.system-card { padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.system-card header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.system-card header strong { font-size: 20px; }
.system-card p, .system-card small { display: block; margin: 7px 0; color: var(--muted); }
#autoGroupDialog form { display: grid; gap: 13px; min-width: min(520px, 80vw); }
#autoGroupDialog label { display: flex; gap: 9px; align-items: flex-start; }
.system-dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; border: 0; padding: 0; }
.system-dialog::backdrop { background: rgba(25, 34, 48, .48); }
.system-dialog-head, .system-dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px max(28px, calc((100vw - 1100px) / 2)); border-bottom: 1px solid var(--line); }
.system-dialog-body { width: min(100% - 56px, 1100px); margin: 0 auto; padding: 30px 0; display: grid; gap: 26px; }
.system-dialog-body > label > span { display: block; margin-bottom: 7px; color: var(--muted); }
.inline-edit { display: flex; gap: 10px; }
.inline-edit input, .inline-edit select { flex: 1; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; }
.system-room-row { display: grid; grid-template-columns: 90px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.system-dialog-actions { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.button.danger { background: #fff0f0; color: #923d3d; border: 1px solid #e7bcbc; }
.personal-base-card { display: block; width: 100%; text-align: left; }
.knowledge-base-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.engineering-database-grid { display: grid; gap: 18px; }
.engineering-database-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.engineering-database-card small { display: block; color: var(--muted); margin: 8px 0 14px; }
.additional-airflow-list, .calculation-parameter-editor { display: grid; gap: 12px; margin: 14px 0; }
.additional-airflow-row { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.additional-airflow-row label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.additional-airflow-row input, .additional-airflow-row select, .additional-airflow-row textarea { width: 100%; min-height: 42px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.additional-airflow-row textarea { resize: none; overflow: hidden; line-height: 1.35; }
.additional-airflow-name { display: block; width: 100%; }
.additional-airflow-values { display: grid; grid-template-columns: minmax(105px, .8fr) minmax(125px, 1fr) auto; gap: 10px; align-items: end; }
.calculation-parameter-editor .method-card { padding: 14px; }

@media (max-width: 900px) {
  .app-sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .app-sidebar.open { transform: translateX(0); }
  .topbar { margin-left: 0; padding: 0 20px; }
  .mobile-menu { display: grid; }
  .page-shell, .shell-content { width: min(100% - 32px, 1440px); margin: 0 auto; padding-top: 30px; }
  .project-grid, .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand small { display: none; }
  .steps { gap: 8px; }
  .step { align-items: flex-start; }
  .step small, .step:not(:last-child)::after { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .findings-list { grid-template-columns: 1fr; }
  .table-tools { align-items: flex-start; flex-direction: column; }
  .selection-bar { align-items: stretch; flex-direction: column; }
  .selection-bar > div:last-child { display: grid; grid-template-columns: 1fr 1fr; }
  .tools-right { width: 100%; }
  .search { flex: 1; }
}

@media (max-width: 1200px) {
  .workspace-head { align-items: stretch; flex-direction: column; }
  .head-actions { flex-wrap: wrap; }
  .head-actions > * { flex: 1 1 auto; }
  .table-wrap { max-width: 100%; }
}

@media (max-width: 600px) {
  .topbar { height: 62px; }
  .local-badge { font-size: 0; padding: 8px; }
  .local-badge span { margin: 0; }
  .page-shell, .shell-content { width: min(100% - 22px, 1440px); padding: 24px 0 40px; }
  .project-grid, .module-grid { grid-template-columns: 1fr; }
  .shell-page-head { align-items: stretch; flex-direction: column; }
  .intro { margin-bottom: 25px; }
  .intro h1 { font-size: 34px; }
  .intro p { font-size: 15px; }
  .steps { margin-bottom: 16px; }
  .step { gap: 6px; }
  .step > span { width: 27px; height: 27px; flex-basis: 27px; font-size: 11px; }
  .step b { font-size: 11px; }
  .drop-zone { min-height: 220px; padding: 20px; }
  .drop-zone strong { text-align: center; }
  .template-row { align-items: stretch; flex-direction: column; gap: 13px; }
  .workspace-head { align-items: stretch; flex-direction: column; }
  .head-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .metrics { gap: 9px; }
  .metrics article { min-height: 110px; padding: 15px; }
  .metrics strong { font-size: 22px; }
  .status-banner { align-items: flex-start; }
  .tools-right { align-items: stretch; flex-direction: column; }
  .search { width: 100%; flex: auto; }
  .filter-button { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .drawer-head, .form-scroll, .drawer-actions, .knowledge-body, .alias-form { padding-left: 18px; padding-right: 18px; }
  .drawer-actions .button { flex: 1; padding: 0 10px; }
  .bulk-field { grid-template-columns: 18px 1fr; }
  .bulk-field > input:last-child { grid-column: 2; width: 100%; }
  .additional-airflow-values { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 1024px) {
  #editDrawer { width: min(420px, 46vw); }
}
@media (max-width: 760px) {
  #editDrawer { width: 100%; }
  .drawer-head-actions { flex-direction: column; }
}
