/* Protostar Quotation Robot — mobile-first UI.
   Brand: deep green #0f4c3a · accent #6cc24a · mid #0f7a4d · amber #f4b942 */
:root {
  --green: #0f4c3a;
  --green-mid: #0f7a4d;
  --accent: #6cc24a;
  --amber: #f4b942;
  --ink: #1f2a28;
  --muted: #5a6b66;
  --hair: #e2e8e4;
  --bg: #f5f8f6;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15,76,58,.06), 0 6px 24px rgba(15,76,58,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + var(--safe-b));
}
a { color: var(--green-mid); }
.hidden { display: none !important; }

/* ---- top bar ---- */
header.app {
  position: sticky; top: 0; z-index: 30;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(12px); gap: 10px;
  box-shadow: 0 2px 12px rgba(15,76,58,.18);
}
header.app .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .3px; }
header.app .brand img { height: 26px; }
header.app .brand .tag { font-size: 11px; color: #bfe0cc; font-weight: 500; }
header.app button.icon {
  background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 10px;
  padding: 8px 12px; font-size: 14px; font-weight: 600;
}
header.app button.icon:active { background: rgba(255,255,255,.24); }

/* ---- layout ---- */
main { max-width: 760px; margin: 0 auto; padding: 14px 14px 0; }
.card {
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card > h2 {
  margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--green); display: flex; align-items: center; gap: 8px;
}
.card > h2 .bar { width: 4px; height: 16px; background: var(--amber); border-radius: 2px; }

/* ---- form controls ---- */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: #fbfdfc; border: 1.5px solid var(--hair); border-radius: 10px;
  padding: 12px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,194,74,.18);
}
textarea { min-height: 64px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hint { font-size: 11.5px; color: #5a6b66; margin-top: 4px; }
.warnings { background: #fff6e6; border: 1px solid #f0d9a0; color: #7a5b00; border-radius: 10px;
  padding: 10px 12px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }

/* segmented control */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 88px; border: 1.5px solid var(--hair); background: #fbfdfc;
  border-radius: 10px; padding: 11px 8px; font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.seg button.on { border-color: var(--green-mid); background: #eef7f1; color: var(--green); }

/* toggle */
.toggle { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; width: 50px; height: 28px; flex: 0 0 auto; }
/* keep the checkbox in the a11y tree + keyboard focusable (don't display:none) */
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(108,194,74,.45); }
.switch span { position: absolute; inset: 0; background: #b6c1bb; border-radius: 20px; transition: .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(22px); }

/* repeating picker rows (inverters/batteries) */
.pick-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.pick-row select { flex: 3; }
.pick-row input { flex: 1; max-width: 78px; text-align: center; }
.pick-row button.del { flex: 0 0 auto; width: 40px; padding: 12px 0; background: #fff0ef; border: 1.5px solid #f3c9c4; color: #b23b30; border-radius: 10px; font-weight: 700; }
button.add {
  width: 100%; border: 1.5px dashed #bcd4c5; background: #f4faf6; color: var(--green-mid);
  border-radius: 10px; padding: 11px; font-weight: 700; font-size: 14px;
}

/* ---- buttons ---- */
.btn { border: 0; border-radius: 12px; padding: 14px 18px; font-size: 16px; font-weight: 700; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:active { background: #0c3e30; }
.btn.amber { background: var(--amber); color: #3a2c05; }
.btn.ghost { background: #eef4f0; color: var(--green); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

/* ---- result / totals ---- */
.totals-wrap { }
.tline { display: flex; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid #eef2ef; font-size: 15px; }
.tline:last-child { border-bottom: 0; }
.tline .k { color: var(--muted); }
.tline .v { font-weight: 600; }
.tline.grand { background: var(--green); color: #fff; margin: 8px -16px -4px; padding: 14px 16px; border-radius: 0 0 var(--radius) var(--radius); }
.tline.grand .k { color: #cfe8dc; font-weight: 700; } .tline.grand .v { color: #fff; font-weight: 800; font-size: 19px; }
.tline.credit .k, .tline.credit .v { color: #7a5b00; }
.tline.net .k, .tline.net .v { color: var(--green-mid); font-weight: 700; }
.group-row { display: flex; justify-content: space-between; padding: 9px 2px; font-size: 14.5px; border-bottom: 1px dashed #eef2ef; }
.group-row .v { font-weight: 600; color: #163e34; }

/* editable line items */
.li { border: 1px solid var(--hair); border-radius: 10px; padding: 10px 11px; margin-bottom: 8px; background: #fbfdfc; }
.li .li-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; }
.li .li-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); font-weight: 700; }
.li .li-edit { display: flex; gap: 8px; margin-top: 8px; }
.li .li-edit label { margin: 0; align-self: center; font-size: 11px; }
.li .li-edit input { padding: 8px 10px; font-size: 14px; }
.li-amt { white-space: nowrap; color: #163e34; }

/* ---- sticky action bar ---- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--hair); padding: 10px 14px calc(10px + var(--safe-b));
  display: flex; gap: 10px; max-width: 760px; margin: 0 auto;
}
.actionbar .btn { flex: 1; }

/* ---- preview overlay ---- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15,30,25,.55); display: flex; flex-direction: column; }
.overlay header { background: var(--green); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.overlay header b { font-size: 15px; }
.overlay header button { background: rgba(255,255,255,.16); border: 0; color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.overlay .frame { flex: 1; background: #555; overflow: auto; -webkit-overflow-scrolling: touch; }
.overlay iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* ---- saved list / sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 55; background: rgba(15,30,25,.45); display: flex; align-items: flex-end; }
.sheet .panel { background: #fff; width: 100%; max-width: 760px; margin: 0 auto; border-radius: 18px 18px 0 0; max-height: 80vh; overflow: auto; padding: 18px 16px calc(18px + var(--safe-b)); }
.sheet .panel h3 { margin: 0 0 12px; color: var(--green); }
.quote-item { display: flex; justify-content: space-between; align-items: center; padding: 13px 12px; border: 1px solid var(--hair); border-radius: 12px; margin-bottom: 9px; }
.quote-item .qi-main { font-weight: 600; } .quote-item .qi-sub { font-size: 12.5px; color: var(--muted); }
.quote-item .qi-del { background: none; border: 0; color: #b23b30; font-weight: 700; padding: 6px 8px; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%); z-index: 80;
  background: var(--green); color: #fff; padding: 11px 18px; border-radius: 24px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: #b23b30; }

/* spinner */
.spin { display: inline-block; width: 16px; height: 16px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (min-width: 620px) {
  .row.wide-2 > * { flex: 1; }
}

/* ===================== work app shell (added for work.protostar.solar) ===== */
/* =======================================================================
   LOGIN — "solar dawn" animated sign-in (work.protostar.solar)
   A deep-green sky with a rising sun, rotating gold rays, a solar-farm
   grid receding to the horizon, and drifting photon particles. The card
   is dark frosted glass with gold accents. All animation is GPU-friendly
   (transform/opacity) and disabled under prefers-reduced-motion.
   ===================================================================== */
.login {
  position: fixed; inset: 0; z-index: 70; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 20px calc(20px + var(--safe-b));
  background: radial-gradient(125% 95% at 50% -12%, #15694b 0%, #0f4c3a 38%, #0a3527 72%, #061d15 100%);
  color: #eaf5ee;
}

/* ---- animated backdrop ---- */
.login-bg { position: absolute; inset: 0; pointer-events: none; }

.lb-glow {
  position: absolute; left: 50%; top: -120px; width: 130vmax; height: 130vmax;
  transform: translate(-50%, -30%);
  background: radial-gradient(circle at center,
    rgba(244,185,66,.40) 0%, rgba(244,185,66,.15) 24%, rgba(244,185,66,0) 55%);
  animation: lb-breathe 7s ease-in-out infinite;
}
.lb-sun {
  position: absolute; left: 50%; top: -118px; width: 230px; height: 230px;
  transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(circle at 50% 46%,
    #ffeeb0 0%, #f8c84f 40%, #f4a72e 68%, rgba(244,167,46,0) 72%);
  box-shadow: 0 0 90px 34px rgba(244,185,66,.34);
  animation: lb-rise 1.5s cubic-bezier(.2,.85,.25,1) both, lb-breathe 7s ease-in-out 1.5s infinite;
}
.lb-rays {
  position: absolute; left: 50%; top: -118px; width: 780px; height: 780px;
  background: repeating-conic-gradient(from 0deg, rgba(244,185,66,.20) 0deg 3.5deg, transparent 3.5deg 18deg);
  -webkit-mask: radial-gradient(circle at center, #000 16%, transparent 60%);
          mask: radial-gradient(circle at center, #000 16%, transparent 60%);
  animation: lb-spin 90s linear infinite; opacity: .85;
}
.lb-grid {
  position: absolute; left: 50%; bottom: -2px; width: 250vw; height: 44vh;
  transform: translateX(-50%) perspective(440px) rotateX(69deg); transform-origin: bottom center;
  background:
    linear-gradient(rgba(108,194,74,.20) 1.5px, transparent 1.5px) 0 0 / 100% 34px,
    linear-gradient(90deg, rgba(108,194,74,.20) 1.5px, transparent 1.5px) 0 0 / 34px 100%;
  -webkit-mask: linear-gradient(to top, #000 0%, transparent 80%);
          mask: linear-gradient(to top, #000 0%, transparent 80%);
  animation: lb-grid-move 5.5s linear infinite; opacity: .65;
}
.lb-particles { position: absolute; inset: 0; }
.lb-particles i {
  position: absolute; bottom: -14px; border-radius: 50%;
  background: radial-gradient(circle, #ffeeb0, rgba(244,185,66,.25));
  box-shadow: 0 0 9px 1px rgba(244,185,66,.6);
  animation: lb-float linear infinite; will-change: transform, opacity;
}

@keyframes lb-rise { from { transform: translateX(-50%) translateY(70px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
@keyframes lb-breathe { 0%, 100% { opacity: .95; } 50% { opacity: .55; } }
@keyframes lb-spin { from { transform: translateX(-50%) rotate(0); } to { transform: translateX(-50%) rotate(360deg); } }
@keyframes lb-grid-move { to { background-position: 0 34px, 0 0; } }
@keyframes lb-float {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  12% { opacity: .9; } 88% { opacity: .9; }
  100% { transform: translateY(-104vh) translateX(var(--drift, 0px)); opacity: 0; }
}

/* ---- the glass card ---- */
.login-card {
  position: relative; z-index: 2; width: 100%; max-width: 384px;
  max-height: calc(100vh - 84px); overflow-y: auto;
  padding: 26px 22px 22px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(12,42,32,.72), rgba(7,28,21,.80));
  border: 1px solid rgba(244,185,66,.30);
  box-shadow: 0 26px 64px -14px rgba(0,0,0,.6), 0 1px 0 rgba(255,255,255,.06) inset;
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
          backdrop-filter: blur(16px) saturate(1.1);
  animation: lb-card-in .6s cubic-bezier(.2,.85,.25,1) both;
}
@keyframes lb-card-in { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }

.login .brand.big {
  display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
  font-weight: 800; font-size: 22px; letter-spacing: .5px; color: #fff;
}
.login .brand.big .brand-mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; flex: 0 0 auto;
  background: radial-gradient(circle at 30% 25%, rgba(244,185,66,.38), rgba(244,185,66,.08));
  border: 1px solid rgba(244,185,66,.42); animation: lb-pulse 3.4s ease-in-out infinite;
}
.login .brand.big .brand-mark img { height: 30px; width: 30px; object-fit: contain; }
.login .brand.big .tag {
  font-size: 11px; color: var(--amber); font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; margin-top: 3px;
}
@keyframes lb-pulse { 0%, 100% { box-shadow: 0 0 16px rgba(244,185,66,.30); } 50% { box-shadow: 0 0 30px rgba(244,185,66,.58); } }

.login .tagline { min-height: 18px; margin: 4px 0 18px; font-size: 13.5px; font-weight: 500; color: #b9d9c5; }
.login .tagline b { color: var(--amber); font-weight: 700; }
.login .tagline .t { display: inline-block; animation: lb-tag .5s ease both; }
@keyframes lb-tag { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ---- form controls scoped to the dark card ---- */
.login label { color: #9fc2ac; }
.login input {
  background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.15);
  color: #fff; border-radius: 12px;
}
.login input::placeholder { color: rgba(255,255,255,.38); }
.login input:focus {
  border-color: var(--amber); background: rgba(255,255,255,.09);
  box-shadow: 0 0 0 3px rgba(244,185,66,.22);
}
.login .field { margin-bottom: 12px; }

.login .btn.primary {
  position: relative; overflow: hidden; letter-spacing: .3px;
  background: linear-gradient(100deg, #f4b942, #f8cf6e 48%, #f4a72e);
  color: #3a2c05; box-shadow: 0 9px 24px -7px rgba(244,185,66,.65);
}
.login .btn.primary::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 38%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  transform: skewX(-20deg); animation: lb-shine 3.8s ease-in-out infinite;
}
@keyframes lb-shine { 0% { left: -60%; } 55%, 100% { left: 135%; } }
.login .btn.primary:active { transform: translateY(1px); }
.login .btn.primary .spin { border-color: rgba(58,44,5,.3); border-top-color: #3a2c05; }
.login .btn.ghost { background: rgba(255,255,255,.08); color: #eaf5ee; }

.login .link {
  display: inline-block; background: none; border: 0; padding: 4px 0; margin: 0;
  color: var(--amber); font-weight: 600; font-size: 13px; font-family: inherit; cursor: pointer;
}
.login .link:hover { text-decoration: underline; }
.login .back-row { margin-top: 12px; text-align: center; }
.login .row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

.login .lg-error {
  color: #ffd6cd; background: rgba(178,59,48,.24); border: 1px solid rgba(255,150,130,.4);
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 12px;
}
.login .lg-note { color: #c3ddcd; font-size: 12.5px; line-height: 1.5; margin: 0 0 14px; }
.login .lg-note b { color: #fff; }

.login .otp-input {
  text-align: center; letter-spacing: 11px; font-size: 22px; font-weight: 800;
  padding-left: 11px; font-variant-numeric: tabular-nums;
}

/* dev-login rows stay readable on the dark card */
.login .row-item { background: rgba(255,255,255,.94); border-color: rgba(255,255,255,.2); }
.login .muted { color: #b9d9c5; }

/* ---- stats strip + footer ---- */
.login-stats {
  display: flex; gap: 6px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.login-stats .stat { flex: 1; text-align: center; }
.login-stats .stat b {
  display: block; font-size: 19px; font-weight: 800; color: var(--amber); font-variant-numeric: tabular-nums;
}
.login-stats .stat span { font-size: 10px; color: #9fc2ac; text-transform: uppercase; letter-spacing: .5px; }
.login-foot {
  position: relative; z-index: 2; margin-top: 18px; text-align: center;
  font-size: 11.5px; letter-spacing: .3px; color: rgba(234,245,238,.55);
}

@media (max-height: 640px) { .login-stats, .login-foot { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .lb-glow, .lb-sun, .lb-rays, .lb-grid, .login-card, .brand-mark,
  .login .btn.primary::after, .login .tagline .t { animation: none !important; }
  .lb-particles { display: none; }
  .lb-sun { transform: translateX(-50%); opacity: 1; }
}

/* user chip in header */
header.app .user { display: flex; align-items: center; gap: 10px; }
header.app .user-meta { text-align: right; line-height: 1.1; display: flex; flex-direction: column; }
header.app #user-chip { font-size: 13px; font-weight: 700; }
header.app .role { font-size: 10.5px; color: #bfe0cc; text-transform: capitalize; }

/* tab nav */
nav.tabs { position: sticky; top: 0; z-index: 25; display: flex; gap: 4px; overflow-x: auto; background: #0c3e30; padding: 0 10px; box-shadow: 0 2px 10px rgba(15,76,58,.18); }
nav.tabs button { flex: 0 0 auto; background: none; border: 0; color: #bfe0cc; font-weight: 700; font-size: 14px; padding: 13px 14px; border-bottom: 3px solid transparent; }
nav.tabs button.on { color: #fff; border-bottom-color: var(--amber); }

.subtoolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }
.subtoolbar .icon { background: #eef4f0; border: 0; color: var(--green); border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 14px; }

/* generic lists / rows used by sites, inventory, users */
.list { display: flex; flex-direction: column; gap: 9px; }
.row-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 13px 13px; border: 1px solid var(--hair); border-radius: 12px; background: #fbfdfc; cursor: pointer; }
.row-item:active { background: #f0f6f2; }
button.row-item { font: inherit; }
.ri-main { font-weight: 600; } .ri-sub { font-size: 12.5px; color: var(--muted); }

.pill { font-size: 11px; font-weight: 800; padding: 4px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .4px; flex: 0 0 auto; }
.pill.ok { background: #e7f6ec; color: #15803d; } .pill.mut { background: #eef2ef; color: var(--muted); }
.pill.warn { background: #fff1d6; color: #92600a; } .pill.bad { background: #fdecea; color: #b23b30; }

.muted { color: var(--muted); } .sm { font-size: 11.5px; }
h4.sub { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--green); }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-bottom: 12px; }
.kv > div { display: flex; flex-direction: column; }
.kv span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kv b { font-size: 14px; }

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.btnrow .btn { flex: 1; padding: 11px 14px; font-size: 14px; }

/* quantity tables (sites BOM, inventory, net-to-buy) */
.qty-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.qty-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 6px 6px; border-bottom: 1.5px solid var(--hair); }
.qty-table td { padding: 9px 6px; border-bottom: 1px solid #eef2ef; vertical-align: top; }
.qty-table td.num { text-align: right; white-space: nowrap; font-weight: 600; }
.qty-table tr.short td { background: #fdf6f5; }

/* photo capture + thumbs (inventory, Phase 3) */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--hair); }
.filechip { display: inline-flex; align-items: center; gap: 8px; border: 1.5px dashed #bcd4c5; background: #f4faf6; color: var(--green-mid);
  border-radius: 10px; padding: 11px; font-weight: 700; font-size: 14px; width: 100%; justify-content: center; cursor: pointer; }
.filechip input { display: none; }
