:root {
  --bg: #f6f8f7;
  --panel: #ffffff;
  --panel-2: #fbfcfc;
  --ink: #17212b;
  --muted: #647383;
  --line: #dce3e7;
  --line-strong: #cbd6dd;
  --brand: #13324b;
  --brand-2: #1d465f;
  --green: #1f8a4c;
  --green-soft: #dff3e7;
  --amber: #b56b12;
  --amber-soft: #fff0d7;
  --red: #b42318;
  --red-soft: #fee4e2;
  --blue-soft: #e6f0f8;
  --shadow: 0 14px 35px rgba(25, 38, 52, .08);
  font-family: Barlow, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; }
.sidebar { background: linear-gradient(180deg, var(--brand), #0f263b); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.logo { display: grid; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.16); }
.brand-logo { display: block; width: 142px; height: auto; border-radius: 3px; }
.logo-text span { display: block; font-size: 11px; color: rgba(255,255,255,.72); line-height: 1.25; }
.side-section { display: grid; gap: 6px; }
.side-label { padding: 0 10px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: rgba(255,255,255,.56); }
.nav-btn { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; border: 0; color: rgba(255,255,255,.8); border-radius: 7px; padding: 11px 12px; text-align: left; font-weight: 650; font-size: 14px; text-decoration: none; }
.nav-btn.active, .nav-btn:hover { background: rgba(255,255,255,.11); color: #fff; }
.nav-icon { width: 18px; text-align: center; color: rgba(255,255,255,.76); }
.login-help { margin-top: auto; padding: 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; color: rgba(255,255,255,.72); font-size: 12px; line-height: 1.45; }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 68px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 22px; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 760; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; background: var(--blue-soft); color: #245574; font-size: 12px; font-weight: 700; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.btn { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); border-radius: 7px; padding: 9px 12px; font-weight: 720; font-size: 13px; min-height: 38px; }
.btn:hover { border-color: #aebbc4; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 30px; padding: 6px 9px; font-size: 12px; }
a.btn.as-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.workspace { padding: 18px; display: grid; grid-template-columns: minmax(290px, 390px) minmax(0, 1fr); gap: 14px; align-items: start; }
.setup-workspace { padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.setup-access-panel { grid-column: 1 / -1; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 780; }
.panel-body { padding: 14px; }
.stack { display: grid; gap: 14px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.address-grid { align-items: start; }
.address-grid textarea { min-height: 94px; height: 94px; }
.thirds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.field { display: grid; gap: 6px; }
.field label { color: #405060; font-size: 12px; font-weight: 760; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); padding: 9px 10px; min-height: 38px; font-size: 13px; }
input[readonly] { background: #f7faf9; color: #405060; }
textarea { min-height: 76px; resize: vertical; }
.search { margin: 12px 14px 8px; position: relative; }
.search input { padding-left: 32px; }
.search:before { content: "\2315"; position: absolute; left: 11px; top: 8px; color: var(--muted); }
.list { display: grid; border-top: 1px solid var(--line); }
.project-row { border: 0; border-bottom: 1px solid var(--line); background: #fff; text-align: left; padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; text-decoration: none; color: #000; }
.project-row:hover, .project-row.active { background: #f7faf9; }
.project-row > span:first-child { min-width: 0; display: grid; gap: 6px; }
.row-title { display: block; font-weight: 760; font-size: 13px; line-height: 1.28; overflow-wrap: anywhere; }
.row-sub { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.row-sub a { color: #256f93; font-weight: 720; text-decoration: none; }
.row-sub a:hover { text-decoration: underline; }
.detail-header { padding: 18px; display: grid; gap: 12px; }
.title-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title-line h2 { margin: 0; font-size: 22px; line-height: 1.2; }
.meta-row { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 13px; }
.meta-row strong { color: var(--ink); font-weight: 780; }
.progress-wrap { padding: 4px 0 2px; }
.stepper { display: grid; grid-template-columns: repeat(var(--step-count, 10), minmax(44px, 1fr)); gap: 0; align-items: start; }
.step { position: relative; display: grid; justify-items: center; gap: 7px; text-align: center; min-width: 0; }
.step:before { content: ""; position: absolute; top: 15px; left: -50%; right: 50%; height: 2px; background: var(--line-strong); z-index: 0; }
.step:first-child:before { display: none; }
.dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--muted); border: 2px solid var(--line-strong); z-index: 1; font-size: 12px; font-weight: 800; }
.step.done .dot, .step.current .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.done:before, .step.current:before { background: var(--green); }
.step span { font-size: 10px; color: var(--muted); line-height: 1.25; overflow-wrap: anywhere; }
.customer-progress .panel-body { padding: 18px; }
.customer-progress .progress-wrap { padding: 6px 0 8px; overflow-x: auto; overflow-y: hidden; }
.customer-progress .stepper { grid-template-columns: repeat(var(--step-count, 10), minmax(112px, 1fr)); min-width: calc(var(--step-count, 10) * 112px); row-gap: 0; column-gap: 0; }
.customer-progress .step:before { top: 20px; }
.customer-progress .dot { width: 40px; height: 40px; font-size: 14px; }
.customer-progress .step { gap: 10px; }
.customer-progress .step:first-child:before { display: none; }
.customer-progress .step span { font-size: 12px; line-height: 1.25; font-weight: 720; color: #405060; max-width: 112px; }
.customer-progress .step.current span { color: var(--ink); }
.install-progress-card .progress-bar { height: 12px; overflow: hidden; background: var(--line); border-radius: 999px; }
.install-progress-card .progress-fill { height: 100%; background: var(--green); border-radius: 999px; }
.install-progress-card strong { font-size: 20px; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.metric { padding: 13px; border-right: 1px solid var(--line); background: #fff; }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.metric strong { font-size: 17px; }
.tabs { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.tab { border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 8px 10px; color: var(--muted); font-size: 13px; font-weight: 760; text-decoration: none; }
.tab.active { background: #fff; color: var(--ink); border-color: var(--line); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { color: var(--muted); text-align: left; font-size: 12px; font-weight: 780; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.empty { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 22px; text-align: center; color: var(--muted); background: #fbfcfc; }
.update-item { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.update-item:last-child { border-bottom: 0; }
.update-item h3 { margin: 0; font-size: 14px; }
.update-item p { margin: 0; color: #405060; line-height: 1.45; font-size: 13px; }
.update-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.update-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.customer-updates { align-self: start; }
.customer-updates .panel-body { max-height: 300px; overflow-y: auto; scrollbar-gutter: stable; }
.project-description { margin: 0; color: #2f4050; line-height: 1.5; font-size: 15px; font-weight: 620; }
.customer-project-description { margin: 0; color: #22313f; line-height: 1.48; font-size: 17px; font-weight: 690; }
.mode { display: none; }
.mode.active { display: block; }
.login { max-width: 520px; margin: 50px auto; padding: 0 18px; }
.notice { padding: 12px 14px; border-radius: 8px; background: #eef6f2; color: #24543b; border: 1px solid #cae6d5; font-size: 13px; line-height: 1.45; }
.error { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #405060; }
.checkbox-row input { width: auto; min-height: 0; }
.checkbox-row.disabled { color: #8a98a5; }
.field .inline-checkbox { color: #405060; font-size: 13px; font-weight: 400; margin-top: 2px; }
.financial-check-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: -8px; }
.financial-check-row .spacer { display: block; }
.team-contact-row { align-items: start; }
.team-contact-row .team-custom-name { margin-top: 6px; }
.form-section { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 14px; }
.form-section h3 { margin: 0; font-size: 14px; font-weight: 780; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.customer-view { padding: 18px; display: grid; gap: 14px; max-width: 1280px; width: 100%; }
.preview-selector-form { display: grid; grid-template-columns: minmax(220px, 420px) auto; gap: 10px; align-items: end; }
.project-switcher-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; padding: 10px; }
.project-switcher-card { display: grid; gap: 3px; min-height: 64px; align-content: center; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); text-decoration: none; background: #fff; }
.project-switcher-card:hover, .project-switcher-card.active { border-color: var(--green); background: #f5fbf7; }
.customer-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 14px; align-items: start; }
.customer-grid > .stack { align-content: start; }
.customer-summary-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.customer-summary-row.single { grid-template-columns: 1fr; }
.file-input { padding: 7px; }
.hidden { display: none !important; }

/* --- additions for server-rendered templates --- */
.messages { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.messages li { padding: 11px 13px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); background: var(--panel-2); }
.messages li.success { background: var(--green-soft); color: var(--green); border-color: #cae6d5; }
.messages li.error { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.messages li.info { background: var(--blue-soft); color: #245574; border-color: #cfe2ef; }
.errorlist { color: var(--red); font-size: 12px; margin: 4px 0 0; padding-left: 16px; }
.muted { color: var(--muted); }

@media (max-width: 1040px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; display: block; }
  .side-section { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace, .setup-workspace, .customer-grid, .customer-summary-row, .split { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 12px; }
  .customer-progress .stepper { grid-template-columns: repeat(var(--step-count, 10), minmax(112px, 1fr)); min-width: calc(var(--step-count, 10) * 112px); }
  .customer-progress .step:before { display: block; }
  .customer-progress .step:first-child:before { display: none; }
}
@media (max-width: 640px) {
  .topbar { height: auto; padding: 14px; align-items: flex-start; flex-direction: column; }
  .workspace, .setup-workspace { padding: 12px; }
  .preview-selector-form { grid-template-columns: 1fr; }
  .thirds, .metric-grid { grid-template-columns: 1fr; }
  .financial-check-row { grid-template-columns: 1fr; margin-top: -6px; }
  .financial-check-row .spacer { display: none; }
  .customer-progress .stepper { grid-template-columns: repeat(var(--step-count, 10), minmax(112px, 1fr)); min-width: calc(var(--step-count, 10) * 112px); row-gap: 0; }
  .customer-progress .step { justify-items: center; grid-template-columns: 1fr; text-align: center; }
  .customer-progress .step:before { display: block; }
  .customer-progress .step:first-child:before { display: none; }
  .customer-progress .step span { max-width: 112px; align-self: start; }
  .title-line { align-items: flex-start; flex-direction: column; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
