/* MobileTrax styles. One look for every page: tokens first, then shell, controls, data display, then page-specific bits. */

:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f8f9fb; --hover: #f1f4f8;
  --text: #0f172a; --muted: #5b6678; --line: #e4e8ef; --line-strong: #cdd4df;
  --accent: #4d7c0f; --accent-hover: #3f6410; --accent-text: #ffffff; --accent-soft: #eef5de; --ring: rgba(77, 124, 15, .22);
  --good: #15803d; --warn: #b45309; --bad: #b91c1c;
  --chip: #eef1f6; --brand: #97bf3b;
  --radius: 10px; --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .25);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117; --surface: #151b23; --surface-2: #1a212b; --hover: #1f2733;
    --text: #e6edf3; --muted: #8b98a9; --line: #262e3a; --line-strong: #364152;
    --accent: #9ccc3c; --accent-hover: #b0dc55; --accent-text: #0b1200; --accent-soft: #232f14; --ring: rgba(156, 204, 60, .28);
    --good: #4ade80; --warn: #f0b04a; --bad: #f08a7e;
    --chip: #232b37;
    --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 650; } h2 { font-size: 16px; font-weight: 650; } h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- shell ---------- */
.topbar { background: #000; border-bottom: 1px solid #1c1c1c; position: sticky; top: 0; z-index: 5; color: #c9d1c0; }
.topbar .in { max-width: 1680px; margin: 0 auto; padding: 10px 32px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--brand); }
.brand:hover { text-decoration: none; }
.brand img { height: 30px; display: block; }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #a3ad98; padding: 6px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; transition: background .15s, color .15s; }
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); text-decoration: none; }
.topbar nav a.on { color: var(--brand); background: rgba(151, 191, 59, .14); }
.user { display: flex; gap: 12px; align-items: center; color: #a3ad98; }
.topbar .btn { background: transparent; color: #c9d1c0; border-color: #3a3a3a; box-shadow: none; }
.topbar .btn:hover { background: rgba(255, 255, 255, .08); border-color: #555; }
main { max-width: 1680px; margin: 0 auto; padding: 28px 32px 32px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.pagehead > div:last-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pagehead .sub { color: var(--muted); margin-top: 4px; }
.crumb { font-size: 13px; margin-bottom: 8px; }
@media (max-width: 720px) { main { padding: 20px 16px 24px; } .topbar .in { padding: 10px 16px; gap: 12px; } }

/* ---------- controls ---------- */
.btn { font: inherit; font-weight: 500; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); cursor: pointer; box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn.link { border: 0; background: none; box-shadow: none; color: var(--accent); padding: 3px 8px; font-weight: 500; }
.btn.link:hover { background: var(--hover); text-decoration: none; }
.btn.link.danger { color: var(--bad); }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
select { cursor: pointer; }

/* segmented toggle (view switches, tile breakdown) */
.seg { display: flex; margin-top: 10px; padding: 2px; background: var(--chip); border-radius: 8px; gap: 2px; }
.seg button { flex: 1; padding: 4px 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.inline { display: inline-flex; margin: 0; }
.seg.inline button { padding: 6px 16px; font-size: 13px; }
.typesel { width: auto; }

/* ---------- cards, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow-xs); }
.card > .head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card.tablewrap { padding: 0; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
thead th:first-child { border-top-left-radius: 8px; } thead th:last-child { border-top-right-radius: 8px; }
th.num { text-align: right; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--line-strong); }
td.actions { white-space: nowrap; text-align: right; }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }
tr.dim td { color: var(--muted); }
th.pick, td:has(> input[type=checkbox]) { width: 38px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; align-items: start; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s; }
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.kpi.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.kpi .expand { margin-top: 10px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer; }
.kpi .expand:hover { text-decoration: underline; }
.breakdown { list-style: none; margin: 10px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line); }
.breakdown[hidden] { display: none; }
.breakdown button { display: flex; justify-content: space-between; width: 100%; padding: 5px 6px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; border-radius: 6px; }
.breakdown button:hover { background: var(--hover); }
.breakdown button:disabled { cursor: default; color: var(--muted); }
.breakdown button:disabled:hover { background: none; }

.bar { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.over > i { background: var(--bad); }
.bar.warn > i { background: var(--warn); }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--chip); color: var(--text); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.new, .chip.received, .chip.paid, .chip.in-service, .chip.returned, .chip.closed, .chip.complete, .chip.accepted, .chip.closed-won,
.chip.done, .chip.active { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.chip.error, .chip.cancelled, .chip.rejected, .chip.issue-reported, .chip.lost, .chip.disputed, .chip.on-hold, .chip.closed-lost,
.chip.declined, .chip.bug-report { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.chip.shipped, .chip.in-rma, .chip.open, .chip.shipped-to-vendor, .chip.partially-received, .chip.pending, .chip.quoted,
.chip.planned, .chip.in-progress { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.feature-request { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.chip.inactive { background: var(--chip); color: var(--muted); }

/* tabs (project pages, CRM) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; transition: color .15s; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* project cards */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.pcard { display: block; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s, transform .15s; }
.pcard:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); text-decoration: none; transform: translateY(-1px); }
.pcard .top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.pcard .nums { display: flex; justify-content: space-between; margin-top: 14px; font-size: 12px; }
.pcard .nums b { display: block; font-size: 16px; color: var(--text); letter-spacing: -.01em; }

.detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 24px; margin: 0; }
.detail dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.detail dd { margin: 2px 0 6px; }

.order { border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 16px; background: var(--surface); box-shadow: var(--shadow-xs); }
.order .oh { padding: 14px 16px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.order .oh .meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 16px; flex-wrap: wrap; }
.order .ob { padding: 0 16px 12px; }

/* ---------- modal ---------- */
dialog.modal { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  padding: 24px; width: min(640px, calc(100vw - 24px)); max-height: 92vh; box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
dialog.modal.wide { width: min(920px, calc(100vw - 24px)); }
.form h2 { font-size: 18px; }
.form .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 18px; }
.form label { display: block; }
.form label.full, .form fieldset.full { grid-column: 1 / -1; }
.form label span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.form .actions { display: flex; justify-content: flex-end; gap: 8px; }
.form input[type=file] { margin: 6px 0 12px; }
@media (max-width: 520px) { .form .grid { grid-template-columns: 1fr; } }
fieldset.checks { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
fieldset.checks legend { font-size: 12px; font-weight: 500; color: var(--muted); padding: 0; margin-bottom: 8px; }
label.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.form label.check span { display: block; font-size: 14px; color: var(--text); margin: 0; }
label.check input { margin-top: 2px; }
label.check small { display: block; font-weight: 400; }

/* ---------- sign-in + setup ---------- */
.authbox { max-width: 400px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow-sm); }
.authbox .logo { display: block; width: calc(100% + 56px); margin: -28px -28px 20px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.authbox h1 { margin-bottom: 4px; }
.authbox form { display: grid; gap: 14px; margin-top: 18px; }
.authbox label span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.authbox .msg { margin-top: 12px; font-size: 13px; }
.setup { max-width: 640px; margin: 8vh auto; padding: 0 16px; }
.setup code { background: var(--chip); padding: 1px 6px; border-radius: 4px; }

#toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: 380px; box-shadow: var(--shadow-lg); font-weight: 500; }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- filter toolbars ---------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.filters.one { grid-template-columns: minmax(0, 520px); }
.filters.two { grid-template-columns: 1fr 1fr; max-width: 560px; }
.filters.codesf { grid-template-columns: 2fr 1.2fr 1fr 1fr; }
.filters.assetsf { grid-template-columns: 2fr 1fr 1fr 1fr 1fr; }
@media (max-width: 720px) { .filters, .filters.codesf, .filters.assetsf { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; } }
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px; }
.bulkbar[hidden] { display: none; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.preview { max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pre { white-space: pre-wrap; margin-top: 2px; }
.note-reply { margin-top: 8px; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; font-size: 13px; }

/* scroll areas that fit the window: scrollbars stay on screen, headers stay visible */
.tablewrap.fit { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.tablewrap.fit thead th { position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--line); }
.tablewrap.fit thead th:first-child, .tablewrap.fit thead th:last-child { border-radius: 0; }

/* ---------- pipeline board ---------- */
.board { display: flex; gap: 14px; overflow: auto; align-items: stretch; }
.board .col { flex: 1 0 260px; display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; }
.board .col header { flex: none; display: flex; flex-direction: column; gap: 1px; margin: 2px 4px 10px; font-size: 13px; }
.board .col header b { font-size: 13px; }
.board .cards { flex: 1; overflow-y: auto; display: grid; gap: 10px; align-content: start; min-height: 40px; padding: 2px; }
.card2 { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: grab; font-size: 13px;
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s; }
.card2:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.card2 .t { display: block; width: 100%; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600;
  text-align: left; cursor: pointer; margin-bottom: 2px; overflow-wrap: anywhere; }
.card2 .t:hover { color: var(--accent); }
.card2 .m { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.card2 .stagepick { margin-top: 10px; padding: 4px 8px; font-size: 12px; }
.board .more { width: 100%; }

/* ---------- user permissions ---------- */
.permchecks { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.permchecks label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }

/* ---------- help ---------- */
.helpwrap { display: grid; grid-template-columns: 220px minmax(0, 860px); gap: 28px; align-items: start; }
.helptoc { position: sticky; top: 84px; display: grid; gap: 2px; }
.helptoc a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.helptoc a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.helpbody .card h2 { margin: 0 0 10px; }
.helpbody li { margin-bottom: 8px; }
.helpbody ul { padding-left: 20px; margin: 0; }
@media (max-width: 800px) { .helpwrap { grid-template-columns: 1fr; } .helptoc { position: static; grid-auto-flow: column; overflow-x: auto; } }

/* ---------- storage meter ---------- */
.storage { display: grid; gap: 8px; max-width: 640px; }
.storage .big { font-size: 22px; letter-spacing: -.02em; }
.storage .bar { height: 10px; border-radius: 5px; }

.importsummary { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 4px; }
details summary { cursor: pointer; }

/* ---------- quotes ---------- */
.qlayout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.qpreview { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; }
.qform .card { margin-bottom: 14px; }
.qform .form .grid { margin: 0; }
label.inline { display: flex; align-items: center; gap: 8px; }
label.inline span { margin: 0; }
.pricetable td { padding: 6px 6px; vertical-align: middle; }
.pricetable th { white-space: nowrap; }
.pricetable input, .pricetable textarea { padding: 5px 7px; }
.pricetable td:nth-child(4) input, .pricetable td:nth-child(5) input { text-align: right; min-width: 72px; }
.pricetable td:nth-child(2) { min-width: 240px; }
.pricetable td:nth-child(3) input { min-width: 70px; }
.paper { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px; padding: 36px 40px; box-shadow: var(--shadow-sm);
  font: 13px/1.45 "Times New Roman", Times, serif; }
.paper .phead { text-align: center; font-size: 11px; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid #555; }
.paper .phead img { display: block; margin: 0 auto 6px; height: 46px; width: auto; }
.paper .pfoot { text-align: center; font-size: 11px; margin-top: 28px; padding-top: 8px; border-top: 1px solid #ccc; color: #444; }
.paper h2.ptitle { font: 400 20px/1.25 "Times New Roman", Times, serif; margin: 0 0 14px; letter-spacing: 0; }
.paper .pnum { background: #d9d9d9; padding: 2px 0; font-size: 14px; margin-bottom: 10px; display: grid; grid-template-columns: 62px 1fr; }
.paper .pfields { display: grid; grid-template-columns: 62px 1fr; margin: 0 0 4px; }
.paper .pfields dt, .paper .pfields dd { margin: 0 0 6px; }
.paper .psubject { margin: 16px 0; display: grid; grid-template-columns: 62px 1fr; }
.paper h4 { text-decoration: underline; font-size: 13px; margin: 16px 0 6px; font-weight: 700; }
.paper p { margin: 0 0 8px; }
.paper ul { margin: 0 0 8px; padding-left: 22px; }
.paper .ptable { width: 100%; border-collapse: collapse; font: 12px/1.35 Calibri, Arial, sans-serif; margin-bottom: 4px; }
.paper .ptable th, .paper .ptable td { border: 1px solid #333; padding: 5px 7px; text-transform: none; letter-spacing: 0; color: #000; vertical-align: middle; }
.paper .ptable th { background: #b4c6e7; font-size: 12px; text-align: center; }
.paper .ptable td.c { text-align: center; } .paper .ptable td.r { text-align: right; }
.paper .ptable tbody tr:hover { background: none; }
@media (max-width: 1180px) { .qlayout { grid-template-columns: 1fr; } .qpreview { position: static; max-height: none; } }
@media print {
  .topbar, .pagehead, .crumb, .qform, #toasts { display: none !important; }
  body { background: #fff; } main { padding: 0; max-width: none; }
  .qlayout { display: block; } .qpreview { position: static; max-height: none; overflow: visible; }
  .paper { border: 0; box-shadow: none; padding: 0; }
}

.filelink { font-weight: 400; font-size: 12px; padding: 0; text-align: left; }
.qform small.muted { display: block; margin-top: 4px; }

/* Rich text editor on the quote form, and the same content in the preview */
.re { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface, #fff); }
.re:focus-within { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2563eb) 18%, transparent); }
.retools { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--bg-soft, rgba(127,127,127,.08)); }
.retools .btn.small { padding: 3px 9px; font-size: 12px; min-height: 0; }
.rebody { min-height: 90px; resize: vertical; overflow: auto; padding: 10px 12px; font: 14px/1.45 "Times New Roman", Times, serif; outline: none; }
.rebody:empty::before { content: attr(data-ph); color: var(--muted, #888); }
.rebody p, .rich p { margin: 0 0 8px; }
.rebody ul, .rebody ol, .rich ul, .rich ol { margin: 0 0 8px; padding-left: 26px; }
.rebody blockquote { margin: 0 0 0 36px; padding: 0; border: 0; }
.rebody img, .rich img { max-width: 100%; height: auto; display: block; }
.rebody p[data-i], .rich p[data-i] { margin-left: calc(var(--i, 1) * 36px); }
.rebody p[data-i="1"], .rich p[data-i="1"] { margin-left: 36px; } .rebody p[data-i="2"], .rich p[data-i="2"] { margin-left: 72px; }
.rebody p[data-i="3"], .rich p[data-i="3"] { margin-left: 108px; } .rebody p[data-i="4"], .rich p[data-i="4"] { margin-left: 144px; }
.rebody p[data-i="5"], .rich p[data-i="5"] { margin-left: 180px; } .rebody p[data-i="6"], .rich p[data-i="6"] { margin-left: 216px; }
.rich ul ul { list-style-type: circle; } .rich ol ol { list-style-type: lower-alpha; } .rich ol ol ol { list-style-type: lower-roman; }

.re { position: relative; }
.rebody img { cursor: pointer; }
.rebody img.sel { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
.rehandle { position: absolute; width: 14px; height: 14px; background: var(--accent, #2563eb); border: 2px solid #fff; border-radius: 3px;
  cursor: nwse-resize; touch-action: none; box-shadow: 0 1px 3px rgba(0,0,0,.35); z-index: 3; }

/* Help menu in the top bar */
.topbar .navmenu { position: relative; }
.topbar .navbtn { font: inherit; background: none; border: 0; color: #a3ad98; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.topbar .navbtn:hover, .topbar .navbtn[aria-expanded="true"] { color: #fff; background: rgba(255, 255, 255, .08); }
.topbar .navbtn.on { color: var(--brand); background: rgba(151, 191, 59, .14); }
.topbar .navpop { position: absolute; left: 0; top: calc(100% + 6px); min-width: 230px; background: #111; border: 1px solid #2c2c2c; border-radius: 10px; padding: 6px; z-index: 20; box-shadow: 0 10px 30px rgba(0,0,0,.45); display: flex; flex-direction: column; }
.topbar .navpop[hidden] { display: none; }
.topbar .navpop a { display: block; }

/* Text boxes grow with their contents and can be dragged larger from the corner */
textarea { resize: vertical; }
textarea.grow { min-height: 38px; overflow: auto; line-height: 1.45; }

.kpis[hidden] { display: none; }

/* Compact pipeline board: narrower columns and tighter cards, with less space above it */
.board { gap: 8px; }
.board .col { flex: 1 0 196px; min-width: 0; padding: 6px; border-radius: 10px; }
.board .col header { flex-direction: column; gap: 0; margin: 1px 3px 6px; font-size: 12px; line-height: 1.3; }
.board .col header b { font-size: 12px; }
.board .cards { gap: 6px; padding: 1px; grid-template-columns: minmax(0, 1fr); }
.board .card2 { padding: 6px 8px; font-size: 12px; line-height: 1.3; border-radius: 8px; }
.board .card2 .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 1px; }
.board .card2 > .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .card2 .m { gap: 6px; margin-top: 3px; }
.board .card2 .m .chip { font-size: 10px; padding: 0 6px; }
.board .card2 .stagepick { margin-top: 5px; padding: 1px 4px; font-size: 11px; min-height: 0; height: 23px; border-radius: 6px; }
.board .more { padding: 4px 8px; font-size: 12px; }
main:has(#board) { padding: 14px 16px 10px; }
main:has(#board) .pagehead { margin-bottom: 8px; }
main:has(#board) .pagehead h1 { font-size: 20px; margin: 0; }
main:has(#board) .pagehead .sub { display: none; }
main:has(#board) .tabs { margin-bottom: 8px; }
main:has(#board) .tabs a { padding: 6px 12px; }
main:has(#board) .kpis { gap: 8px; margin-bottom: 8px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
main:has(#board) .kpi { padding: 7px 10px; }
main:has(#board) .kpi .val { font-size: 18px; margin-top: 1px; }
main:has(#board) .card { padding: 10px; margin-bottom: 0; }
main:has(#board) .filters { margin-bottom: 8px; }
main:has(#board) .filters input, main:has(#board) .filters select { padding-top: 5px; padding-bottom: 5px; }
.board .card2 .m { flex-wrap: nowrap; min-width: 0; }
.board .card2 .m > .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main:has(#board) .tabs { overflow-y: hidden; }

/* Quote-to-payment status bar and the linked records under a project's title */
ol.chain { display: flex; gap: 4px; list-style: none; margin: 0 0 14px; padding: 0; }
ol.chain li { flex: 1; min-width: 0; text-align: center; font-size: 12px; padding: 6px 2px; border-top: 3px solid var(--line); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.chain li.done { border-color: var(--accent); color: var(--text); }
ol.chain li.now { border-color: var(--accent); color: var(--text); font-weight: 650; background: color-mix(in srgb, var(--accent) 14%, transparent); }
.chainlinks { font-size: 13px; margin: -6px 0 14px; }
.linkcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 16px; }
.linkcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.linkcard .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
dialog.modal ol.chain { margin-bottom: 8px; }

/* Delivery: simple project timeline and template lists */
.timeline { display: grid; gap: 4px; font-size: 12px; }
.tl-row { display: grid; grid-template-columns: minmax(120px, 28%) 1fr 90px; gap: 10px; align-items: center; }
.tl-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-row em { font-style: normal; color: var(--muted); text-align: right; }
.tl-track { position: relative; height: 14px; border-radius: 4px; background: var(--surface-2); margin: 0 7px; }
.tl-bar { position: absolute; top: 3px; height: 8px; min-width: 4px; border-radius: 4px; background: var(--accent); }
.tl-ms { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; transform: rotate(45deg); background: var(--accent); }
.tl-bar.done, .tl-ms.done { background: var(--line-strong); }
.tl-bar.late, .tl-ms.late { background: #c2410c; }
input[type="checkbox"][data-task], input[type="checkbox"][data-closeout] { width: auto; }
.card details { border-top: 1px solid var(--line); padding: 8px 0; }
.card summary { cursor: pointer; }
.tabs { scrollbar-width: thin; overflow-y: hidden; }

/* Planning: staffing board and calendar */
.plantools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
.plantools input[type=search] { max-width: 280px; }
.plantools input[type=checkbox] { width: auto; }
table.staff { table-layout: fixed; min-width: 900px; font-size: 12px; }
table.staff th, table.staff td { padding: 4px; border: 1px solid var(--line); }
table.staff thead th { text-align: center; }
table.staff thead th:first-child, table.staff tbody th { width: 160px; text-align: left; }
table.staff thead th:last-child { width: 68px; }
table.staff tbody th { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); background: var(--surface); font-weight: 600; position: sticky; left: 0; z-index: 1; overflow: hidden; text-overflow: ellipsis; }
table.staff tbody th div { font-weight: 400; font-size: 11px; }
table.staff .we { background: var(--surface-2); }
table.staff td.sc { height: 34px; vertical-align: top; overflow: hidden; }
table.staff td.add, table.staff.weeks td.sc { cursor: pointer; }
table.staff td.over { background: color-mix(in srgb, var(--bad) 18%, transparent); }
table.staff td .jobs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb { display: block; width: 100%; margin-bottom: 2px; padding: 1px 4px; border: 0; border-radius: 4px; background: var(--accent-soft); color: var(--text); font: inherit; font-size: 11px; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.calgrid .dow, .calgrid .day { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calgrid .dow { padding: 4px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.calgrid .day { min-height: 104px; padding: 4px; min-width: 0; }
.calgrid .day.we, .calgrid .day.out { background: var(--surface-2); }
.calgrid .day.now { box-shadow: inset 0 0 0 2px var(--accent); }
.calgrid .date { font-size: 12px; font-weight: 600; color: var(--muted); }
.calgrid .wd { display: none; }
.calgrid .more { padding: 0 4px; font-size: 11px; }
.ev { display: block; margin-top: 2px; padding: 1px 5px; border-radius: 4px; border-left: 3px solid var(--k); background: color-mix(in srgb, var(--k) 12%, transparent); color: var(--text); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.staff, .key.staff { --k: #2563eb; } .ev.task, .key.task { --k: #65a30d; } .ev.permit, .key.permit { --k: #9333ea; }
.ev.equipment, .key.equipment { --k: #d97706; } .ev.project, .key.project { --k: #0891b2; }
.ev.late { --k: var(--bad); color: var(--bad); font-weight: 600; }
.ev.done { opacity: .55; text-decoration: line-through; }
.key span { border-bottom: 3px solid var(--k); }
.daylist { margin: 12px 0 16px; }
.daylist .ev { white-space: normal; font-size: 13px; padding: 4px 8px; }
@media (max-width: 720px) {
  .calgrid { grid-template-columns: 1fr; }
  .calgrid .dow, .calgrid .day.out, .calgrid .day.none { display: none; }
  .calgrid .day { min-height: 0; }
  .calgrid .wd { display: inline; }
  table.staff thead th:first-child, table.staff tbody th { width: 110px; }
}

/* Home dashboard */
.homegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 400px) { .homegrid { grid-template-columns: 1fr; } }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li + li { border-top: 1px solid var(--line); }
.todo a { display: flex; gap: 12px; align-items: baseline; padding: 8px 4px; color: var(--text); }
.todo a:hover { background: var(--hover); text-decoration: none; }
.todo b { min-width: 28px; font-size: 18px; text-align: right; }
.todo small { display: block; }
.homegrid h3 { margin: 10px 0 4px; font-size: 13px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; flex-wrap: wrap; }
.weekbar { display: grid; grid-template-columns: 160px minmax(80px, 1fr) 260px; gap: 12px; align-items: center; padding: 4px 0; font-size: 13px; }
@media (max-width: 720px) { .weekbar { grid-template-columns: 1fr; gap: 2px; } }
h2.section { margin: 8px 0 12px; }
a.kpi { color: var(--text); display: block; }
a.kpi:hover { text-decoration: none; }
.card .head label.inline { display: inline-flex; }
.card .head label.inline input { width: auto; }

/* Management dashboards */
table.weekly { table-layout: fixed; min-width: 900px; }
table.weekly th:first-child { width: 31%; }
table.weekly th div { font-weight: 400; text-transform: none; letter-spacing: 0; }
table.weekly td { font-size: 12px; overflow-wrap: anywhere; }
table.weekly td.who { font-size: 13px; }
.wk { padding: 1px 0; }
.wk.muted { color: var(--muted); }
td.meter { width: 40%; vertical-align: middle; }
body.dash .card .tablewrap { max-height: none; }
@page dashboard { size: landscape; margin: 10mm; }
@media print {
  body.dash { page: dashboard; font-size: 11px; --bg: #fff; --surface: #fff; --surface-2: #f4f5f7; --text: #000; --muted: #444; --line: #ccc; --chip: #eee; --good: #15803d; --warn: #b45309; --bad: #b91c1c; --accent: #4d7c0f;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.dash .pagehead { display: flex !important; margin-bottom: 8px; }
  body.dash .noprint { display: none !important; }
  body.dash main { padding: 0; max-width: none; }
  body.dash .card, body.dash .kpi { box-shadow: none; }
  body.dash .card { padding: 10px; margin-bottom: 8px; }
  body.dash .kpis { grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
  body.dash .kpi { padding: 8px 10px; }
  body.dash .kpi .val { font-size: 18px; }
  body.dash .tablewrap { overflow: visible; }
  body.dash table.weekly { min-width: 0; }
  body.dash th, body.dash td { padding: 4px 6px; }
  body.dash tr { break-inside: avoid; }
  body.dash h2 { break-after: avoid; }
  body.dash .card:not(:has(table.weekly)) { break-inside: avoid; }
}
