:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e5e9;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8983;
  --brand: #1f5fb8;
  --brand-soft: #e8f0fb;
  --series-1: #2a78d6;
  --track: #e6ebf2;
  --good: #1f8a4c;
  --good-soft: #e5f4ea;
  --warn: #b26b00;
  --warn-soft: #fdf1dc;
  --bad: #c62f2f;
  --bad-soft: #fbe7e7;
  --info: #2a78d6;
  --info-soft: #e7f0fb;
  --muted-soft: #eeeff1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
small, .muted { color: var(--text-2); }
.tiny { font-size: 12px; color: var(--text-3); }
.en { font-size: 12px; color: var(--text-3); font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }

.mock-banner {
  background: #1d2330; color: #fff; font-size: 13px; text-align: center; padding: 6px 12px;
}
.mock-banner a { color: #9cc3ff; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #194f9b; }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-good:hover { background: #18703d; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 14px 20px; font-size: 17px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-ai { background: linear-gradient(135deg, #5b3fd1, #2a78d6); border: 0; color: #fff; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: -1px; border-color: transparent; }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea { min-height: 76px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- chips / badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; user-select: none;
}
.chip.on { background: var(--brand-soft); border-color: var(--series-1); color: var(--brand); font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.draft { background: var(--muted-soft); color: var(--text-2); }
.badge.submitted { background: var(--info-soft); color: var(--info); }
.badge.reviewed { background: var(--good-soft); color: var(--good); }
.badge.missing { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.role-admin { background: #efeafd; color: #4a3aa7; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

details.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 12px; }
details.section > summary {
  list-style: none; cursor: pointer; padding: 14px 16px; display: flex; align-items: center; gap: 10px; font-weight: 600;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after { content: "▾"; margin-left: auto; color: var(--text-3); transition: transform .15s; }
details.section[open] > summary::after { transform: rotate(180deg); }
details.section > .body { padding: 0 16px 16px; }
.step {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none;
}
.opt { font-size: 12px; color: var(--text-3); font-weight: 400; }

.rowcard { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-2); position: relative; }
.rowcard + .rowcard { margin-top: 10px; }
.rowcard .remove { position: absolute; top: 8px; right: 8px; border: 0; background: none; color: var(--text-3); cursor: pointer; font-size: 18px; }
.add-row { margin-top: 10px; width: 100%; border-style: dashed; color: var(--brand); }

.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.photo {
  width: 72px; height: 72px; border-radius: 8px; background: #dfe6ef center/cover no-repeat; position: relative;
  display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 22px; overflow: hidden;
}
.photo.add { border: 1.5px dashed #b9c3d0; background: var(--surface); cursor: pointer; }
.photo .cap { position: absolute; bottom: 0; left: 0; right: 0; font-size: 10px; background: rgba(0,0,0,.45); color: #fff; padding: 1px 4px; }
.notice { font-size: 12px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 6px 10px; margin-top: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: none; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }

/* ---------- stat tiles & meters ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 13px; color: var(--text-2); }
.tile .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.meter { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--series-1); border-radius: 999px; }
.meter.tall { height: 12px; }

.summary-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary-strip .s { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.summary-strip .s b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.summary-strip .s span { font-size: 11px; color: var(--text-2); }
.summary-strip .s.money { grid-column: span 3; display: flex; justify-content: space-between; align-items: baseline; }
.summary-strip .s.money b { font-size: 20px; color: var(--brand); }

/* bar chart (single series) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 8px 0 0; border-bottom: 1px solid var(--border); position: relative; }
.bars .b { flex: 1; background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; cursor: default; }
.bars .b:hover { filter: brightness(.88); }
.bars .b:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #1d2330; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 5;
}
.bars .b.empty { background: var(--track); }
.bar-labels { display: flex; gap: 6px; font-size: 11px; color: var(--text-3); margin-top: 4px; }
.bar-labels span { flex: 1; text-align: center; }

/* AI summary */
.ai-card { border: 1px solid #d9d2f7; background: linear-gradient(180deg, #faf8ff, #fff 60%); }
.ai-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: #4a3aa7; background: #efeafd; padding: 2px 10px; border-radius: 999px; }
.ai-card ul { margin: 6px 0 0; padding-left: 20px; }
.ai-card li { margin: 3px 0; }
.ai-card h3 { margin-top: 14px; display: flex; align-items: center; gap: 6px; }
.tabs { display: inline-flex; background: var(--muted-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; font: inherit; font-size: 13px; padding: 5px 14px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.tabs button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- Sale (mobile) layout ---------- */
.mobile { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 90px; }
.m-top { background: var(--brand); color: #fff; padding: 16px 16px 20px; }
.m-top .row { justify-content: space-between; }
.m-top a { color: #fff; }
.m-top .sub { opacity: .85; font-size: 13px; }
.m-body { padding: 14px; margin-top: -10px; }
.m-head { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 14px; display: flex; align-items: center; gap: 10px; }
.m-head h1 { font-size: 17px; flex: 1; }
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); z-index: 20;
}
.bottom-bar .inner { max-width: 492px; margin: 0 auto; display: flex; gap: 8px; }
.bottom-bar .inner .btn { flex: 1; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 20; }
.tabbar .inner { max-width: 520px; margin: 0 auto; display: flex; }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: 12px; color: var(--text-2); text-decoration: none; }
.tabbar a .ic { display: block; font-size: 20px; }
.tabbar a.on { color: var(--brand); font-weight: 600; }
.autosave { font-size: 12px; color: var(--text-3); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
.list-item .date { width: 48px; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 4px 0; flex: none; }
.list-item .date b { display: block; font-size: 18px; line-height: 1.1; }
.list-item .date span { font-size: 11px; color: var(--text-2); }
.list-item .grow { flex: 1; min-width: 0; }

/* ---------- Admin layout ---------- */
.admin { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #141a26; color: #c8cfdb; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.side .logo { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.side .logo small { display: block; color: #8b95a7; font-weight: 400; font-size: 12px; }
.side a { display: flex; align-items: center; gap: 10px; color: #c8cfdb; padding: 9px 10px; border-radius: 8px; font-size: 14px; text-decoration: none; }
.side a:hover { background: #1f2738; }
.side a.on { background: #2a3550; color: #fff; font-weight: 600; }
.side .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.side .me { position: absolute; bottom: 16px; left: 12px; right: 12px; font-size: 13px; padding: 10px; border-top: 1px solid #2a3245; }
.main { padding: 22px 28px 40px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input, .filters select { width: auto; padding: 7px 10px; font-size: 14px; }
.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.diff-old { background: var(--bad-soft); text-decoration: line-through; padding: 0 4px; border-radius: 4px; }
.diff-new { background: var(--good-soft); padding: 0 4px; border-radius: 4px; }
.timeline { border-left: 2px solid var(--border); padding-left: 14px; margin-left: 6px; }
.timeline .ev { position: relative; padding-bottom: 14px; font-size: 14px; }
.timeline .ev::before { content: ""; position: absolute; left: -21px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--series-1); border: 2px solid var(--surface); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery .photo { width: 100%; height: 96px; }

.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 460px; padding: 20px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }

.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: #1d2330; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60; display: none; }
.toast.show { display: block; }

/* ---------- login / index ---------- */
.center-page { min-height: calc(100vh - 32px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 14px; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 760px; width: 100%; }
.pick a.card { color: inherit; text-decoration: none; display: block; transition: transform .1s; }
.pick a.card:hover { transform: translateY(-2px); border-color: var(--series-1); }
.pick ul { padding-left: 18px; margin: 8px 0 0; color: var(--text-2); font-size: 14px; }

/* ---------- responsive ---------- */
.home-grid { display: grid; gap: 12px; }
.home-grid > .btn, .home-grid > .row { grid-column: 1 / -1; }
.home-grid > .btn { white-space: normal; }
.home-grid > .row { margin-top: -4px; }
.home-grid > .card + .card, .view-grid > .card + .card { margin-top: 0; }
.card-head { flex-wrap: wrap; }
.tabs button { white-space: nowrap; }
.form-side > .card + .card { margin-top: 12px; }

/* Sale on tablet/desktop: widen, nav moves to top, form gets a sticky summary column */
@media (min-width: 900px) {
  .mobile { max-width: 1180px; display: flex; flex-direction: column; padding-bottom: 40px; }
  .tabbar { order: -1; position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--border); }
  .tabbar .inner { max-width: 1180px; justify-content: flex-start; gap: 4px; padding: 0 14px; }
  .tabbar a { flex: none; display: flex; align-items: center; gap: 6px; padding: 12px 14px; font-size: 14px; border-bottom: 2px solid transparent; }
  .tabbar a .ic { display: inline; font-size: 16px; }
  .tabbar a.on { border-bottom-color: var(--brand); }
  .m-top { border-radius: 0 0 16px 16px; padding: 22px 24px 28px; }
  .m-body { padding: 18px 24px; }
  .m-head { padding: 12px 24px; }
  .home-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .home-grid > .btn { justify-self: start; min-width: 360px; }
  .view-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .view-grid > * + * { margin-top: 0; }
  .view-grid > .btn { grid-column: 1 / -1; justify-self: start; width: auto; }
  .form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; padding-bottom: 90px; }
  .form-side { order: 2; position: sticky; top: 70px; }
  .form-main { order: 1; }
  .form-main details.section:first-child { margin-top: 0; }
  .rowcard .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .bottom-bar .inner { max-width: 1132px; justify-content: flex-end; }
  .bottom-bar .inner .btn { flex: none; min-width: 160px; }
}

/* Admin on tablet/mobile: sidebar becomes a scrollable top bar, tables become cards */
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 30; height: auto; display: flex; align-items: center; gap: 2px; padding: 8px 10px; overflow-x: auto; white-space: nowrap; }
  .side .logo { padding: 0 10px 0 4px; font-size: 14px; }
  .side .logo small, .side .me { display: none; }
  .side a { padding: 7px 10px; font-size: 13px; }
  .main { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile .value { font-size: 20px; }
  .tile { padding: 12px; }
  .two-col { grid-template-columns: 1fr; }
  .pick { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 19px; }
}
@media screen and (max-width: 700px) {
  .filters > * { flex: 1 1 140px; min-width: 0 !important; }
  table.rtable thead { display: none; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable tr { border: 1px solid var(--border); border-radius: 10px; margin: 10px; width: auto; padding: 6px 12px; background: var(--surface); }
  table.rtable td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 0; text-align: right; }
  table.rtable td::before { content: attr(data-label); color: var(--text-2); font-size: 12px; text-align: left; flex: none; max-width: 45%; }
  table.rtable td[data-label=""]::before { content: none; }
  table.rtable td[colspan] { justify-content: flex-start; }
  .kv { grid-template-columns: 1fr; }
  .kv dd { margin-bottom: 6px; }
}
@media (max-width: 340px) {
  .tiles { grid-template-columns: 1fr; }
}

/* ---------- required photos ---------- */
.req { color: var(--bad); font-weight: 700; }
.rowcard.need-photo { border-color: var(--bad); background: var(--bad-soft); }
.rowcard.need-photo .photo.add { border-color: var(--bad); color: var(--bad); }
.photo-hint { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.rowcard.need-photo .photo-hint { color: var(--bad); font-weight: 600; }

/* ---------- expenses / bills ---------- */
.bill-thumb { display: inline-block; width: 40px; height: 40px; border-radius: 6px; background: center/cover no-repeat; cursor: pointer; vertical-align: middle; }
.bill { width: 100%; border-radius: 8px; background: center/cover no-repeat; }
.tiny-table td { padding: 6px 0; }

/* ---------- print ---------- */
.print-page { background: #e9ebef; }
.print-toolbar { max-width: 210mm; margin: 14px auto; display: flex; justify-content: space-between; gap: 8px; padding: 0 8px; }
.paper { background: #fff; max-width: 210mm; margin: 0 auto 30px; padding: 16mm 14mm; box-shadow: var(--shadow); font-size: 13px; }
.print-table { font-size: 12.5px; }
.print-table th, .print-table td { border: 1px solid #cfd3da; padding: 5px 7px; }
.print-table tfoot td { background: var(--surface-2); }
.signatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 48px; text-align: center; font-size: 13px; }
.sig-line { border-bottom: 1px dotted #555; height: 40px; margin-bottom: 6px; }
.bill-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bill-grid figure { margin: 0; }
.bill-grid .bill { height: 150px; border: 1px solid var(--border); }
.bill-grid figcaption { font-size: 11px; color: var(--text-2); text-align: center; margin-top: 2px; }
.page-break { margin-top: 28px; }

@media print {
  @page { size: A4; margin: 12mm; }
  body, .print-page { background: #fff !important; font-size: 12px; }
  .no-print, .mock-banner, .tabbar, .bottom-bar, .side, .m-head a, .btn, .filters, .toast, .modal-bg { display: none !important; }
  .paper { box-shadow: none; padding: 0; margin: 0; max-width: none; }
  .page-break { break-before: page; margin-top: 0; }
  .admin { display: block; }
  .main, .m-body { padding: 0 !important; }
  .mobile { max-width: none; padding: 0; }
  .card, .tile, details.section { box-shadow: none !important; break-inside: avoid; }
  .two-col, .view-grid, .form-layout, .home-grid { display: block !important; }
  .two-col > * + *, .view-grid > * + * { margin-top: 12px !important; }
  table.rtable thead { display: table-header-group !important; }
  .table-wrap { overflow: visible; }
  table.rtable { display: table !important; width: 100%; }
  table.rtable tbody { display: table-row-group !important; }
  table.rtable tfoot { display: table-footer-group !important; }
  table.rtable tr { display: table-row !important; border: 0; margin: 0; padding: 0; }
  table.rtable td { display: table-cell !important; text-align: left; padding: 6px; border-bottom: 1px solid #ddd; }
  table.rtable th, table.rtable td { width: auto; white-space: normal; overflow-wrap: anywhere; }
  table.rtable td.r, table.rtable th.r { text-align: right; }
  table.rtable .no-print { display: none !important; }
  table.rtable td::before { content: none !important; }
  a { color: inherit; }
}

/* ---------- admin expenses grouped by person ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.person-badges { margin-left: auto; }
details.person > summary::after { margin-left: 10px; }
details.person { scroll-margin-top: 70px; }
table tfoot td { background: var(--surface-2); border-top: 1px solid var(--border); }
@media screen and (max-width: 700px) {
  table.rtable tfoot, table.rtable tfoot tr, table.rtable tfoot td { display: block; width: auto; }
  table.rtable tfoot td { display: flex; justify-content: space-between; text-align: right; border: 0; padding: 4px 0; background: none; }
  table.rtable tfoot td::before { content: attr(data-label); color: var(--text-2); font-size: 12px; }
  table.rtable tfoot tr { border: 1px solid var(--border); border-radius: 10px; margin: 10px; padding: 6px 12px; background: var(--surface-2); }
  details.person > summary { flex-wrap: wrap; position: relative; padding-right: 40px; }
  details.person > summary::after { position: absolute; right: 16px; top: 18px; }
  table.rtable td > .v { text-align: right; }
  .person-badges { margin-left: 44px; width: 100%; }
}

/* ---------- print-only blocks inside app pages ---------- */
.print-only { display: none; }
tr.is-draft td { opacity: .55; }
@media print {
  .print-only { display: block; }
  .signatures.print-only { display: grid; }
  .tiles.no-print, .page-head.no-print { display: none !important; }
  .print-flat { border: 0 !important; padding: 0 !important; }
  .print-flat h2 { font-size: 14px; }
  table.rtable tr.is-draft { display: none !important; }
  .bill-thumb { width: 28px; height: 28px; }
  .main > .card, .main > .two-col { margin-top: 12px !important; }
}
