:root {
  /* KimBee brand palette — olive bee on warm cream */
  --olive: #6f7f43;
  --olive-dark: #59682f;
  --olive-soft: #eef1e4;
  --cream: #f7f5ee;
  --card: #ffffff;
  --ink: #2c2e26;
  --muted: #8b8675;
  --line: #e6e2d4;
  --good: #5d7d3b;
  --danger: #a8432f;
  --shadow: 0 1px 2px rgba(44,46,38,.05), 0 8px 28px rgba(44,46,38,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand-name {
  font-family: "Poppins", "Inter", system-ui, sans-serif;
}

/* ---------------- Header ---------------- */
header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 26px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand img { width: 46px; height: 46px; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .14em;
  color: var(--olive);
  text-transform: uppercase;
}
.brand-tag {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
nav#tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  border: none;
  background: transparent;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: .02em;
  transition: background .15s, color .15s;
}
.tab:hover { background: var(--olive-soft); color: var(--olive-dark); }
.tab.active { background: var(--olive); color: #fff; }

main { max-width: 720px; margin: 32px auto; padding: 0 16px; }
/* Estimates & Quotes carries the most columns (est/quote rates, stage, up to 4 row
   actions), and Jobs has long no-wrap cells (location address, crew list) — give
   both a wide canvas so they fit without horizontal scrolling at most resolutions.
   Caps at the viewport width on smaller screens via the min(). */
main:has(#tab-estimates.active),
main:has(#tab-jobs.active) { max-width: min(96vw, 1120px); }
.panel { display: none; }
.panel.active { display: block; }
/* The Schedule calendar needs more room than the 720px column — break it out
   and center it on the viewport so week/month cells get the full width. */
#tab-schedule.active {
  width: min(1280px, 94vw);
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

.card, .wizard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* ---------------- Wizard steps ---------------- */
.steps { display: flex; list-style: none; padding: 0; margin: 0 0 26px; gap: 6px; }
.steps li {
  flex: 1;
  text-align: center;
  font-size: 12px;
  letter-spacing: .03em;
  color: var(--muted);
  padding: 9px 4px;
  border-bottom: 3px solid var(--line);
  transition: color .15s, border-color .15s;
}
.steps li.active { color: var(--olive-dark); border-color: var(--olive); font-weight: 600; }
.steps li.done { color: var(--good); border-color: var(--good); }

.step { display: none; animation: fade .18s ease; }
.step.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

label { display: block; margin-bottom: 15px; font-size: 13px; font-weight: 500; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 500; }
label.check input { width: auto; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(111,127,67,.16);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.hint { font-size: 13px; color: var(--olive-dark); margin: -7px 0 15px; min-height: 18px; }

.wizard-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
button {
  border: 1px solid var(--line);
  background: #fff;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:hover:not(:disabled) { background: var(--cream); }
button:disabled { opacity: .45; cursor: default; }
button.primary, #job-next {
  background: var(--olive);
  color: #fff;
  border-color: var(--olive);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 13px;
}
button.primary:hover:not(:disabled), #job-next:hover:not(:disabled) {
  background: var(--olive-dark); border-color: var(--olive-dark);
}
button.ghost { color: var(--muted); }

h3 { margin: 0 0 18px; font-size: 16px; color: var(--ink); }

table.review { width: 100%; border-collapse: collapse; }
table.review td { padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.review td:first-child { color: var(--muted); width: 42%; }

table.roster { width: 100%; border-collapse: collapse; margin-top: 14px; }
table.roster td { padding: 9px 6px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
table.roster tr { cursor: pointer; }
table.roster tr:hover { background: var(--olive-soft); }
.roster .name { font-weight: 600; color: var(--ink); }
.roster .sub { color: var(--muted); font-size: 12.5px; }

/* ---------------- Dashboard ---------------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dash-head h2 { margin: 0; font-size: 22px; color: var(--ink); }
.year-picker { display: flex; align-items: center; gap: 10px; }
label.inline { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
label.inline select { width: auto; margin: 0; padding: 7px 12px; }
button.small { padding: 7px 14px; font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 15px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.stat .value { font-family: "Poppins", sans-serif; font-size: 22px; font-weight: 600; margin-top: 6px; color: var(--ink); }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat.accent { background: var(--olive); border-color: var(--olive); }
.stat.accent .label, .stat.accent .sub { color: rgba(255,255,255,.82); }
.stat.accent .value { color: #fff; }
.stat .value.neg { color: var(--danger); }

.table-wrap { overflow-x: auto; }
table.months { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
table.months th, table.months td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); }
table.months th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
table.months th:first-child, table.months td:first-child { text-align: left; }
table.months tr.total td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: none; }
table.months td.neg { color: var(--danger); }
table.months tr.zero td { color: var(--muted); }

.catbar { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; font-size: 13.5px; }
.catbar .cname { width: 150px; flex-shrink: 0; color: var(--ink); }
.catbar .track { flex: 1; display: block; background: var(--olive-soft); border-radius: 6px; height: 14px; overflow: hidden; }
.catbar .fill { display: block; height: 100%; background: var(--olive); border-radius: 6px; }
.catbar .camt { width: 92px; text-align: right; color: var(--muted); flex-shrink: 0; }

.footnote { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.card.empty { color: var(--muted); text-align: center; padding: 40px 26px; }
.muted-text { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 16px; }

/* ---------------- Toolbars & data tables ---------------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 180px; margin: 0; }
.toolbar select { width: auto; margin: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--olive-soft); }
table.data .primaryc { font-weight: 600; color: var(--ink); }
table.data .sub { color: var(--muted); font-size: 12px; }
table.data td.neg { color: var(--danger); }
/* Keep the actions cell a normal table cell (no flex) so its bottom border stays
   aligned with the other columns; lay the icon buttons out inline instead. */
.row-actions { white-space: nowrap; }
.row-actions button { vertical-align: middle; }
.row-actions button + button { margin-left: 6px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.badge.paid { background: #e3efd9; color: #3f5a23; }
.badge.unpaid { background: #f6dcd5; color: #92301f; }
.badge.partial { background: #f7eccf; color: #8a6d1e; }
.badge.na { background: var(--cream); color: var(--muted); }
.badge.overdue { background: #f6dcd5; color: #92301f; }
.badge.soon { background: #f7eccf; color: #8a6d1e; }
.badge.ok { background: #e3efd9; color: #3f5a23; }

/* ---------------- Modal ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(44,46,38,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 50; overflow-y: auto;
}
.overlay[hidden] { display: none; }  /* author display:flex would otherwise override the hidden attribute */
.modal {
  background: var(--card); border-radius: 16px; padding: 26px;
  width: 100%; max-width: 560px; box-shadow: 0 18px 50px rgba(0,0,0,.25);
  position: relative; animation: fade .18s ease;
}
.modal-close {
  position: absolute; top: 12px; right: 14px; border: none; background: transparent;
  font-size: 26px; line-height: 1; color: var(--muted); padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { background: var(--cream); }
.modal h3 { margin-top: 4px; }
.modal h4 { margin: 0 0 12px; font-size: 15px; }
.form-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.form-actions .right { display: flex; gap: 10px; margin-left: auto; }
/* Funnel action buttons in the estimate editor (send preliminary, mark detailed, etc.) */
.funnel-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.funnel-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Next-step call-to-action card — names the single action that advances the funnel. */
.next-step { display: flex; gap: 16px; align-items: center; justify-content: space-between;
  background: var(--olive-soft); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; margin: 0 0 16px; }
.next-step.is-done { background: var(--cream); }
.next-step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.next-step-cap { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600; color: var(--olive); }
.next-step.is-done .next-step-cap { color: var(--muted); }
.next-step-title { font-weight: 600; color: var(--ink); font-size: 15px; }
.next-step-desc { font-size: 12.5px; color: var(--muted); }
.next-step-info { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--ink); }
.next-step-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

/* Funnel stepper — clickable pipeline of the engagement stages in the estimate editor. */
.funnel-stepper { display: flex; align-items: center; gap: 2px; margin: 0 0 16px; overflow-x: auto; padding-bottom: 4px; }
.fstep { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; background: none;
  border: 1px solid transparent; border-radius: 8px; padding: 5px 9px; cursor: pointer;
  color: var(--muted); white-space: nowrap; }
.fstep:hover:not(:disabled) { background: var(--cream); color: var(--ink); }
.fstep:disabled { cursor: default; }
.fstep-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line);
  background: #fff; flex: 0 0 auto; }
.fstep.done { color: var(--ink); }
.fstep.done .fstep-dot { background: var(--olive); border-color: var(--olive); }
.fstep.current { color: var(--ink); font-weight: 600; border-color: var(--line); background: var(--olive-soft); }
.fstep.current .fstep-dot { border-color: var(--olive); box-shadow: 0 0 0 3px var(--olive-soft); }
.fstep-label { display: inline-flex; flex-direction: column; line-height: 1.15; font-size: 13px; text-align: left; }
.fstep-sub { font-size: 10.5px; font-weight: 400; color: var(--muted); }
.fstep-conn { flex: 0 0 14px; height: 2px; background: var(--line); }
button.danger { color: var(--danger); border-color: #e6c9c1; }
button.danger:hover:not(:disabled) { background: #f9ece8; }

fieldset.ar-box { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px 6px; margin: 6px 0 16px; }
fieldset.ar-box legend { font-size: 12px; font-weight: 600; color: var(--olive-dark); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; }

/* ---------------- Schedule ---------------- */
.badge.sched { background: #e8eedd; color: #4a5a2a; }
.badge.cancelled { background: var(--cream); color: var(--muted); text-decoration: line-through; }
/* Timesheet: a punch taken away from the job's address, and a session still open. */
.badge.warn { background: #f7eccf; color: #8a6d1e; }
.badge.live { background: #e3efd9; color: #3f5a23; }
/* Timesheet "Punched from": in/out distances stacked in one cell so the table
   fits the card without a horizontal scroll. */
.ts-where { font-size: 11.5px; color: var(--muted); line-height: 1.9; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg-btn { border: none; border-radius: 0; padding: 8px 16px; font-size: 13px; background: #fff; color: var(--muted); }
.seg-btn:hover { background: var(--olive-soft); }
.seg-btn.active { background: var(--olive); color: #fff; }
.sched-group { margin-top: 14px; }
.sched-group:first-child { margin-top: 4px; }
.sched-group .ghead {
  font-family: "Poppins", sans-serif; font-size: 13px; font-weight: 600; color: var(--olive-dark);
  padding: 6px 0; border-bottom: 2px solid var(--olive-soft); margin-bottom: 4px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.sched-group .ghead .gsub { font-family: "Inter", sans-serif; font-weight: 400; font-size: 12px; color: var(--muted); }
.appt {
  display: flex; align-items: center; gap: 12px; padding: 9px 8px;
  border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px;
}
.appt:hover { background: var(--olive-soft); }
.appt.done { opacity: .55; }
.appt .when { width: 64px; flex-shrink: 0; font-weight: 600; color: var(--ink); font-size: 13px; }
.appt .who { flex: 1; min-width: 0; }
.appt .who .c { font-weight: 600; }
.appt .who .d { color: var(--muted); font-size: 12px; }
.appt .act { display: flex; gap: 6px; flex-shrink: 0; }
.sched-empty { color: var(--muted); padding: 18px 4px; font-size: 14px; }

.head-actions { display: flex; gap: 8px; align-items: center; }

/* conflict banner */
.conflict-banner {
  background: #f9ece8; border: 1px solid #e6c9c1; color: #92301f;
  border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: 13px;
}
.conflict-banner b { font-weight: 600; }
.conflict-banner ul { margin: 6px 0 0; padding-left: 18px; }

/* week grid */
.week-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.week-nav .label { font-family: "Poppins", sans-serif; font-weight: 600; font-size: 14px; color: var(--ink); }
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wday { border: 1px solid var(--line); border-radius: 10px; min-height: 90px; padding: 6px; background: #fff; }
.wday.today { border-color: var(--olive); box-shadow: 0 0 0 2px rgba(111,127,67,.14); }
.wday .wh { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 5px; display: flex; justify-content: space-between; }
.wday .wh .dn { color: var(--ink); }
.chip {
  background: var(--olive-soft); border-left: 3px solid var(--olive); border-radius: 6px;
  padding: 4px 6px; margin-bottom: 4px; font-size: 11.5px; cursor: pointer; line-height: 1.3;
}
.chip:hover { background: #e3e9d4; }
.chip .ct { font-weight: 600; color: var(--olive-dark); }
.chip .cc { color: var(--ink); }
.chip .cl { color: var(--muted); }
.chip.notime { border-left-color: var(--muted); background: var(--cream); }
.chip.done { opacity: .5; }
.chip.conflict { border-left-color: var(--danger); background: #f9ece8; }
.chip.conflict .ct { color: var(--danger); }

/* ---------------- Schedule: month view ---------------- */
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.mdow { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; text-align: center; padding: 2px 0; }
.mcell { border: 1px solid var(--line); border-radius: 8px; min-height: 92px; padding: 4px; background: #fff; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.mcell.out { background: var(--cream); }
.mcell.out .mh { color: var(--muted); opacity: .6; }
.mcell.today { border-color: var(--olive); box-shadow: 0 0 0 2px rgba(111,127,67,.14); }
.mcell .mh { font-size: 12px; font-weight: 600; color: var(--ink); text-align: right; line-height: 1; margin-bottom: 1px; }
.mchip { margin-bottom: 3px; padding: 2px 6px; font-size: 11px; }
.mchip .cc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mmore { font-size: 11px; color: var(--olive-dark); cursor: pointer; padding: 0 5px; }
.mmore:hover { text-decoration: underline; }
@media (max-width: 640px) {
  .week-grid { grid-template-columns: 1fr; }
  .month-grid { gap: 2px; }
  .mcell { min-height: 64px; }
}

/* cleaner colour legend */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.cdot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 7px; vertical-align: middle; }
.color-row { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; }
.color-row input[type=color] { width: 46px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; }
.color-row input[type=color]:disabled { opacity: .4; cursor: not-allowed; }
.color-hex { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* crew multi-pick + nested location list */
.crew { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 14px; }
.crew label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--ink); }
.crew input { width: auto; margin: 0; }
.subcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }
.subcard .srow { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.subcard .srow:last-child { border-bottom: none; }
.subcard .srow .meta { color: var(--muted); font-size: 12px; }
.attr-line { font-size: 12.5px; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  background: var(--ink);
  color: #fff;
  padding: 13px 24px;
  border-radius: 12px;
  font-size: 14.5px;
  box-shadow: var(--shadow);
  transition: transform .25s ease;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--olive); }

/* ---------------- Estimator: man-hour editor ---------------- */
.readout-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--olive-soft); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 16px;
}
.readout-bar #f-readout, .readout-bar #q-readout { font-size: 15px; color: var(--ink); }
/* Quote audit / change history */
.audit-list { display: flex; flex-direction: column; gap: 8px; }
.audit-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.audit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.audit-note { margin-top: 2px; font-style: italic; }
button.small { padding: 6px 12px; font-size: 12px; }
h4.form-section {
  margin: 20px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--olive-dark); border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
label.chk { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
label.chk input { width: auto; margin-top: 0; }
.cat-block { margin-bottom: 16px; }
.cat-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px;
}
/* Estimate editor: give each Area its own card with a tinted header band */
#f-rooms .cat-block { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
#f-rooms .cat-block.is-empty { border-style: dashed; }
#f-rooms .cat-title {
  margin: 0; padding: 8px 12px; color: var(--olive-dark);
  background: var(--olive-soft); border-bottom: 1px solid var(--line);
}
#f-rooms .cat-title .scope-tag { font-weight: 400; color: var(--muted); font-size: 11.5px; }
#f-rooms .cat-body { padding: 10px 12px; }
.room-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fcfbf7; }
.room-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.room-head .room-label { margin-top: 0; flex: 1; }
.room-items { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.room-items label { margin-bottom: 6px; }
.room-items label.ri-count { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.room-items label.ri-count input { width: 84px; margin-top: 0; }
.link-danger { border: none; background: none; color: var(--danger); padding: 2px 4px; font-size: 12px; }
.link-danger:hover { background: none; text-decoration: underline; }
.icon-trash { width: 15px; height: 15px; display: block; }
.link-danger.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 4px; line-height: 0; border-radius: 6px; }
.link-danger.icon-btn:hover { background: #fbeeea; text-decoration: none; }
button.icon-text { display: inline-flex; align-items: center; gap: 6px; }
/* Icon-only row actions in the Estimates & Quotes grid. */
button.ghost.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 5px; line-height: 0; border-radius: 6px; }
button.ghost.icon-btn:hover:not(:disabled) { background: var(--cream); color: var(--ink); }

/* ---------------- Estimator settings tab ---------------- */
.est-cat-card { margin-bottom: 14px; }
.est-cat-card .cat-title .scope-tag { font-weight: 400; color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; }
table.weights { width: 100%; border-collapse: collapse; }
table.weights th, table.weights td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: left; }
table.weights th { color: var(--muted); font-weight: 500; }
table.weights td.num, table.weights th.num { text-align: right; }
table.weights input { width: 90px; margin-top: 0; padding: 6px 8px; }

/* ---------------- Estimator: calculation breakdown ---------------- */
#f-calc-wrap { margin: -4px 0 16px; }
#f-calc-wrap > summary { cursor: pointer; font-weight: 500; margin-bottom: 8px; }
.calc {
  border: 1px solid var(--line); border-radius: 10px; background: #fcfbf7;
  padding: 10px 14px; font-size: 13px;
}
.calc-sec { margin-bottom: 10px; }
.calc-cap {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 4px 0 6px;
}
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; color: var(--ink); }
.calc-row span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.calc-room { border-left: 2px solid var(--olive-soft); padding-left: 8px; margin: 4px 0; }
.calc-row.room { font-weight: 600; }
.calc-row.sub { color: var(--muted); font-size: 12px; }
.calc-ind { padding-left: 4px; }
.calc-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; font-weight: 600; }
.calc-final {
  border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px;
  font-size: 14px; color: var(--olive-dark);
}

/* ---------------- Estimator: drag-to-reorder ---------------- */
.grip { cursor: grab; color: var(--muted); user-select: none; font-size: 13px; }
.cat-title .grip { margin-right: 2px; }
.est-cat-card[draggable="true"] .cat-title,
table.weights tr.click[draggable="true"] { cursor: default; }
.est-cat-card.dragging, table.weights tr.dragging { opacity: .4; }
table.weights tr.click:hover .grip { color: var(--olive); }
.est-cat-card.dragging { outline: 2px dashed var(--olive); outline-offset: -2px; }

/* ---------------- Estimate dialog: wide + tabs ---------------- */
.modal.wide { max-width: 980px; }
.ftabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 16px; }
.ftab {
  border: none; background: none; border-radius: 8px 8px 0 0; padding: 8px 16px;
  font-size: 13px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent;
  text-transform: none; letter-spacing: 0;
}
.ftab:hover:not(:disabled) { background: var(--olive-soft); color: var(--olive-dark); }
.ftab.active { color: var(--olive-dark); border-bottom-color: var(--olive); background: none; }
.ftab-panel { display: none; }
.ftab-panel.active { display: block; animation: fade .15s ease; }
/* compact room cards laid out in a wrapping grid (saves vertical space) */
.empty-area {
  display: inline-flex; align-items: center; gap: 6px; margin: 4px 0;
  padding: 6px 12px; border: 1px dashed var(--danger); border-radius: 8px;
  background: #fbeeea; color: var(--danger); font-size: 13px; font-weight: 600;
}
.empty-area::before { content: "⚠"; font-size: 13px; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; align-items: start; }
.room-grid .room-card { margin-bottom: 0; }
.room-grid .room-items { grid-template-columns: 1fr; }
.room-grid .room-items label { margin-bottom: 4px; }
