/* Invoice builder demo — layout and component styles.
   Colours and radii mirror the design system tokens the vendored components
   already declare (see vendor/css/button.css); nothing here overrides a .ll-*
   component. */

:root {
  --ink:       #333;
  --ink-2:     #545454;
  --ink-3:     #8b8b8b;
  --line:      #e6e6e6;
  --line-soft: #f0f0f0;
  --bg:        #f4f6f7;
  --white:     #fff;
  --brand:     #005b82;
  --brand-900: #004563;
  --brand-50:  #e6f8fd;
  --link:      #0b7ab0;
  --green:     #0a6b33;
  --green-soft:#f3faf5;
  --red:       #a01323;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.05);
  --shadow-2: 0 8px 32px rgba(0,0,0,.16);
  --shadow-pop: 0 6px 24px rgba(0,0,0,.18);
}

/* Design system component hosts. LLButton / LLIconButton / LLChip render into a
   wrapper node; `display: contents` keeps the DS element itself as the flex or
   grid child, so the wrapper never affects layout. */
.ll-host { display: contents; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Nunito Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.is-modal-open { overflow: hidden; }
button { font: inherit; color: inherit; }

/* ============================================================ launcher page */

.page { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px; background: var(--white);
  border-bottom: 1px solid var(--line); flex: none;
}
.topbar__l, .topbar__r { display: flex; align-items: center; gap: 8px; }
.topbar__l b { font-weight: 800; }
.topbar__sep { color: #cfd4d7; }
.topbar__crumb { color: var(--ink-3); font-size: 14px; }

.launch { flex: 1; display: flex; justify-content: center; padding: 40px 20px; }
.launch__card {
  width: 100%; max-width: 640px; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 28px; box-shadow: var(--shadow-1);
}
.launch__card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 800; }
.launch__card p { margin: 0 0 20px; color: var(--ink-2); font-size: 16px; max-width: 52ch; }
.launch__foot { display: flex; gap: 10px; margin-top: 20px; }

.stulist { display: flex; flex-direction: column; gap: 6px; }
.stu {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 12px; background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-md); cursor: pointer;
}
.stu:hover { background: #fafafa; }
.stu.is-on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.stu__av {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: var(--brand-50);
  color: var(--brand); font-weight: 800; font-size: 14px;
}
.stu__t { display: flex; flex-direction: column; line-height: 1.3; }
.stu__t b { font-size: 16px; font-weight: 700; }
.stu__t span { font-size: 14px; color: var(--ink-3); }
.stu__pick { margin-left: auto; font-size: 14px; color: var(--ink-3); }
.stu.is-on .stu__pick { color: var(--brand); font-weight: 700; }

.issued { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.issued__h { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.issued__row {
  display: grid; grid-template-columns: 92px 1fr 70px auto; gap: 12px;
  font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--line-soft);
}
.issued__row b { text-align: right; }

/* =================================================================== modal */

.scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.38);
  display: flex; padding: 24px; z-index: 40;
}
.modal {
  margin: auto; width: 100%; height: 100%;
  background: var(--white); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal__head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 8px 20px; border-bottom: 1px solid var(--line); background: #fbfbfb;
}
.modal__title { font-size: 18px; font-weight: 700; }
.modal__headr { display: flex; align-items: center; gap: 4px; }
.modal__body { flex: 1; display: flex; min-height: 0; }
.modal__main { flex: 1; overflow: auto; padding: 28px 24px 40px; background: #fcfcfc; }
.modal__foot {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--white);
}
.modal__probs { display: flex; align-items: center; gap: 6px; color: var(--red); font-size: 14px; }


/* ============================================================ summary rail */

.rail {
  flex: none; width: 30vw; border-left: 1px solid var(--line);
  padding: 24px 24px 32px; overflow: auto; background: var(--white);
}
.rail__h { font-weight: 700; font-size: 18px; margin-bottom: 10px; }
.rail__h--sec { margin-top: 26px; }
.sum__row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 16px; padding: 3px 0; color: var(--ink-2);
}
.sum__row--ded span:last-child { color: var(--green); }
/* The grand total is the same 16px body size as the rows above it — bold and
   brand-coloured is the whole emphasis. */
.sum__row--grand { color: var(--brand); font-weight: 700; padding-top: 6px; }

.info { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.info__cell--wide { grid-column: 1 / -1; }
.info__k { font-size: 14px; color: var(--ink-3); }
.info__v { font-size: 16px; }
.remarks__wrap { margin-top: 16px; }
.remarks {
  width: 100%; margin-top: 4px; resize: vertical; min-height: 92px;
  border: 1px solid #c9c9c9; border-radius: var(--r-sm); padding: 8px 10px;
  font: inherit; font-size: 16px; color: var(--ink);
}
.remarks:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.remarks__count { text-align: right; font-size: 14px; color: var(--ink-3); margin-top: 2px; }

/* ================================================================= builder */

.builder { max-width: 700px; }
.builder { width: 100%; max-width: 840px; margin: 0 auto; }
.builder__h1 { margin: 0 0 18px; font-size: 20px; font-weight: 800; }
.builder__lbl { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.builder__lbl--sec { margin-top: 22px; }
.builder__rule { border-top: 1px solid var(--line); margin: 26px 0 18px; }
.builder__actions { display: flex; gap: 10px; }

/* ---------------------------------------------------------------- groups */

.group + .group { margin-top: 22px; }
.group__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.group__headl { display: flex; align-items: center; gap: 6px; }
.group__name {
  font-size: 18px; font-weight: 700; outline: none; border-radius: var(--r-sm);
  padding: 1px 3px; min-width: 40px;
}
.group__name:focus { box-shadow: 0 0 0 2px var(--brand); }
.group__items { display: flex; flex-direction: column; gap: 10px; }
.group__empty {
  border: 1px dashed var(--line); border-radius: var(--r-md);
  padding: 14px; text-align: center; color: var(--ink-3); font-size: 14px;
}
.group__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 6px 0 0;
}
/* Ghost buttons carry their own 12px inline padding, so the row gap is small. */
.group__footl { display: flex; align-items: center; gap: 4px; }
.group__sub { font-size: 16px; font-weight: 600; }

/* ----------------------------------------------------------------- cards */

.card {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--white); overflow: hidden;
}
.card--err { border-color: #e3a6ae; }
.card__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; padding: 10px 12px 10px 14px; cursor: pointer;
}
.card__head:hover { background: #fafafa; }
.card--open .card__head { background: var(--brand); color: var(--white); cursor: pointer; }
.card--open .card__head:hover { background: var(--brand-900); }
/* The brand-filled open card head has no design system equivalent (see
   DESIGN-SYSTEM-AUDIT.md § E), and LLIconButton has no on-brand intent to switch
   to, so the ghost button's colour is forced for this one container. */
.card--open .card__head .ll-icon-button { color: var(--white); }
.card--open .card__head .ll-icon-button:hover { background: rgba(255,255,255,.18); }
.card__titlewrap { min-width: 0; }
.card__title { display: flex; align-items: center; gap: 6px; font-size: 16px; }
.card__title b { font-weight: 700; }
.card__qty { color: inherit; }
.card__pen { display: inline-flex; opacity: .85; }
.card__sub { font-size: 14px; margin-top: 1px; }
.card--open .card__sub { color: rgba(255,255,255,.9); }
.card:not(.card--open) .card__sub { color: var(--ink-2); }
.card__right { display: flex; align-items: center; gap: 10px; flex: none; }
.card__amt { font-weight: 700; font-size: 16px; }
.card__body { padding: 14px 16px 4px; }
.card__rule { border-top: 1px solid var(--line-soft); margin: 14px 0 10px; }
.card__foot { border-top: 1px solid var(--line-soft); padding: 4px 6px; }

.sec-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }

.sums { padding-bottom: 10px; }
.sums__row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 16px; padding: 3px 0; color: var(--ink-2);
}
.sums__row--total { color: var(--ink); font-size: 16px; }

/* ------------------------------------------------------------- item form */

.itemform {
  display: grid; gap: 12px 12px;
  grid-template-columns: 1fr 96px 148px;
}
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld--item { grid-column: 1; }
.fld--qty  { grid-column: 2; }
.fld--price{ grid-column: 3; }
.itemform__months { grid-column: 1 / -1; display: flex; gap: 12px; }
.fld--month { width: 164px; }
.fld__label { font-size: 14px; font-weight: 600; color: var(--ink-2); display: flex; gap: 3px; }
.fld__req { color: #a01323; }
.fld__input {
  width: 100%; height: 38px; padding: 0 10px; font: inherit; font-size: 16px;
  border: 1px solid #c9c9c9; border-radius: var(--r-sm); background: var(--white); color: var(--ink);
}
.fld__input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.fld__input.is-err { border-color: #c0392b; }
.fld__select { appearance: none; padding-right: 34px; cursor: pointer; }
.selwrap { position: relative; }
.selwrap__chev {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--ink-2);
}
.priceWrap {
  display: flex; align-items: center; border: 1px solid #c9c9c9;
  border-radius: var(--r-sm); background: var(--line-soft); overflow: hidden;
}
.priceWrap--flex { background: var(--white); }
.priceWrap .fld__price {
  border: 0; background: transparent; height: 36px; text-align: left;
}
.priceWrap .fld__price:focus { outline: none; }
.priceWrap--flex:focus-within { outline: 2px solid var(--brand); outline-offset: -1px; }
.priceWrap__cur { padding: 0 10px; color: var(--ink-3); font-size: 14px; }

/* GST tag — Figma node 6628-61889 uses the -soft-secondary surface and stroke,
   which the DS Chip has no colour for; only its tint variables are overridden. */
.chip--gst .ll-chip {
  --bg: #fafafa;
  --bg-hover: #fafafa;
  --bg-active: #fafafa;
  --border: var(--line);
  --border-active: var(--line);
  --label: var(--ink-2);
  cursor: default;
}

/* month field + picker ---------------------------------------------------- */

.fld__month {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  text-align: left; cursor: pointer;
}
.fld__monthv.is-empty { color: var(--ink-3); }
.fld__monthchev { display: inline-flex; color: var(--ink-2); flex: none; }

.mpick__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 2px 8px;
}
.mpick__y { font-weight: 700; font-size: 16px; }
.mpick__nav {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.mpick__nav:hover { background: var(--line-soft); }
.mpick__nav:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.mpick__nav--prev svg { transform: rotate(90deg); }
.mpick__nav--next svg { transform: rotate(-90deg); }

.mpick__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.mpick__m {
  height: 36px; border: 0; border-radius: var(--r-sm); background: transparent;
  font: inherit; font-size: 15px; color: var(--ink); cursor: pointer;
}
.mpick__m:hover { background: var(--line-soft); }
.mpick__m:focus-visible { outline: 2px solid var(--brand); outline-offset: -1px; }
.mpick__m.is-on { background: var(--brand); color: #fff; font-weight: 700; }

.mpick__foot { display: flex; justify-content: flex-end; padding-top: 6px; }
.mpick__clear {
  border: 0; background: transparent; font: inherit; font-size: 14px;
  color: var(--ink-2); cursor: pointer; padding: 4px 6px; border-radius: var(--r-sm);
}
.mpick__clear:hover { background: var(--line-soft); color: var(--ink); }

.itemform__errs { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.itemform__err { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--red); }

/* ------------------------------------------------------- deduction rows */

.dedrow {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 14px; border-top: 1px solid var(--line-soft);
  font-size: 16px; background: var(--white);
}
.dedrow--indent { padding-left: 30px; }
.dedrow__name {
  color: var(--green); display: inline-flex; align-items: center; gap: 6px;
}
.dedrow__amt { margin-left: auto; color: var(--green); font-weight: 600; }

.dedcard {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--white); margin-top: 10px; overflow: hidden;
}
.dedcard .dedrow { border-top: 0; }
/* Deduction names read as regular body text at every scope — the scheme's
   percentage is spelled out in the name itself, not tagged with a chip. */



/* ------------------------------------------------------------- popovers */

.pop {
  position: fixed; z-index: 60; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 8px; min-width: 300px;
}
/* LLDropdownMenu brings its own card — 8px radius, 1.5px stroke, 4/8/.25 shadow —
   so the anchor layer must contribute position and nothing else. */
.pop--bare {
  background: none; border: 0; box-shadow: none; padding: 0; min-width: 0;
}


/* ---------------------------------------------------------------- toast */

#toast-root {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: #2b2b2b; color: var(--white); font-size: 14px;
  padding: 9px 14px; border-radius: 999px; box-shadow: var(--shadow-pop);
  transition: opacity .25s ease, transform .25s ease;
}
.toast--error { background: #7a1524; }
.toast.is-out { opacity: 0; transform: translateY(6px); }

/* --------------------------------------------------------------- narrow */

@media (max-width: 960px) {
  /* one document that scrolls end to end — the summary sits after the line
     items instead of being pinned in its own pane, like a paper invoice. */
  .modal__body { flex-direction: column; overflow: auto; }
  .modal__main { flex: none; overflow: visible; padding-bottom: 28px; }
  .rail {
    width: auto; flex: none; overflow: visible;
    border-left: 0; border-top: 1px solid var(--line);
    background: #fcfcfc; padding: 24px 24px 40px;
  }
  .rail > * { max-width: 840px; margin-left: auto; margin-right: auto; }
  .itemform { grid-template-columns: 1fr 88px; }
  .fld--price { grid-column: 1 / -1; }
}
