:root {
  --bg: #f1f1f1; --card: #fff; --text: #303030; --muted: #616161; --line: #e3e3e3;
  --accent: #1a5fb4; --accent-text: #fff; --danger: #b42318; --ok: #1f7a3d; --warn: #8a5a00;
  --radius: 10px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.bar h1 { font-size: 20px; font-weight: 600; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line); padding: 16px; margin-bottom: 12px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #c9c9c9; border-radius: 8px; background: #fff; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid #c9c9c9; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
button:hover { background: #f7f7f7; }
a.btnlink { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid #c9c9c9; background: #fff; color: var(--text); text-decoration: none; white-space: nowrap; }
a.btnlink:hover { background: #f7f7f7; }
input:disabled { background: #f4f4f4; color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
button:disabled { opacity: .55; cursor: default; }
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #e9eef6; color: #1d3c66; white-space: nowrap; }
.pill.s-Approved, .pill.s-Complete { background: #e3f1e6; color: #1f5130; }
.pill.s-In-progress { background: #e6effa; color: #163f72; }
.pill.s-Waiting-on-parts { background: #fbf0d9; color: #6b4600; }
.pill.s-Invoiced { background: #efe7fa; color: #4a2b7a; }
.pill.s-Closed { background: #ececec; color: #4a4a4a; }
.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px; border-bottom: 1px solid var(--line); }
.list td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr.row { cursor: pointer; }
.list tr.row:hover td { background: #fafafa; }
.right { text-align: right; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters input { max-width: 280px; }
.filters select { max-width: 200px; }
.results { border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; max-height: 260px; overflow: auto; background: #fff; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 12px; white-space: normal; }
.results button:last-child { border-bottom: 0; }
.results small { color: var(--muted); display: block; }
.line { display: grid; grid-template-columns: 90px 1fr 90px 100px 100px 32px; gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line .type { font-size: 12px; color: var(--muted); padding-bottom: 9px; }
.line .amt { text-align: right; padding-bottom: 9px; font-variant-numeric: tabular-nums; }
.line .x { border: 0; background: none; color: var(--muted); padding: 6px; font-size: 18px; line-height: 1; }
.line .tax { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.line .tax input { width: auto; }
.totals { margin-left: auto; max-width: 280px; padding-top: 10px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-weight: 600; font-size: 16px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.notice { padding: 10px 12px; border-radius: 8px; background: #fbf0d9; color: #6b4600; margin-bottom: 12px; }
.notice.err { background: #fde8e6; color: var(--danger); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 160px; }
details summary { cursor: pointer; font-weight: 600; font-size: 15px; }
details[open] summary { margin-bottom: 12px; }
.span2 { grid-column: 1 / -1; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
#print-root { display: none; }

@media (max-width: 640px) {
  .wrap { padding: 10px; }
  .line { grid-template-columns: 1fr 1fr; }
  .line .type { grid-column: 1 / -1; padding: 0; }
  .line .desc { grid-column: 1 / -1; }
  .line .amt { padding: 0; }
  .list .hide-sm { display: none; }
}

@media print {
  body { background: #fff; }
  #app { display: none !important; }
  #print-root { display: block !important; }
}
