:root { --radius: 8px; }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body {
  margin: 0;
  color: #222;
  background: #F7F7F7;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid #222; outline-offset: 2px; }
a { color: inherit; }

.nav-inner, main { max-width: 1200px; margin: 0 auto; }
main { padding: 32px 24px 80px; }
nav.top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #ddd;
}
.nav-inner {
  display: flex;
  align-items: center;
  height: 64px;
  padding: 0 24px;
  gap: 4px;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  margin-right: 16px;
  color: #222;
}
nav.top a.item {
  height: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 16px;
  color: #717171;
}
nav.top a.item[aria-current="page"] {
  color: #222;
  font-weight: 600;
  background: #F7F7F7;
}
details.more { position: relative; }
details.more > summary {
  list-style: none;
  cursor: pointer;
}
details.more > summary::-webkit-details-marker { display: none; }
nav.top details.more > summary.item {
  height: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 16px;
  color: #717171;
}
nav.top details.more > summary.item[aria-current="page"] {
  color: #222;
  font-weight: 600;
  background: #F7F7F7;
}
details.more .menu {
  position: absolute;
  top: 44px;
  left: 0;
  z-index: 30;
  min-width: 160px;
  padding: 8px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
}
details.more .menu a {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: #222;
}
details.more .menu a:hover,
details.more .menu a[aria-current="page"] { background: #F7F7F7; }
.who {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: #222;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #222;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}
nav.bottom { display: none; }
nav.bottom a,
nav.bottom details.more > summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  text-decoration: none;
  font-size: 16px;
  color: #717171;
}
nav.bottom a[aria-current="page"],
nav.bottom details.more > summary[aria-current="page"] { color: #222; font-weight: 600; }

@media (min-width: 1248px) {
  .nav-inner, main { padding-left: 0; padding-right: 0; }
}

h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.page-h { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.page-h h1 { flex: 1; min-width: 0; }

.primary, .secondary, .text, button.choice, summary.add {
  height: 40px;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 16px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.primary { background: #222; color: #fff; border: 1px solid #222; }
.secondary, summary.add {
  background: #fff;
  color: #222;
  border: 1px solid #222;
  text-decoration: none;
}
.text, button.ghost {
  background: transparent;
  color: #222;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0 8px;
  min-width: 40px;
}
button.x {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #717171;
  font-size: 18px;
  line-height: 1;
}
.line .x, .cat-line .x { opacity: 0; }
.line:hover .x, .cat-line:hover .x,
.line .x:focus-visible, .cat-line .x:focus-visible,
.line .x[data-armed="1"], .cat-line .x[data-armed="1"] { opacity: 1; }
.line .x:hover { background: #F7F7F7; color: #222; }
.line .x[data-armed="1"], .cat-line .x[data-armed="1"] {
  width: auto;
  min-width: 48px;
  padding: 0 8px;
  font-size: 13px;
  border: 1px solid #222;
  color: #222;
  background: #fff;
}
button.choice {
  background: #fff;
  color: #222;
  border: 1px solid #ddd;
  width: 100%;
  min-height: 48px;
  height: auto;
  padding: 12px 16px;
  text-align: left;
  justify-content: flex-start;
}
button.choice.on { border-color: #222; background: #F7F7F7; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 64px;
  min-width: 64px;
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #eee;
  color: #222;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  flex: none;
}
button.pill { cursor: pointer; appearance: none; height: 40px; min-height: 40px; max-height: none; border-radius: var(--radius); }
.pill.outline {
  background: #fff;
  border-color: #DDDDDD;
}

input, select {
  height: 40px;
  min-height: 40px;
  background-color: #fff;
  border: 1px solid #DDDDDD;
  border-radius: var(--radius);
  padding: 0 12px;
  font-size: 16px;
}
input:not([type="checkbox"]):hover,
select:hover,
textarea:hover {
  border-color: #222;
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-left: 12px;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5' stroke='%23222' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-origin: border-box;
  background-position: right 12px center;
  background-size: 16px 16px;
}
select::-ms-expand { display: none; }
input[type="checkbox"] {
  accent-color: #222;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border-radius: 4px;
}
textarea { border: 1px solid #DDDDDD; border-radius: var(--radius); padding: 8px 12px; font: inherit; }

.note { margin: 0 0 24px; font-size: 16px; }
.alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  margin-bottom: 32px;
  padding: 12px 16px;
  background: #F7F7F7;
  color: #222;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
}
.alerts[hidden] { display: none !important; }
.bad { color: #222; font-weight: 700; }
.loss { color: #222; font-weight: 700; }
#quote-error { margin: 16px 0 0; font-size: 13px; color: #222; font-weight: 700; }

.card {
  min-width: 0;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  padding: 24px;
  background: #fff;
}
.cards { display: flex; flex-direction: column; gap: 32px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-height: 32px; }
.card-h .amt, .subtotal { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card h2 + .rows, .card .card-h + .field, .card .card-h + .rows, .card h2 + .card-h { margin-top: 8px; }
.k { font-size: 13px; color: #717171; font-weight: 500; }
.basis { font-size: 13px; color: #717171; font-weight: 500; }
.stick {
  position: sticky;
  top: 64px;
  z-index: 10;
  background: #F7F7F7;
  padding-bottom: 16px;
  margin-bottom: 16px;
}
.stick + .alerts { margin-top: 0; }
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  padding: 20px 0;
  margin-bottom: 32px;
}
.stick .metrics { margin-bottom: 0; }
.metrics > div {
  padding: 0 20px;
  border-left: 1px solid #e5e5e5;
  min-width: 0;
}
.metrics > div:first-child { border-left: 0; }
@media (min-width: 641px) { .project-metrics.metrics > div:first-child, .project-metrics .metrics > div:first-child { padding-left: 24px; } }
.metrics .v {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.dash,
.metrics .v.dash,
.metrics .v .dash,
.quote .v.dash,
.quote .v .dash,
td.dash { font-weight: 400; }

.quote .v { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.quote .emphasis { font-size: 28px; font-weight: 700; color: #222; }
.quote .emphasis.dash { font-weight: 400; }
.quote .pair { margin-top: 24px; }
.quiet { display: flex; justify-content: space-between; gap: 16px; min-height: 40px; align-items: center; margin-top: 16px; font-size: 16px; font-variant-numeric: tabular-nums; }

.sheet { display: block; }
.sheet > * { min-width: 0; }
.rows { border-top: 1px solid #eee; }
.line, .layer {
  display: grid;
  align-items: center;
  min-height: 48px;
  gap: 8px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid #eee;
}
.line { grid-template-columns: minmax(0, 1fr) 128px 80px 48px; }
.line.spend { grid-template-columns: 40px minmax(0, 1.4fr) 196px 112px 40px; min-width: 0; }
.line.spend.readonly { grid-template-columns: minmax(0, 1.4fr) 168px 112px; }
.line.spend > .x { justify-self: center; }
.line.spend .labor {
  grid-column: 1 / -1;
  justify-self: stretch;
  text-align: left;
  display: grid;
  grid-template-columns: 40px minmax(0, 1.4fr) 196px 112px 40px;
  column-gap: 8px;
  align-items: start;
  padding: 4px 0 8px;
}
.line.spend .labor-note { grid-column: 1 / -1; }
.line.spend .labor[hidden] { display: none !important; }
.labor-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  color: #717171;
}
.labor-field .k, .labor-eq-slot .ghost { min-height: 18px; line-height: 18px; }
.labor-field input {
  width: 100%;
  height: 40px;
  min-height: 40px;
  color: #222;
  font-size: 16px;
}
.labor-field .field-error { margin: 0; }
.labor-eq-slot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.labor-eq {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}
.line.spend .labor > .labor-eq-slot .labor-eq[hidden] {
  display: flex !important;
  visibility: hidden;
}
.line.spend .labor > .labor-mismatch { grid-column: 2 / -1; }
.bad-input { border-color: #222; }
.labor-fields {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
}
.labor-fields[hidden] { display: none !important; }
.labor-fields .labor-field { width: 168px; }
input.date-field { width: 9.5rem; min-width: 9.5rem; height: 40px; min-height: 40px; }
.spend-title { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
.handle {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #717171;
  font-weight: 700;
  cursor: grab;
  font-size: 13px;
  line-height: 24px;
}
.handle::before { content: "⋮⋮"; letter-spacing: -1px; }
.line.dragging, .cost-edit.dragging { opacity: 0.45; }
.line.spend > * { min-width: 0; }
.line.spend .summary { overflow-wrap: anywhere; line-height: 1.35; }
.line.spend select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  min-height: 40px;
}
.foot {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 96px 96px 88px;
  gap: 8px;
  min-height: 32px;
  align-items: center;
  font-size: 16px;
  width: 100%;
}
button.foot {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border-radius: 0;
}
button.foot:hover { background: #f7f7f7; }
.foot .num { text-align: right; font-variant-numeric: tabular-nums; }
.foot .over { color: #222; font-weight: 700; }
.foot.head { color: #717171; font-size: 13px; min-height: 28px; }
.foot.total { font-weight: 600; border-top: 1px solid #eee; margin-top: 8px; padding-top: 8px; }
.foot.total .over { color: #222; font-weight: 700; }
.cat-lines { padding: 0 0 8px 8px; }
.cat-group { margin-top: 8px; font-size: 13px; color: #717171; }
.cat-line {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 96px 40px;
  gap: 8px;
  min-height: 40px;
  align-items: center;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.cat-line .num { text-align: right; }
.cat-line.head { color: #717171; font-size: 13px; min-height: 28px; }
.cat-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0 4px; }
.cat-add > .field-error, form[data-add] > .field-error { flex: 1 0 100%; }
.cat-add input { height: 40px; min-height: 40px; }
.compare { color: #717171; font-size: 13px; font-weight: 500; }
.quote-case { margin-top: 24px; border-top: 1px solid #eee; padding-top: 8px; }
.qline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  align-items: baseline;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.qline span:first-child { min-width: 0; }
.qline span:last-child { white-space: nowrap; }
.qline.total { font-weight: 600; border-top: 1px solid #eee; margin-top: 8px; padding-top: 8px; }
.line.expense { grid-template-columns: 120px minmax(0, 1fr) 128px 48px; }
.line.receipt { grid-template-columns: minmax(0, 1.2fr) 128px 112px 80px 48px; }
.line.receipt.readonly { grid-template-columns: minmax(0, 1.2fr) 128px 112px 80px; }
.line.head {
  min-height: 40px;
  font-size: 13px;
  color: #717171;
  font-weight: 500;
  white-space: nowrap;
}
.line .pill,
.line .st,
.line .act,
.line > :last-child { justify-self: center; text-align: center; }
.line .num, .layer span:not(:first-child), .line.head .num { text-align: right; }
.grow { min-width: 0; }
.layer { grid-template-columns: 1.2fr 0.9fr 0.9fr 0.7fr; }
.layer.head { color: #717171; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: 13px; color: #717171; }
.field input, .field select { color: #222; max-width: 240px; }
#create-project #name { max-width: none; width: 100%; }
.suggest {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-width: 240px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius);
}
.suggest button {
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  font-size: 16px;
}
.suggest button:hover { background: #F7F7F7; }
.suggest-field { position: relative; }
.suggest-field > .suggest { position: absolute; top: 100%; left: 0; z-index: 15; max-height: 160px; overflow-y: auto; }
.field-error { color: #222; font-size: 13px; font-weight: 700; margin: 4px 0 0; }
.row-error { margin: 0 0 8px; }
.plain { color: #222; font-size: 16px; }
.stack-list { display: none; }
.hfield {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 48px;
  margin-top: 8px;
  font-size: 16px;
  color: #222;
}
.hfield > span:first-child { flex: 1; }
.hfield input { width: 120px; }
.hfield input.roomy { width: 176px; }
.suffix { display: flex; align-items: center; gap: 8px; color: #222; }
.suffix input { width: 120px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }

details form, .tpl form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0 16px; }
details form input, details form select, .tpl form input { min-width: 8rem; }
summary { cursor: pointer; }
summary.add {
  width: fit-content;
  margin-top: 16px;
  list-style: none;
}
summary.add::-webkit-details-marker { display: none; }
summary.add::marker { content: ""; }
details.fold { margin-top: 24px; }
details.fold summary { font-size: 16px; min-height: 40px; display: flex; align-items: center; }

.segment { display: inline-flex; background: #fff; border: 1px solid #222; border-radius: var(--radius); overflow: hidden; }
.segment a {
  height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 16px;
  border-right: 1px solid #222;
  color: #222;
  background: #fff;
}
.segment a:last-child { border-right: 0; }
.segment a[aria-current="true"] { background: #F7F7F7; font-weight: 600; }

.cats { display: inline-flex; margin-bottom: 0; }
.cats a { white-space: nowrap; }
.cats-scroll { margin-bottom: 16px; max-width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 32px; }
.filters form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
label.filter-line { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #717171; }
label.filter-line select { width: auto; min-width: 120px; color: #222; }
.filters label.filter-date {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
}
.filters label.filter-date .k { grid-column: 1; }
.filters label.filter-date input { grid-column: 2; }
.filters label.filter-date .field-error { grid-column: 2; }
.filters input[name="min"], .filters input[name="max"] { width: 8rem; }
.chip {
  height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  font-size: 16px;
}
.chip.on { border-color: #222; background: #F7F7F7; }
.filters input[name="q"] { width: 200px; }

.panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  overflow: hidden;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 16px; background: #fff; }
table.grid th, table.grid td { height: 48px; padding: 0 16px; border-bottom: 1px solid #eee; vertical-align: middle; }
table.grid th { font-size: 13px; color: #717171; font-weight: 500; text-align: left; background: #F7F7F7; }
table.grid th.num, table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dashboard-table th.num,
.dashboard-table td.num { min-width: 136px; white-space: nowrap; }
.dashboard-label { display: none; }
table.grid a { text-decoration: none; font-weight: 600; }
table.grid tbody tr:hover td { background: #fafafa; }
.panel table.grid tr:last-child td { border-bottom: 0; }
.flag { font-size: 13px; border: 1px solid #222; border-radius: 999px; padding: 2px 8px; margin-left: 8px; font-weight: 500; }

.block { margin-top: 48px; }
.block h2 { margin-bottom: 16px; }
#login-card { width: min(100%, 400px); margin: 12vh auto 0; }
.brand-lockup { margin: 0; font-size: 18px; font-weight: 700; color: #222; }
.login { display: flex; flex-direction: column; gap: 16px; }
.login h1 { margin-bottom: 8px; }
.login input, .login .primary { width: 100%; }

#wizard { max-width: 640px; }
.wizard-top { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.dots { display: flex; gap: 8px; }
.dots i { width: 8px; height: 8px; border: 1px solid #222; border-radius: var(--radius); display: block; }
.dots i.on { background: #222; }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cost-edit { display: grid; grid-template-columns: 40px 24px minmax(0, 1fr) 128px 140px; gap: 12px; align-items: center; min-height: 48px; }
#budget-lines .cost-edit { grid-template-columns: 40px minmax(0, 1fr) 196px 120px 40px; }
.cost-edit select, .cost-edit input.summary, .cost-edit input.amt { width: 100%; min-width: 0; height: 40px; }
.wizard-actions { display: flex; gap: 16px; margin-top: 32px; }
.quotes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 8px; }
.quotes .v { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.quotes .emphasis { font-weight: 700; }
.temp { font-size: 28px; font-weight: 600; letter-spacing: 0.04em; margin: 8px 0; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { height: 40px; min-height: 40px; }
.tpl { margin-top: 24px; }
.tpl-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.tpl h3 { font-size: 16px; font-weight: 600; margin: 0; flex: 1; min-width: 0; }
.tpl .line { grid-template-columns: 40px minmax(0, 1.4fr) 196px 120px 40px; }
.tpl .line.readonly {
  grid-template-columns: minmax(0, 1fr) 120px 120px;
  justify-items: start;
}
.tpl .line.readonly > * {
  justify-self: start;
  text-align: left;
  min-width: 0;
}
.tpl .line.readonly .num { text-align: right; }
#category-items .line { grid-template-columns: minmax(0, 1fr) 40px; }
#category-items .line > * { justify-self: start; text-align: left; min-width: 0; }
.pending { color: #717171; }
.pending-count { margin: 8px 0 0; color: #717171; font-size: 13px; }
#budget-lines { margin-top: 16px; }
#add-budget { margin-top: 16px; }
.tpl .line select, .tpl .line input { height: 40px; min-height: 40px; width: 100%; min-width: 0; padding: 0 12px; font-size: 16px; }
.tpl .line button.x { width: 40px; min-width: 40px; height: 40px; min-height: 40px; }
.tpl .line select { padding-right: 40px; }
.restore-banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #222;
  border-radius: var(--radius);
  color: #222;
  font-size: 16px;
  font-weight: 700;
}
.restore-banner[hidden] { display: none !important; }
#flash:not([hidden]),
.restore-banner:not([hidden]) {
  position: fixed;
  z-index: 40;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  margin: 0;
  background: #fff;
  border: 1px solid #222;
  border-radius: var(--radius);
  box-shadow: none;
}
.wide-table table.grid { table-layout: fixed; }
/* 1440px 下表格可用 1230px；固定列之外，名称保留 294px（已删除 314px）。 */
main.projects-page { max-width: 1280px; }
.wide-table th,
.wide-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wide-table td:last-child,
.wide-table th:last-child { width: 112px; overflow: visible; text-overflow: clip; }
.wide-table.projects th,
.wide-table.projects td { padding-left: 6px; padding-right: 6px; }
.wide-table.projects th:last-child,
.wide-table.projects td:last-child { width: auto; padding-right: 16px; }
.wide-table.projects col.c-client,
.wide-table.projects th.client { width: 140px; }
.wide-table.projects col.c-line,
.wide-table.projects th.biz { width: 64px; }
.wide-table.projects col.c-stage,
.wide-table.projects th.stage { width: 64px; }
.wide-table.projects col.c-money,
.wide-table.projects th.money,
.wide-table.projects col.c-profit,
.wide-table.projects th.profit { width: 120px; min-width: 120px; }
.wide-table.projects td.num { min-width: 120px; }
.wide-table.projects col.c-date,
.wide-table.projects th.date,
.wide-table.projects col.c-when,
.wide-table.projects th.when { width: 108px; min-width: 108px; }
.wide-table.projects td.date,
.wide-table.projects td.when { min-width: 108px; font-variant-numeric: tabular-nums; }
.wide-table.projects col.c-who,
.wide-table.projects th.who { width: 56px; }
.wide-table.projects col.c-act,
.wide-table.projects th.act,
.wide-table.projects td.act { width: 80px; overflow: visible; text-overflow: clip; }
.wide-table.projects.is-deleted td.when {
  height: 48px;
  vertical-align: middle;
  white-space: normal;
  overflow: hidden;
  line-height: 1.15;
}
.wide-table.projects.is-deleted td.when .when-line {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.15;
}
.wide-table.projects thead a { font-weight: inherit; }
.wide-table.projects td.name,
.wide-table.projects td.client {
  height: auto;
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
}
.wide-table.projects td.name a,
.wide-table.projects td.client span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
  max-height: calc(1.35em * 2);
}
button[data-restore-project] { white-space: nowrap; }
dialog.confirm {
  border: 1px solid #222;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  background: #fff;
  color: #222;
}
dialog.confirm h2 { margin-bottom: 8px; }
dialog.confirm p { margin: 0 0 24px; }
dialog.confirm .actions { margin-top: 0; }
dialog.confirm::backdrop { background: rgba(34, 34, 34, 0.4); }
.actions { display: flex; gap: 16px; align-items: center; margin-top: 16px; }
[data-edit] input.inline { width: 100%; height: 40px; }

@media (max-width: 800px) {
  nav.top { display: none; }
  nav.bottom {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #fff;
    border-top: 1px solid #ddd;
    z-index: 20;
  }
  nav.bottom .tabs { display: flex; min-width: 0; }
  nav.bottom .tabs > a,
  nav.bottom .tabs > button {
    flex: 1 1 0;
    justify-content: center;
    min-height: 56px;
    min-width: 0;
    padding: 0 2px;
    white-space: nowrap;
  }
  nav.bottom .tabs > button {
    height: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #717171;
    font-size: 16px;
  }
  nav.bottom .tabs > button[aria-expanded="true"],
  nav.bottom .tabs > button[aria-current="page"] { color: #222; font-weight: 600; }
  nav.bottom .menu {
    display: flex;
    flex-direction: column;
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    transform: none;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-sizing: border-box;
  }
  nav.bottom .menu a {
    height: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    text-decoration: none;
    color: #222;
  }
  main { padding: 24px 16px 96px; }
  input, select, button, textarea { scroll-margin-bottom: 88px; }
  .stick { position: static; }
  .quote { position: static; }
  .sheet, .types, .quotes, .grid-2 { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics > div { border-left: 0; border-top: 1px solid #e5e5e5; padding: 16px 20px; }
  .metrics > div:nth-child(-n+2) { border-top: 0; }
  .metrics > div:nth-child(even) { border-left: 1px solid #e5e5e5; }
  #flash:not([hidden]),
  .restore-banner:not([hidden]) { top: 16px; }
  .wide-table { display: none; }
  .stack-card p { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
  .stack-list { display: grid; gap: 16px; }
  .stack-card {
    min-width: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .stack-card h2 { line-height: 1.35; }
  .stack-card p { margin: 0; }
  .page-h { flex-wrap: wrap; }
  .page-h h1, #badge { flex: 1 0 100%; }
  .line.spend.head { display: none; }
  .line.spend:not(.readonly):not(.head) {
    grid-template-columns: 40px minmax(0, 1fr) 4.75rem 32px;
    grid-template-areas: "handle summary amount remove" "handle category category remove" "labor labor labor labor";
    gap: 4px;
  }
  .line.spend:not(.readonly):not(.head) > .handle { grid-area: handle; }
  .line.spend:not(.readonly):not(.head) > .summary { grid-area: summary; }
  .line.spend:not(.readonly):not(.head) > select { grid-area: category; }
  .line.spend:not(.readonly):not(.head) > .num { grid-area: amount; }
  .line.spend:not(.readonly):not(.head) > .x { grid-area: remove; }
  .line.spend:not(.readonly):not(.head) > .labor {
    grid-area: labor;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0 8px;
  }
  .line.spend .labor > .gap { display: none; }
  .line.spend .labor > .labor-field { flex: 1 1 8rem; }
  .line.spend .labor > .labor-eq-slot { flex: 1 0 100%; }
  .line.spend .labor > .labor-eq-slot .ghost { display: none; }
  .line.spend .labor > .labor-eq-slot .labor-eq { justify-content: flex-start; }
  .line.spend .labor > .labor-eq-slot .labor-eq[hidden] { display: none !important; }
  .line.spend .labor > .labor-mismatch { flex: 1 0 100%; }
  .labor-fields .labor-field { width: min(168px, 100%); }
  .line.spend.readonly { grid-template-columns: minmax(0, 1fr) minmax(0, 5.5rem) 4.5rem; }
  .line.receipt { grid-template-columns: minmax(0, 1fr) 4.5rem 5.5rem 64px 32px; gap: 4px; }
  .line.receipt.readonly { grid-template-columns: minmax(0, 1fr) 4.5rem 5.5rem 4rem; }
  .line.receipt > * { min-width: 0; }
  .foot { grid-template-columns: minmax(0, 1fr) 4.5rem 4.5rem 4rem; gap: 4px; }
  .cat-line { grid-template-columns: 6.5rem minmax(0, 1fr) 4.5rem 32px; gap: 4px; }
  .card-h { flex-wrap: wrap; }
  .hfield input.roomy { width: min(176px, 100%); }
  #budget-lines .cost-edit {
    grid-template-columns: 40px minmax(0, 1fr) 6.5rem 40px;
    grid-template-areas: "handle summary summary remove" "handle category amount remove";
    gap: 4px;
  }
  #budget-lines .cost-edit > * { min-width: 0; }
  #budget-lines .cost-edit .handle { grid-area: handle; }
  #budget-lines .cost-edit .summary { grid-area: summary; }
  #budget-lines .cost-edit .cat { grid-area: category; }
  #budget-lines .cost-edit .amt { grid-area: amount; }
  #budget-lines .cost-edit .x { grid-area: remove; }
  .tpl .line:not(.readonly) {
    grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 40px;
    grid-template-areas: "handle summary summary remove" "handle category amount remove";
    gap: 4px;
  }
  .tpl .line:not(.readonly) .handle { grid-area: handle; }
  .tpl .line:not(.readonly) [data-tpl-summary] { grid-area: summary; }
  .tpl .line:not(.readonly) select { grid-area: category; }
  .tpl .line:not(.readonly) input { grid-area: amount; }
  .tpl .line:not(.readonly) .x { grid-area: remove; }
  .tpl .line.readonly { grid-template-columns: minmax(0, 1fr) minmax(4.5rem, 6.5rem) 4.5rem; }
  .cats-scroll { position: static; }
  .cats-scroll::after { content: none; }
  .cats-scroll .cats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid #222;
    border-radius: var(--radius);
  }
  .cats-scroll .cats a {
    justify-content: center;
    min-width: 0;
    height: 40px;
    padding: 0 4px;
    border-right: 1px solid #222;
    border-bottom: 1px solid #222;
    border-radius: 0;
    white-space: nowrap;
  }
  .cats-scroll .cats a:nth-child(3n) { border-right: 0; }
  .cats-scroll .cats a:nth-child(n+4) { border-bottom: 0; }
}

.project-page .dash,
.project-page .v.dash,
.project-page .emphasis.dash {
  font-weight: 400;
}

/* 先看后改：展开入口和数值都保留 40px 点击区。 */
button, summary, [data-edit], .brand { min-height: 40px; }
button { border-radius: var(--radius); }
.hit { display: inline-flex; align-items: center; min-width: 40px; max-width: 100%; cursor: pointer; color: #222; }
.value-field { display: inline-flex; flex-direction: column; min-width: 0; }
.value-field .hit { flex-wrap: wrap; }
.hit .field-error { flex-basis: 100%; }
.hit input { min-width: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.project-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quote-hint { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 25px 0; font-size: 16px; }
.project-page > .alerts { padding-inline: 25px; }
.project-heading > select { width: 128px; }
.project-heading h1 { overflow-wrap: anywhere; }
.project-page .stick { position: static; }
.card-h { align-items: center; }
.card-h h2 { margin-right: auto; }
.fee-row { display: grid; grid-template-columns: minmax(96px, 1fr) minmax(0, 2fr) minmax(80px, 1fr); gap: 16px; align-items: center; min-height: 56px; border-bottom: 1px solid #eee; }
.fee-row:last-child { border-bottom: 0; }
.fee-row input { width: 120px; }
.funding-values { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; }
.funding-values > span { display: inline-flex; align-items: center; gap: 8px; }
.deduction > summary { display: flex; align-items: center; font-size: 18px; font-weight: 600; }
.actions-menu { position: relative; min-width: 40px; }
.actions-menu > summary { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: auto; border: 1px solid #ddd; border-radius: var(--radius); list-style: none; background: #fff; color: #222; }
.actions-menu > summary::-webkit-details-marker, .filter-options > summary::-webkit-details-marker { display: none; }
.menu-items { padding: 8px 0; min-width: 0; white-space: normal; }
.menu-items { text-align: left; }
.menu-items > a, .menu-items button { display: flex; align-items: center; justify-content: flex-start; width: 100%; min-height: 40px; height: 40px; padding: 0 8px; background: #fff; color: #222; border: 0; border-radius: var(--radius); text-decoration: none; overflow-wrap: anywhere; }
.menu-items > a:hover, .menu-items button:hover { background: #f7f7f7; }
.menu-items .menu-delete { display: flex; width: 100%; grid-column: 1 / -1; border-top: 1px solid #ddd; border-radius: var(--radius); margin-top: 8px; }
.menu-items form { display: flex; flex-direction: column; align-items: stretch; margin: 0; padding: 0; }
.menu-items .entry-field { width: 100%; }
.entry-field { display: flex; flex-direction: column; align-items: stretch; gap: 8px; color: #717171; font-size: 13px; min-width: 0; margin: 0; }
.entry-field input, .entry-field select, .entry-field .hit { width: 100%; min-width: 0; color: #222; font-size: 16px; }
.entry-field .field-error { margin: 0; display: block; }
.entry-form, details form.entry-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: start; gap: 16px; padding: 16px 0; }
.tpl form.entry-form { display: grid; align-items: start; }
.entry-form.simple-entry { grid-template-columns: minmax(0, 320px) auto; justify-content: start; }
.entry-form > button { margin-top: 27px; }
.spend-entry { grid-template-columns: minmax(136px, 1fr) minmax(0, 1.6fr) minmax(160px, 1fr) minmax(96px, 1fr) auto; }
.entry-form input, .entry-form select, .entry-form .date-field { width: 100%; min-width: 0; }
.entry-form .labor-fields { grid-column: 1 / -1; }
.multiply { align-self: center; }
.budget-head, .budget-row { display: grid; align-items: center; min-height: 48px; border-bottom: 1px solid #eee; }
.budget-head { color: #717171; background: #f7f7f7; font-size: 13px; }
.budget-row > * { min-width: 0; overflow-wrap: anywhere; }
.budget-head > .detail-actions { grid-column: 5; justify-self: end; width: 40px; text-align: center; }
.budget-row > .summary, .cat-line > .summary { grid-column: 1; grid-row: 1; }
.budget-row > [data-budget-amount] { grid-column: 2; grid-row: 1; }
.budget-row > [data-budget-actual], .cat-line > .num { grid-column: 3; grid-row: 1; }
.budget-row > .row-menu, .cat-line > .row-menu { grid-column: 5; grid-row: 1; }
.budget-row .row-menu[open], .cat-line .row-menu[open], .receipt .row-menu[open] { grid-column: 1 / -1; width: 100%; }
.cat-line > .row-menu[open] { grid-row: 2; }
.detail-date { display: block; font-size: 13px; color: #717171; }
.budget-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr) minmax(96px, 1fr); gap: 16px; }
.budget-fields > .handle { grid-column: 1 / -1; width: 40px; color: #717171; }
.budget-fields .labor { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 16px; }
.budget-fields .labor > label { flex: 0 1 160px; }
.empty-categories > summary { display: flex; align-items: center; }
button.foot { min-height: 40px; border-radius: var(--radius); }
.cat-line { padding: 8px 0; }
.cat-line > * { min-width: 0; overflow-wrap: anywhere; }
.cat-line .menu-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.project-info .card-h:has(details[open]) { flex-wrap: wrap; }
.project-info details[open] { flex-basis: 100%; }
.project-info .menu-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.filters form { width: 100%; display: grid; grid-template-columns: minmax(0, 320px) auto; justify-content: start; }
.filters input[name="q"] { width: 100%; }
.filter-options { display: contents; }
.filter-options > summary { list-style: none; }
.filter-fields { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; padding-top: 8px; }
.filter-options:not([open]) .filter-fields { display: none; }
.filter-fields > .secondary, .filter-fields > .text { margin-top: 27px; }
.profit-help { display: inline-flex; vertical-align: middle; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: inherit; }
.profit-tooltip { position: fixed; z-index: 30; width: min(320px, calc(100vw - 32px)); padding: 8px 12px; border: 1px solid #ddd; border-radius: var(--radius); background: #fff; font-size: 13px; font-weight: 400; text-align: left; white-space: normal; }
table.grid th.profit { white-space: nowrap; }
.account-create { margin-bottom: 32px; }
.account-card + .card { margin-top: 16px; }
.account-create form.grid-2 { display: grid; align-items: start; }
.account-create .field input, .account-create .field select { max-width: 100%; }
.account-create form > button { margin-top: 43px; }
.card > .panel { border: 0; border-radius: 0; }
.card .stack-card { border: 0; border-bottom: 1px solid #eee; border-radius: var(--radius); padding: 16px 0; }
#create-project { max-width: 528px; }
#create-project > .field, #create-project .new-pair { width: 100%; max-width: 480px; }
#create-project .field input, #create-project .field select, #create-project #name, .suggest { width: 100%; max-width: 480px; }
.new-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.suggest { grid-column: 1 / -1; }
.suggest [aria-selected="true"] button { background: #eee; }
.menu-toggle { height: 40px; min-width: 40px; background: #fff; color: #222; border: 1px solid #ddd; }
.setting-value { display: flex; justify-content: space-between; gap: 16px; min-height: 40px; align-items: center; }
.suffix { flex-wrap: wrap; }
.suffix .field-error { flex-basis: 100%; }
.tpl .line.template-row { grid-template-columns: minmax(0, 2fr) minmax(128px, 1fr) minmax(88px, 1fr) 40px; }
.tpl .line.template-row > span { justify-self: stretch; text-align: left; }
.tpl .line.template-row > .num { text-align: right; }
.tpl .row-menu[open], #category-items .row-menu[open] { grid-column: 1 / -1; width: 100%; }
.template-fields { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(160px, 1fr) minmax(96px, 1fr); gap: 16px; }
.template-fields .field-error { grid-column: 1 / -1; }
.tpl-head:has(details[open]) { flex-wrap: wrap; }
.tpl-head details[open] { width: 100%; }
#budget-lines .cost-edit { grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr) 40px; grid-template-areas: "handle summary summary remove" "handle category amount remove"; }
#budget-lines .cost-edit .handle { grid-area: handle; }
#budget-lines .cost-edit .summary { grid-area: summary; }
#budget-lines .cost-edit .cat { grid-area: category; }
#budget-lines .cost-edit .amt { grid-area: amount; }
#budget-lines .cost-edit .x { grid-area: remove; }
#budget-lines .summary-slot { grid-area: summary; }
#budget-lines .category-slot { grid-area: category; }
#budget-lines .amount-slot { grid-area: amount; }
@media (min-width: 801px) {
  .panel:has(.actions-menu) { overflow: visible; }
  td > .actions-menu .menu-items, .project-heading > .actions-menu .menu-items { position: absolute; top: 40px; right: 0; z-index: 12; width: 224px; padding: 8px; border: 1px solid #ddd; border-radius: var(--radius); background: #fff; }
}
@media (max-width: 800px) {
  body { --bottom-nav-height: 57px; }
  main { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 24px); }
  nav.bottom { padding-bottom: env(safe-area-inset-bottom); }
  .project-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; }
  .metrics > div { padding: 16px; }
  .quote-hint { padding-inline: 17px; }
  .project-page > .alerts { padding-inline: 17px; }
  .metrics .v { overflow-wrap: anywhere; }
  .project-heading { display: grid; grid-template-columns: auto 128px minmax(40px, 1fr); gap: 8px; }
  .project-heading > h1 { grid-column: 1 / -1; grid-row: 1; }
  .project-heading > .text { grid-column: 1; grid-row: 2; }
  .project-heading > select, .project-heading > .pill { grid-column: 2; grid-row: 2; }
  .project-heading > .actions-menu { grid-column: 3; grid-row: 2; }
  .project-heading > .actions-menu > summary { grid-column: 3; grid-row: 2; justify-self: end; }
  .project-heading > .text, .project-heading > select, .project-heading > .pill { align-self: start; position: relative; z-index: 1; }
  .project-heading > .actions-menu[open] { grid-column: 1 / -1; grid-row: 2 / span 2; pointer-events: none; }
  .project-heading > .actions-menu[open] > summary, .project-heading > .actions-menu[open] > .menu-items { pointer-events: auto; }
  .project-heading > .actions-menu > .menu-items { position: static; box-sizing: border-box; width: 100%; margin-top: 8px; padding: 8px; border: 1px solid #ddd; border-radius: var(--radius); background: #fff; }
  .menu-items { position: static; width: 100%; }
  .stack-card .actions-menu[open] { width: 100%; }
  .card { padding: 16px; }
  .budget-row { padding: 8px 0; }
  .budget-row > .row-menu[open] { grid-column: 1 / -1; grid-row: 2; }
  .budget-fields, .cat-line .menu-items, .project-info .menu-items { grid-template-columns: 1fr; }
  .fee-row { grid-template-columns: minmax(72px, 1fr) minmax(0, 1.5fr) minmax(60px, 1fr); gap: 8px; }
  .fee-row input { width: 100%; }
  .funding-values > span { flex-wrap: wrap; }
  .entry-form, details form.entry-form, .spend-entry, .entry-form.simple-entry { grid-template-columns: 1fr; }
  .entry-form > button { margin-top: 0; }
  .entry-form .labor-fields { display: grid; grid-template-columns: 1fr auto 1fr; }
  .entry-form .entry-field, .entry-form input { min-width: 0; max-width: 100%; }
  .cat-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(56px, 1fr) 40px; gap: 8px; }
  .line.receipt, .line.receipt.readonly { grid-template-columns: minmax(0, 1fr) minmax(64px, 1fr); gap: 8px; padding: 8px 0; }
  .line.receipt.head { display: none; }
  .line.receipt > .grow { grid-column: 1 / -1; }
  .line.receipt > details { justify-self: stretch; }
  .new-pair { grid-template-columns: 1fr; gap: 0; }
  .tpl .line.template-row { grid-template-columns: minmax(0, 1fr) minmax(64px, 1fr) 40px; grid-template-areas: none; }
  .tpl .line.template-row > [data-template-summary] { grid-column: 1 / 3; }
  .tpl .line.template-row > details { grid-column: 3; grid-row: 1 / 3; }
  .tpl .line.template-row > details[open] { grid-column: 1 / -1; grid-row: 3; }
  .template-fields { display: flex; flex-direction: column; align-items: stretch; }
  .filter-fields > .entry-field { flex: 1 1 128px; }
  .filter-fields input, .filter-fields select, .filters input[name="min"], .filters input[name="max"] { min-width: 0; width: 100%; }
}
@media (max-width: 640px) {
  .dashboard-table { border: 0; background: transparent; overflow: visible; }
  .dashboard-table table.grid { display: block; background: transparent; }
  .dashboard-table thead { display: none; }
  .dashboard-table tbody { display: grid; gap: 16px; }
  .dashboard-table tr { display: flex; flex-direction: column; min-width: 0; padding: 16px; gap: 8px; background: #fff; border: 1px solid #ddd; border-radius: var(--radius); }
  .dashboard-table table.grid td { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; width: 100%; min-width: 0; height: auto; padding: 0; border: 0; white-space: normal; text-align: right; }
  .dashboard-table table.grid td.dashboard-name { display: block; text-align: left; }
  .dashboard-table td > :last-child { min-width: 0; overflow-wrap: anywhere; }
  .dashboard-table .dashboard-label { display: block; flex-shrink: 0; color: #717171; font-size: 13px; font-weight: 400; text-align: left; }
}
@media (min-width: 801px) {
  .budget-row > .row-menu[open] { grid-column: 1 / -1; grid-row: 1 / span 2; align-self: start; pointer-events: none; }
  .budget-row:has(> .row-menu[open]) { grid-template-rows: 48px auto; }
  .budget-row > .row-menu[open] > summary { margin-top: 4px; }
  .budget-row > .row-menu[open] > summary, .budget-row > .row-menu[open] > .menu-items { pointer-events: auto; }
  .budget-row:has(> .row-menu[open]) > span { grid-row: 1; position: relative; z-index: 1; }
  .budget-row:has(> .row-menu[open]) > span:nth-child(1) { grid-column: 1; }
  .budget-row:has(> .row-menu[open]) > span:nth-child(2) { grid-column: 2; }
  .budget-row:has(> .row-menu[open]) > span:nth-child(3) { grid-column: 3; }
  .budget-fields { grid-template-columns: 40px minmax(0, 2fr) minmax(160px, 1fr) minmax(96px, 1fr); }
  .budget-fields > .handle { grid-column: auto; align-self: end; height: 40px; }
}
@media (max-width: 800px) {
  .project-heading > .actions-menu .menu-delete { position: relative; box-sizing: border-box; width: calc(100% + 16px); margin-inline: -8px; padding-inline: 16px; border-top: 0; overflow: visible; }
  .project-heading > .actions-menu .menu-delete::before { content: ""; position: absolute; top: -4px; left: 0; right: 0; border-top: 1px solid #ddd; }
}
@media (max-width: 640px) {
  #totals > div:last-child:nth-child(odd) { grid-column: 1 / -1; border-left: 0; }
}

/* 项目页的核算、科目表；不改变其他页面。 */
.project-page { --category-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)) minmax(48px, .6fr); --category-gap: 16px; }
.project-summary { margin-bottom: 24px; padding: 24px; background: #fff; border: 1px solid #ddd; border-radius: 8px; }
.project-summary .project-metrics { grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr) 24px minmax(0, 1fr) minmax(0, .8fr); gap: 16px; margin: 0; padding: 0; border: 0; align-items: start; }
.project-summary .project-metrics > div { padding: 0; border: 0; }
.project-summary .project-metrics > div:first-child { padding-left: 0; }
.project-summary .project-metrics .v { overflow-wrap: anywhere; }
.equation-sign { font-size: 28px; text-align: center; align-self: center; }
#cost-incomplete { margin: 8px 0 0; font-size: 13px; color: #717171; }
.project-summary .k { font-size: 16px; color: #222; }
.profit-basis { margin: 16px 0; font-size: 16px; }
#price-missing { margin: 8px 0 16px; }
.quote-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.proposed-field { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.proposed-field input { width: 160px; min-width: 0; }
.project-summary .quote-hint { display: flex; flex-direction: column; gap: 4px; padding: 0; }
.project-summary .quote-hint .v { margin-top: 0; }
.cost-explanation { border-top: 1px solid #ddd; padding-top: 16px; }
.cost-explanation h2 { margin-bottom: 16px; }
.cost-split { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); align-items: center; gap: 16px; }
.cost-split > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; }
.cost-split > div > span:nth-child(2) { grid-column: 1; }
.cost-split strong { grid-column: 2; grid-row: 1 / 3; align-self: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.split-sign { text-align: center; }
.project-page .foot, .project-page .budget-head, .project-page .budget-row, .project-page .cat-line { grid-template-columns: var(--category-columns); gap: var(--category-gap); }
.project-page .foot { min-height: 48px; }
.project-page .foot > * { min-width: 0; }
.project-page .foot.head { min-height: 40px; }
.project-page .foot.head > span { white-space: nowrap; }
.project-page button.foot { border-bottom: 1px solid #eee; border-radius: 0; }
.empty-categories > summary { font-size: 13px; font-weight: 400; }
.cat-arrow { display: inline-block; width: 16px; }
.estimate-metrics, .quote-tools { margin: 0; padding: 0; border: 0; gap: 24px; align-items: start; }
.estimate-metrics { grid-template-columns: 1fr 1fr 2fr; }
.project-summary .estimate-metrics > div, .project-summary .quote-tools > div { border: 0; padding: 0; }
.estimate-metrics > div:first-child { padding-left: 0; }
.estimate-metrics .v, .quote-tools .v { overflow-wrap: anywhere; }
.estimating { --category-columns: minmax(0, 1fr) minmax(80px, .4fr) 40px; }
.estimating .foot { grid-template-columns: minmax(0, 1fr) minmax(80px, .4fr); }
.estimating .budget-row > .row-menu:not([open]), .estimating .budget-head > .detail-actions { grid-column: 3; }
.estimating .budget-row > .labor { grid-column: 1 / -1; grid-row: 2; padding-block: 8px; }
@media (min-width: 801px) {
  /* 展开菜单占前两行，常驻人工输入另起一行，不能互相覆盖。 */
  .estimating .budget-row:has(> .row-menu[open]) > .labor { grid-row: 3; }
}
.fee-details > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; min-height: 40px; }
.fee-details > summary::before { content: "▸"; }
.fee-details[open] > summary::before { content: "▾"; }
.fee-details > summary strong { margin-left: auto; font-variant-numeric: tabular-nums; }
#fee-equation { font-size: 13px; color: #717171; }
.cost-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 24px; }
.cost-total strong { margin-left: auto; font-size: 28px; }
.cost-total > span { font-size: 13px; color: #717171; }
.estimate-profit { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 24px; }
.estimate-profit > div { display: flex; gap: 16px; align-items: baseline; }
.estimate-profit strong { font-size: 28px; }
#sign-project { margin-bottom: 16px; }
.presign-spend summary { min-height: 40px; cursor: pointer; }
.project-page .foot .num { white-space: nowrap; }
.budget-progress { display: block; height: 6px; background: #eee; border-radius: 8px; overflow: hidden; }
.budget-progress i { display: block; height: 100%; background: #222; }
.project-page .foot .over { color: #b42318; }
.project-page .budget-progress.over i { background: #b42318; }
.labor-display { display: block; font-size: 13px; font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; }
.project-page .cat-lines { padding: 8px 0 16px; }
.project-page .cat-group { display: block; color: #222; margin: 8px 0; }
.project-page .fee-row { grid-template-columns: minmax(88px, 1fr) 72px minmax(0, 3fr) minmax(88px, 1fr) 40px; position: relative; }
.project-page .fee-row > * { min-width: 0; }
.project-page .fee-row > .num { grid-column: 4; }
.project-page .fee-row > .actions-menu { grid-column: 5; position: static; }
.project-page .fee-row .menu-items { position: absolute; right: 0; top: 48px; z-index: 3; width: 224px; padding: 16px; background: #fff; border: 1px solid #ddd; border-radius: 8px; }
.fee-total { display: grid; grid-template-columns: minmax(88px, 1fr) 72px minmax(0, 3fr) minmax(88px, 1fr) 40px; gap: 16px; align-items: center; min-height: 48px; font-weight: 600; }
.fee-total .num { grid-column: 4; }
.project-page .deduction:not([open]) { padding-block: 0; }
.project-page .deduction > summary { min-height: 40px; }
.project-page .receipts-card.is-empty:not(:has(details[open])) { padding-block: 0; border-color: transparent; background: transparent; }
.project-page .cards { gap: 16px; }
@media (max-width: 640px) {
  .project-summary { padding: 16px; }
  .project-summary .project-metrics { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; }
  .project-summary .project-metrics .equation-profit { grid-column: 1; grid-row: 1; }
  .project-summary .project-metrics .equation-margin { grid-column: 2; grid-row: 1; }
  .project-summary .project-metrics .equation-price { grid-column: 1 / -1; grid-row: 2; }
  .project-summary .project-metrics .equation-cost { grid-column: 1 / -1; grid-row: 3; }
  .project-summary .equation-price, .project-summary .equation-cost { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
  .project-summary .equation-price .v, .project-summary .equation-cost .v { font-size: 18px; margin: 0; }
  #cost-incomplete { flex-basis: 100%; margin: 0; }
  .equation-sign, .split-sign { display: none; }
  .quote-tools { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .proposed-field { width: 100%; justify-content: space-between; }
  .cost-split { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .cost-split > div { column-gap: 8px; }
  .project-page #direct-costs { padding-inline: 16px; }
  .project-page #direct-costs > .card-h { padding-inline: 0; }
  .project-page #direct-costs > details { margin-inline: 0; }
  .project-page { --category-columns: minmax(76px, 1fr) repeat(3, minmax(0, 1fr)) 40px; --category-gap: 4px; }
  .project-page .foot, .project-page .budget-row, .project-page .cat-line { font-size: 13px; }
  .project-page .foot .num, .project-page .budget-row > .num, .project-page .cat-line > .num { font-size: 13px; letter-spacing: -.04em; white-space: normal; overflow-wrap: anywhere; }
  .project-page .foot .labor-display { font-size: 13px; letter-spacing: -.03em; }
  /* 费率列也要容纳加粗的合计百分比，不能挤入金额列。 */
  .project-page .fee-row { grid-template-columns: minmax(72px, 1fr) 72px minmax(72px, 1fr) 40px; gap: 4px 8px; padding-block: 8px; }
  .project-page .fee-row > .num { grid-column: 3; grid-row: 1; }
  .project-page .fee-row > .actions-menu { grid-column: 4; grid-row: 1; }
  .project-page .fee-formula { grid-column: 1 / -1; grid-row: 2; }
  .project-page .fee-row:has(.actions-menu[open]) { padding-bottom: 80px; }
  .project-page .fee-row .menu-items { top: auto; bottom: 8px; width: 100%; padding: 8px; }
  .project-page .fee-row .menu-items label { flex-direction: row; align-items: center; justify-content: space-between; }
  .fee-total { grid-template-columns: minmax(72px, 1fr) 72px minmax(72px, 1fr) 40px; gap: 8px; }
  .fee-total .num { grid-column: 3; }
}

/* 阶段页手机：科目与估算一行，已花、剩余及进度在下一行。 */
@media (max-width: 640px) {
  .estimate-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .estimate-metrics > .quote-hint { grid-column: 1 / -1; }
  .project-summary .project-metrics { grid-template-columns: 24px minmax(0, 1fr); }
  .project-summary .project-metrics .equation-price { grid-column: 2; grid-row: 1; }
  .project-summary .project-metrics .equation-cost { grid-column: 2; grid-row: 2; }
  .project-summary .project-metrics .equation-profit { grid-column: 2; grid-row: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .project-summary .project-metrics .equation-margin { grid-column: 2; grid-row: 4; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .project-summary .project-metrics .equation-margin .v { font-size: 18px; margin: 0; }
  .project-summary .equation-sign { display: block; grid-column: 1; font-size: 18px; }
  .project-summary .equation-minus { grid-row: 2; }
  .project-summary .equation-equals { grid-row: 3; }
  .signed .foot { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 8px 0; }
  .signed .foot > :first-child { grid-column: 1 / 3; grid-row: 1; }
  .signed .foot > :nth-child(2) { grid-column: 3 / 5; grid-row: 1; }
  .signed .foot > :nth-child(3) { grid-column: 2 / 4; grid-row: 2; }
  .signed .foot > :nth-child(4) { grid-column: 4; grid-row: 2; }
  .signed .foot > .budget-progress { grid-column: 1; grid-row: 2; }
  .signed .foot.head > :nth-child(n+3) { display: none; }
  .signed .foot [data-mobile-label]::before { content: attr(data-mobile-label) " "; color: #717171; font-weight: 400; }
  .signed .foot .over[data-mobile-label]::before { content: ""; }
  .signed .budget-row, .signed .budget-head, .signed .cat-line {
    /* 保留 3:2:2 比例；名称列独占余量，避免多个 fr 取整丢失 1/64px。 */
    grid-template-columns: minmax(0, 1fr) repeat(2, minmax(0, calc((100% - 40px - 3 * 8px) * 2 / 7))) 40px;
    gap: 8px;
  }
  .signed .budget-row > .row-menu, .signed .cat-line > .row-menu, .signed .budget-head > .detail-actions { grid-column: 4; }
  .signed .budget-row > .row-menu[open], .signed .cat-line > .row-menu[open] { grid-column: 1 / -1; }
  .estimating .foot { grid-template-columns: minmax(0, 1fr) minmax(80px, .4fr); gap: 8px; padding: 8px 0; }
  .estimating .budget-row > .row-menu[open] { grid-column: 1 / -1; grid-row: 3; }
  .estimating .budget-row, .estimating .budget-head { grid-template-columns: minmax(0, 1fr) minmax(80px, .4fr) 40px; gap: 8px; }
  .estimating .budget-row > [data-budget-amount], .estimating .budget-head > .num { grid-column: 2; grid-row: 1; }
  .estimating .budget-row > .row-menu:not([open]), .estimating .budget-head > .detail-actions { grid-column: 3; grid-row: 1; }
  .project-page .foot .num { letter-spacing: normal; }
  .fee-details > summary { column-gap: 8px; }
  .fee-details > summary #fee-equation { order: 3; flex-basis: 100%; }
}

/* 明细默认折叠；空科目直接录入，保存完成后收为文字。 */
.budget-row [data-inline-amount], [data-quick-amount] { width: 100%; min-width: 0; text-align: right; font-size: 16px; font-weight: 400; }
.category-heading { border-bottom: 1px solid #eee; }
[data-category-budget-value] { display: none; }
.category-heading.showing-details [data-quick-amount],
.category-heading.showing-details > .labor { display: none; }
.category-heading.showing-details [data-category-budget-value] { display: inline; }
.cat-toggle { background: transparent; border: 0; border-radius: 0; padding: 0; min-height: 40px; text-align: left; font: inherit; font-weight: 400; color: inherit; }
.cat-toggle:hover { background: #f7f7f7; }
.cat-toggle:focus-visible { border-radius: var(--radius); }
a:focus-visible, .cats-scroll .cats a:focus-visible, summary:focus-visible, .project-page button.foot:focus-visible { border-radius: var(--radius); }
.project-page .budget-row > .labor { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-block: 8px; }
.project-page .budget-row > .labor[hidden] { display: none !important; }
.project-page .labor .labor-field, .labor-fields .labor-field { display: flex; flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto; width: auto; flex-wrap: wrap; }
.project-page .labor .labor-field input, .labor-fields .labor-field input { width: 7ch; min-width: 40px; max-width: 120px; padding-inline: 8px; font-size: 16px; }
.project-page .labor .labor-field .k, .labor-fields .labor-field .k { white-space: nowrap; }
.labor-field .field-error { flex-basis: 100%; }
.entry-form .labor-fields, .category-entry .labor-fields { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }
.category-heading > .labor { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-bottom: 8px; }
.category-heading .labor-eq, .category-heading .labor-mismatch { flex-basis: 100%; }
.labor-mismatch button { font-size: inherit; }
#budget-lines .category-entry { grid-template-columns: minmax(0, 1fr) 120px; grid-template-areas: none; gap: 8px; border-bottom: 1px solid #eee; padding-block: 8px; }
#budget-lines .category-entry .category-title { grid-column: 1; grid-row: 1; }
#budget-lines .category-entry .amt { grid-area: auto; grid-column: 2; grid-row: 1; text-align: right; }
#budget-lines .category-entry .labor-fields { grid-column: 1 / -1; grid-row: 2; }
@media (max-width: 640px) { .signed .category-heading > .labor { grid-row: 3; } }
.project-page .budget-row > .labor .labor-eq,
.project-page .budget-row > .labor .labor-mismatch { flex-basis: 100%; }
.project-page .budget-row:has(> .row-menu[open]) > .labor { grid-row: 3; }
@media (max-width: 640px) { .estimating .budget-row:has(> .row-menu[open]) > .labor { grid-row: 2; } }
.expected-direct { display: flex; justify-content: space-between; gap: 16px; padding-block: 16px; border-top: 1px solid #ddd; }
.labor-missing { display: block; color: #717171; font-size: 13px; font-weight: 400; }

.quote-input input { width: 100%; max-width: 200px; min-width: 0; }
.board-heading { margin: 24px 0 8px; }
.board-heading small { font-size: 16px; font-weight: 400; }
.board-secondary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 32px; margin: 16px 0; }
.board-secondary p { margin: 8px 0; }
.board-secondary summary { cursor: pointer; }
.spend-feedback { margin: 8px 0; }
.spend-feedback button { margin-left: 8px; }
#add-spend { margin: 16px 0; }
@media (min-width: 801px) {
  #create-project { max-width: 880px; }
  #budget-lines .cost-edit:not(.category-entry) { grid-template-columns: 32px minmax(0, 2fr) minmax(120px, 1fr) minmax(96px, 1fr) 40px; grid-template-areas: "handle summary category amount remove"; }
  #totals { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .project-heading:has([data-sign-project]) { grid-template-columns: auto auto minmax(88px, 1fr) 40px; }
  .project-heading > [data-sign-project] { grid-column: 3; grid-row: 2; justify-self: end; align-self: start; z-index: 1; }
  .project-heading:has([data-sign-project]) > .actions-menu:not([open]) { grid-column: 4; }
  .spend-entry .suggest { position: static; max-height: 128px; overflow: auto; }
}
@media (max-width: 640px) {
  .entry-form.spend-entry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spend-entry .entry-field:has([name="spent_on"]) { grid-column: 1; grid-row: 1; }
  .spend-entry button[type="submit"] { grid-column: 2; grid-row: 1; align-self: end; }
  .spend-entry .suggest-field { grid-column: 1 / -1; grid-row: 2; }
  .spend-entry .entry-field:has([name="category"]) { grid-column: 1; grid-row: 3; }
  .spend-entry .entry-field:has([name="amount"]) { grid-column: 2; grid-row: 3; }
}

.lifecycle-summary,.plan-heading,.settle-line {display:grid;gap:.75rem;align-items:center}
.lifecycle-summary {grid-template-columns:repeat(3,minmax(0,1fr));margin-block:1rem}
.lifecycle-summary>div {display:grid;gap:.3rem}
.lifecycle-summary button {justify-self:start}
.signing-basis {margin-block:1rem}
.receipt-plan {padding:.8rem 0;border-bottom:1px solid #d4dce0;overflow-wrap:anywhere}
.plan-heading {grid-template-columns:1fr auto auto}
.receipt-plan .row-menu {display:block}
.settle-line {grid-template-columns:1.3fr 1fr 1fr 1.3fr;padding:.45rem 0}
.settle-line input {min-width:0;width:100%;box-sizing:border-box}
@media(max-width:600px){.lifecycle-summary{grid-template-columns:1fr}.lifecycle-summary>div{grid-template-columns:1fr 1fr;align-items:center}.lifecycle-summary>div>:last-child{grid-column:2}.plan-heading{grid-template-columns:1fr auto}.plan-heading strong{grid-column:1/-1}.settle-line{gap:.3rem;font-size:.85rem}}

.receipt-plan .row-menu>summary {width:auto;min-width:6em;padding-inline:.75rem}
.receipt-plan .row-menu>.menu-items {position:static;width:100%}

.quote-export {max-width:48rem;margin:auto;overflow-wrap:anywhere}
.quote-export .card {margin-block:1rem}
.quote-export details {margin-top:1rem}
.quote-map {display:grid;grid-template-columns:1fr 1fr;align-items:center;gap:.8rem;margin:.7rem 0}
.quote-map small {display:block}
.quote-map input {width:100%;min-width:0;box-sizing:border-box}
.quote-prices {width:100%;border-collapse:collapse}
.quote-prices :is(th,td) {text-align:left;padding:.65rem .2rem;border-bottom:1px solid #ddd}
.quote-prices :is(th,td):last-child {text-align:right;white-space:nowrap}
.new-budget { margin-top: 16px; }
.new-budget > summary, .quote-export details > summary { padding-block: 12px; min-height: 44px; cursor: pointer; }
.quote-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.quote-actions > *, .quote-download, #create-project .wizard-actions button { min-height: 44px; }
.quote-download { margin-top: 16px; }
#proposed, #direct-costs, #fee-summary { scroll-margin-top: 80px; }
@media (max-width: 480px) {
  .quote-actions .primary { flex: 1 1 auto; }
  .quote-download, #create-project .wizard-actions button { width: 100%; }
}
@media(max-width:480px){.quote-map{grid-template-columns:1fr;gap:.25rem}}

.quote-download[hidden] {display:none}
