/* Y2 Solar — quoting tool.
 *
 * The palette is lifted from the quotation the tool produces (navy, amber,
 * cream) rather than invented. A rep often turns the laptop round mid-call, and
 * having the screen and the PDF look like the same company is worth more than
 * any individual flourish here.
 *
 * Class names are load-bearing: app.js builds the DOM and expects every one of
 * them. Restyle freely, rename nothing.
 */

:root {
  /* structure */
  --navy: #12294A;
  --navy-2: #1B3A63;
  --navy-3: #2E5183;

  /* action and attention. Amber earns its place by being rare. */
  --amber: #B45F0A;
  --amber-soft: #FBEEDC;
  --amber-line: #E8C79A;
  --gold: #E8B75F;

  /* neutrals, very slightly cool so the amber reads warm against them */
  --bg: #F1F3F6;
  --panel: #FFFFFF;
  --panel-2: #F7F9FB;
  --ink: #151A21;
  --ink-2: #3D4653;
  --muted: #6A7482;
  --line: #E1E5EB;
  --line-2: #EDF0F4;

  /* semantic — the same greens and reds the quote document uses */
  --good: #2F6F4E;
  --danger: #A3402C;
  --danger-bg: #FDF3F2;

  /* kept so any older rule referring to the brand still resolves */
  --brand: #12294A;
  --brand-ink: #ffffff;
  --accent: #B45F0A;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 41, 74, .05);
  --shadow-lift: 0 4px 14px rgba(18, 41, 74, .10);

  --control-h: 36px;
  --header-h: 56px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Every figure here is read against another figure, so digits line up by
   default rather than only where a class happened to be applied. */
.kpi .v, .fact .v, td.num, th.num, .totals td, .money { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- header */
header.top {
  background: var(--navy);
  color: #fff;
  height: var(--header-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
/* The mark is a JPEG on white, so it sits on its own chip rather than showing
   a white rectangle against the navy. */
header.top .mark {
  background: #fff;
  border-radius: 7px;
  padding: 4px 5px;
  line-height: 0;
  flex: 0 0 auto;
}
header.top .mark img { height: 26px; display: block; }
header.top h1 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .1px; color: #fff; }
header.top .sub { font-size: 11.5px; color: #A9BCD6; margin-top: 1px; }
header.top nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
header.top nav a {
  color: #C9D6E8; text-decoration: none; font-size: 13px;
  padding: 7px 12px; border-radius: 7px; background: transparent;
  transition: background .12s, color .12s;
}
header.top nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
header.top nav a.on { background: rgba(255,255,255,.16); color: #fff; font-weight: 550; }

/* Icon-only navigation. The name is carried by the title attribute, which the
   browser shows on hover - no custom tooltip to maintain, and it stays
   available to screen readers through aria-label. */
header.top nav a.navico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
}
header.top nav a.navico svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}

.wrap { max-width: 1560px; margin: 0 auto; padding: 16px 20px 40px; width: 100%; }

.grid { display: grid; grid-template-columns: minmax(340px, 420px) 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------- summary bar */
/* Four equal cards made the rep hunt for the one number the customer had just
   asked about. The quoted price now outranks the rest outright. */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px 12px;
  box-shadow: var(--shadow);
}
.kpi .k {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 600;
}
.kpi .v { font-size: 21px; font-weight: 620; margin-top: 3px; letter-spacing: -.4px; }
.kpi .v small { font-size: 12.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.kpi.hi {
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-color: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-lift);
}
.kpi.hi .k { color: var(--gold); }
.kpi.hi .v { font-size: 27px; font-weight: 680; }
.kpi.hi .v small { color: rgba(255,255,255,.72); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  scroll-margin-top: 12px;          /* section-rail jumps land cleanly */
}
.card > h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .9px;
  color: var(--navy); font-weight: 700;
  margin: 0; padding: 12px 16px 11px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 8px;
}
.card > .body { padding: 16px; }

/* --------------------------------------------------------- section rail */
/* Nine stacked sections is a lot to scroll past when all you wanted was to
   change the inverter. The rail turns that into one click. */
.rail {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 0 0 12px;
  background: linear-gradient(var(--bg) 72%, rgba(241, 243, 246, 0));
}
.rail button {
  font: inherit; font-size: 11.5px; line-height: 1; min-height: 0;
  padding: 6px 10px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  cursor: pointer; transition: all .12s;
}
.rail button:hover { border-color: var(--navy-3); color: var(--navy); background: var(--panel); }
.rail button.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 550; }

/* ------------------------------------------------------------- controls */
label.field { display: block; margin-bottom: 13px; }
label.field > span {
  display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 550;
}

select, input[type=text], input[type=number], input[type=date], input[type=email], textarea {
  width: 100%;
  min-height: var(--control-h);
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  font: inherit;
  color: inherit;
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 62px; resize: vertical; }

/* A native select looks unfinished beside styled inputs; one chevron fixes it. */
select {
  appearance: none;
  /* In a narrow column a long option ("Single Phase") is clipped mid-word by
     the native control; an ellipsis at least reads as deliberate. */
  text-overflow: ellipsis;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%236A7482' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
select:hover, input:hover, textarea:hover { border-color: #C9D0DA; }

/* One focus treatment, and it follows the keyboard as well as the mouse. */
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(180, 95, 10, .16);
}
input[type=range] { width: 100%; accent-color: var(--amber); min-height: 0; padding: 0; border: none; }
input[type=checkbox], input[type=radio] { accent-color: var(--navy); width: auto; min-height: 0; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 11px; }

/* -------------------------------------------------------------- buttons */
button {
  font: inherit; font-weight: 550;
  min-height: var(--control-h);
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { background: var(--panel-2); border-color: #C9D0DA; color: var(--ink); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(180, 95, 10, .22); }
button:disabled { opacity: .55; cursor: default; }
button:disabled:hover { background: var(--panel); border-color: var(--line); }

button.primary { background: var(--amber); border-color: var(--amber); color: #fff; }
button.primary:hover { background: #9C5208; border-color: #9C5208; color: #fff; }
button.small { min-height: 0; padding: 4px 9px; font-size: 12px; }
button.danger { color: var(--danger); border-color: #E7C4BD; background: #fff; }
button.danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- tabs */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  padding: 0 12px; background: var(--panel-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.tabs button {
  border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 11px 13px; color: var(--muted); font-size: 13px; min-height: 0; font-weight: 550;
}
.tabs button:hover { background: none; color: var(--navy); border-bottom-color: var(--line); }
.tabs button.active { color: var(--navy); border-bottom-color: var(--amber); font-weight: 650; }

/* --------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 11px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
th {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  font-weight: 700; background: var(--panel-2); position: sticky; top: 0; z-index: 1;
}
td.num, th.num { text-align: right; }
tr.cat td {
  background: #EEF2F7; font-weight: 650; font-size: 11px;
  text-transform: uppercase; letter-spacing: .7px; color: var(--navy);
}
tbody tr:hover td { background: var(--panel-2); }
tr.cat:hover td { background: #E6ECF4; }

/* --------------------------------------------------------------- totals */
.totals { width: 100%; font-size: 14px; }
.totals td { padding: 6px 11px; border: none; }
.totals tr.grand td { border-top: 2px solid var(--navy); font-weight: 700; font-size: 16px; padding-top: 9px; }
.totals tr.net td { color: var(--amber); font-weight: 700; }

/* ------------------------------------------------------ notes and chips */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spec { color: var(--muted); font-size: 12px; }
.right { text-align: right; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: #EEF2F7; color: #47536A; border: 1px solid #DFE6EF; font-weight: 550;
}
.pill.warn { background: var(--amber-soft); border-color: var(--amber-line); color: #8A4B06; }

.note {
  background: var(--amber-soft); border: 1px solid var(--amber-line); color: #6B5537;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px; margin: 10px 0;
}
.err {
  background: var(--danger-bg); border: 1px solid #F0C9C2; color: #7F1D1D;
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 20px; cursor: pointer;
  font-size: 12px; background: var(--panel); transition: all .12s;
}
.chips label:hover { border-color: #C9D0DA; }
.chips label:has(input:checked) {
  background: var(--amber-soft); border-color: var(--amber-line); color: #8A4B06; font-weight: 550;
}

.structure-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.fact { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; background: var(--panel-2); }
.fact .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.fact .v { font-weight: 620; margin-top: 1px; }


/* ------------------------------------------------------------- add-ons */
/* A long, filterable catalogue. Each row is one decision: what it is, what it
   costs, and how many — so the three sit in fixed columns rather than running
   together as a wall of text. */
.addon-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  max-height: 340px; overflow-y: auto; background: var(--panel);
}
.addon {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 10px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer; font-size: 12.5px;
}
.addon:last-child { border-bottom: none; }
.addon:hover { background: var(--panel-2); }
.addon.on { background: var(--amber-soft); }
.addon-name { line-height: 1.3; }
.addon-rate {
  color: var(--ink-2); font-weight: 620; white-space: nowrap;
  font-variant-numeric: tabular-nums; font-size: 12px;
}
/* A discount is a different kind of number from a charge; colour says so. */
.addon-rate.neg { color: var(--good); }
.addon-qty { width: 58px; min-height: 28px; padding: 3px 7px; font-size: 12px; }

/* --------------------------------------------------------- availability */
/* Out of stock is information, not a barrier: these stay selectable and stay
   priceable, so a rep can quote a part that has to be ordered in. */
option.unavailable { color: #98A2B0; }
.addon.unavailable .addon-name,
.addon.unavailable .addon-rate { color: #98A2B0; }
.oos {
  font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--danger); font-weight: 600; margin-left: 6px;
}

/* ------------------------------------------------------ inverter grid */
/* One row per unit. Larger roofs take several inverters and they are not always
   the same model, so each is chosen on its own line. */
.inv-grid { display: flex; flex-direction: column; gap: 7px; }
.inv-row { display: grid; grid-template-columns: 26px 1fr; align-items: center; gap: 8px; }
.inv-n {
  font-size: 11px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right;
}

/* --------------------------------------------------------- label / value */
/* Payment milestones and ROI both read as "name … value". Without this they
   collapse into one run of text: "Booking — 10%₹20,619". */
.ptrow {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line-2);
}
.ptrow:last-child { border-bottom: none; }
.ptrow > span { color: var(--ink-2); }
.ptrow > b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------- custom payment stages */
.pt-edit {
  display: grid;
  grid-template-columns: 1fr 64px 12px 92px 30px;
  align-items: center; gap: 6px; margin-bottom: 6px;
}
.pt-edit input { min-height: 30px; padding: 4px 8px; font-size: 12.5px; }
.pt-edit button { min-height: 30px; padding: 0; color: var(--muted); }
.pt-edit button:hover { color: var(--danger); border-color: var(--danger); }
.pt-unit { font-size: 11px; color: var(--muted); }
.pt-head span {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600;
}

/* ------------------------------------------------------------ CRM lookup */
.crm-results { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.crm-hit {
  text-align: left; min-height: 0; padding: 7px 10px; font-weight: 500;
  border-color: var(--line-2); background: var(--panel-2); font-size: 12.5px;
}
.crm-hit:hover { background: var(--amber-soft); border-color: var(--amber-line); }

/* ------------------------------------------------- disclosure and scope */
.disclose { border-top: 1px solid var(--line-2); margin-top: 10px; padding-top: 8px; }
.disclose > summary {
  cursor: pointer; font-size: 12px; color: var(--muted); font-weight: 550;
  list-style: none; user-select: none;
}
.disclose > summary::-webkit-details-marker { display: none; }
.disclose > summary::before { content: '▸ '; color: var(--muted); }
.disclose[open] > summary::before { content: '▾ '; }
.disclose > summary:hover { color: var(--navy); }

.exclude {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.exclude.on { color: var(--danger); font-weight: 550; }
/* Struck through, because the line is still listed but no longer charged. */
.excluded-row td { color: var(--muted); text-decoration: line-through; }
.excluded-row td:last-child { text-decoration: none; }

.slider { padding: 0; }

/* ----------------------------------------------------------- scrollbars */
.grid > * { scrollbar-width: thin; scrollbar-color: #C9D0DA transparent; }
.grid > *::-webkit-scrollbar { width: 9px; }
.grid > *::-webkit-scrollbar-thumb { background: #CFD6DF; border-radius: 20px; border: 2px solid var(--bg); }
.grid > *::-webkit-scrollbar-thumb:hover { background: #B3BDC9; }
.grid > *::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- app shell
   On a wide screen the page stops scrolling as one document. The header and the
   live totals stay put, and the two columns scroll independently: you can work
   down a long input list on the left while the quote stays in view on the right,
   which is the whole point of a configurator.

   Only above the single-column breakpoint. On a phone the two panes are stacked,
   and locking the viewport there would trap the user in a short scroll box. */
/* Scoped to body.app deliberately: the price list uses .wrap with no .grid, and
   an unscoped overflow:hidden on body made that page unscrollable. */
@media (min-width: 1001px) {
  html, body.app { height: 100%; }
  body.app { display: flex; flex-direction: column; overflow: hidden; }

  /* The shell pins it now, so sticky (and its stacking context) is redundant. */
  body.app header.top { flex: 0 0 auto; position: static; }

  body.app .wrap {
    flex: 1 1 auto;
    min-height: 0;              /* lets the grid below actually shrink */
    display: flex;
    flex-direction: column;
    padding-bottom: 16px;
  }
  body.app .wrap > .err, body.app .wrap > .kpis { flex: 0 0 auto; }

  body.app .grid {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;       /* overrides the start alignment above */
    margin-top: 16px;
  }
  body.app .grid > * {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;   /* scrolling one pane never scrolls the other */
    padding-right: 6px;
  }
  body.app .grid > * > .card:last-child { margin-bottom: 4px; }
}

@media print {
  header.top, .tabs, .noprint, .rail, .card > h2 { display: none !important; }
  body { background: #fff; }
  .card { border: none; box-shadow: none; }
  .grid { display: block; }
  /* Undo the app shell, or only the first screenful reaches the paper. */
  html, body, body.app { height: auto; overflow: visible; display: block; }
  .wrap, body.app .wrap { display: block; }
  .grid > *, body.app .grid > * { overflow: visible; height: auto; padding-right: 0; }
}
