:root {
  --green: #0f7c99;
  --green-dark: #072c38;
  --green-soft: #e8f3ec;
  --ink: #12211a;
  --muted: #5d6f64;
  --line: #dbe7df;
  --bg: #f4f8f5;
  --white: #fff;
  --red: #b42318;
  --amber: #b57d09;
  --blue: #1d4ed8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--green); }
h1, h2, h3 { margin: 0 0 10px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #e6f3ea, var(--bg)); }
.login-card { width: 100%; max-width: 400px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: 0 18px 40px rgba(7, 37, 46, 0.09); }
.login-card .login-logo { width: 64px; height: 64px; object-fit: contain; display: block; margin: 0 0 10px; }
.login-card .logo { font-weight: 800; font-size: 22px; color: var(--green-dark); letter-spacing: -0.02em; }
.login-card .logo span { color: var(--green); }
.login-card p.sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; background: #fbfdfb; color: var(--ink); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px rgba(30, 122, 70, 0.12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 9px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #14889f, #0b6577); color: #fff; font: inherit; font-weight: 650;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--green-dark); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: #fef3f2; color: var(--red); border: 1px solid #fbd5d1; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.msg { display: none; border-radius: 9px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.msg.err { display: block; background: #fef3f2; color: var(--red); border: 1px solid #fbd5d1; }
.msg.ok { display: block; background: var(--green-soft); color: var(--green-dark); border: 1px solid #c8e3d2; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; background: var(--white); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.topbar .brand-logo { width: 34px; height: 34px; object-fit: contain; display: block; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; color: var(--green-dark); font-size: 17px; letter-spacing: -0.02em; }
.topbar .brand small { font-weight: 600; color: var(--muted); font-size: 12px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.08em; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button {
  background: transparent; border: 0; padding: 8px 13px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tabs button.active { background: var(--green-soft); color: var(--green-dark); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.chip { background: var(--green-soft); color: var(--green-dark); padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
main { padding: 22px 20px 60px; max-width: 1680px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- cards / kpi ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .v.green { color: var(--green); }
.kpi .v.blue { color: var(--blue); }
.kpi .v.amber { color: var(--amber); }

/* ---------- forms ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 16px; }
legend { padding: 0 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--green); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.calc-strip { display: flex; gap: 22px; flex-wrap: wrap; background: var(--green-soft); border-radius: 10px; padding: 12px 14px; font-size: 14px; margin: 14px 0; }
.calc-strip strong { color: var(--green-dark); }

/* ---------- table ---------- */
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); max-height: 74vh; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* the records table carries all 34 Excel columns - keep it dense so more fit on screen */
#rec-table { font-size: 12.5px; }
#rec-table th, #rec-table td { padding: 6px 8px; }
#rec-table th:first-child, #rec-table td:first-child { position: sticky; left: 0; background: var(--white); box-shadow: 1px 0 0 var(--line); z-index: 2; }
#rec-table thead th { z-index: 3; }
#rec-table thead th:first-child { z-index: 4; }
th { background: #f1f7f3; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); position: sticky; top: 0; }
tbody tr:hover { background: #f8fcf9; }
/* a stage with zero applications: dimmed row, no fake bar */
.hbar.is-zero .lbl, .hbar.is-zero .val { color: #9aa8a0; font-weight: 500; }
.hbar.is-zero .fill { background: transparent; }
#rec-table td.editable { cursor: cell; }
#rec-table td.editable:hover { background: #f2faf5; box-shadow: inset 0 0 0 1px #c8e3d2; }
#rec-table td.editing { padding: 1px 2px; background: #fff; }
#rec-table td.saving { opacity: 0.5; }
#rec-table .celledit { width: 100%; min-width: 64px; padding: 4px 6px; border: 1px solid var(--green); border-radius: 5px; font: inherit; font-size: 12.5px; background: #fff; box-shadow: 0 0 0 3px rgba(30, 122, 70, 0.12); }
td.num, th.num { text-align: right; }
.tag { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); }
.tag.warn { background: #fef6e7; color: var(--amber); }
.searchbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.searchbar input { max-width: 420px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--green-dark); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #7f1d1d; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }
.rangebar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.rangebar__lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.seg { display: inline-flex; background: #eaf3ed; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--white); color: var(--green-dark); box-shadow: 0 1px 3px rgba(7, 37, 46, 0.12); }
.seg button:hover { color: var(--green-dark); }

/* ---------- record detail drawer ---------- */
#drawer-save[hidden] { display: none !important; }
#rec-table td.linkcell { cursor: pointer; }
#rec-table .applink { color: var(--green); font-weight: 700; text-decoration: underline; text-decoration-color: rgba(30,122,70,.35); text-underline-offset: 2px; }
#rec-table .applink:hover { color: var(--green-dark); text-decoration-color: var(--green-dark); }
body.drawer-open { overflow: hidden; }
.drawer { position: fixed; inset: 0; z-index: 80; }
.drawer[hidden] { display: none; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(12, 33, 22, 0.38); }
.drawer__panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(480px, 96vw);
  background: var(--white); display: flex; flex-direction: column;
  box-shadow: -18px 0 40px rgba(7, 37, 46, 0.18); animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(24px); } to { transform: translateX(0); } }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer__head h2 { margin: 0 0 4px; font-size: 18px; }
.drawer__head .hint { margin: 0; }
.drawer__body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer__foot { display: flex; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line); background: #fbfdfb; }
.dfield { margin-bottom: 12px; }
.dfield label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 4px; }
.dfield .dval { padding: 8px 0; font-weight: 600; color: var(--ink); }
.dfield input, .dfield select { width: 100%; }
.dsec { margin: 18px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--green); }

/* ---------- clickable dashboard + drill chips ---------- */
.kpi.clickable { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; }
.kpi.clickable:hover { border-color: var(--green); box-shadow: 0 8px 20px rgba(7, 37, 46, 0.09); transform: translateY(-1px); }
.hbar.clickable, .vcol.clickable { cursor: pointer; }
.hbar.clickable:hover .lbl { color: var(--green-dark); font-weight: 650; }
.hbar.clickable:hover .fill { filter: brightness(1.12); }
.vcol.clickable:hover .vbar { filter: brightness(1.14); }
.vcol.clickable:hover .vlab { color: var(--green-dark); font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips:empty { display: none; }
.chipbtn { border: 1px solid #c8e3d2; background: var(--green-soft); color: var(--green-dark); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer; }
.chipbtn span { opacity: 0.5; margin-left: 2px; }
.chipbtn:hover { border-color: var(--green); }
.chipbtn.clear { background: var(--white); color: var(--muted); border-color: var(--line); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--green-dark); }

/* ---------- dashboard split: PMSG + Industrial side by side ---------- */
.dash-split { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.dash-col { min-width: 0; }
.dash-col[hidden] { display: none; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.pane-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.kpis--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpis--compact .kpi .v { font-size: 21px; }
#dash-col-ind .chart-card { margin-bottom: 14px; }
body.staff-mode .dash-split { grid-template-columns: 1fr; }
#dash-col-psg .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* keep the two dashboards side by side on every desktop size */
@media (max-width: 1100px) {
  .dash-split { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; }
  #dash-col-psg .kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .kpis--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* only phones stack them */
@media (max-width: 780px) {
  .dash-split { grid-template-columns: 1fr; }
}
/* ---------- staff mode: no cost, no profit, no dashboard ---------- */
body.staff-mode .fin { display: none !important; }
.staff-only { display: none; }
body.staff-mode .kpis.staff-only { display: grid; }
body.staff-mode #cost-section,
body.staff-mode .strip-cost,
body.staff-mode .strip-profit,
body.staff-mode .col-cost,
body.staff-mode .col-profit { display: none; }

/* ---------- charts (pure CSS + SVG, no libraries) ---------- */
.chart-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; margin-bottom: 18px; }
.chart-card { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px 18px; }
.chart-card h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 14px; }
.hbar { display: grid; grid-template-columns: minmax(96px, 132px) 1fr auto; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.hbar .lbl { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { display: block; background: #edf4f6; border-radius: 6px; height: 12px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #30a8c0, #0f7c99); }
.hbar .fill.amber { background: linear-gradient(90deg, #f0c018, #b57d09); }
.hbar .val { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--green-dark); min-width: 62px; text-align: right; }
.vbars { display: flex; align-items: flex-end; justify-content: space-around; gap: 10px; height: 172px; padding-top: 6px; }
.vgroup { display: flex; align-items: flex-end; gap: 4px; height: 150px; width: 100%; }
.vbar { flex: 1; background: linear-gradient(180deg, #30a8c0, #0f7c99); border-radius: 4px 4px 0 0; min-height: 3px; transition: filter 0.15s; }
.vbar:hover { filter: brightness(1.12); }
.vcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.vval { font-size: 12px; font-weight: 700; color: var(--green-dark); }
.vgroup .vval { align-self: center; }
.vlab { font-size: 11.5px; color: var(--muted); text-align: center; white-space: nowrap; }
.donut-wrap { position: relative; display: flex; justify-content: center; margin-bottom: 10px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center strong { font-size: 19px; color: var(--green-dark); letter-spacing: -0.02em; }
.donut-center span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .hbar { grid-template-columns: 92px 1fr auto; font-size: 12px; }
  .vbars { height: 150px; }
  .vgroup { height: 128px; }
}
/* Netlify injects this badge at runtime; the main site hides it too */
#nl-badge-frame, iframe[title="Powered by Netlify"] { display: none !important; visibility: hidden !important; pointer-events: none !important; }
@media (max-width: 640px) {
  .topbar { gap: 10px; }
  .who { width: 100%; margin-left: 0; }
  main { padding: 16px 12px 50px; }
  .kpi .v { font-size: 20px; }
}


/* ================= login page (split screen) ================= */
.login-body { background: #f2f8f4; }
.login-shell { display: grid; grid-template-columns: 1.02fr 1fr; min-height: 100dvh; }

.login-brand {
  position: relative; overflow: hidden; padding: 40px 44px 34px; color: #fff;
  background: radial-gradient(120% 90% at 12% 8%, #1793b0 0%, #0d6c85 44%, #072c38 100%);
  display: flex; flex-direction: column; justify-content: space-between; gap: 26px;
}
.lb-glow { position: absolute; width: 420px; height: 420px; right: -120px; top: -140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 192, 24, .34), transparent 62%); filter: blur(6px);
  animation: lb-float 12s ease-in-out infinite; }
@keyframes lb-float { 0%, 100% { transform: translate3d(0,0,0) } 50% { transform: translate3d(-14px, 18px, 0) } }
.lb-sun { position: absolute; right: 30px; top: 28px; width: 104px; opacity: .92; }
.lb-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.lb-logo { width: 46px; height: 46px; object-fit: contain; background: #fff; border-radius: 12px; padding: 5px;
  box-shadow: 0 8px 20px rgba(0,0,0,.20); }
.lb-word { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.lb-word span { color: #c6ecf5; }
.lb-copy { position: relative; z-index: 1; margin-top: auto; }
.lb-kicker { text-transform: uppercase; letter-spacing: .16em; font-size: 11px; font-weight: 700; color: #f0d15a; margin: 0 0 12px; }
.lb-copy h1 { font-size: clamp(26px, 3vw, 40px); line-height: 1.12; margin: 0 0 12px; letter-spacing: -0.025em; }
.lb-lead { color: rgba(255,255,255,.84); max-width: 42ch; margin: 0 0 18px; font-size: 15px; line-height: 1.55; }
.lb-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.lb-points li { position: relative; padding-left: 26px; font-size: 14px; color: rgba(255,255,255,.92); }
.lb-points li::before { content: ""; position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(140, 192, 47, .20); border: 1px solid rgba(140, 192, 47, .65); }
.lb-points li::after { content: ""; position: absolute; left: 5px; top: 8px; width: 6px; height: 3px;
  border-left: 2px solid #d8ffe7; border-bottom: 2px solid #d8ffe7; transform: rotate(-45deg); }
.lb-foot { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 12px; font-size: 12px;
  color: rgba(255,255,255,.64); border-top: 1px solid rgba(255,255,255,.14); padding-top: 14px; }
.lb-ridge { position: absolute; left: 0; right: 0; bottom: 0; height: 110px; width: 100%; }
/* faint solar-panel texture filling the middle of the panel */
.login-brand::before {
  content: ""; position: absolute; left: 50%; top: 30%; width: 420px; height: 220px; margin-left: -210px;
  background-image:
    linear-gradient(rgba(190,242,210,.20) 1px, transparent 1px),
    linear-gradient(90deg, rgba(190,242,210,.20) 1px, transparent 1px);
  background-size: 64px 46px;
  transform: perspective(700px) rotateX(42deg) rotate(-7deg);
  opacity: .55; pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 42%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 42%, transparent 100%);
}

.login-panel { display: grid; place-items: center; padding: 48px 28px;
  background: radial-gradient(90% 60% at 100% 0%, #eaf6ee 0%, #f7fbf8 46%, #ffffff 100%); }
.login-card { width: 100%; max-width: 402px; background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 30px 30px 22px; box-shadow: 0 26px 60px rgba(12,59,38,.13);
  animation: lc-rise .5s cubic-bezier(.2,.7,.3,1) both; }
@keyframes lc-rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
.lc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #eef6f1; border: 1px solid #e2efe7;
  border-radius: 12px; padding: 4px; margin-bottom: 9px; }
.login-tabs { margin-bottom: 16px !important; }
.login-tabs button { border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; font: inherit; font-size: 14px;
  font-weight: 650; color: var(--muted); cursor: pointer; transition: background .15s ease, color .15s ease, box-shadow .15s ease; }
.login-tabs button:hover:not(.active) { color: var(--green-dark); background: rgba(255,255,255,.55); }
.login-tabs button.active { background: #fff; color: var(--green-dark); box-shadow: 0 2px 9px rgba(12,59,38,.13); }
.login-tabs button[data-mode="staff"].active { color: #8a5a12; }
.tab-hint { margin: 0 0 16px; font-size: 12.5px; line-height: 1.45; color: var(--muted); min-height: 18px; }
.login-card .login-logo { width: 52px; height: 52px; margin: 0; }
.lc-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; color: var(--ink); }
.lc-head .sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.field { position: relative; margin-bottom: 14px; }
.field > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px;
  color: #8aa79a; pointer-events: none; }
.field input { padding-left: 40px; height: 46px; border-radius: 11px; }
.field input[type="password"], .field input#password { padding-right: 44px; }
.field .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px;
  display: grid; place-items: center; border: 0; background: transparent; border-radius: 8px; color: #8aa79a; cursor: pointer; }
.field .eye svg { width: 18px; height: 18px; }
.field .eye:hover { background: #eef6f1; color: var(--green); }
.field .eye.on { color: var(--green); }
.login-card label { margin-bottom: 6px; }
.btn.lg { min-height: 48px; border-radius: 12px; font-size: 15px; display: inline-flex; align-items: center;
  justify-content: center; gap: 10px; margin-top: 4px;
  background: linear-gradient(180deg, #24a3bd, #0f7c99); box-shadow: 0 10px 22px rgba(26,116,68,.28);
  transition: transform .15s ease, box-shadow .15s ease; }
.btn.lg:hover { transform: translateY(-1px); box-shadow: 0 14px 26px rgba(26,116,68,.32); }
.btn.lg svg { width: 19px; height: 19px; transition: transform .15s ease; }
.btn.lg:hover svg { transform: translateX(3px); }
.btn.lg:disabled { opacity: .75; transform: none; }
.lc-note { margin: 16px 0 0; font-size: 12.5px; line-height: 1.5; }
.lc-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.lc-foot a { color: var(--green); font-weight: 650; text-decoration: none; }
.lc-foot a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 26px 22px 56px; gap: 16px; }
  .lb-copy h1 { font-size: 26px; }
  .lb-lead, .lb-points, .lb-foot { display: none; }
  .lb-sun { width: 76px; top: 18px; right: 20px; }
  .login-brand::before { display: none; }
  .login-panel { padding: 0 18px 42px; margin-top: -34px; }
  .login-card { padding: 24px 20px 18px; }
}
@media (prefers-reduced-motion: reduce) { .lb-glow { animation: none } .login-card { animation: none } }


/* ============================================================
   Corporate shell  (sidebar + appbar + refined surfaces)
   ============================================================ */
:root {
  /* palette sampled from the EG logo: teal + gold + lime */
  --ink: #0b1f26;
  --ink-2: #14343d;
  --muted: #587079;
  --line: #dfeaee;
  --line-2: #edf4f6;
  --green: #14889f;
  --green-dark: #0b6577;
  --green-soft: #eaf6f9;
  --blue: #30a8c0;
  --lime: #8cc02f;
  --lime-dark: #6f9a22;
  --gold: #d9a900;
  --amber: #b57d09;
  --side-bg: #07252e;
  --side-ink: #cbe4ea;
  --surface: #ffffff;
  --page-bg: #f4f8fa;
  --shadow-sm: 0 1px 2px rgba(7, 37, 46, .06), 0 1px 3px rgba(7, 37, 46, .04);
  --shadow-md: 0 6px 20px rgba(7, 37, 46, .08);
}

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* ---------- frame ---------- */
.app { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100dvh; }

.side {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(48, 168, 192, .34), transparent 62%),
    radial-gradient(80% 50% at 20% 110%, rgba(140, 192, 47, .16), transparent 60%),
    linear-gradient(180deg, #0a3441 0%, #06202a 100%);
  color: var(--side-ink);
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px 16px; position: sticky; top: 0; height: 100dvh;
}
.side__brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.side .brand-logo { width: 36px; height: 36px; border-radius: 10px; background: #fff; padding: 3px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -0.01em; }
.brand-text small { font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgba(207, 227, 216, .62); margin-top: 3px; }

.tabs { display: flex; flex-direction: column; gap: 3px; }
.tabs button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: rgba(207, 227, 216, .78);
  font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; text-align: left;
  transition: background .16s ease, color .16s ease;
}
.tabs button svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.tabs button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.tabs button.active { background: #fff; color: #0b6577; font-weight: 650; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.tabs button.active svg { opacity: 1; color: #14889f; }
.tabs button[hidden] { display: none !important; }

.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .10); }
.who { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.who__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, .14); color: #fff; text-transform: uppercase;
}
.who__meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.who__meta #who-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .chip { align-self: flex-start; background: rgba(255, 255, 255, .12); color: #bfe6ef; font-size: 10px; padding: 2px 8px; text-transform: uppercase; letter-spacing: .07em; }
.side .btn.ghost { color: #d6eadf; border-color: rgba(255, 255, 255, .18); background: transparent; }
.side .btn.ghost:hover { background: rgba(255, 255, 255, .10); color: #fff; }

/* ---------- main column ---------- */
.app__main { display: flex; flex-direction: column; min-width: 0; }
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 26px; background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.appbar__kicker { margin: 0 0 2px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.appbar h1 { margin: 0; font-size: 19px; font-weight: 680; letter-spacing: -0.02em; color: var(--ink); }
.app__content { flex: 1 1 auto; min-width: 0; }
main { padding: 22px 26px 56px; max-width: none; margin: 0; }

/* ---------- surfaces ---------- */
.card, .chart-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.chart-card { margin-bottom: 0; }
.card h2, .chart-card h2, .pane-head h2 {
  font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 14px;
}
.card h2 .hint, .chart-card h2 .hint { letter-spacing: 0; text-transform: none; font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px 15px; box-shadow: var(--shadow-sm); min-width: 0;
}
.kpi .k {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .v {
  font-size: clamp(16px, 1.42vw, 23px); font-weight: 680; letter-spacing: -0.035em; line-height: 1.15;
  margin-top: 8px; color: var(--ink); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.kpis--compact .kpi { padding: 12px 14px; }
.kpis--compact .kpi .v { font-size: clamp(15px, 1.1vw, 19px); letter-spacing: -0.03em; }
.kpi .v.amber { color: var(--amber); }
.kpi.clickable { cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.kpi.clickable:hover { border-color: #bfdfe8; box-shadow: var(--shadow-md); transform: translateY(-1px); }

.chart-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }

/* charts polish */
.hbar .track { height: 8px; border-radius: 6px; background: var(--line-2); }
.hbar .fill { border-radius: 6px; background: linear-gradient(90deg, #30a8c0, #14889f); }
.hbar .fill.amber { background: linear-gradient(90deg, #f0c018, #d9a900); }
.hbar .lbl { font-size: 12.5px; color: var(--ink-2); }
.hbar .val { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vbar { border-radius: 5px 5px 0 0; }
.seg { background: var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border-radius: 8px; font-size: 12.5px; }
.seg button.active { background: #fff; box-shadow: var(--shadow-sm); color: #0b6577; }

/* tables */
.tablewrap { border: 1px solid var(--line); border-radius: 12px; }
table th {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); background: #f7faf8; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); }
table tbody tr:hover td { background: #f8fcfa; }
table tbody tr:last-child td { border-bottom: 0; }

/* forms + buttons */
input, select, textarea { border-radius: 10px; border-color: var(--line); font-size: 13.5px; }
input:focus, select:focus, textarea:focus { border-color: #8fc9d8; box-shadow: 0 0 0 3px rgba(48, 168, 192, .14); }
label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.btn { border-radius: 10px; font-weight: 620; font-size: 13.5px; min-height: 40px; padding: 9px 18px; }
.btn.ghost { border-color: var(--line); color: var(--ink-2); background: #fff; }
.btn.ghost:hover { border-color: #bfdfe8; background: var(--green-soft); color: var(--green-dark); }
.btn.sm { min-height: 32px; padding: 6px 12px; font-size: 12.5px; }
.rangebar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.firmseg__lbl { margin-left: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
#firm-filter button[data-firm="Ecogrid"].active { color: #0b6577; }
#firm-filter button[data-firm="Sunroot"].active { color: #b57d09; }
.rangebar__lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---------- responsive: sidebar becomes a strip ---------- */
/* staff-only blocks must stay hidden for admins (the .kpis rule above would show them) */
.kpis.staff-only { display: none; }
body.staff-mode .kpis.staff-only { display: grid; }
#dash-col-psg .kpis { grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); }

@media (max-width: 700px) {
  .dash-split { grid-template-columns: 1fr; }
  #dash-col-psg .kpis, .kpis, .kpis--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 21px; }
  .chart-wrap { grid-template-columns: 1fr; }
  .tabs button span { display: none; }
  .tabs button.active span { display: inline; }
}

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 14px;
    padding: 12px 14px; overflow-x: auto;
  }
  .side__brand { flex: 0 0 auto; }
  .brand-text small { display: none; }
  .tabs { flex-direction: row; flex-wrap: nowrap; gap: 4px; overflow-x: auto; }
  .tabs button { width: auto; flex: 0 0 auto; white-space: nowrap; padding: 8px 12px; color: rgba(255, 255, 255, .8); }
  .tabs button span { display: none; }
  .tabs button svg { width: 19px; height: 19px; }
  .tabs button.active span { display: inline; }
  .side__foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; border: 0; padding: 0; }
  .side .who__meta, .side .chip { display: none; }
  .appbar { padding: 12px 16px; }
  main { padding: 16px 14px 44px; }
}

/* staff who were granted the industrial module never see the money margin */
#dash-col-ind.staff-pane .ind-fin { display: none; }


/* ============================================================
   App mode — when EcoGrid Office runs from the installed icon
   (standalone display): behave like a native app, not a web page
   ============================================================ */
html.app-mode, html.app-mode body {
  overscroll-behavior: none;            /* no rubber-band / pull-to-refresh */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  background: #f4f8fa;
}
html.app-mode body { -webkit-user-select: none; user-select: none; }
html.app-mode input,
html.app-mode select,
html.app-mode textarea,
html.app-mode .dval,
html.app-mode table td,
html.app-mode .applink { -webkit-user-select: text; user-select: text; }
html.app-mode #install-app { display: none !important; }
html.app-mode .hint { display: none; }
html.app-mode ::selection { background: rgba(48, 168, 192, .22); }

/* kills the 300ms tap delay so buttons feel native */
html.app-mode .btn, html.app-mode .tabs button, html.app-mode .seg button,
html.app-mode .chipbtn, html.app-mode .kpi.clickable, html.app-mode .sortable,
html.app-mode .applink, html.app-mode .eye { touch-action: manipulation; }

/* login screen inside the app */
html.app-mode .login-shell { min-height: 100dvh; }
html.app-mode .login-body { background: #07252e; }
html.app-mode .login-panel { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
html.app-mode .login-brand { padding-top: calc(26px + env(safe-area-inset-top)); }

/* buttons/cells feel tappable, not clickable-with-hover */
html.app-mode .btn, html.app-mode .kpi.clickable, html.app-mode .tabs button,
html.app-mode .hbar.clickable, html.app-mode .chipbtn, html.app-mode .sortable {
  -webkit-user-select: none; user-select: none;
}
html.app-mode .btn:active { transform: scale(.98); }
html.app-mode .kpi.clickable:active { transform: scale(.995); }

/* safe areas: notch at the top, gesture bar at the bottom */
html.app-mode .side { padding-top: calc(14px + env(safe-area-inset-top)); }
html.app-mode .appbar { padding-top: calc(12px + env(safe-area-inset-top)); }
html.app-mode main { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

/* phones in app mode: real app chrome — compact bar + bottom tab bar */
@media (max-width: 820px) {
  html.app-mode .side {
    position: sticky; top: 0; z-index: 60;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    gap: 10px; background: linear-gradient(180deg, #0a3441 0%, #07252e 100%);
    backdrop-filter: none;
  }
  html.app-mode .side__brand .brand-text { font-size: 15px; }
  html.app-mode .side__brand .brand-text small { display: none; }
  html.app-mode .side .tabs {
    position: fixed; left: 0; right: 0; bottom: 0;
    display: flex; justify-content: space-between; gap: 2px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: #06202a; border-top: 1px solid rgba(255, 255, 255, .10);
    z-index: 70; overflow: visible;
  }
  html.app-mode .side .tabs button {
    flex: 1 1 0; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; border-radius: 12px; font-size: 10.5px; font-weight: 600;
    color: rgba(214, 234, 223, .72);
  }
  html.app-mode .side .tabs button span { display: block; }
  html.app-mode .side .tabs button svg { width: 21px; height: 21px; }
  html.app-mode .side .tabs button.active { background: rgba(255, 255, 255, .10); color: #fff; }
  html.app-mode .side .tabs button.active svg { color: #7fd7e8; }
  html.app-mode .side__foot { margin-left: auto; }
  html.app-mode main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  html.app-mode .appbar { display: none; }   /* the sidebar already carries the identity on mobile */
  html.app-mode .card, html.app-mode .chart-card { border-radius: 16px; }
}

/* ---------- phones: applications as cards (no sideways scrolling) ---------- */
.rec-cards { display: none; }
@media (max-width: 820px) {
  .rec-cards { display: grid; gap: 10px; }
  .desktop-only { display: none !important; }
  .rcard {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 14px; box-shadow: var(--shadow-sm); cursor: pointer;
  }
  .rcard:active { transform: scale(.995); }
  .rcard__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .rcard__no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; color: var(--muted); }
  .rtag {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: 3px 8px; border-radius: 999px; background: #eef4f7; color: #33525c; white-space: nowrap;
  }
  .rtag.warn { background: #fff5d6; color: #8a6100; }
  .rtag.ok { background: #e4f6ec; color: #14683f; }
  .rcard__name { font-size: 15px; font-weight: 650; margin-top: 7px; color: var(--ink); }
  .rcard__meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
  .rcard__foot {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
    margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line);
    font-size: 12px; color: var(--muted);
  }
  .rcard__money b { color: var(--ink); font-variant-numeric: tabular-nums; }
}

/* ---------- Costing module (super admin) ---------- */
#view-costing .c { text-align: center; }
#view-costing .hint { font-size: 12.5px; }
#view-costing input.narrow { max-width: 118px; }
#view-costing table input { width: 100%; min-width: 70px; }
#view-costing td.num.strong { font-weight: 700; color: var(--green-dark); }
#view-costing td.num.total { font-weight: 800; background: var(--green-soft); color: var(--green-dark); }
#view-costing td.num.less { color: var(--red); }
#view-costing td.num.add { color: var(--green-dark); }
#view-costing #ct-profit td { padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
#view-costing #ct-profit td.num { font-variant-numeric: tabular-nums; }
#view-costing .card h2 + h2 { margin-top: 18px; font-size: 14px; }

@media print {
  .side, .appbar, .toast, .no-print, #install-app, .page-head, .chips { display: none !important; }
  .app { display: block !important; grid-template-columns: 1fr !important; }
  .app__main { margin: 0 !important; }
  .app__content { padding: 0 !important; }
  .view { display: none !important; }
  .view.active { display: block !important; }
  .card { box-shadow: none !important; border: 1px solid #b9c6c3 !important; break-inside: avoid; margin: 0 0 8px !important; }
  .tablewrap { overflow: visible !important; }
  #view-costing table { font-size: 11px !important; }
  body { background: #fff !important; }
}

/* ---------- Leads tab badge ---------- */
.tabs button .tabbadge {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: #f0c018; color: #3a2c00; font-size: 11px; font-weight: 800;
  line-height: 17px; text-align: center;
}
.tabs button .tabbadge[hidden] { display: none !important; }
.tabs button.active .tabbadge { background: #d9a900; color: #2a2000; }
@media (max-width: 1024px) {
  .tabs button .tabbadge { margin-left: 4px; }
}

/* ---------- KPI value used for the Lead Lost count ---------- */
.kpi .v.muted { color: #8a6a6a; }

/* an empty strip must really disappear: .calc-strip sets display:flex, which beats [hidden] */
.calc-strip[hidden] { display: none !important; }
