/* ==========================================================
   Uniqside Quotes — styles
   Uniqside brand colours: charcoal and yellow.
   ========================================================== */

:root {
  --paper: #F3F0EA;
  --paper-2: #E9E4DB;
  --surface: #FBFAF7;
  --white: #FFFFFF;
  --ink: #262626;
  --charcoal: #474747;
  --ink-2: #45443F;
  --muted: #6A675F;
  --line: #DDD7CB;
  --field: #CFC8BA;
  --accent: #DCD35E;        /* Uniqside yellow, for fills */
  --accent-strong: #5F5A1C; /* dark olive, for accent text on light backgrounds */
  --accent-light: #E6DD6E;  /* yellow on dark backgrounds */

  --ok: #2F6B47;
  --ok-bg: #E2EEE5;
  --info: #2B5884;
  --info-bg: #E1E9F2;
  --warn-bg: #F6EDD8;
  --warn-line: #E5D3A6;
  --danger: #A3321F;
  --danger-bg: #F6E2DC;

  --font-display: 'Archivo', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  --gutter: clamp(16px, 3vw, 32px);
  --radius: 4px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%231C1C1A' stroke-width='1.6'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }

.i {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.accent-fill { fill: var(--accent); }
.muted { color: var(--muted); }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.optional { font-weight: 400; color: var(--muted); }

/* ---------------- Top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--charcoal);
  color: #fff;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 1280px;
  height: 60px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .wordmark { width: auto; height: 17px; }
.brand .logomark { display: none; width: 28px; height: 28px; }
.brand-app {
  padding-left: 10px;
  border-left: 1px solid #6A6A6A;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #CFCFCF;
}
.topnav { display: flex; gap: 22px; align-self: stretch; }
.topnav a {
  display: flex;
  align-items: center;
  border-bottom: 2px solid transparent;
  color: #DADADA;
  font-size: .92rem;
  font-weight: 500;
  text-decoration: none;
}
.topnav a:hover { color: #fff; }
.topnav a[aria-current="page"] { color: #fff; border-bottom-color: var(--accent); }
.save-state {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: #CFCFCF;
  white-space: nowrap;
}
.save-state.error { color: #FFB3A6; }

@media (max-width: 640px) {
  .topbar-inner { gap: 16px; }
  .brand-app, .hide-sm { display: none; }
  .save-state { display: none; }
  .topbar-new { margin-left: auto; }
  .topnav { gap: 16px; }
}
@media (max-width: 520px) {
  .brand .wordmark { display: none; }
  .brand .logomark { display: block; }
}
.topbar-new + .account { margin-left: -12px; }
@media (max-width: 640px) { .topbar-new + .account { margin-left: -4px; } }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-accent:hover { background: #CDC44A; border-color: #CDC44A; }
.btn-ghost { border-color: var(--field); background: var(--surface); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
}
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.notice .btn-link { text-decoration: underline; text-underline-offset: 3px; }
.add-link { min-height: 32px; font-size: .88rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { border-color: var(--line); background: var(--surface); color: var(--ink); }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* ---------------- Page frame ---------------- */

.page { max-width: 1280px; margin: 0 auto; padding: 28px var(--gutter) 96px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 750;
  font-stretch: 108%;
  letter-spacing: -.015em;
  line-height: 1.05;
}
.eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.notice {
  margin-bottom: 12px;
  padding: 11px 16px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-bg);
  font-size: .9rem;
}
.notice.error { border-color: #E4B8AE; background: var(--danger-bg); }

/* ---------------- Quote list ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 8px 0 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}
.stat { display: flex; flex-direction: column; gap: 3px; padding: 18px 20px; background: var(--surface); }
.stat-label {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  font-stretch: 106%;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat.accent .stat-value { color: var(--accent-strong); }
.stat-sub { font-size: .82rem; color: var(--muted); }

@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .stat { padding: 14px; } .stat-value { font-size: 1.2rem; } }

.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.search {
  flex: 1 1 260px;
  max-width: 420px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--field);
  border-radius: 3px;
  background: var(--white);
}
.search:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(28, 28, 26, .08); }
.seg {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--field);
  border-radius: 3px;
  background: var(--white);
}
.seg button {
  flex: none;
  padding: 8px 14px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.qlist { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.qhead, .qrow {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 120px 110px 150px 72px;
  gap: 16px;
  align-items: center;
  padding: 0 16px;
}
.qhead {
  min-height: 40px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.qrow { position: relative; min-height: 64px; border-bottom: 1px solid var(--line); transition: background-color .15s; }
.qrow:last-child { border-bottom: 0; }
.qrow:hover { background: var(--white); }
.qlink { font-family: var(--font-mono); font-size: .85rem; font-weight: 500; text-decoration: none; }
.qlink::after { content: ""; position: absolute; inset: 0; }
.qclient { display: flex; flex-direction: column; min-width: 0; }
.qclient strong, .qclient span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qclient strong { font-weight: 600; }
.qclient span { font-size: .85rem; color: var(--muted); }
.qdate { font-size: .88rem; color: var(--ink-2); }
.qdate small { display: block; color: var(--muted); font-size: .76rem; }
.qamt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.qactions { position: relative; z-index: 1; display: flex; justify-content: flex-end; gap: 2px; }

@media (max-width: 760px) {
  .qhead { display: none; }
  .qrow {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "num status"
      "client amt"
      "date actions";
    gap: 4px 12px;
    padding: 14px 16px;
  }
  .qlink { grid-area: num; }
  .qstatus { grid-area: status; justify-self: end; }
  .qclient { grid-area: client; }
  .qamt { grid-area: amt; align-self: end; }
  .qdate { grid-area: date; align-self: center; }
  .qactions { grid-area: actions; }
}

.chip, .status-select {
  border-radius: 999px;
  background-color: var(--paper-2);
  color: var(--ink-2);
  font-size: .78rem;
  font-weight: 600;
}
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
[data-status="sent"] { background-color: var(--info-bg); color: var(--info); }
[data-status="accepted"] { background-color: var(--ok-bg); color: var(--ok); }
[data-status="rejected"] { background-color: var(--danger-bg); color: var(--danger); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px 64px;
  border: 1px dashed var(--field);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.empty > svg { width: 110px; height: auto; margin-bottom: 18px; color: var(--ink); }
.empty h2 { margin-bottom: 8px; font-size: 1.4rem; font-weight: 700; }
.empty p { max-width: 32em; margin: 0 0 22px; color: var(--ink-2); }
.empty-small { padding: 24px; color: var(--muted); text-align: center; }

/* ---------------- Editor ---------------- */

.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 20px;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
}
.back:hover { color: var(--ink); }
.editor-title { display: flex; flex: 1 1 auto; align-items: center; gap: 12px; min-width: 0; }
.editor-title h1 { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 500; letter-spacing: .02em; }
.status-select {
  appearance: none;
  padding: 5px 28px 5px 12px;
  border: 0;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 9px 6px;
  cursor: pointer;
}
.editor-actions { display: flex; gap: 8px; }
.editor-meta { margin: -10px 0 16px; color: var(--muted); font-size: .82rem; }
.conflict { margin-bottom: 16px; }
.conflict p { margin: 0 0 10px; }
.conflict .btn-row { margin-top: 0; }

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.editor-side { position: sticky; top: 80px; }

@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; }
  .editor { padding-bottom: 120px; }
}

.card {
  container-type: inline-size;
  padding: 20px 22px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 14px;
}
.card-title { margin-bottom: 14px; font-size: 1.05rem; font-weight: 700; font-stretch: 104%; }
.card-head .card-title { margin-bottom: 0; }
.card-note { font-size: .8rem; color: var(--muted); }
.card-sub { margin: -8px 0 16px; color: var(--muted); font-size: .88rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.grid-2.nested { gap: 14px 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.field small { font-size: .78rem; color: var(--muted); }

@container (max-width: 520px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

.field input, .field select, .field textarea,
.item-row input, .item-row select, .item-row textarea,
.pay-row input, .section-title {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--field);
  border-radius: 3px;
  background: var(--white);
  font-size: .93rem;
}
.field select, .item-row select, .input-group select {
  appearance: none;
  padding-right: 30px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 10px 7px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(28, 28, 26, .08);
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
::placeholder { color: #9A968D; }

/* Item sections */
.section-block {
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.section-letter {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: .78rem;
}
.section-head .section-title {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  border-color: transparent;
  background: transparent;
  font-weight: 600;
}
.section-head .section-title:hover { border-color: var(--field); }
.section-head .section-title:focus { background: var(--white); }

.items-head, .item-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 86px 74px 100px 112px 92px;
  gap: 8px;
  padding: 0 12px;
}
.items-head {
  padding-top: 10px;
  padding-bottom: 4px;
  font-family: var(--font-mono);
  font-size: .64rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.item-row { align-items: start; padding-top: 8px; padding-bottom: 8px; }
.item-row + .item-row { border-top: 1px dashed var(--line); }
.item-no { padding-top: 10px; font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }
.item-row textarea { min-height: 40px; overflow: hidden; resize: none; }
.item-row input[type="number"] { text-align: right; }
.item-amt {
  padding-top: 10px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.item-actions { display: flex; justify-content: flex-end; padding-top: 5px; }
.no-items { margin: 0; padding: 14px 12px; color: var(--muted); font-size: .9rem; }

.section-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: .9rem;
}
.section-sub { color: var(--muted); }
.section-sub strong { margin-left: 6px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Stacked item rows when the card is narrow (phones, tablets) */
@container (max-width: 700px) {
  .items-head { display: none; }
  .item-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "desc desc desc"
      "unit qty rate"
      "amt amt actions";
    row-gap: 8px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .item-no { display: none; }
  .item-desc { grid-area: desc; }
  .item-unit { grid-area: unit; }
  .item-qty { grid-area: qty; }
  .item-rate { grid-area: rate; }
  .item-amt { grid-area: amt; padding-top: 6px; text-align: left; }
  .item-amt::before { content: "Amount  "; font-weight: 400; color: var(--muted); white-space: pre; }
  .item-actions { grid-area: actions; padding-top: 0; }
}

/* Payment schedule */
.pay-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 100px 130px 30px;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}
.pay-row + .pay-row { border-top: 1px dashed var(--line); }
.pay-no { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }
.pay-pct { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pay-pct input { text-align: right; }
.pay-amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.pay-list { margin-bottom: 8px; }
.pct-total {
  padding: 3px 9px;
  border-radius: 3px;
  background: var(--danger-bg);
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: .76rem;
}
.pct-total[data-ok="true"] { background: var(--ok-bg); color: var(--ok); }

@container (max-width: 520px) {
  .pay-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px;
    grid-template-areas: "label label del" "pct amt amt";
    padding: 10px 0;
  }
  .pay-no { display: none; }
  .pay-label { grid-area: label; }
  .pay-pct { grid-area: pct; }
  .pay-amt { grid-area: amt; }
  .pay-row .icon-btn { grid-area: del; }
}

/* Summary */
.summary .field + .sum-grid { margin-top: 12px; }
.sum-grid { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 10px; }
.input-group { display: flex; }
.input-group input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; text-align: right; }
.input-group select {
  width: 64px;
  flex: none;
  min-height: 40px;
  padding-left: 12px;
  border: 1px solid var(--field);
  border-left: 0;
  border-radius: 0 3px 3px 0;
  background-color: var(--paper);
}
.sum-grid input { text-align: right; }

.totals { margin: 18px 0 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.t-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  color: var(--ink-2);
  font-size: .92rem;
  font-variant-numeric: tabular-nums;
}
.t-grand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
}
.t-grand span { font-weight: 600; }
.t-grand strong {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 750;
  font-stretch: 104%;
  font-variant-numeric: tabular-nums;
}
.t-words { margin: 8px 0 0; color: var(--muted); font-size: .82rem; }
.t-sqft { margin: 6px 0 0; color: var(--accent-strong); font-size: .82rem; font-weight: 600; }
.side-note { margin: 10px 0 0; color: var(--muted); font-size: .78rem; text-align: center; }

/* Grand total bar on phones and tablets */
.mobile-total { display: none; }
@media (max-width: 1100px) {
  .mobile-total {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: var(--charcoal);
    color: var(--paper);
  }
  .mobile-total span {
    display: block;
    font-family: var(--font-mono);
    font-size: .66rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #A8A398;
  }
  .mobile-total strong { font-family: var(--font-display); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
}

/* ---------------- New quote dialog ---------------- */

dialog {
  width: min(540px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(28, 28, 26, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.dialog-head h2 { font-size: 1.3rem; font-weight: 750; font-stretch: 106%; }
.dialog-sub { margin: 4px 20px 16px; color: var(--muted); font-size: .9rem; }
.templates { display: grid; gap: 8px; padding: 0 20px 20px; }
.template {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 4px;
  background: var(--white);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s;
}
.template:hover, .template:focus-visible { border-color: var(--ink); border-left-color: var(--accent); }
.t-title { font-weight: 700; }
.t-desc { color: var(--muted); font-size: .85rem; }

/* ---------------- Settings ---------------- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: minmax(0, 1fr); } }
.backup-meta { margin: 0; color: var(--ink-2); font-size: .88rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* Team */
.people { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.person {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.person.off { opacity: .6; }
.person-main { display: flex; flex-direction: column; min-width: 0; }
.person-main strong, .person-main > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-main > span { color: var(--muted); font-size: .85rem; }
.person-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 6px; }
.person-meta small { width: 100%; color: var(--muted); font-size: .76rem; text-align: right; }
.chip[data-role="admin"] { background-color: #F0ECC0; color: var(--accent-strong); }
.chip[data-role]::before { display: none; }
@container (max-width: 480px) {
  .person { grid-template-columns: auto minmax(0, 1fr) auto; }
  .person > .btn { grid-column: 3; grid-row: 1; }
  .person-meta { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }
  .person-meta small { width: auto; text-align: left; }
}
.person-edit { padding: 12px 0; border-bottom: 1px solid var(--line); }
.person-form { margin: 0 0 14px; padding: 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); }
.person-edit .person-form { margin: 0; }
.person-form h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
.person-form .form-error { margin-top: 10px; }
.person-form .btn-row { margin-top: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent-strong); }

/* ---------------- Sign-in, setup and loading ---------------- */

body:not([data-auth="in"]) .topnav,
body:not([data-auth="in"]) .save-state,
body:not([data-auth="in"]) .topbar-new,
body:not([data-auth="in"]) .account { display: none; }

.boot { display: grid; place-items: center; min-height: calc(100vh - 60px); }
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.auth { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 40px var(--gutter) 64px; }
.auth-card {
  width: min(420px, 100%);
  padding: clamp(24px, 4vw, 36px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(28, 28, 26, .06);
}
.auth-card.wide { width: min(520px, 100%); }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 120%;
  letter-spacing: .08em;
}
.auth-brand .wordmark { width: auto; height: 24px; color: var(--charcoal); }
.auth h1 { font-size: 1.7rem; font-weight: 750; font-stretch: 106%; letter-spacing: -.01em; }
.auth-sub { margin: 8px 0 20px; color: var(--ink-2); }
.auth .notice { margin-bottom: 16px; }
.auth-form { display: grid; gap: 14px; }
.auth-foot { margin: 18px 0 0; color: var(--muted); font-size: .85rem; text-align: center; }
.form-error { margin: 0; color: var(--danger); font-size: .88rem; font-weight: 500; }
.form-error:empty { display: none; }
code { padding: 1px 5px; border-radius: 3px; background: var(--paper-2); font-family: var(--font-mono); font-size: .9em; }

.checks { display: grid; gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.checks li { display: flex; gap: 12px; padding: 10px 12px; border-radius: 4px; background: var(--ok-bg); }
.checks li.bad { background: var(--danger-bg); }
.check-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
}
.checks li.bad .check-mark { background: var(--danger); }
.checks strong { font-size: .9rem; }
.checks p { margin: 4px 0 0; color: var(--ink-2); font-size: .85rem; }

/* Account menu in the top bar */
.account { position: relative; }
.account-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-strong);
  color: #fff;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.topbar .avatar { border: 1px solid #7A7A7A; background: #5A5A5A; color: #fff; }
.account-btn:hover .avatar, .account-btn[aria-expanded="true"] .avatar { border-color: var(--accent-light); }
.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: 240px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .18);
}
.account-menu[hidden] { display: none; }
.account-name { margin: 0; font-weight: 700; }
.account-email { margin: 0; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.account-role {
  margin: 6px 0 8px;
  font-family: var(--font-mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-strong);
}
.account-menu a, .account-menu button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.account-menu a:hover, .account-menu button:hover { background: var(--paper); }
.account-menu a { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; padding-top: 12px; }

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-size: .88rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body[data-view="editor"] .toast { bottom: 84px; }

/* ---------------- Interior (amount per item) editing ---------------- */

.items-head.lump,
.item-row.lump {
  grid-template-columns: 22px minmax(0, 1fr) 130px 130px 112px 92px;
}
.item-row.lump {
  grid-template-areas:
    "no name req incl rate actions"
    ". spec spec spec opt opt";
  row-gap: 6px;
}
.item-row.lump .item-opt { grid-area: opt; display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: .82rem; cursor: pointer; }
.item-row.lump .item-opt input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent-strong); }
.item-row.lump .item-no { grid-area: no; }
.item-row.lump .item-name { grid-area: name; font-weight: 600; }
.item-row.lump .item-req { grid-area: req; }
.item-row.lump .item-incl { grid-area: incl; }
.item-row.lump .item-rate { grid-area: rate; text-align: right; font-weight: 600; }
.item-row.lump .item-actions { grid-area: actions; }
.item-row.lump .item-spec { grid-area: spec; min-height: 34px; padding-top: 6px; padding-bottom: 6px; color: var(--ink-2); font-size: .86rem; }

.section-extra {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.section-extra textarea, .section-extra input {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--field);
  border-radius: 3px;
  background: var(--white);
  font-size: .86rem;
  resize: none;
  overflow: hidden;
}

@container (max-width: 700px) {
  .items-head.lump { display: none; }
  .item-row.lump {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "name name name"
      "spec spec spec"
      "req incl rate"
      "opt actions actions";
  }
  .item-row.lump .item-no { display: none; }
  .section-extra { grid-template-columns: minmax(0, 1fr); }
}

.pages-field { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.pages-field legend { margin-bottom: 8px; padding: 0; font-size: .8rem; font-weight: 600; color: var(--ink-2); }

.template-group + .template-group { margin-top: 6px; }
.template-group h3 {
  margin: 4px 0 6px;
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.template-group .template { width: 100%; }
.template-group .template + .template { margin-top: 8px; }
.templates { max-height: min(70vh, 640px); overflow-y: auto; }

/* ---------------- Printed proposal (Uniqside house style) ---------------- */

.preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 820px;
  margin: 0 auto 10px;
}
.preview-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-tip { max-width: 820px; margin: 0 auto 18px; color: var(--muted); font-size: .85rem; }

.proposal {
  --u-dark: #474747;
  --u-yellow: #DCD35E;
  --u-head: #DCD6B8;
  --u-row: #F4F4F2;
  --u-grid: #9A9A9A;
  --u-green: #C5D89C;
  --u-orange: #F7C08D;
  --u-red: #D3261E;
  display: grid;
  gap: 24px;
  max-width: 820px;
  margin: 0 auto;
  color: #222;
}
.sheet {
  padding: 48px 52px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 12px 40px rgba(0, 0, 0, .08);
  font-size: 13px;
  line-height: 1.5;
}
.sheet p { margin: 0; }
.sheet .wordmark { display: block; width: auto; }
.sheet .pill {
  display: block;
  width: fit-content;
  margin: 28px auto 22px;
  padding: 9px 30px;
  border: 4px solid var(--u-yellow);
  border-radius: 14px;
  background: #666;
  color: #fff;
  font-family: 'Poppins', var(--font-body);
  font-size: 1.15rem;
  text-align: center;
}

/* Cover */
.sheet-cover {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 210 / 297;
  padding: 0;
  overflow: hidden;
}
.cover-band { display: grid; place-items: center; height: 9%; background: var(--u-dark); color: #fff; }
.cover-band .wordmark { height: 46%; }
.cover-art { position: relative; height: 56%; margin-top: 4%; }
.cover-svg { display: block; width: 100%; height: 100%; }
.cover-title {
  position: absolute;
  top: 34%;
  left: 8%;
  right: 8%;
  margin: 0;
  color: #fff;
  font-family: 'Poppins', var(--font-body);
  font-size: clamp(1.3rem, 4.2vw, 2.25rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}
.cover-foot { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 0 8%; text-align: center; }
.cover-tagline {
  font-family: 'Poppins', var(--font-body);
  font-size: clamp(1.5rem, 4.6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}
.cover-email { font-size: 1rem; }
.cover-meta { margin-top: 6px; color: #555; font-size: .9rem; }
.cover-ribbon { display: flex; align-items: stretch; height: 4.4%; }
.ribbon-left {
  display: flex;
  flex: 1;
  align-items: center;
  padding-left: 6%;
  background: var(--u-yellow);
  clip-path: polygon(0 0, 100% 0, calc(100% - 22px) 50%, 100% 100%, 0 100%);
  font-size: .9rem;
}
.ribbon-right {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36%;
  margin-left: 16px;
  background: var(--u-dark);
  clip-path: polygon(22px 0, 100% 0, 100% 100%, 22px 100%, 0 50%);
  color: #fff;
}
.ribbon-right .wordmark { height: 46%; }

/* Why choose us */
.why-title { margin: 8px 0 0; font-family: 'Poppins', var(--font-body); text-align: center; text-transform: uppercase; line-height: 1.1; }
.why-title span { display: block; font-size: 2rem; font-weight: 400; letter-spacing: .02em; }
.why-title strong { display: block; font-size: 2.1rem; font-weight: 700; }
.why-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 36px; margin: 0; padding: 0 12px; list-style: none; }
.why-grid li { display: flex; align-items: center; gap: 16px; font-size: 1rem; font-weight: 600; }
.why-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 50%;
  background: #5A5A5A;
  box-shadow: 0 0 0 5px var(--u-yellow);
}
.why-icon svg { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.reliability { margin: 0; padding: 18px 26px 18px 44px; border: 1.5px solid #888; border-radius: 18px; font-size: 1rem; }
.reliability li + li { margin-top: 8px; }

/* How we work */
.steps-flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 22px; margin: 0 0 40px; padding: 0; list-style: none; counter-reset: step; }
.steps-flow li {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 78px;
  padding: 10px 12px;
  border: 1.5px solid #C4C4C4;
  border-radius: 12px;
  font-size: .82rem;
  font-weight: 600;
  text-transform: uppercase;
}
.steps-flow li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -17px;
  border: 7px solid transparent;
  border-left: 9px solid var(--u-yellow);
  transform: translateY(-50%);
}
.step-n { color: #8E8233; font-family: 'Poppins', var(--font-body); font-size: .8rem; }
.pay-band { position: relative; padding: 26px 24px 22px; background: var(--u-dark); color: #fff; box-shadow: 14px 14px 0 var(--u-yellow); }
.pay-band h2 { margin: 0 0 22px; font-family: 'Poppins', var(--font-body); font-size: 1.5rem; font-weight: 700; text-align: center; text-transform: uppercase; }
.pay-rings { display: flex; flex-wrap: wrap; justify-content: space-around; gap: 20px; margin: 0; padding: 0; list-style: none; }
.pay-rings li { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 150px; text-align: center; }
.ring {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255, 255, 255, .16) 0);
}
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: #9E9E9E; }
.ring b { position: relative; font-family: 'Poppins', var(--font-body); font-size: 1.25rem; }
.ring-label { font-size: .78rem; line-height: 1.35; }
.ring-label strong { display: block; color: var(--u-yellow); }
.pay-site { margin-top: 20px !important; text-align: center; color: var(--u-yellow); }

/* Quotation */
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: -48px -52px 22px; padding: 16px 52px; background: var(--u-dark); color: #fff; }
.q-logo .wordmark { height: 24px; }
.q-head-right { text-align: right; }
.q-gstin { font-weight: 700; letter-spacing: .02em; }
.q-contact { margin-top: 2px !important; color: #DADADA; font-size: .78rem; }
.q-info { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.q-info th, .q-info td { padding: 7px 10px; border: 1px solid var(--u-grid); text-align: left; vertical-align: top; }
.q-info th { width: 16%; background: var(--u-row); font-weight: 700; white-space: nowrap; }
.q-title { margin: 0 0 12px; font-family: 'Poppins', var(--font-body); font-size: 1.35rem; font-weight: 700; text-align: center; text-decoration: underline; text-underline-offset: 5px; text-transform: uppercase; }

.doc-table-wrap { overflow-x: auto; }
.q-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.q-table th, .q-table td { padding: 6px 8px; border: 1px solid var(--u-grid); vertical-align: top; }
.q-table thead th { background: var(--u-head); font-size: .8rem; font-weight: 700; text-align: left; text-transform: uppercase; white-space: nowrap; }
.q-table thead th.r { text-align: right; }
.q-table tbody td { background: var(--u-row); }
.q-table .c-no { font-weight: 700; }
.q-table td { overflow-wrap: anywhere; }
.q-table .c-item strong { display: block; font-weight: 700; }
.q-table .spec { display: block; color: #444; font-size: .82rem; line-height: 1.4; }
.q-table.is-lump td:nth-child(3), .q-table.is-lump td:nth-child(4) { text-align: center; }
.q-table.is-lump th:nth-child(3), .q-table.is-lump th:nth-child(4) { text-align: center; }
.q-table .amt { font-weight: 700; white-space: nowrap; }
.q-table .opt-tag { display: block; margin-top: 2px; color: var(--u-red); font-size: .78rem; font-style: italic; }
.q-table .is-optional .amt { color: #777; font-weight: 500; }
.q-table .g-head td { background: #ECECE8; }
.q-table .g-total td { background: #fff; font-weight: 700; }
.q-totals td { padding: 9px 10px; border: 1px solid var(--u-grid); font-weight: 700; white-space: nowrap; }
.q-totals td:first-child { text-align: center; }
.q-totals .qt-sub td { background: var(--u-green); }
.q-totals .qt-adj td { background: #fff; font-weight: 500; }
.q-totals .qt-grand td { background: var(--u-orange); font-family: 'Poppins', var(--font-body); font-size: 1.15rem; text-transform: uppercase; }

.q-close { margin-top: 22px; font-size: 13.5px; }
.q-words { font-size: 1.05rem; }
.q-sqft { margin-top: 4px !important; color: #555; }
.q-note { margin-top: 12px !important; color: var(--u-red); }
.q-payterms { margin-top: 16px; padding: 14px 16px; border: 1px solid #555; color: var(--u-red); }
.q-payterms h3 { margin: 0 0 6px; font-family: inherit; font-size: .95rem; font-weight: 700; }
.q-payterms ul { margin: 0 0 8px; padding: 0; list-style: none; }
.q-payterms li + li { margin-top: 3px; }
.q-h { margin: 18px 0 6px; font-family: inherit; font-size: .95rem; font-weight: 700; text-transform: uppercase; }
.q-terms { margin: 0; padding-left: 20px; }
.q-terms li + li { margin-top: 3px; }
.q-valid { margin-top: 18px !important; font-family: 'Poppins', var(--font-body); font-weight: 700; text-decoration: underline; text-transform: uppercase; }
.q-thanks { margin-top: 14px !important; font-size: 1.02rem; }
.q-sign { display: grid; grid-template-columns: 1fr auto; gap: 24px 40px; align-items: end; margin-top: 28px; }
.q-accounts { color: var(--u-red); }
.q-accounts h3 { margin: 0 0 6px; font-family: inherit; font-size: .95rem; font-weight: 700; text-transform: uppercase; }
.q-accounts .acc-title { margin-top: 8px !important; font-weight: 600; }
.q-accounts dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 2px 0 0; }
.q-accounts dl div { display: contents; }
.q-accounts dt { white-space: nowrap; }
.q-accounts dd { margin: 0; font-weight: 600; }
.q-for { min-width: 220px; font-size: 1rem; }
.q-for .sign-line { height: 46px; border-bottom: 1px solid #444; }
.q-for p:last-child { margin-top: 6px !important; font-size: .9rem; }
.q-site { grid-column: 1 / -1; color: #2B5BA8; text-align: center; text-decoration: underline; }

@media screen and (max-width: 700px) {
  .sheet { padding: 22px 16px; }
  .sheet-cover { padding: 0; }
  .q-head { margin: -22px -16px 18px; padding: 14px 16px; flex-wrap: wrap; }
  .q-info th { width: auto; }
  .q-info tr { display: grid; grid-template-columns: auto 1fr; }
  .why-grid { grid-template-columns: 1fr; }
  .steps-flow { grid-template-columns: 1fr 1fr; }
  .steps-flow li:nth-child(2n)::after { display: none; }
  .q-sign { grid-template-columns: 1fr; }
  .why-title span, .why-title strong { font-size: 1.5rem; }
}

/* ---------------- Print (Save as PDF) ---------------- */

@media print {
  @page { size: A4; margin: 12mm 12mm 14mm; }
  @page cover { margin: 0; }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }
  .topbar, .no-print, .toast, .mobile-total { display: none !important; }
  .page { max-width: none; padding: 0; }
  .proposal { display: block; max-width: none; }
  .sheet { padding: 0; box-shadow: none; font-size: 11.5px; break-after: page; }
  .sheet:last-child { break-after: auto; }
  .sheet-cover { page: cover; width: 210mm; height: 297mm; aspect-ratio: auto; }
  .cover-title { font-size: 26pt; }
  .cover-tagline { font-size: 28pt; }
  .q-head { margin: 0 0 16px; padding: 12px 16px; }
  .doc-table-wrap { overflow: visible; }
  .q-table thead { display: table-header-group; }
  .q-table tr, .q-payterms, .q-sign, .why-grid li, .steps-flow li, .pay-band { break-inside: avoid; }
  .q-h, .q-payterms h3 { break-after: avoid; }
}
