:root {
  color-scheme: light;
  --bg: #f3efe6;
  --surface: #fffdf8;
  --ink: #1c1914;
  --muted: #6f675c;
  --line: #e3dacb;
  --brass: #8c6b2f;
  --brass-soft: #f3e6c8;
  --pine: #1e4a38;
  --pine-soft: #dce8e2;
  --danger: #8f3d3a;
  --sans: ui-sans-serif, system-ui, "PingFang TC", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", sans-serif;
  --display: Georgia, "Iowan Old Style", "Palatino Linotype", "PingFang TC", "Microsoft JhengHei", serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
}
img { max-width: 100%; }
a { color: var(--brass); }
h1, h2, .brand-name {
  font-family: var(--display);
  font-weight: 560;
  letter-spacing: -0.02em;
}
h1 { margin: 0; font-size: 1.875rem; line-height: 1.15; }
h2 { margin: 0 0 8px; font-size: 1.35rem; }
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-inner, main { width: min(96rem, calc(100% - 24px)); margin: 0 auto; }
.top-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img, .mark { width: 44px; height: 44px; border-radius: 999px; background: white; }
.brand-name { display: block; font-size: 1.15rem; line-height: 1.15; }
.brand small { display: block; margin-top: 4px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
nav a.active { background: var(--ink); color: var(--bg); font-weight: 600; }
nav a.quiet,
a.quiet {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
}
a.lang.lang-on {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
  font-weight: 700;
}
main { padding: 12px 0 28px; }
.csv-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.csv-form input { width: auto; min-width: 180px; margin: 0; background: var(--surface); }
.card, .sheet, .directory {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.card { padding: 10px; margin: 8px 0; }
.sheet { margin-top: 8px; overflow-x: auto; }
.narrow { max-width: 36rem; margin: 16px auto; padding: 32px; }
.narrow .mark { width: 64px; height: 64px; }
.narrow h1 { margin-top: 24px; font-size: 2.25rem; }
.bullets { margin: 24px 0; padding: 0; list-style: none; }
.bullets li { display: flex; gap: 12px; margin: 8px 0; font-size: 0.875rem; }
.bullets li::before { content: ""; width: 8px; height: 8px; margin-top: 7px; border-radius: 99px; background: var(--brass); flex: none; }
button.ink, .ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.narrow button.ink { width: 100%; }
.page-head, .row, .actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.csv-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.csv-form input { width: auto; min-width: 180px; margin: 0; background: var(--surface); }
label { display: block; margin: 0 0 2px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
input, select, textarea {
  width: 100%;
  min-height: 34px;
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  padding: 4px 8px;
  font: inherit;
  font-size: 0.875rem;
  outline: none;
}
textarea { min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); }
button, .primary, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.8rem/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.primary, button.primary { background: var(--brass); border-color: var(--brass); color: var(--bg); }
button.danger { border-color: transparent; background: transparent; color: var(--danger); }
.muted { color: var(--muted); font-weight: 400; }
.danger { color: var(--danger); }
.flash { background: var(--brass-soft); border-radius: 8px; padding: 10px 12px; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; background: var(--pine-soft); color: var(--pine); padding: 4px 10px; font-size: 0.8rem; font-weight: 600; }
.project-layout { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: start; margin-top: 16px; }
.type-nav { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px; position: sticky; top: 12px; width: 100%; }
.type-nav a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  text-decoration: none;
}
.type-nav a.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.project-layout .filters { display: flex; gap: 12px; margin-top: 0; }
.filters input, .filters select { margin: 0; background: var(--surface); }
.filters input { flex: 1; }
.filters select { width: 180px; }
.filters select[name="company"] { width: 240px; }
.filters button { flex: none; }
.empty { margin-top: 24px; border: 1px dashed var(--line); border-radius: 1rem; background: var(--surface); padding: 48px 24px; text-align: center; }
.sheet { margin-top: 8px; overflow-x: auto; }
.urgent-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
}
.action-flag {
  display: inline-block;
  margin-right: 6px;
  color: #b42318;
  font-size: 1.05rem;
  line-height: 1;
  vertical-align: middle;
}
.since-start {
  display: block;
  clear: both;
  width: fit-content;
  max-width: 100%;
  margin-top: 4px;
  border-radius: 999px;
  background: #e6e2da;
  color: #4f493f;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
}
.due-text { color: var(--danger); font-weight: 700; }
.follow-remark {
  display: block;
  margin-top: 2px;
  color: #b42318;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}
.pay-files { display: grid; gap: 4px; margin-top: 4px; }
.pay-file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.summary-list { display: grid; gap: 10px; margin: 16px 0; }
.summary-list div { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.8125rem; }
th { padding: 6px 8px; border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 500; }
td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.cards { display: none; }
.directory { margin-top: 16px; overflow: hidden; }
.directory.staff-list article {
  display: grid;
  align-items: start;
  justify-content: stretch;
  gap: 8px;
}
.staff-lead, .staff-meta { overflow-wrap: anywhere; }
.staff-meta { margin: 2px 0 0; }
.staff-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
.staff-form label { margin: 0; min-width: 0; }
.staff-form button { justify-self: start; }
.staff-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.staff-rename { display: flex; flex: 1 1 220px; gap: 8px; align-items: center; min-width: 0; }
.staff-rename input { width: auto; flex: 1 1 140px; min-width: 0; margin: 0; }
.directory article:last-child { border-bottom: 0; }
.actions form, .actions a, td form { display: inline-flex; }
.actions { justify-content: flex-start; margin-top: 8px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.quote-fields select { max-width: 140px; }
[hidden] { display: none !important; }
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(28, 25, 20, 0.5);
  padding: 16px;
}
.overlay .dialog {
  width: min(64rem, 100%);
  max-height: calc(100vh - 24px);
  overflow: auto;
  max-width: 64rem;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 1rem;
  padding: 12px 14px;
  box-shadow: 0 24px 48px rgba(28, 25, 20, 0.16);
}
.dialog h2 { font-size: 1.5rem; }
label.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--ink); }
label.check input { width: auto; min-height: 0; margin: 0; }
.entry-photo { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; margin: 6px 6px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.form-grid label, .wide { margin: 0; font-size: 0.75rem; }
.span-2, .wide, fieldset.wide { grid-column: 1 / -1; }
.price { display: flex; gap: 8px; }
.price input { flex: 1; min-width: 0; }
.price select { width: 96px; margin-top: 4px; }
.manage { display: inline-flex; align-items: center; min-height: 32px; font-size: 0.8rem; font-weight: 600; }
.party-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.875rem; font-weight: 500; }
.pay-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-top: 6px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) 4.6rem minmax(0, 1.2fr); gap: 6px; }
.pay-card label { margin: 0; font-size: 0.75rem; }
.pay-card input, .pay-card select { min-height: 34px; margin-top: 2px; padding: 4px 8px; }
.pay-card .btn, .slot-files + .btn, .model-row .btn { min-height: 32px; padding: 0 8px; }
.pay-card .full { grid-column: 1 / -1; }
.model-row { display: grid; grid-template-columns: minmax(0, 1.5fr) 4.5rem 6.5rem 5rem auto; gap: 6px; align-items: center; margin-top: 6px; }
.model-head { display: grid; grid-template-columns: minmax(0, 1.5fr) 4.5rem 6.5rem 5rem auto; gap: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.model-row input { margin: 0; }
.model-line-total { font-size: 0.8rem; font-weight: 650; }
.slot-files { display: grid; gap: 6px; }
fieldset.wide { border: 0; padding: 0; margin-top: 6px; }
.doc { margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); padding: 8px; }
.doc p { margin: 0; font-size: 0.8rem; font-weight: 500; color: var(--ink); }
.form-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.form-actions .danger { margin-right: auto; }
@media (max-width: 800px) {
  .form-grid, .pay-card { grid-template-columns: 1fr 1fr; }
  .sheet { display: none; }
  .cards { display: block; }
  .split, .filters { display: block; }
  .filters select, .filters input { width: 100%; margin-top: 8px; }
  .narrow { padding: 20px; }
}
.type-extra[hidden] { display: none !important; }
.type-menu { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.milestone-list { display: grid; gap: 8px; }
.milestone-list .ms { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 8px 12px; border-top: 1px solid var(--line); }
.milestone-list .ms input { width: auto; min-width: 11rem; }
.milestone-list { display: block; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.milestone-list > p { margin: 12px 12px 4px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.contents { display: contents; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat strong { display: block; font-family: var(--display); font-size: 1.25rem; line-height: 1.1; color: var(--ink); font-weight: 560; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; }
.field-label { margin: 2px 0 4px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 6px 0 0; }
.chips legend { width: 100%; margin-bottom: 4px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.chips label.check { min-height: 32px; margin: 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.overlay .dialog { width: min(64rem, 100%); max-width: 64rem; border-radius: 1rem; padding: 12px 14px; }
.record-no { margin: 4px 0 0; color: var(--muted); font-size: 0.875rem; }
.pill.wait { background: var(--brass-soft); color: var(--brass); }
.pill.done { background: var(--pine); color: #fffdf8; }
.pill.bad { background: var(--danger); color: #fffdf8; }
input[type="file"] { width: auto; max-width: 100%; border: 0; background: transparent; padding-left: 0; }
.add-menu { position: relative; }
.add-menu .menu { display: none; position: absolute; right: 0; z-index: 20; margin-top: 8px; width: 16rem; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 16px 32px rgba(28, 25, 20, 0.12); }
.add-menu.open .menu { display: block; }
.add-menu .menu button { width: 100%; justify-content: flex-start; border: 0; background: transparent; }
button.ink.type-pick, .tabs button.ink { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.total-price { display: flex; min-height: 34px; align-items: center; font-weight: 650; }
@media (max-width: 800px) {
  .project-layout { grid-template-columns: 1fr; }
  .type-nav { position: static; flex-direction: row; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; }
  .type-nav a { width: auto; }
  .stats { grid-template-columns: 1fr 1fr; }
}
