:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --panel: #ffffff;
  --sidebar: #fbfbf9;
  --text: #171715;
  --muted: #73736d;
  --muted-dark: #575752;
  --line: #deded9;
  --line-soft: #ecece8;
  --black: #181817;
  --green: #0a7241;
  --green-bg: #dcf4e6;
  --amber: #8b5b00;
  --amber-bg: #fff0c3;
  --gray-bg: #eeeeeb;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
tr:focus-visible {
  outline: 2px solid #2586ad;
  outline-offset: 2px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  width: 232px;
  display: flex;
  flex-direction: column;
  padding: 24px 14px 18px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.brand {
  display: block;
  width: auto;
  margin: 0 0 25px;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  display: block;
  width: 100%;
  height: 43px;
  object-fit: contain;
  object-position: center;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .22em;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 40px;
  padding: 0 13px;
  border-radius: 7px;
  color: #4d4d48;
  text-decoration: none;
}

.nav-item svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.nav-item.active {
  background: var(--black);
  color: #fff;
  font-weight: 700;
}

.recent {
  min-height: 0;
  margin-top: 28px;
  padding: 0 8px;
}

.recent h2 {
  margin: 0 0 11px;
  color: #777771;
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.recent-project {
  display: block;
  width: 100%;
  padding: 6px 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: #686863;
  cursor: pointer;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-project:hover {
  color: var(--text);
}

.new-project {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: 7px;
  background: var(--black);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.new-project span {
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
}

.new-project:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.sidebar-action {
  width: 100%;
  margin-top: auto;
}

.page {
  width: min(1240px, calc(100% - 232px));
  margin-left: 232px;
  padding: 42px 36px 72px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 25px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 25px;
}

.stage-card {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  min-height: 91px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.stage-card:hover {
  border-color: #bebeb8;
  transform: translateY(-1px);
}

.stage-card.active {
  border-color: var(--black);
  box-shadow: inset 0 0 0 1px var(--black);
}

.stage-icon {
  width: 27px;
  height: 27px;
  border-radius: 7px;
}

.stage-icon.in-progress {
  background: var(--green-bg);
  box-shadow: inset 0 0 0 8px var(--green-bg), inset 0 0 0 10px var(--green);
}

.stage-icon.bidding {
  background: var(--amber-bg);
  box-shadow: inset 0 0 0 8px var(--amber-bg), inset 0 0 0 10px var(--amber);
}

.stage-icon.completed {
  background: var(--gray-bg);
  box-shadow: inset 0 0 0 8px var(--gray-bg), inset 0 0 0 10px #696963;
}

.stage-copy {
  display: grid;
  gap: 4px;
}

.stage-copy strong {
  font-size: 14px;
}

.stage-copy small {
  color: var(--muted);
  font-size: 12px;
}

.stage-count {
  min-width: 30px;
  color: var(--muted-dark);
  font-size: 23px;
  font-weight: 650;
  text-align: right;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.table-heading {
  display: flex;
  min-height: 67px;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.table-heading h2 {
  margin-bottom: 2px;
  font-size: 15px;
}

.table-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  height: 42px;
  padding: 0 18px;
  background: #f1f1ef;
  color: #686863;
  font-size: 12px;
  font-weight: 650;
  text-align: left;
}

td {
  height: 67px;
  padding: 9px 18px;
  border-top: 1px solid var(--line-soft);
  vertical-align: middle;
}

tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #fafaf8;
}

.project-name {
  font-weight: 700;
}

.project-number {
  width: 150px;
  font-weight: 700;
  text-align: center;
}

.project-subtitle {
  max-width: 290px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
}

.badge.active {
  background: var(--green-bg);
  color: var(--green);
}

.badge.draft {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.complete,
.badge.archived {
  background: var(--gray-bg);
  color: #5d5d58;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 54px 20px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--text);
}

.back-link {
  margin-top: auto;
  padding: 10px 8px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--muted-dark);
  font-size: 12px;
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.project-page {
  max-width: 1500px;
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.project-header-actions,
.form-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
}

.secondary-action:hover {
  border-color: #bcbcb6;
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.project-header h1 {
  margin: 4px 0 6px;
}

.project-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.project-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.project-tabs-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.project-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
}

.tab-kebab { flex: 0 0 auto; padding-bottom: 6px; }

.project-tab {
  position: relative;
  flex: 0 0 auto;
  padding: 12px 14px 13px;
  border: 0;
  background: transparent;
  color: var(--muted-dark);
  cursor: pointer;
  font-size: 13px;
}

.project-tab.active {
  color: var(--text);
  font-weight: 700;
}

.project-tab.active::after {
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--black);
  content: "";
}

.project-panel {
  display: none;
}

.project-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card,
.info-card,
.content-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.stat-card {
  display: grid;
  gap: 7px;
  min-height: 88px;
  align-content: center;
  padding: 15px 17px;
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
}

.stat-card strong {
  font-size: 20px;
  letter-spacing: -.02em;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.info-card,
.content-card {
  padding: 18px;
}

.info-card h2,
.content-card h2 {
  margin-bottom: 15px;
  font-size: 14px;
}

.info-list {
  display: grid;
  grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr);
  margin: 0;
}

.info-list dt,
.info-list dd {
  margin: 0;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}

.info-list dt {
  color: var(--muted);
  font-size: 12px;
}

.info-list dd {
  overflow-wrap: anywhere;
  font-weight: 550;
}

.budget-rev-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.budget-rev-list {
  display: grid;
  gap: 8px;
}

.budget-rev-list h2 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.budget-rev-item {
  display: grid;
  gap: 2px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}

.budget-rev-item:hover {
  border-color: #c9c9c4;
}

.budget-rev-item.active {
  background: #33312e;
  border-color: #33312e;
  color: #fff;
}

.budget-rev-name {
  font-size: 13px;
  font-weight: 600;
}

.budget-rev-sub {
  font-size: 11px;
  color: var(--muted);
}

.budget-rev-item.active .budget-rev-sub {
  color: rgba(255, 255, 255, .72);
}

.budget-rev-total {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.budget-rev-content {
  min-width: 0;
}

.budget-rev-content .budget-roll {
  margin-bottom: 0;
}

.budget-roll {
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.budget-roll__section,
.budget-roll__row,
.budget-roll__total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.budget-roll__section {
  padding: 11px 18px;
  background: #33312e;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.budget-roll__row {
  padding: 10px 18px 10px 30px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
}

.budget-roll__row:last-of-type {
  border-bottom: 0;
}

.budget-roll__total {
  padding: 13px 18px;
  background: #faf4e4;
  border-top: 1px solid #ece3c9;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.budget-roll .amt {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.budget-roll__row .amt {
  color: #4a4a45;
}

/* ---- Budget Detail builder ---- */
.detail-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-toolbar__left { display: flex; align-items: center; gap: 12px; min-height: 36px; }

.kebab { position: relative; }

.kebab-btn {
  width: 40px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.kebab-btn:hover { border-color: #bcbcb6; }

.kebab-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 240px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .16);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kebab-menu[hidden] { display: none; }

.kebab-item {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.kebab-item:hover:not(:disabled) { background: #f4f3f0; }
.kebab-item--muted { color: var(--muted); cursor: default; font-weight: 500; }

.link-action {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.link-action:hover { color: var(--text); }
.detail-toolbar__right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.lock-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 7px;
  background: #faf4e4;
  border: 1px solid #ece3c9;
  color: #6b5a2a;
  font-size: 12.5px;
  font-weight: 650;
}

/* ---- Sidebar iterations ---- */
.sidebar-iterations {
  margin-top: 26px;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-iterations h2 {
  margin: 0 0 10px;
  color: #777771;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.iteration-empty { color: var(--muted); font-size: 12px; margin: 0; }

.iteration-item {
  position: relative;
  display: grid;
  gap: 2px;
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 26px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: left;
  cursor: pointer;
}

.iteration-kebab-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.iteration-kebab-btn:hover { background: rgba(0, 0, 0, .07); color: var(--text); }

.iteration-saved {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.iteration-item:hover { border-color: #bcbcb6; }
.iteration-item.contract { border-color: #d8c79a; background: #faf6ea; }

.iteration-live {
  border-color: #bfe3c8;
  background: #f1faf3;
  cursor: default;
}
.iteration-live .iteration-name { color: #1f9d4d; }
.iteration-live-tag { font-size: 11px; font-weight: 700; color: #1f9d4d; }
.iteration-name { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; }
.iteration-total { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.iteration-contract-badge {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9a7d2e;
}

/* Toggle that reveals iterations older than the locked contract budget. */
.iteration-prior-toggle {
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.iteration-prior-toggle::before { content: "▸ "; }
.iteration-prior-toggle.open::before { content: "▾ "; }
.iteration-prior-toggle:hover { border-color: #bcbcb6; color: var(--text); }
.iteration-prior { display: grid; gap: 8px; margin-top: 8px; }
.iteration-prior[hidden] { display: none; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 19, 17, .42);
}

.modal-card {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}

.modal-title { margin: 0 0 8px; font-size: 16px; }
.modal-msg { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-error { margin: 4px 0 0; color: #b23b3b; font-size: 12.5px; min-height: 1em; }

.modal-field { display: block; margin-bottom: 12px; }
.modal-field span { display: block; margin-bottom: 5px; font-size: 12px; font-weight: 600; color: var(--text); }
.modal-field input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
.modal-field input:focus { border-color: #9a9a94; outline: none; }

/* Password field with a show/hide toggle. */
.password-input { position: relative; display: flex; align-items: center; }
.password-input input { width: 100%; padding-right: 40px; }
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--text); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.modal-card--wide { width: min(640px, 100%); }

.modal-textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.modal-textarea:focus { border-color: #9a9a94; outline: none; }

/* ---- Change log viewer ---- */
.log-wrap { max-height: 60vh; overflow-y: auto; margin: 4px 0 8px; }
.log-section { margin-bottom: 14px; }
.log-section__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.log-delta { font-size: 12px; font-variant-numeric: tabular-nums; }
.log-delta.pos { color: #1f9d4d; }
.log-delta.neg { color: #c0392b; }
.log-entry {
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.log-entry__head { display: flex; align-items: center; gap: 8px; }
.log-badge { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.log-badge--created { background: #e6eefb; color: #2a5db0; }
.log-badge--added { background: #e7f6ea; color: #1f7a3d; }
.log-badge--edited { background: #fff4e0; color: #9a6a2f; }
.log-badge--removed { background: #fbeeee; color: #c0392b; }
.log-entry__title { font-size: 13px; font-weight: 600; color: var(--text); }
.log-entry__details { margin-top: 3px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.log-entry__reason { margin-top: 4px; font-size: 12.5px; color: var(--text); }

.iteration-saved__time { margin-bottom: 6px; }
.iteration-log-btn {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.iteration-log-btn:hover { border-color: #bcbcb6; }
.iteration-saved .iteration-log-btn { display: block; margin-top: 6px; }

.iteration-view-actions { display: flex; gap: 8px; }

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid #33312e;
  border-radius: 7px;
  background: #33312e;
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

.primary-action:hover { background: #1f1d1b; }
.primary-action:disabled { cursor: not-allowed; opacity: .55; }

.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid #d9a3a3;
  border-radius: 7px;
  background: #fff;
  color: #c0392b;
  font-weight: 650;
  cursor: pointer;
}
.danger-action:hover { background: #fbeeee; border-color: #c0392b; }

.detail-group { margin: 18px 0 10px; }

.detail-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 8px;
  background: #33312e;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.detail-group-head::-webkit-details-marker { display: none; }
.detail-group-head__left { display: flex; align-items: center; gap: 9px; }
.detail-group-caret { font-size: 10px; transition: transform .15s; }
.detail-group:not([open]) .detail-group-caret { transform: rotate(-90deg); }
.detail-group[open] .detail-group-head { border-radius: 8px 8px 0 0; }
.detail-group .trade-list { margin-top: 10px; }

.detail-group-head .amt { font-variant-numeric: tabular-nums; }

.detail-total-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 10px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #1f1d1b;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.detail-total-head .amt { font-variant-numeric: tabular-nums; }

.budget-builder { margin-bottom: 18px; }

.builder-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.builder-actions--co { justify-content: flex-end; }

.builder-actions__left { display: flex; align-items: baseline; gap: 10px; }
.builder-grand-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.builder-grand { font-size: 18px; font-variant-numeric: tabular-nums; }
.builder-actions__right { display: flex; gap: 8px; }

.builder-group { margin-bottom: 22px; }

.builder-group__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #33312e;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.builder-group__head::-webkit-details-marker { display: none; }
.builder-group[open] > .builder-group__head { margin-bottom: 12px; }
.builder-group__head-left { display: flex; align-items: center; gap: 8px; }

.builder-group__total { font-variant-numeric: tabular-nums; }

/* Collapse/expand caret for groups and category cards in the builder. */
.builder-caret {
  display: inline-block;
  width: 1em;
  font-size: 11px;
  transition: transform 0.15s ease;
}
details:not([open]) > summary .builder-caret { transform: rotate(-90deg); }

.builder-trade {
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.builder-trade__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  background: #f4f3f0;
}

.builder-trade__summary::-webkit-details-marker { display: none; }

.builder-trade__name {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
}

.builder-trade__name:focus { border-color: var(--line); background: #fff; outline: none; }
.builder-trade__total { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13px; }

.builder-table { padding: 8px 12px; }

.builder-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}

.builder-row__cols {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1.6fr 0.8fr 0.5fr 0.9fr 0.8fr auto;
  gap: 8px;
  align-items: center;
}

.builder-row__cols.schema-pm {
  grid-template-columns: 1.2fr 1.3fr 1fr 0.9fr auto;
}

/* Standard layout minus the inline Description column (GC Fee, Overhead). */
.builder-row__cols.schema-std-nodesc {
  grid-template-columns: 1.1fr 0.9fr 0.8fr 0.5fr 0.9fr 0.8fr auto;
}

/* Percentage rows, inline: Subcategory | % input | Applied-to text | Amount | Status.
   The subcategory holds a single option, so it stays compact. */
.builder-row__cols.schema-percent {
  grid-template-columns: 190px 150px minmax(0, 1fr) 0.8fr 64px;
}
.builder-percent-input {
  display: flex;
  align-items: center;
  gap: 6px;
}
.builder-percent-input .builder-input--num { max-width: 90px; }
.builder-percent-sign { color: var(--muted); font-weight: 600; }
.builder-percent-applied {
  font-size: 12.5px;
  color: var(--ink, #2a2a26);
  align-self: center;
}
/* Align the AMOUNT header over its right-aligned dollar value, and shift both a
   bit left of the Status column for breathing room (percent rows). */
.builder-row--head .schema-percent span:nth-child(4),
.builder-row__cols.schema-percent .builder-amt { text-align: right; padding-right: 44px; }

.builder-line-wrap { display: block; }
.builder-line-desc { margin: 2px 12px 10px; }

.builder-row__cols.schema-labor {
  grid-template-columns: 1.2fr 1fr 1fr 1.1fr 0.9fr auto;
}

.builder-input--readonly {
  background: #f4f3f0;
  color: #6a6a64;
}

.builder-shared-desc {
  margin: 6px 12px 12px;
}
.builder-shared-desc__label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.builder-shared-desc__input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: inherit;
  resize: vertical;
}
.builder-shared-desc__input:focus { border-color: #9a9a94; outline: none; }

.trade-shared-desc {
  margin: 8px 18px 14px;
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.5;
}

.builder-row__controls {
  flex: 0 0 auto;
  width: 62px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.builder-check,
.builder-trash {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}

.builder-check { color: #c2c2bc; font-size: 14px; font-weight: 800; }
.builder-check:hover { border-color: #8fc99e; color: #2f9d52; }
.builder-check.confirmed { background: #1f9d4d; border-color: #1f9d4d; color: #fff; }

.builder-trash { color: #9a9a94; }
.builder-trash:hover { border-color: #d9a3a3; color: #b23b3b; }
.builder-trash svg { display: block; }

@media print {
  .no-print { display: none !important; }
  .sidebar, .project-tabs-bar, .project-header-actions, .kebab, .tab-kebab,
  .back-link, .detail-toolbar__right { display: none !important; }
  .page, .project-page { margin: 0 !important; width: 100% !important; padding: 0 !important; }
  .project-panel:not(.active) { display: none !important; }
  .project-panel.active { display: block !important; }
  details:not([open]) > *:not(summary) { display: revert !important; }
  details > summary { list-style: none; }
}

.builder-row--head {
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.builder-input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12.5px;
}

.builder-input:focus { border-color: #9a9a94; outline: none; }
.builder-input--num { text-align: right; }
.builder-amt { text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; }

.builder-toggle {
  padding: 5px 8px;
  border: 1px solid #cde8d3;
  border-radius: 6px;
  background: #e7f6ea;
  color: #1f7a3d;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.builder-toggle.off {
  border-color: #e6bcbc;
  background: #fbeeee;
  color: #c0392b;
  text-transform: uppercase;
}

.builder-remove {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: #b23b3b;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.builder-remove--line { padding: 4px 9px; }
.builder-remove:hover { border-color: #d9a3a3; }

.builder-add {
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.builder-add--line { margin: 4px 12px 12px; }
.builder-add:hover { border-color: #9a9a94; color: var(--text); }

.trade-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.trade-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.trade-card summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  min-height: 54px;
  padding: 0 18px;
  cursor: pointer;
  list-style: none;
}

.trade-card summary::-webkit-details-marker {
  display: none;
}

.trade-card[open] summary {
  border-bottom: 1px solid var(--line);
}

.trade-title {
  font-weight: 700;
}

.trade-meta {
  color: var(--muted);
  font-size: 12px;
}

.data-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  min-width: 720px;
}

.data-table td {
  height: auto;
  min-height: 54px;
  padding-top: 11px;
  padding-bottom: 11px;
}

.data-table tbody tr {
  cursor: default;
}

.module-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 220px;
  align-content: center;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.module-empty strong {
  color: var(--text);
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  width: max-content;
  align-items: center;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--gray-bg);
  color: var(--muted-dark);
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.status-pill.ok,
.status-pill.on,
.status-pill.active,
.status-pill.approved {
  background: var(--green-bg);
  color: var(--green);
}

.status-pill.warn,
.status-pill.crit,
.status-pill.draft,
.status-pill.off {
  background: var(--amber-bg);
  color: var(--amber);
}

.status-pill.expired,
.status-pill.missing {
  background: #fde4e1;
  color: #9b2c22;
}

.status-pill.submitted { background: var(--amber-bg); color: var(--amber); }
.status-pill.wip { background: #eef0f3; color: #5a6473; }

/* ---- Change Orders ---- */
.builder-input--date { font-family: inherit; }
.co-credit { color: #b42318; }
.co-unlock {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d8c79a;
  border-radius: 6px;
  background: #faf6ea;
  cursor: pointer;
}
.co-unlock:hover { border-color: #c2a85a; }

/* R.O.M. vs Change Orders sections (collapsible) */
.co-section { margin-bottom: 16px; }
.co-section__bubble {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafaf8;
  cursor: pointer;
  list-style: none;
}
.co-section__bubble::-webkit-details-marker { display: none; }
.co-section[open] > .co-section__bubble { border-radius: 12px 12px 0 0; margin-bottom: 0; }
.co-section__head-left { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.co-section__title { font-size: 14px; font-weight: 700; color: var(--text); }
.co-section__sub { font-size: 12px; color: var(--muted); }
.co-section__right { display: flex; align-items: center; gap: 16px; }
.co-section__count { font-size: 12px; color: var(--muted); }
.co-section__total { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.co-section__list {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 12px;
}

/* Read-only CO cards */
.co-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 10px;
  overflow: hidden;
}
.co-card__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  background: #f4f3f0;
}
.co-card__summary::-webkit-details-marker { display: none; }
.co-card__title { flex: 1; display: flex; align-items: baseline; gap: 10px; font-weight: 600; font-size: 13px; }
.co-card__num { color: var(--muted); font-weight: 700; }
.co-card__amt { font-variant-numeric: tabular-nums; font-weight: 650; }
.co-card__body { padding: 12px 16px 16px; }
.co-card__meta { display: flex; gap: 24px; margin: 10px 2px; color: var(--muted); font-size: 12px; }
.co-card__actions { display: flex; gap: 8px; }

/* ---- Requisitions (AIA G702/G703) ---- */
.req-summary { display: flex; flex-direction: column; gap: 2px; margin: 12px 0; max-width: 540px; }
.req-summary__row { display: flex; justify-content: space-between; gap: 24px; padding: 5px 10px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.req-summary__row--due { background: #fff7cc; font-weight: 700; border-radius: 4px; }
.req-summary__amt { font-variant-numeric: tabular-nums; }
.req-header { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.req-header .co-gc-input .builder-input--num { max-width: 70px; }
.req-grid { overflow-x: auto; }
.builder-row__cols.schema-req {
  grid-template-columns: 44px minmax(150px, 1.4fr) 92px 92px 62px 92px 84px 92px 46px 92px 84px 52px;
  gap: 6px;
  min-width: 1020px;
}
.req-section-row { font-weight: 700; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 10px 4px 2px; }
.req-item { font-size: 11px; color: var(--muted); }
.req-desc { font-size: 12px; }
.req-desc--parent { font-weight: 700; }
.req-num { font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; align-self: center; }
.req-input.builder-input--num { max-width: 100%; }
.co-empty { color: var(--muted); font-size: 12.5px; padding: 8px 2px; }

/* CO editor: per-CO line-item builder */
.co-build-summary { gap: 10px; }
.co-num-input { max-width: 96px; flex: 0 0 auto; }
.builder-row__cols.schema-coline {
  grid-template-columns: 130px 110px minmax(0, 1fr) 100px 60px 100px 90px;
}
.co-build-body { padding: 10px 12px 14px; }
.co-meta-row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; }
.co-field { display: flex; flex-direction: column; gap: 4px; }
.co-field__label { font-size: 11px; font-weight: 600; color: var(--muted); }
.co-gc-input { display: flex; align-items: center; gap: 6px; }
.co-gc-input .builder-input--num { max-width: 70px; }
.co-totals { margin: 12px 0 4px; display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.co-tot-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  width: 280px;
  padding: 6px 10px;
}
.co-tot-label { font-weight: 700; font-size: 12px; }
.co-tot-amt { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px; }
.co-tot-sub { border-top: 1.5px solid #111; }
.co-tot-oh { background: #9a9a94; color: #fff; }
.co-tot-gc { background: #7f7f7f; color: #fff; }
.co-tot-total { background: #111; color: #fff; }

.requisition-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  background: #fafaf8;
}

.requisition-meta .stat-card {
  min-height: 70px;
}

.form-page {
  max-width: 1140px;
}

.form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.form-header p {
  margin: 7px 0 0;
  color: var(--muted);
}

.form-error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #e8b7b1;
  border-radius: 7px;
  background: #fff1ef;
  color: #8f241b;
  font-weight: 650;
}

.form-section {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.form-section > h2,
.section-heading h2 {
  margin-bottom: 4px;
  font-size: 15px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.form-grid,
.address-grid,
.owner-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  color: #686863;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field input,
.field select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid #d4d4ce;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.field input:focus,
.field select:focus {
  border-color: #76766f;
  outline: 0;
  box-shadow: 0 0 0 2px rgba(23, 23, 21, .08);
}

.field input[readonly] {
  background: #f2f2ef;
  color: var(--muted);
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-dark);
  cursor: pointer;
  font-size: 12px;
}

.check-field input {
  width: 15px;
  height: 15px;
  accent-color: var(--black);
}

.owner-list {
  display: grid;
  gap: 12px;
}

.owner-card {
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fafaf8;
}

.owner-grid {
  grid-template-columns: 1.2fr .8fr 1.2fr auto;
  align-items: end;
}

.owner-remove {
  height: 40px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: #a32d24;
  cursor: pointer;
  font-weight: 700;
}

.owner-secondary-toggle {
  margin-top: 12px;
}

.owner-secondary {
  max-width: 50%;
  margin-top: 12px;
}

.owner-secondary[hidden] {
  display: none;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 5px 0 30px;
}

@media (max-width: 960px) {
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .stage-card {
    min-height: 78px;
  }

  .stats-grid,
  .requisition-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .sidebar {
    position: static;
    width: 100%;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    width: 126px;
    margin-bottom: 16px;
  }

  .brand img {
    height: 35px;
  }

  .recent,
  .sidebar-action {
    display: none;
  }

  .back-link {
    display: none;
  }

  .page {
    width: 100%;
    margin-left: 0;
    padding: 28px 18px 48px;
  }

  .page-header {
    align-items: center;
  }

  .header-action {
    display: none;
  }

  .table-card {
    overflow-x: auto;
  }

  table {
    min-width: 620px;
  }

  .info-grid,
  .stats-grid,
  .requisition-meta {
    grid-template-columns: 1fr;
  }

  .form-header,
  .section-heading,
  .project-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-header-actions {
    justify-content: flex-end;
  }

  .form-grid,
  .address-grid,
  .owner-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .owner-secondary {
    max-width: none;
  }

  .trade-card summary {
    grid-template-columns: 1fr auto;
  }

  .trade-meta {
    display: none;
  }
}

.req-imported-tag {
  font-size: 12px;
  color: #6B7682;
  font-style: italic;
  align-self: center;
}

.live-test-suffix {
  color: #1a9e4b;
  font-weight: 600;
}

.sub-editor {
  border: 1px solid #E2E5E9;
  border-radius: 10px;
  padding: 16px 18px;
  margin: 12px 0 18px;
  background: #FCFCFD;
}
.sub-editor h3 { margin: 0 0 12px; font-size: 15px; }
.sub-editor__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 16px;
}
.sub-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.sub-field__label { color: #6B7682; }
.sub-field input[type="text"],
.sub-field input[type="email"],
.sub-field input[type="date"],
.sub-editor textarea {
  border: 1px solid #D5D9DE;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
}
.sub-field input[type="checkbox"] { width: 18px; height: 18px; align-self: flex-start; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; white-space: nowrap; }
.link-action {
  background: none; border: none; padding: 0; cursor: pointer;
  color: #2563eb; font: inherit; font-size: 12px; text-decoration: underline;
}
.link-action--danger { color: #c0392b; }
@media (max-width: 900px) {
  .sub-editor__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.doc-section { border: 1px solid var(--line); border-radius: 8px; margin: 10px 0; background: var(--panel); }
.doc-section__summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; font-weight: 650; }
.doc-section__count { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 12px; }
.doc-cat { padding: 8px 16px 2px; color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }

.account-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft, #ecece8);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.account-user { font-size: 12px; color: var(--muted, #73736d); }
.account-user strong { color: var(--text, #171715); }
.account-link {
  background: none; border: none; padding: 0; text-align: left;
  color: #2563eb; font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline;
}

/* ---- Punchlist ---------------------------------------------------- */
.punch-plan-select {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

.punch-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  padding: 10px 14px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 8px;
  font-weight: 600;
}

.punch-plan-wrap {
  margin: 16px 0 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
  max-height: 72vh;
  background: #fafafa;
}
.punch-plan-wrap.placing { outline: 2px solid var(--green); }
.punch-plan-wrap.placing .punch-plan-stage { cursor: crosshair; }

.punch-plan-stage {
  position: relative;
  display: inline-block;
  min-width: 100%;
  line-height: 0;
}
.punch-plan-img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

.punch-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  background: #555;
  padding: 0;
}
.punch-pin:hover { transform: translate(-50%, -50%) scale(1.15); z-index: 5; }
.punch-pin.punch-open { background: #c0392b; }
.punch-pin.punch-progress { background: #b8860b; }
.punch-pin.punch-review { background: #2563eb; }
.punch-pin.punch-done { background: var(--green); }

.status-pill.punch-open { background: #fde4e1; color: #9b2c22; }
.status-pill.punch-progress { background: var(--amber-bg); color: var(--amber); }
.status-pill.punch-review { background: #e3eaff; color: #2746b8; }
.status-pill.punch-done { background: var(--green-bg); color: var(--green); }

.punch-list-section { margin-top: 10px; }
.punch-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.punch-filters { display: flex; gap: 8px; }
.punch-filters select {
  font: inherit;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
.punch-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
  display: block;
}

/* Item modal */
.punch-modal .punch-form {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  margin: 10px 0 4px;
}
.punch-photo-field { display: flex; flex-direction: column; gap: 8px; }
.punch-photo-preview {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--gray-bg);
}
.punch-photo-preview.empty { display: block; min-height: 200px; }
.punch-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}
.punch-fields .sub-field { display: flex; flex-direction: column; gap: 4px; }
.punch-fields .sub-field input,
.punch-fields .sub-field select,
.punch-fields .sub-field textarea {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  width: 100%;
}
.punch-fields .punch-notes { grid-column: 1 / -1; }
.punch-del { color: #9b2c22; border-color: #e7b7b0; margin-right: auto; }

@media (max-width: 760px) {
  .punch-modal .punch-form { grid-template-columns: 1fr; }
  .punch-fields { grid-template-columns: 1fr; }
}

/* ---- Subcontractor payments ---- */
.sub-payments { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.sub-payments__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sub-payments__head h4 { margin: 0; font-size: 15px; }
.sub-payments__empty { color: var(--muted); font-size: 13px; margin: 6px 0 10px; }
.sub-payments__form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.sub-payments__form input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
.sub-payments__form input[type="number"] { max-width: 130px; }

/* ---- Punchlist (list-first redesign) ----------------------------- */
.punch-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.punch-toolbar__left { display: flex; align-items: center; gap: 10px; }
.punch-toolbar__right { display: flex; align-items: center; gap: 8px; }
.punch-h2 { margin: 0; font-size: 18px; }
.punch-add-btn { font-weight: 700; }
.punch-stats { margin-bottom: 16px; }

.punch-items-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.punch-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--text);
  cursor: pointer; font: inherit;
  transition: background .12s, border-color .12s;
}
.punch-row:hover { background: var(--gray-bg); border-color: #c9c9c9; }
.punch-row__no {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; background: #555;
}
.punch-row__no.punch-open { background: #c0392b; }
.punch-row__no.punch-progress { background: #b8860b; }
.punch-row__no.punch-review { background: #2563eb; }
.punch-row__no.punch-done { background: var(--green); }
.punch-row__thumb {
  flex: 0 0 auto; position: relative; width: 44px; height: 44px;
  border-radius: 7px; overflow: hidden; background: var(--gray-bg);
  border: 1px solid var(--line);
}
.punch-row__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.punch-row__count {
  position: absolute; right: 2px; bottom: 2px;
  background: rgba(0,0,0,.72); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 4px; border-radius: 4px; line-height: 1;
}
.punch-row__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.punch-row__title {
  font-weight: 600; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.punch-row__meta {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Floor-plan picker modal */
.punch-plan-modal .punch-plan-select { margin-bottom: 10px; width: 100%; }
.punch-pick-hint {
  margin: 4px 0 12px; padding: 10px 14px;
  background: var(--green-bg); color: var(--green);
  border: 1px solid var(--green); border-radius: 8px; font-weight: 600;
}
.punch-plan-stage-holder {
  border: 1px solid var(--line); border-radius: 10px; overflow: auto;
  max-height: 68vh; background: #fafafa; cursor: crosshair;
}
.punch-plan-modal .punch-plan-stage { cursor: crosshair; }
.punch-pin--ghost { opacity: .5; pointer-events: none; }
.punch-pin--draft {
  background: var(--green); width: 30px; height: 30px; font-size: 16px;
  z-index: 6; pointer-events: none; animation: punchpop .2s ease;
}
@keyframes punchpop { from { transform: translate(-50%,-50%) scale(0.4); } to { transform: translate(-50%,-50%) scale(1); } }

/* Multi-photo gallery in the item modal */
.punch-photo-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.punch-photo-cell { position: relative; aspect-ratio: 1 / 1; }
.punch-photo-cell img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; display: block;
}
.punch-photo-remove {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #c0392b; color: #fff; border: 2px solid #fff;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.punch-photo-empty {
  grid-column: 1 / -1; padding: 24px; text-align: center;
  color: var(--muted); font-size: 13px;
  border: 1px dashed var(--line); border-radius: 8px;
}
.punch-addphoto { align-self: flex-start; }

.punch-pin-row { display: flex; align-items: center; gap: 10px; }
.punch-pin-status { font-size: 13px; color: var(--muted); }
.punch-pin-status.ok { color: var(--green); font-weight: 600; }

/* Lightbox */
.punch-lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
}
.punch-lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 6px; }
.punch-lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.14); color: #fff; border: none;
  width: 52px; height: 72px; font-size: 40px; cursor: pointer;
}
.punch-lb-nav.prev { left: 0; }
.punch-lb-nav.next { right: 0; }

/* Floor-plan manager */
.punch-plan-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 12px; }
.punch-plan-list__row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px;
}
.punch-plan-list__thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); }
.punch-plan-list__name { font-weight: 600; flex: 1 1 auto; }
.punch-plan-list__count { font-size: 12px; color: var(--muted); }
.punch-plan-list__lock { font-size: 12px; color: var(--muted); }
.punch-lock-note { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

@media (max-width: 760px) {
  .punch-toolbar { align-items: stretch; }
  .punch-toolbar__right { width: 100%; }
  .punch-toolbar__right .primary-action,
  .punch-toolbar__right .secondary-action { flex: 1 1 auto; text-align: center; }
  .punch-add-btn { min-height: 46px; font-size: 16px; }
  .punch-row { padding: 12px; }
  .punch-row__no { width: 34px; height: 34px; }
  .punch-row__thumb { width: 50px; height: 50px; }
  .punch-filters { flex-wrap: wrap; }
  .punch-filters select { flex: 1 1 auto; min-height: 42px; }
  .punch-plan-stage-holder { max-height: 60vh; }
  .punch-addphoto { width: 100%; min-height: 46px; }
  .punch-photo-gallery { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}
