:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1c2521;
  background: #edf1ef;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --green: #173f34;
  --green-2: #245b4b;
  --green-soft: #e6f0eb;
  --yellow: #f5c200;
  --ink: #1c2521;
  --muted: #66736d;
  --line: #d8dfdb;
  --surface: #ffffff;
  --danger: #a33838;
  --warning: #946200;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c9d2cd;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  min-height: 40px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(36,91,75,.12); }
textarea { resize: vertical; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.mobile-only { display: none !important; }

.app-shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.project-sidebar { background: #132f28; color: #fff; padding: 22px 14px 16px; display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; height: 100vh; z-index: 30; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 20px; }
.brand-mark { display: flex; align-items: center; gap: 9px; font-weight: 900; letter-spacing: 1.6px; font-size: 14px; }
.brand-mark svg { width: 23px; height: 23px; color: var(--yellow); fill: var(--yellow); stroke-width: 1.4; }
.sun-symbol { color: var(--yellow); font-size: 22px; line-height: 1; }
.local-icon, .nav-icon, .diagram-symbol { font-weight: 900; font-size: 19px; color: var(--green-2); }
.project-sidebar .local-icon { color: var(--yellow); }
.new-project { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 6px; background: var(--yellow); color: #1e2a25; font-weight: 800; }
.new-project svg, .secondary-button svg, .primary-button svg { width: 17px; }
.search { margin: 14px 0 10px; }
.search input { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; }
.search input::placeholder { color: #a9bab3; }
.project-list { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; padding-right: 2px; }
.project-item { border: 0; border-left: 3px solid transparent; background: transparent; color: #d8e3de; text-align: left; padding: 11px 10px; border-radius: 4px; display: grid; gap: 3px; }
.project-item:hover { background: rgba(255,255,255,.06); }
.project-item.active { background: rgba(255,255,255,.11); border-left-color: var(--yellow); color: #fff; }
.project-item strong { font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.project-item span { font-size: 11px; color: #a9bab3; }
.project-item .project-code { color: #f5d761; font-weight: 800; text-transform: uppercase; }
.local-note { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,.12); display: flex; gap: 10px; align-items: flex-start; color: #afc0b9; font-size: 11px; }
.local-note svg { width: 18px; flex: 0 0 auto; }
.local-note span { display: grid; gap: 2px; }
.local-note strong { color: #fff; }

.workspace { min-width: 0; }
.topbar { height: 74px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; position: sticky; top: 0; z-index: 20; }
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-title span { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; }
.topbar-title h1 { margin: 2px 0 0; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 35vw; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.save-state { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-right: 5px; }
.save-state svg { width: 15px; }
.save-state.error { color: var(--danger); }
.secondary-button, .primary-button { min-height: 40px; border-radius: 6px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 750; border: 1px solid #c9d2cd; background: #fff; color: var(--ink); }
.secondary-button:hover { background: #f2f5f3; }
.primary-button { border-color: var(--green); background: var(--green); color: #fff; }
.primary-button:hover { background: #0d3027; }
.icon-button { width: 40px; height: 40px; border: 1px solid #d2dad6; border-radius: 6px; background: #fff; display: inline-grid; place-items: center; color: #45524c; padding: 0; }
.icon-button:hover { background: #f0f4f2; }
.icon-button svg { width: 19px; }
.icon-button.danger { color: var(--danger); }
.menu-wrap { position: relative; }
.action-menu { position: absolute; right: 0; top: 45px; width: 205px; background: #fff; border: 1px solid var(--line); box-shadow: 0 16px 38px rgba(21,46,38,.18); border-radius: 7px; padding: 6px; z-index: 60; }
.action-menu button { width: 100%; border: 0; background: transparent; padding: 10px; border-radius: 4px; display: flex; align-items: center; gap: 9px; text-align: left; color: var(--ink); }
.action-menu button:hover { background: #eef3f0; }
.action-menu button svg { width: 17px; }
.action-menu .danger { color: var(--danger); border-top: 1px solid #edf0ee; margin-top: 4px; }

.workflow-nav { height: 54px; display: flex; background: #fff; border-bottom: 1px solid var(--line); padding: 0 24px; gap: 3px; overflow-x: auto; position: sticky; top: 74px; z-index: 15; }
.workflow-nav button { position: relative; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #65716c; padding: 0 13px; display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.workflow-nav button svg { width: 17px; }
.workflow-nav button:hover { color: var(--green); background: #f7f9f8; }
.workflow-nav button.active { color: var(--green); border-bottom-color: var(--green); }
.workflow-nav button b { background: #f6e7b4; color: #704e00; min-width: 19px; height: 19px; border-radius: 9px; display: grid; place-items: center; font-size: 10px; }

.content { padding: 28px clamp(20px, 3vw, 44px) 80px; max-width: 1500px; margin: 0 auto; }
.page-section { animation: enter .2s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.section-head h2 { margin: 3px 0 6px; font-size: clamp(22px, 2vw, 28px); letter-spacing: 0; }
.section-head p { margin: 0; color: var(--muted); max-width: 700px; }
.eyebrow { color: var(--green-2); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.status-select { width: auto; min-width: 190px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 26px; row-gap: 18px; background: #fff; padding: 26px; border: 1px solid var(--line); border-radius: 8px; }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field-label { font-size: 12px; color: #4d5b55; font-weight: 750; }
.field small { color: var(--muted); font-size: 11px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 44px; }
.input-unit span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; pointer-events: none; }

.component-layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 28px; align-items: start; }
.component-form { background: #fff; border: 1px solid var(--line); padding: 24px; border-radius: 8px; display: grid; gap: 20px; }
.temperature-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; border-top: 1px solid var(--line); padding-top: 20px; }
.spec-sheet { border-top: 4px solid var(--green); background: #fff; padding: 24px; box-shadow: 0 8px 30px rgba(29,50,42,.08); }
.spec-kicker { color: var(--green-2); font-size: 11px; text-transform: uppercase; font-weight: 850; }
.spec-sheet h3 { font-size: 19px; margin: 5px 0 18px; }
.spec-sheet dl { margin: 0; }
.spec-sheet dl div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-top: 1px solid #edf0ee; }
.spec-sheet dt { color: var(--muted); font-size: 12px; }
.spec-sheet dd { margin: 0; font-weight: 800; text-align: right; font-size: 12px; }
.source-warning { display: flex; align-items: flex-start; gap: 10px; padding: 13px; background: #fff5d8; color: #5f4700; margin-top: 16px; font-size: 12px; }
.source-warning svg { width: 18px; flex: 0 0 auto; }
.source-warning span { display: grid; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: #fff; border: 1px solid var(--line); margin-bottom: 18px; }
.stat { padding: 18px 21px; display: grid; gap: 3px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.stat strong { color: var(--green); font-size: 23px; }
.stat small { color: var(--muted); }
.string-list { display: grid; gap: 8px; }
.string-row { display: grid; grid-template-columns: 110px 90px 85px 85px minmax(320px, 1fr) 42px; gap: 11px; align-items: end; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--green-2); padding: 14px; border-radius: 5px; }
.string-identity { display: grid; gap: 5px; }
.string-identity span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.string-identity input { font-weight: 800; }
.string-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-self: stretch; }
.string-result span { display: flex; flex-direction: column; justify-content: center; border-left: 1px solid var(--line); padding-left: 10px; color: var(--muted); font-size: 10px; }
.string-result strong { color: var(--ink); font-size: 13px; margin-top: 2px; }

.roof-actions { display: flex; gap: 8px; }
.roof-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.roof-workspace { min-width: 0; background: #fff; border: 1px solid var(--line); }
.design-toolbar { min-height: 48px; display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.design-toolbar span { flex: 1; }
.design-toolbar button { border: 0; background: transparent; min-height: 34px; padding: 0 10px; border-radius: 4px; white-space: nowrap; color: #53615b; font-size: 12px; font-weight: 700; }
.design-toolbar button:hover, .design-toolbar button.active { background: var(--green-soft); color: var(--green); }
.design-toolbar button.danger { color: var(--danger); }
.roof-canvas-wrap { position: relative; aspect-ratio: 1000 / 650; overflow: hidden; background: #dfe6e2; }
#roof-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.canvas-empty { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,.9); padding: 10px 14px; border-radius: 4px; color: var(--muted); font-size: 12px; pointer-events: none; }
.roof-inspector { background: #fff; border: 1px solid var(--line); padding: 18px; display: grid; gap: 13px; }
.roof-inspector h3, .energy-inputs h3, .pricing-inputs h3 { margin: 0 0 2px; font-size: 14px; }
.roof-inspector h3:not(:first-child) { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 15px; }
.map-link { display: block; color: var(--green-2); font-size: 12px; font-weight: 750; }
.roof-stats { display: grid; grid-template-columns: 1fr 1fr; background: #f1f5f3; padding: 12px; gap: 12px; }
.roof-stats span { display: grid; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.roof-stats strong { color: var(--ink); font-size: 16px; margin-top: 2px; }
.inspector-note { margin: 0; background: #fff5d8; padding: 11px; color: #664d00; font-size: 11px; line-height: 1.45; }

.model-tag { background: #fff5d8; color: #664d00; padding: 8px 11px; font-size: 10px; font-weight: 850; }
.energy-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: stretch; }
.production-chart { background: #fff; border: 1px solid var(--line); padding: 21px; min-width: 0; }
.production-chart h3 { margin: 0 0 25px; font-size: 14px; }
.bars { height: 270px; display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; border-bottom: 1px solid var(--line); }
.bar-column { flex: 1; min-width: 0; height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar-column > span { width: min(30px, 70%); background: var(--green-2); border-radius: 2px 2px 0 0; transition: height .2s ease; }
.bar-column strong { font-size: 9px; margin: 5px 0 2px; }
.bar-column small { color: var(--muted); font-size: 9px; }
.energy-inputs, .pricing-inputs { background: #fff; border: 1px solid var(--line); padding: 19px; display: grid; gap: 12px; }
.energy-flow { background: var(--green); color: #fff; padding: 13px; display: grid; gap: 8px; margin-top: 4px; }
.energy-flow span { display: flex; justify-content: space-between; color: #cfe0d8; font-size: 11px; }
.energy-flow strong { color: #fff; }

.quote-total { min-width: 240px; background: var(--green); color: #fff; padding: 12px 16px; display: grid; }
.quote-total span { color: #cfe0d8; font-size: 10px; text-transform: uppercase; }
.quote-total strong { font-size: 22px; }
.quote-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.quote-table { background: #fff; border: 1px solid var(--line); }
.quote-row { display: grid; grid-template-columns: minmax(180px, 1.5fr) .5fr .8fr .8fr; gap: 10px; align-items: center; padding: 12px 15px; border-top: 1px solid #edf0ee; font-size: 12px; }
.quote-row.head { border: 0; background: var(--green); color: #fff; font-weight: 800; }
.quote-row span:not(:first-child), .quote-row strong { text-align: right; }
.quote-row.total { background: #f1f5f3; border-top: 2px solid var(--green); }
.compact-field { grid-template-columns: minmax(110px, 1fr) 130px; align-items: center; }
.simple-payback { background: #fff5d8; padding: 13px; display: grid; gap: 3px; margin-top: 5px; }
.simple-payback span { color: #6a530d; font-size: 10px; text-transform: uppercase; font-weight: 800; }
.simple-payback strong { font-size: 19px; }
.simple-payback small { color: #6a530d; line-height: 1.4; }

.validation-badge { display: flex; align-items: center; gap: 7px; min-height: 39px; padding: 0 13px; border-radius: 4px; font-size: 12px; font-weight: 850; }
.validation-badge svg { width: 18px; }
.validation-badge.blocked { background: #f9e9e7; color: var(--danger); }
.validation-badge.clear { background: var(--green-soft); color: var(--green); }
.validation-columns { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.validation-columns h3 { font-size: 14px; margin: 0 0 12px; }
.issue { display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-left: 4px solid; padding: 16px; margin-bottom: 8px; }
.issue svg { flex: 0 0 auto; }
.issue.blocker { border-left-color: var(--danger); }
.issue.blocker svg { color: var(--danger); }
.issue.warning { border-left-color: #d69c00; }
.issue.warning svg { color: var(--warning); }
.issue strong { font-size: 13px; }
.issue p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.calculation-note { background: #183f34; color: #fff; padding: 23px; border-radius: 5px; position: sticky; top: 150px; }
.calculation-note h3 { font-size: 16px; }
.calculation-note p { color: #cddbd5; font-size: 12px; line-height: 1.55; }
.calculation-note code { display: block; background: rgba(255,255,255,.1); padding: 12px; color: #ffe166; font-size: 12px; white-space: normal; }

.diagram { max-width: 840px; margin: 5px auto 28px; background: #fff; border: 1px solid var(--line); padding: 28px clamp(20px, 5vw, 64px); }
.diagram-step { display: flex; flex-direction: column; align-items: center; }
.diagram-node { width: 100%; min-height: 66px; display: flex; align-items: center; gap: 15px; border: 1px solid #bfcac5; padding: 13px 18px; }
.diagram-node.primary { border: 2px solid var(--green); background: var(--green-soft); }
.diagram-node svg { width: 27px; color: var(--green); }
.diagram-node div { display: grid; gap: 3px; }
.diagram-node strong { font-size: 14px; }
.diagram-node span { color: var(--muted); font-size: 11px; }
.diagram-line { height: 34px; width: 2px; background: var(--green); position: relative; }
.diagram-line span { position: absolute; bottom: -1px; left: -4px; width: 9px; height: 9px; border-right: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: rotate(45deg); }
.diagram-disclaimer { max-width: 840px; margin: 0 auto; display: flex; gap: 12px; background: #fff5d8; color: #5f4700; padding: 15px; font-size: 12px; }
.diagram-disclaimer svg { width: 19px; flex: 0 0 auto; }
.diagram-disclaimer p { margin: 0; }

.instrument-row, .signoff-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; background: #fff; border: 1px solid var(--line); padding: 18px; margin-bottom: 16px; }
.signoff-row { grid-template-columns: 1fr 1fr; margin-top: 16px; }
.test-table { background: #fff; border: 1px solid var(--line); overflow-x: auto; }
.test-head, .test-row { min-width: 900px; display: grid; grid-template-columns: 100px 140px 150px 150px 150px 150px; gap: 10px; align-items: center; padding: 10px 14px; }
.test-head { background: var(--green); color: #fff; font-size: 11px; font-weight: 800; }
.test-row { border-top: 1px solid var(--line); }
.test-row strong { color: var(--green); }

.document-layout { display: grid; grid-template-columns: minmax(360px, .9fr) minmax(360px, 1.1fr); gap: 34px; align-items: start; }
.package-preview { background: #d9dfdc; padding: 30px; display: grid; place-items: center; min-height: 610px; }
.paper { width: min(100%, 390px); aspect-ratio: 210 / 297; background: #fff; box-shadow: 0 14px 35px rgba(20,39,32,.18); padding: 34px; display: flex; flex-direction: column; }
.paper-brand { display: flex; gap: 7px; align-items: center; color: var(--green); font-weight: 900; letter-spacing: 1px; }
.paper-brand svg { color: var(--yellow); fill: var(--yellow); width: 18px; }
.paper > p { margin: auto 0 5px; color: var(--green-2); font-size: 10px; font-weight: 800; }
.paper h3 { font-size: 26px; margin: 0 0 8px; overflow-wrap: anywhere; }
.paper h4 { margin: 0; color: var(--muted); font-size: 13px; font-weight: 500; }
.paper-lines { display: grid; gap: 6px; margin: 24px 0; }
.paper-lines span { height: 2px; background: #e8ecea; }
.paper small { color: var(--danger); font-weight: 800; margin-top: auto; }
.package-actions { background: #fff; padding: 25px; border: 1px solid var(--line); }
.package-actions h3 { margin: 0 0 13px; }
.package-item { display: flex; align-items: center; gap: 10px; border-top: 1px solid #edf0ee; padding: 11px 0; font-size: 13px; }
.package-item svg { width: 17px; color: var(--green-2); }
.package-status { margin: 16px 0; background: #f2f5f3; padding: 14px; display: grid; gap: 9px; }
.package-status span { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.package-status strong { color: var(--ink); }
.full { width: 100%; margin-top: 8px; }
.blocked-help { color: var(--danger); text-align: center; font-size: 11px; margin-bottom: 0; }

.empty-state { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px; }
.empty-state .brand-mark { color: var(--green); }
.empty-state h1 { margin: 24px 0 8px; }
.empty-state p { color: var(--muted); }
.empty-state button { margin-top: 16px; }
.toast { position: fixed; bottom: 20px; right: 22px; z-index: 100; background: #173f34; color: #fff; padding: 13px 17px; border-radius: 5px; box-shadow: 0 12px 32px rgba(11,36,29,.28); font-size: 13px; max-width: min(420px, calc(100vw - 40px)); }

@media (max-width: 1150px) {
  .string-row { grid-template-columns: 90px 80px 75px 75px 1fr 42px; }
  .string-result span:nth-child(2) { display: none; }
  .string-result { grid-template-columns: 1fr 1fr; }
  .component-layout, .validation-columns { grid-template-columns: minmax(0, 1fr) 310px; }
}

@media (max-width: 900px) {
  .mobile-only { display: inline-grid !important; }
  .app-shell { display: block; }
  .project-sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 18px 0 45px rgba(0,0,0,.24); }
  .project-sidebar.open { transform: translateX(0); }
  .topbar { padding: 0 14px; }
  .topbar-title h1 { max-width: 40vw; }
  .save-state { display: none; }
  .workflow-nav { padding: 0 10px; }
  .workflow-nav button { padding: 0 10px; }
  .content { padding: 22px 16px 70px; }
  .component-layout, .validation-columns, .document-layout { grid-template-columns: 1fr; }
  .roof-layout, .energy-layout, .quote-layout { grid-template-columns: 1fr; }
  .calculation-note { position: static; }
  .string-row { grid-template-columns: repeat(4, 1fr) 42px; align-items: end; }
  .string-result { grid-column: 1 / -1; grid-row: 2; }
  .string-identity { grid-column: span 1; }
}

@media (max-width: 620px) {
  .topbar-actions .secondary-button { display: none; }
  .topbar-title h1 { max-width: 53vw; font-size: 16px; }
  .workflow-nav button span { display: none; }
  .workflow-nav button { min-width: 48px; justify-content: center; }
  .section-head { flex-direction: column; }
  .status-select { width: 100%; }
  .form-grid { grid-template-columns: 1fr; padding: 18px; }
  .temperature-row, .instrument-row, .signoff-row { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: 0; }
  .string-row { grid-template-columns: 1fr 1fr 1fr 42px; }
  .string-identity { grid-column: 1 / -1; }
  .package-preview { padding: 16px; min-height: auto; }
  .roof-actions { width: 100%; }
  .roof-actions button { flex: 1; }
  .quote-row { grid-template-columns: minmax(125px, 1.2fr) .45fr .7fr .8fr; padding: 10px; font-size: 10px; }
  .energy-metrics { grid-template-columns: 1fr; }
  .paper { min-height: 480px; }
}

@media print {
  .project-sidebar, .topbar, .workflow-nav, .section-head button, .toast { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .diagram { border: 0; }
}
