:root {
  /* Colors taken from the CheckPoint Appraisals logo */
  --bg: #f3f6fa;
  --panel: #ffffff;
  --ink: #141a22;
  --muted: #5a6575;
  --line: #e1e7ef;
  --brand: #1f5fa8;
  --brand-dark: #0d4a8a;
  --brand-ink: #ffffff;
  --brand-soft: #e7eff9;
  --danger: #c2362b;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --side: #ffffff;
  --side-ink: #2a3646;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 22, .06), 0 1px 1px rgba(16, 24, 22, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot, .loading { padding: 40px; color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.muted { color: var(--muted); }
.danger { color: var(--danger); font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); }
.brand { display: flex; flex-direction: column; align-items: center; padding: 4px 8px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
a.brand { text-decoration: none; }
.brand .logo-full { width: 100%; max-width: 180px; height: auto; display: block; }
.brand .logo-icon { display: none; width: 36px; height: 36px; }
.brand small { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .02em; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { color: var(--side-ink); text-decoration: none; padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.sidebar nav a:hover { background: var(--bg); }
.sidebar nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sidebar nav svg { width: 18px; height: 18px; flex: none; }
.me { border-top: 1px solid var(--line); padding: 12px 8px 0; font-size: 13px; }
.me strong { color: var(--ink); display: block; }
.me small { display: block; color: var(--muted); }
.me button { background: none; border: 0; color: var(--brand); padding: 6px 0 0; cursor: pointer; text-decoration: underline; }
main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c9d2cf; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 14px; }
.icon-btn:hover { background: var(--bg); color: var(--danger); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd8d5; border-radius: 8px; background: #fff; min-height: 36px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
label.f.full { grid-column: 1 / -1; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--ink); font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 14px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.err { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: 8px; margin-top: 10px; }

/* ---------- cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .body { padding: 14px 16px; }
.card + .card { margin-top: 16px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 16px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv div b { font-weight: 500; overflow-wrap: anywhere; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ---------- dashboard tiles */
.tiles-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.tile:hover { border-color: #b8c6c1; }
.tile.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.tile span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.tile b { display: block; font-size: 24px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile.alert b { color: var(--danger); }
.tile.static { cursor: default; }

/* ---------- tables */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 380px; flex: 1; min-width: 200px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 4px 6px 4px 12px; font-weight: 600; font-size: 13px; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; padding: 0 4px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfb; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7faf9; }
td a.row-link { color: var(--ink); text-decoration: none; font-weight: 600; }
td a.row-link:hover { text-decoration: underline; }
tfoot td { font-weight: 700; background: #fafbfb; }
.orders td { white-space: nowrap; }
.orders td.wrap { white-space: normal; min-width: 180px; }

/* ---------- badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; color: #fff; }
.badge.rush { background: var(--danger); margin-left: 4px; }
.badge.soft { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* ---------- order page */
.order-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.order-head h1 { font-size: 24px; }
.order-head .meta { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; color: var(--muted); }
.order-head .controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.order-head select { width: auto; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; color: var(--muted); }
.stepper { display: flex; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stepper div { flex: 1; padding: 10px 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); position: relative; }
.stepper div + div { border-left: 1px solid var(--line); }
.stepper div.done { background: var(--brand-soft); color: var(--brand); }
.stepper div.current { background: var(--brand); color: #fff; }
.cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.due-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.team-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.team-row:last-child { border-bottom: 0; }
.role-tag { font-size: 12px; color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.contact-block + .contact-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.contact-block h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--brand-soft); color: var(--brand); }
.msgs { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.msg { background: var(--bg); border-radius: 10px; padding: 8px 12px; max-width: 92%; }
.msg.mine { background: var(--brand-soft); align-self: flex-end; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { min-height: 42px; height: 42px; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-row:last-child { border-bottom: 0; }
.file-row a { font-weight: 600; overflow-wrap: anywhere; }
.files-sec + .files-sec { margin-top: 14px; }
.files-sec h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.activity { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.money-table td, .money-table th { padding: 7px 8px; }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.add-row > * { flex: 1 1 100px; min-width: 0; width: auto; }
.add-row > [name=description], .add-row > [name=user] { flex: 2 1 180px; }
.add-row > .btn, .add-row > .icon-btn { flex: 0 0 auto; }
.add-row > [type=date] { flex: 1 1 145px; }
.totals { display: flex; justify-content: flex-end; gap: 24px; margin-top: 12px; flex-wrap: wrap; }
.totals div { text-align: right; }
.totals span { display: block; font-size: 12px; color: var(--muted); }
.totals b { font-size: 18px; }
.totals .owed b { color: var(--danger); }
.totals .paid b { color: var(--brand); }
.instructions { white-space: pre-wrap; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px; margin-top: 12px; }

/* ---------- forms page */
.form-section + .form-section { margin-top: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- calendar */
.cal-head { display: flex; gap: 8px; align-items: center; }
.cal-head h2 { font-size: 18px; min-width: 170px; text-align: center; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.calendar .dow { padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); background: #fafbfb; border-bottom: 1px solid var(--line); }
.calendar .day { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar .day:nth-child(7n) { border-right: 0; }
.calendar .day.other { background: #fafbfb; color: #a3aeaa; }
.calendar .day.today .dnum { background: var(--brand); color: #fff; }
.dnum { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-bottom: 4px; }
.ev { display: block; font-size: 12px; padding: 3px 6px; border-radius: 5px; margin-bottom: 3px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.appt { background: #e0ecff; color: #1d4ed8; }
.ev.due { background: #fff1e0; color: #b45309; }
.ev.due.late { background: var(--danger-soft); color: var(--danger); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.agenda { display: none; }
.agenda h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #0b2547, var(--brand)); }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card .brand { padding: 0 0 16px; margin-bottom: 16px; }
.auth-card .brand .logo-full { max-width: 240px; }
.auth-card p { color: var(--muted); margin: 0 0 16px; }
.auth-card .stack { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn { width: 100%; padding: 10px; margin-top: 6px; }

/* ---------- modal & toast */
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.modal.wide { width: min(820px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(10, 20, 18, .45); }
.modal-form > header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
.modal-form > .err { margin: 0 18px; }
.modal-form > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 1000; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--danger); }

/* ---------- invoice */
.invoice { max-width: 800px; margin: 0 auto; background: #fff; padding: 40px; border: 1px solid var(--line); border-radius: var(--radius); }
.invoice header { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.invoice h1 { font-size: 28px; color: var(--brand); }
.invoice .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.invoice .parties h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.invoice table { margin-bottom: 16px; }
.print-bar { display: flex; justify-content: space-between; max-width: 800px; margin: 0 auto 14px; gap: 8px; }

@media print {
  .sidebar, .print-bar, .toast { display: none !important; }
  .app { display: block; }
  main { padding: 0; }
  body, html { background: #fff; }
  .invoice { border: 0; padding: 0; }
}

/* ---------- small screens */
@media (max-width: 960px) {
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand { padding: 0; margin: 0; border: 0; }
  .sidebar .brand .logo-full, .sidebar .brand small { display: none; }
  .sidebar .brand .logo-icon { display: block; }
  .sidebar nav { flex-direction: row; overflow-x: auto; gap: 2px; }
  .sidebar nav a { padding: 8px 10px; white-space: nowrap; }
  .sidebar nav a span { display: none; }
  .sidebar nav a.on span { display: inline; }
  .me { border: 0; padding: 0; }
  .me strong, .me small { display: none; }
  .me button { padding: 0; white-space: nowrap; }
  main { padding: 16px 16px 40px; }
  .calendar { display: none; }
  .agenda { display: block; }
  .invoice { padding: 20px; }
  .invoice .parties { grid-template-columns: 1fr; }
}
