/* ============================================================
   J&G Estimator — mobile-first stylesheet
   Brand palette: black, white, and the logo orange (#F4571A).
   ============================================================ */

:root{
  /* Brand: black, white, and the logo's construction orange (#F4571A). */
  --bg:#000000;
  --surface:#0C0C0D;
  --surface-2:#141416;
  --surface-3:#1C1C1F;
  --line:#2A2A2E;
  --line-soft:#19191C;

  --text:#FFFFFF;
  --text-dim:#A6A6AB;
  --text-faint:#6E6E74;

  --orange:#F4571A;
  --orange-bright:#FF7A3D;
  --orange-tint:rgba(244,87,26,.13);
  --orange-line:#6B2408;

  --grey:#9A9AA0;
  --grey-dim:#55555B;
  --red:#FF6B6B;

  --radius:14px;
  --radius-sm:10px;
  --tap:48px;

  --safe-t:env(safe-area-inset-top,0px);
  --safe-b:env(safe-area-inset-bottom,0px);
  --safe-l:env(safe-area-inset-left,0px);
  --safe-r:env(safe-area-inset-right,0px);

  --bar-h:calc(8px + var(--safe-b));
}

*,*::before,*::after{box-sizing:border-box}

/* The [hidden] attribute must always win. Several components below set an
   explicit display (flex/grid), which would otherwise beat the UA stylesheet's
   [hidden]{display:none} and leave invisible panels swallowing taps. */
[hidden]{display:none !important}

html{ -webkit-text-size-adjust:100%; }

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font:400 16px/1.45 -apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
  overscroll-behavior-y:none;
}

h1,h2,h3{margin:0;font-weight:650;letter-spacing:-.01em}

svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;display:block}

.num,.kpi-value,.bidbar-value,.tot-num,.cell-out b,.bidbar-margin{
  font-variant-numeric:tabular-nums;
  font-feature-settings:"tnum" 1;
}

/* ---------------- top bar ---------------- */
.topbar{
  /* Scrolls away with the page — the bid was covering content on phones.
     The final numbers live in the Job Totals panel at the end instead. */
  position:static;
  padding:calc(var(--safe-t) + 8px) 12px 8px;
  padding-left:calc(12px + var(--safe-l));
  padding-right:calc(12px + var(--safe-r));
  background:rgba(0,0,0,.88);
  backdrop-filter:saturate(160%) blur(14px);
  -webkit-backdrop-filter:saturate(160%) blur(14px);
  border-bottom:1px solid var(--line-soft);
}
.topbar-row{display:flex;align-items:center;gap:6px}

.brand{display:none;align-items:center;gap:8px;flex:none;min-width:0}
.brand-logo{
  height:21px;width:auto;flex:none;
  /* the mark is fine white line-art; a touch of contrast keeps it crisp small */
  filter:brightness(1.15);
}
.brand-mark{font-weight:800;letter-spacing:.01em;font-size:17px;color:#fff;display:none}
.brand-sub{font-size:12px;color:var(--text-faint);text-transform:uppercase;letter-spacing:.14em;display:none}

/* ---------------- view tabs (Estimate / Saved) ---------------- */
.tabs{
  flex:1;display:flex;gap:3px;min-width:0;
  background:var(--surface-2);border:1px solid var(--line);
  border-radius:99px;padding:3px;
}
.tab{
  flex:1;min-height:40px;min-width:0;
  display:flex;align-items:center;justify-content:center;gap:4px;
  border:0;border-radius:99px;background:transparent;
  color:var(--text-dim);font:inherit;font-size:13px;font-weight:650;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  white-space:nowrap;overflow:hidden;
  padding:0 4px;
}
.tab[aria-selected="true"]{background:var(--orange);color:#000;font-weight:750}
.tab-badge{
  font-style:normal;font-size:11px;font-weight:800;
  background:rgba(0,0,0,.25);color:inherit;
  min-width:18px;height:18px;border-radius:99px;
  display:grid;place-items:center;padding:0 5px;
}
.tab[aria-selected="false"] .tab-badge{background:var(--surface-3);color:var(--text-dim)}

/* small ghost button that fits a panel head */
.btn-mini{min-height:40px;padding:8px 14px;font-size:13px;flex:none}

.save-state{
  font-size:11px;color:var(--text-faint);
  border:1px solid var(--line);border-radius:99px;
  padding:4px 9px;white-space:nowrap;
}
.save-state[data-dirty="true"]{color:var(--orange-bright);border-color:var(--orange-line)}

.icon-btn{
  width:44px;height:44px;flex:none;
  display:grid;place-items:center;
  background:transparent;border:0;color:var(--text-dim);
  border-radius:12px;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.icon-btn:active{background:var(--surface-2)}

/* ---------------- bid bar ---------------- */
.bidbar{
  width:100%;display:flex;align-items:center;gap:12px;text-align:left;
  padding:12px 14px;border:0;margin-bottom:10px;
  border-radius:var(--radius);
  color:#000;
  background:var(--orange);
  box-shadow:0 4px 18px -14px rgba(244,87,26,.8);
  -webkit-tap-highlight-color:transparent;
}
.bidbar-left{flex:1;min-width:0}
.bidbar-label{font-size:10.5px;text-transform:uppercase;letter-spacing:.13em;color:rgba(0,0,0,.68);font-weight:700}
.bidbar-value{font-size:clamp(24px,7vw,32px);font-weight:750;letter-spacing:-.02em;line-height:1.1;margin-top:2px}
.bidbar-meta{font-size:12px;color:rgba(0,0,0,.66);font-weight:600;margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.bidbar-right{display:flex;flex-direction:column;align-items:flex-end;gap:1px;flex:none}
.bidbar-margin{font-size:19px;font-weight:700}
.bidbar-margin-label{font-size:10px;text-transform:uppercase;letter-spacing:.1em;color:rgba(0,0,0,.66);font-weight:700}
.bidbar .chev{display:none}

/* ---------------- layout ---------------- */
.wrap{
  padding:12px;
  padding-left:calc(12px + var(--safe-l));
  padding-right:calc(12px + var(--safe-r));
  max-width:1180px;margin:0 auto;
}
.foot-space{height:calc(24px + var(--safe-b))}

/* ---------------- KPI grid ---------------- */
.kpi-grid{
  display:grid;grid-template-columns:1fr 1fr;gap:8px;
  padding:0 12px 12px;
}
.kpi{
  background:var(--surface);border:1px solid var(--line-soft);
  border-radius:var(--radius-sm);padding:12px;
}
.kpi-label{font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--text-faint)}
.kpi-value{font-size:clamp(17px,4.8vw,20px);font-weight:700;margin-top:5px;letter-spacing:-.015em}
.kpi-note{font-size:11px;color:var(--text-faint);margin-top:3px}
.amber{color:var(--orange-bright)} .green{color:#fff} .red{color:var(--red)}

/* ---------------- panels ---------------- */
.panel{
  background:var(--surface);
  border:1px solid var(--line-soft);
  border-radius:var(--radius);
  margin-bottom:10px;
  overflow:hidden;
}
.panel-head{
  width:100%;display:flex;align-items:center;gap:10px;
  padding:12px 14px;background:transparent;border:0;color:var(--text);
  cursor:pointer;text-align:left;min-height:var(--tap);
  -webkit-tap-highlight-color:transparent;
}
.panel-head.static{cursor:default}
.panel-head h2{font-size:12px;text-transform:uppercase;letter-spacing:.13em;color:var(--text-dim);flex:none}
.panel-hint{
  flex:1;font-size:12.5px;color:var(--text-faint);text-align:right;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.panel-head .chev{flex:none;color:var(--text-faint)}
.panel-head[aria-expanded="true"] .chev{transform:rotate(180deg)}
.panel-body{padding:0 14px 16px}

/* ---------------- fields ---------------- */
.field{margin-bottom:14px}
.field:last-child{margin-bottom:0}
.field > label{
  display:block;font-size:11px;text-transform:uppercase;letter-spacing:.1em;
  color:var(--text-faint);margin-bottom:6px;
}
.field-row{display:flex;gap:10px;flex-wrap:wrap}
.field-row > .field{flex:1 1 140px;margin-bottom:14px}
.field-row > button,.field-row > .file-label{flex:1 1 auto}

input[type=text],input[type=number],input[type=date],input[type=password],input[type=search],textarea,select{
  width:100%;
  background:var(--surface-2);
  border:1px solid var(--line);
  color:var(--text);
  border-radius:var(--radius-sm);
  padding:12px 13px;
  font:inherit;
  font-size:16px; /* >=16px stops iOS zoom-on-focus */
  min-height:var(--tap);
  -webkit-appearance:none;appearance:none;
}
textarea{min-height:96px;resize:vertical;line-height:1.5}
input:focus,textarea:focus,select:focus{
  outline:none;border-color:var(--orange);
  box-shadow:0 0 0 3px rgba(244,87,26,.22);
}
input::placeholder,textarea::placeholder{color:#55555B}
input[type=date]{min-height:var(--tap)}
input[type=number]{-moz-appearance:textfield}
input[type=search]::-webkit-search-cancel-button{-webkit-appearance:none}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}

.helper{font-size:12px;color:var(--text-faint);margin:7px 0 0;line-height:1.45}

/* segmented control */
.segmented{display:flex;background:var(--surface-2);border:1px solid var(--line);border-radius:var(--radius-sm);padding:3px;gap:3px}
.seg{
  flex:1;min-height:42px;border:0;border-radius:9px;background:transparent;
  color:var(--text-dim);font:inherit;font-size:14px;font-weight:600;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.seg[aria-pressed="true"]{background:var(--orange);color:#000;font-weight:700}

/* ---------------- line items ---------------- */
.table-head{display:none}

.items{display:flex;flex-direction:column;gap:8px;padding:0 12px 4px}

.item{
  background:var(--surface-2);
  border:1px solid var(--line);
  border-left:3px solid var(--grey-dim);
  border-radius:var(--radius-sm);
  overflow:hidden;
}

/* -- collapsed one-line summary: name · cost · charge -- */
.item-head{
  width:100%;display:flex;align-items:center;gap:10px;
  min-height:48px;padding:8px 12px;
  background:transparent;border:0;color:var(--text);
  font:inherit;text-align:left;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.ih-name{
  flex:1;min-width:0;font-weight:600;font-size:14.5px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.ih-cost{flex:none;font-size:12.5px;color:var(--text-faint);font-variant-numeric:tabular-nums}
.ih-charge{flex:none;font-size:15px;font-weight:700;color:#fff;font-variant-numeric:tabular-nums}
.item-head .chev{width:16px;height:16px;flex:none;color:var(--text-faint);transition:transform .2s ease}
.item[data-open="true"] .item-head .chev{transform:rotate(180deg)}
.item[data-open="true"] .item-head{border-bottom:1px dashed var(--line-soft)}
.item[data-open="true"] .ih-cost,
.item[data-open="true"] .ih-charge{opacity:0}   /* the body shows the detail */

/* -- expanded editing body -- */
.item-body{
  position:relative;
  display:none;
  padding:10px 12px;
  grid-template-columns:1fr 1fr;
  gap:9px;
}
.item[data-open="true"] .item-body{display:grid}
.item[data-cat=labor]{border-left-color:var(--orange)}
.item[data-cat=materials]{border-left-color:#fff}
.item[data-cat=other]{border-left-color:var(--grey)}
.item[data-cat=buffer]{border-left-color:var(--grey-dim)}

/* padding-right reserves the absolutely-positioned delete button's column so
   the category chip can never sit underneath it */
.cell-name{grid-column:1 / -1;display:flex;gap:8px;align-items:center;padding-right:42px}
.cell-name input{flex:1;min-width:0;background:transparent;border:0;border-bottom:1px solid transparent;border-radius:0;padding:6px 2px;font-weight:600;font-size:16px;min-height:44px}
.cell-name input:focus{border-bottom-color:var(--orange);box-shadow:none}

/* 16px keeps iOS from zooming the page when this select is focused; the
   compact uppercase treatment returns at desktop widths. */
.cat-select{
  flex:none;width:auto;min-height:44px;padding:6px 28px 6px 12px;
  font-size:16px;font-weight:700;letter-spacing:0;
  border-radius:99px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0ab' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 7px center;background-size:13px;
}
.item[data-cat=labor] .cat-select{color:var(--orange-bright);border-color:var(--orange-line);background-color:var(--orange-tint)}
.item[data-cat=materials] .cat-select{color:#fff;border-color:#3A3A3E;background-color:rgba(255,255,255,.09)}
.item[data-cat=other] .cat-select{color:var(--grey);border-color:#333338;background-color:rgba(255,255,255,.05)}
.item[data-cat=buffer] .cat-select{color:var(--grey-dim);border-color:#2A2A2E;background-color:transparent}

.cell-in{display:flex;flex-direction:column;gap:5px;min-width:0}
.cell-in label,.cell-out span{font-size:10px;text-transform:uppercase;letter-spacing:.1em;color:var(--text-faint)}
.cell-in input{font-size:17px;font-weight:650;padding:8px 10px;min-height:44px}
.cell-in input[readonly]{color:var(--text-dim);font-style:italic;background:#0F0F11;border-style:dashed}

.cell-out{display:flex;flex-direction:column;gap:3px;min-width:0;justify-content:flex-end}
.cell-out b{font-size:15px;font-weight:650;letter-spacing:-.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.cell-out.charge b{color:#fff;font-size:17px}
.cell-out.profit b{color:#fff}
.cell-out.share b{color:var(--text-dim)}
/* Orange is reserved for the roll-ups (totals + KPIs) so the eye lands on the
   numbers that decide the bid, not on every cell. */
.cell-out.neg b{color:var(--red)}

.cell-del{position:absolute;top:2px;right:2px}
.cell-del .icon-btn{width:44px;height:44px;color:#5c626d}
.cell-del .icon-btn svg{width:17px;height:17px}
.cell-del .icon-btn:active{color:var(--red)}

.empty{padding:28px 16px 32px;text-align:center;color:var(--text-dim)}
.empty p{margin:0 0 4px}
.empty-logo{
  width:min(230px,64%);height:auto;display:block;margin:0 auto 20px;
  opacity:.9;
}

/* totals */
.totals{
  display:grid;grid-template-columns:1fr 1fr;gap:10px;
  margin:10px 12px 0;padding:12px;
  border-top:1px dashed var(--line);
  background:var(--surface-3);border-radius:var(--radius-sm);
}
.tot-name{grid-column:1 / -1;font-size:11px;text-transform:uppercase;letter-spacing:.13em;color:var(--text-dim);font-weight:700}
.tot-num{display:flex;flex-direction:column;gap:2px;font-size:15px;font-weight:650}
.tot-num::before{content:attr(data-l);font-size:10px;font-weight:500;text-transform:uppercase;letter-spacing:.1em;color:var(--text-faint)}
.tot-del{display:none}
#totCharge{color:#fff} #totProfit{color:var(--orange-bright)} #totMargin{color:var(--orange-bright)}

/* quick add */
.quickadd{padding:14px 12px calc(14px + 2px)}
.quickadd-label{display:block;font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--text-faint);margin-bottom:9px}
.chips{display:grid;grid-template-columns:repeat(auto-fill,minmax(104px,1fr));gap:8px}
.chip{
  min-height:42px;padding:9px 12px;
  background:var(--surface-2);border:1px solid var(--line);
  color:var(--text);border-radius:99px;font:inherit;font-size:13.5px;font-weight:600;
  cursor:pointer;-webkit-tap-highlight-color:transparent;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.chip:active{transform:scale(.97)}
.chip[data-cat=labor]{color:var(--orange-bright);border-color:var(--orange-line)}
.chip[data-cat=materials]{color:#fff;border-color:#3A3A3E}
.chip[data-cat=other]{color:var(--grey);border-color:#2F2F34}
.chip[data-cat=buffer]{color:var(--grey-dim)}
/* full width so the longest label never truncates on a narrow phone */
.chip[data-cat=custom]{color:var(--text-dim);border-color:#2F2F34;grid-column:1 / -1}

/* optional-field label suffix */
.lbl-opt{text-transform:none;letter-spacing:0;color:var(--grey-dim)}

/* status filter chips (Saved view) + status tags */
.lib-filter{margin:0 14px 10px}
.segf{
  flex:1;min-height:42px;border:0;border-radius:9px;background:transparent;
  color:var(--text-dim);font:inherit;font-size:13.5px;font-weight:650;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.segf[aria-pressed="true"]{background:var(--orange);color:#000;font-weight:750}

.lib-tag{
  display:inline-block;margin-left:8px;padding:2px 8px;border-radius:99px;
  font-size:10px;font-weight:800;letter-spacing:.08em;vertical-align:2px;
}
.lib-tag[data-s="won"]{background:var(--orange);color:#000}
.lib-tag[data-s="lost"]{background:transparent;color:var(--text-faint);border:1px solid var(--line)}
.lib-item[data-s="lost"] .lib-bid{color:var(--text-faint);text-decoration:line-through}

/* ---------------- project tracker ---------------- */
.back-btn{
  display:inline-flex;align-items:center;gap:4px;
  min-height:44px;padding:8px 14px 8px 8px;margin-bottom:10px;
  background:transparent;border:0;color:var(--text-dim);
  font:inherit;font-size:14px;font-weight:650;cursor:pointer;
  border-radius:var(--radius-sm);
  -webkit-tap-highlight-color:transparent;
}
.back-btn svg{width:18px;height:18px}
.back-btn:active{background:var(--surface-2)}

/* hero: black card with orange rail — deliberately different from the orange
   estimator bid bar so the two sides of the app read differently at a glance */
.trk-hero{
  display:flex;align-items:center;gap:12px;
  background:var(--surface);
  border:1px solid var(--line);
  border-left:4px solid var(--orange);
  border-radius:var(--radius);
  padding:14px 16px;margin-bottom:10px;
}
.trk-hero-left{flex:1;min-width:0}
.trk-hero-label{font-size:10.5px;text-transform:uppercase;letter-spacing:.13em;color:var(--text-faint);font-weight:700}
.trk-hero-value{
  font-size:clamp(24px,7vw,32px);font-weight:750;letter-spacing:-.02em;line-height:1.1;
  margin-top:2px;color:var(--orange-bright);
  font-variant-numeric:tabular-nums;
}
.trk-hero-value.neg{color:var(--red)}
.trk-hero-meta{font-size:12px;color:var(--text-faint);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.trk-hero-right{flex:none;text-align:right}
.trk-hero-pct{font-size:19px;font-weight:700;color:var(--text);font-variant-numeric:tabular-nums}
.trk-hero-pct-label{font-size:10px;text-transform:uppercase;letter-spacing:.1em;color:var(--text-faint)}

/* money rows (Contract + Final Numbers panels) */
.m-rows{display:flex;flex-direction:column}
.m-rows.in-panel{padding:0 14px 14px}
.m-row{
  display:flex;align-items:baseline;justify-content:space-between;gap:12px;
  padding:9px 0;border-bottom:1px dashed var(--line-soft);
}
.m-row:last-child{border-bottom:0}
.m-row span{font-size:13px;color:var(--text-dim)}
.m-row b{font-size:16px;font-weight:650;font-variant-numeric:tabular-nums;white-space:nowrap}
.m-row.strong b{color:#fff;font-size:17px}
.m-row.total{border-top:1px solid var(--line);margin-top:4px;padding-top:12px}
.m-row.total span{color:var(--text);font-weight:650}
.m-row.total b{font-size:20px;font-weight:750;color:var(--orange-bright)}
.m-row.total b.neg{color:var(--red)}
.m-auto{
  font-style:normal;font-size:9px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;
  background:var(--orange-tint);color:var(--orange-bright);
  padding:2px 6px;border-radius:99px;margin-left:6px;vertical-align:1px;
}

/* payment-collection bar inside the tracker hero */
.pay-track{
  height:8px;border-radius:99px;background:var(--surface-3);
  overflow:hidden;margin-top:10px;
}
.pay-fill{height:100%;border-radius:99px;background:var(--orange);width:0%;transition:width .25s ease}
.fn-margin{color:var(--orange-bright)}

.btn-track{width:100%;margin-top:10px}

.m-row.dim span{color:var(--text-faint);font-size:12.5px}
.m-row.dim b{color:var(--text-dim);font-size:14px}

/* entry date input — compact, sits beside the name */
.ded .js-ddate{
  width:132px;flex:none;min-height:40px;padding:6px 8px;font-size:16px;
  color:var(--text-dim);
}
.ded-top{grid-column:1 / -1;display:flex;gap:8px;align-items:center}
.ded-top .js-dname{flex:1;min-width:0;grid-column:auto}

/* deduction entries */
.trk-entries{display:flex;flex-direction:column;gap:8px;padding:0 12px 4px}
.ded{
  display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center;
  background:var(--surface-2);border:1px solid var(--line);
  border-radius:var(--radius-sm);padding:10px 12px;
}
.ded .js-dname{
  grid-column:1 / -1;
  background:transparent;border:0;border-bottom:1px solid transparent;border-radius:0;
  padding:4px 2px;font-weight:600;font-size:16px;min-height:40px;
}
.ded .js-dname:focus{border-bottom-color:var(--orange);box-shadow:none}
.ded-num{display:flex;gap:6px;align-items:center;min-width:0}
.ded-num .js-dval{width:110px;font-size:17px;font-weight:650;padding:8px 10px;min-height:44px;text-align:right}
.ded-num .js-dtype{
  width:auto;min-height:44px;padding:8px 26px 8px 12px;font-weight:700;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A6A6AB' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 8px center;background-size:13px;
}
.ded-out{display:flex;align-items:center;gap:2px;justify-content:flex-end}
.ded-out b{font-size:15px;font-weight:650;color:#fff;font-variant-numeric:tabular-nums;white-space:nowrap}
.ded-out .js-ddel{width:40px;height:40px;color:#5c626d}
.ded-out .js-ddel svg{width:16px;height:16px}
.ded-pct-note{font-size:11px;color:var(--text-faint);white-space:nowrap;margin-right:auto;padding-left:2px}

/* project cards reuse .lib-item; tracker-specific bits */
.proj-remaining{font-size:16px;font-weight:700;color:var(--orange-bright);white-space:nowrap;flex:none;font-variant-numeric:tabular-nums}
.proj-remaining.neg{color:var(--red)}
.lib-tag[data-s="complete"]{background:transparent;color:var(--text-faint);border:1px solid var(--line)}
.lib-tag[data-s="active"]{background:var(--orange-tint);color:var(--orange-bright)}

@media (min-width:720px){
  .ded{grid-template-columns:minmax(280px,1fr) auto auto;padding:8px 14px}
  .ded-top{grid-column:auto}
  .ded .js-dname{min-height:38px}
  .trk-hero{padding:18px 22px}
}

/* ---------------- saved view ---------------- */
.lib-tools{display:flex;gap:8px;margin:0 14px 12px}
.lib-tools input{flex:1;min-width:0}
.lib-tools select{flex:none;width:auto;padding-right:34px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A6A6AB' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 10px center;background-size:14px;
}
#viewSaved .lib-list{padding:0 14px 14px}
#viewSaved .sync-strip{margin:0 14px 12px}
#viewSaved .empty{padding-bottom:24px}

/* ---------------- sheets ---------------- */
.sheet-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:50;backdrop-filter:blur(2px)}
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:55;
  background:var(--surface);
  border-top:1px solid var(--line);
  border-radius:20px 20px 0 0;
  max-height:88vh;max-height:88dvh;
  display:flex;flex-direction:column;
  animation:sheetUp .26s cubic-bezier(.32,.72,0,1);
  padding-bottom:var(--safe-b);
}
@keyframes sheetUp{from{transform:translateY(100%)}to{transform:translateY(0)}}
.sheet-grab{width:38px;height:4px;border-radius:99px;background:var(--line);margin:8px auto 0;flex:none}
.sheet-head{display:flex;align-items:center;padding:10px 8px 10px 18px;border-bottom:1px solid var(--line-soft);flex:none}
.sheet-head h2{flex:1;font-size:16px}
.sheet-body{padding:16px;overflow-y:auto;-webkit-overflow-scrolling:touch}

.def-row{display:flex;gap:10px;align-items:flex-end}
.def-field{flex:1;min-width:0}
.def-field > span{
  display:block;font-size:10px;text-transform:uppercase;letter-spacing:.1em;
  color:var(--text-faint);margin-bottom:5px;
}
.def-row .btn-solid{flex:none;padding:12px 18px}

.sync-strip{
  display:flex;align-items:center;gap:12px;
  background:var(--surface-2);border:1px solid var(--line);
  border-radius:var(--radius-sm);padding:12px;margin-bottom:14px;
}
.sync-strip > div{flex:1;min-width:0}
.sync-title{font-size:13px;font-weight:650;display:flex;align-items:center;gap:8px}
.sync-note{font-size:12px;color:var(--text-faint);margin-top:2px}
.pill{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;padding:2px 8px;border-radius:99px;background:var(--surface-3);color:var(--text-dim)}
.pill[data-on="true"]{background:var(--orange-tint);color:var(--orange-bright)}
.sync-status{font-size:12.5px;color:var(--text-faint);margin-top:12px;line-height:1.5}

.lib-list{display:flex;flex-direction:column;gap:9px}
.lib-item{
  display:flex;align-items:center;gap:12px;
  background:var(--surface-2);border:1px solid var(--line);
  border-radius:var(--radius-sm);padding:12px;
}
.lib-main{flex:1;min-width:0;text-align:left;background:transparent;border:0;color:var(--text);font:inherit;cursor:pointer;padding:0}
.lib-name{font-weight:650;font-size:15px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lib-meta{font-size:12px;color:var(--text-faint);margin-top:3px}
.lib-bid{font-size:16px;font-weight:700;color:#fff;white-space:nowrap;flex:none}
.lib-del{flex:none}
.lib-del .icon-btn{width:44px;height:44px;color:#5c626d}
.lib-del .icon-btn svg{width:17px;height:17px}

/* buttons */
.btn-solid,.btn-ghost,.btn-danger{
  min-height:var(--tap);padding:12px 16px;border-radius:var(--radius-sm);
  font:inherit;font-size:15px;font-weight:650;cursor:pointer;
  -webkit-tap-highlight-color:transparent;
  display:inline-flex;align-items:center;justify-content:center;
}
.btn-solid{background:var(--orange);color:#000;border:0;font-weight:700}
.btn-ghost{background:var(--surface-2);color:var(--text);border:1px solid var(--line)}
.btn-danger{background:var(--red);color:#2A0A0A;border:0;font-weight:700}
.file-label{cursor:pointer}
.rule{border:0;border-top:1px solid var(--line-soft);margin:18px 0}
.about{font-size:13px;color:var(--text-dim);line-height:1.5}

/* confirm dialog
   The explicit display rules are a fallback for browsers with no <dialog>
   support (iOS < 15.4). Without them the confirm box renders inline and
   permanently visible at the bottom of the page. */
dialog:not([open]){display:none}
.confirm[open]{display:block}
.confirm{
  border:1px solid var(--line);background:var(--surface);color:var(--text);
  border-radius:var(--radius);padding:20px;max-width:min(400px,90vw);
}
.confirm::backdrop{background:rgba(0,0,0,.6)}
.confirm h3{font-size:17px;margin-bottom:8px}
.confirm p{color:var(--text-dim);font-size:14px;margin:0 0 18px;line-height:1.5}
.confirm-actions{display:flex;gap:10px}
.confirm-actions button{flex:1}

/* toast */
.toast{
  position:fixed;left:50%;transform:translateX(-50%);
  bottom:calc(18px + var(--safe-b));z-index:70;
  background:var(--surface-3);border:1px solid var(--line);
  color:var(--text);padding:12px 18px;border-radius:99px;
  font-size:14px;font-weight:600;
  box-shadow:0 10px 30px -12px rgba(0,0,0,.95);
  animation:toastIn .2s ease;
  max-width:88vw;text-align:center;
}
@keyframes toastIn{from{opacity:0;transform:translate(-50%,10px)}to{opacity:1;transform:translate(-50%,0)}}

/* ============================================================
   TABLET / DESKTOP
   ============================================================ */
@media (min-width:720px){
  :root{--bar-h:0px}
  .wrap{padding:18px 22px}

  .kpi-grid{grid-template-columns:repeat(4,1fr);padding:0 14px 14px}

  .kpi-value{font-size:24px}

  /* line items become a real table */
  .table-head{
    display:grid;
    grid-template-columns:minmax(200px,2.2fr) .9fr .8fr 1.15fr 1fr 1.1fr 44px;
    gap:12px;align-items:center;
    padding:10px 16px;margin:0 12px;
    border-bottom:1px solid var(--line-soft);
  }
  .table-head span{font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--text-faint)}
  .th-num{text-align:right}

  .items{gap:0;padding:0 12px}
  .item{
    border:0;border-bottom:1px solid var(--line-soft);
    border-left:3px solid var(--grey-dim);
    border-radius:0;background:transparent;overflow:visible;
  }
  .item:hover{background:var(--surface-2)}
  .item-head{display:none}                     /* desktop always shows the full row */
  .item-body,
  .item[data-open="false"] .item-body{
    display:grid;
    grid-template-columns:minmax(200px,2.2fr) .9fr .8fr 1.15fr 1fr 1.1fr 44px;
    gap:12px;align-items:center;
    padding:8px 16px;
  }
  .cell-name{grid-column:auto;padding-right:0}
  .cell-name input{min-height:38px}
  .chip[data-cat=custom]{grid-column:auto}
  .cat-select{
    min-height:32px;padding:5px 26px 5px 10px;
    font-size:11px;letter-spacing:.09em;text-transform:uppercase;
  }
  .cell-in{flex-direction:row;align-items:center;gap:0}
  .cell-in label{display:none}
  .cell-in input{text-align:right;font-size:16px;min-height:42px;background:transparent;border-color:transparent}
  .cell-in input:hover{border-color:var(--line)}
  .cell-in input:focus{background:var(--surface-2);border-color:var(--orange)}
  .cell-out{align-items:flex-end;justify-content:center}
  .cell-out span{display:none}
  .cell-out b{font-size:15px}
  .cell-out.charge b{font-size:16px}
  .cell-del{position:static}

  .totals{
    display:grid;
    grid-template-columns:minmax(200px,2.2fr) .9fr .8fr 1.15fr 1fr 1.1fr 44px;
    gap:12px;align-items:center;
    margin:0 12px;padding:16px;background:transparent;border-radius:0;
  }
  .tot-name{grid-column:auto;font-size:11px}
  .tot-num{text-align:right;align-items:flex-end;font-size:16px}
  .tot-num::before{display:none}
  .tot-del{display:block}

  .quickadd{display:flex;align-items:center;gap:14px;padding:16px}
  .quickadd-label{margin:0;flex:none}
  .chips{display:flex;flex-wrap:wrap;gap:8px;flex:1}
  .chip{min-height:40px;padding:9px 16px}

  .brand{display:flex;flex:1}
  .brand-mark,.brand-sub{display:inline}
  .tabs{flex:0 1 400px;margin-left:auto}
  .tab{font-size:14px;padding:0 10px}
  .brand-logo{height:26px}
  .foot-space{height:24px}

  .sheet{
    left:50%;right:auto;bottom:auto;top:50%;
    transform:translate(-50%,-50%);
    width:min(620px,92vw);max-height:82vh;
    border-radius:var(--radius);border:1px solid var(--line);
    animation:none;
  }
  .sheet-grab{display:none}
  .toast{bottom:28px}
}

@media (min-width:1024px){
  .bidbar{padding:20px 24px}
  .bidbar-value{font-size:42px}
  .bidbar-margin{font-size:24px}
}

@media (prefers-reduced-motion:reduce){
  *{animation-duration:.01ms !important;transition-duration:.01ms !important}
}

/* ============================================================
   DRAG TO REORDER
   ============================================================ */
.js-drag{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:30px;align-self:stretch;flex:none;
  color:var(--text-faint);cursor:grab;
  touch-action:none;                 /* the handle drags; the page still scrolls elsewhere */
  user-select:none;-webkit-user-select:none;
  -webkit-tap-highlight-color:transparent;
}
.js-drag svg{width:15px;height:15px;pointer-events:none}
.js-drag:active{cursor:grabbing;color:var(--orange)}

/* estimator rows: the handle sits on the row's left edge at every size */
.item{position:relative}
.item > .item-drag{
  position:absolute;left:0;top:0;bottom:0;width:32px;z-index:2;
}
.item-head{padding-left:34px}

/* the row visibly lifts while it is being moved */
.item.dragging,.ded.dragging{
  opacity:.95;
  outline:2px solid var(--orange);
  outline-offset:-1px;
  border-radius:var(--radius-sm);
  box-shadow:0 10px 28px rgba(0,0,0,.55);
  position:relative;z-index:6;
  background:var(--surface-2);
}
body.is-dragging{user-select:none;-webkit-user-select:none}
body.is-dragging .item,body.is-dragging .ded{transition:none}

@media (min-width:720px){
  .item-body,
  .item[data-open="false"] .item-body{padding-left:36px}
  .item.dragging{border-radius:var(--radius-sm)}
}

/* ============================================================
   PRINT / SAVE AS PDF
   Screen: hidden. Paper: the ONLY thing that exists.
   White page, black ink, restrained orange accents.
   ============================================================ */
#printRoot{display:none}

@media print{
  @page{margin:14mm 13mm}
  body > *:not(#printRoot){display:none !important}
  html,body{background:#fff !important;color:#000 !important}
  body{padding:0 !important;margin:0 !important}

  #printRoot{
    display:block !important;
    color:#111;
    font:13px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  }

  .pd-head{
    display:flex;align-items:flex-end;justify-content:space-between;gap:16px;
    padding-bottom:12px;margin-bottom:22px;
    border-bottom:3px solid #F4571A;
  }
  .pd-logo-chip{
    display:inline-flex;align-items:center;justify-content:center;
    background:#000;border-radius:8px;padding:7px 12px;
    print-color-adjust:exact;-webkit-print-color-adjust:exact;
  }
  .pd-logo{height:38px;width:auto;display:block}
  .pd-doc{
    font-size:24px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;
    color:#111;
  }

  .pd-meta{
    display:flex;justify-content:space-between;gap:24px;align-items:flex-end;
    margin-bottom:22px;break-inside:avoid;
  }
  .pd-meta-main h1{margin:2px 0 0;font-size:20px;font-weight:750;color:#000}
  .pd-meta-side{display:flex;gap:28px;text-align:right}
  .pd-meta-side div{display:flex;flex-direction:column;gap:2px}
  .pd-meta-side b{font-size:13.5px;color:#000}
  .pd-label{
    font-size:9.5px;font-weight:700;letter-spacing:.14em;text-transform:uppercase;
    color:#8a8a8a;
  }

  .pd-tiles{
    display:flex;gap:0;margin-bottom:20px;break-inside:avoid;
    border:1px solid #e2e2e2;border-radius:6px;overflow:hidden;
  }
  .pd-tile{flex:1;padding:10px 14px;border-left:1px solid #e2e2e2}
  .pd-tile:first-child{border-left:0}
  .pd-tile span{display:block;font-size:9.5px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:#8a8a8a;margin-bottom:3px}
  .pd-tile b{font-size:15px;font-weight:750;color:#000;font-variant-numeric:tabular-nums}

  .pd-progress{margin-bottom:22px;break-inside:avoid}
  .pd-progress-line{display:flex;justify-content:space-between;font-size:11px;margin-bottom:5px}
  .pd-progress-line span{color:#8a8a8a;font-weight:700;letter-spacing:.1em;text-transform:uppercase;font-size:9.5px;align-self:flex-end}
  .pd-progress-line b{color:#000}
  .pd-bar{height:8px;border-radius:4px;background:#eee;overflow:hidden;
    print-color-adjust:exact;-webkit-print-color-adjust:exact}
  .pd-bar-fill{height:100%;background:#F4571A;border-radius:4px;
    print-color-adjust:exact;-webkit-print-color-adjust:exact}

  .pd-h2{
    font-size:11px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;
    color:#111;margin:20px 0 8px;display:flex;justify-content:space-between;align-items:baseline;
    break-after:avoid;
  }
  .pd-h2-note{font-weight:600;letter-spacing:0;text-transform:none;font-size:11.5px;color:#8a8a8a}

  .pd-table{width:100%;border-collapse:collapse;margin-bottom:6px}
  .pd-table thead{display:table-header-group}   /* header repeats on every page */
  .pd-table th{
    text-align:left;font-size:9.5px;font-weight:700;letter-spacing:.13em;text-transform:uppercase;
    color:#8a8a8a;padding:6px 8px;border-bottom:1.5px solid #111;
  }
  .pd-table td{
    padding:7px 8px;border-bottom:1px solid #e8e8e8;font-size:12.5px;color:#111;
    vertical-align:top;
  }
  .pd-table tr{break-inside:avoid}              /* never split a row across pages */
  .pd-n{width:26px;color:#aaa !important;font-variant-numeric:tabular-nums}
  .pd-date{width:90px;white-space:nowrap;color:#555 !important;font-variant-numeric:tabular-nums}
  .pd-amt{text-align:right !important;width:110px;white-space:nowrap;
    font-variant-numeric:tabular-nums;font-weight:650}
  .pd-em{color:#8a8a8a;font-style:normal;font-size:11px}

  .pd-totals{
    margin:14px 0 6px;margin-left:auto;width:290px;break-inside:avoid;
  }
  .pd-row{display:flex;justify-content:space-between;padding:4px 8px;font-size:12.5px}
  .pd-row span{color:#555}
  .pd-row b{font-variant-numeric:tabular-nums;font-weight:650;color:#111}
  .pd-grand{
    display:flex;justify-content:space-between;align-items:baseline;
    margin-top:6px;padding:9px 8px 8px;
    border-top:2.5px solid #F4571A;
  }
  .pd-grand span{font-size:11px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;color:#111}
  .pd-grand b{font-size:19px;font-weight:800;color:#000;font-variant-numeric:tabular-nums}
  .pd-per{text-align:right;font-size:11px;color:#8a8a8a;padding:3px 8px 0}

  .pd-notes{margin-top:18px;break-inside:avoid}
  .pd-notes h2{
    font-size:11px;font-weight:800;letter-spacing:.14em;text-transform:uppercase;
    color:#111;margin:0 0 6px;
  }
  .pd-notes p{margin:0;font-size:12.5px;color:#333;white-space:normal}

  .pd-fine{margin-top:26px;font-size:10.5px;color:#8a8a8a}

  .pd-foot{
    margin-top:30px;padding-top:10px;border-top:1px solid #e2e2e2;
    display:flex;justify-content:space-between;
    font-size:10px;color:#8a8a8a;letter-spacing:.04em;
  }
}
