/* BuildDesk. A restrained, desk-first interface: warm paper background,
   a dark eucalyptus sidebar, and status colour used only where it means something. */

:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #1c2321;
  --ink-2: #4a5350;
  --muted: #6b7471;
  --line: #e2dfd7;
  --line-2: #ece9e2;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e5efe9;
  --side: #1d2b27;
  --side-2: #263833;
  --side-ink: #d9e3df;
  --side-muted: #8fa39c;
  --ok: #2c6e49;      --ok-bg: #e3f1e7;
  --warn: #8a5a00;    --warn-bg: #fbefd5;
  --bad: #b42318;     --bad-bg: #fde8e6;
  --info: #285a85;    --info-bg: #e4eef8;
  --internal: #6a3fa0; --internal-bg: #efe8f8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 1px 1px rgba(20, 30, 25, .04);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
a:hover { color: #1f4238; }
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 3px solid #7fb59f; outline-offset: 2px; }
.ico { flex: none; vertical-align: -3px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack > * + * { margin-top: 16px; }

/* ----------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 12px;
}
.main-wrap { min-width: 0; display: flex; flex-direction: column; }
main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; outline: none; }
.topbar { display: none; }

.brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 14px; }
.brand-link { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; }
.brand-link:hover { color: #fff; }
.brand-link small { display: block; color: var(--side-muted); font-size: .75rem; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: #d9a441; color: #1d2b27; font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}
.brand .sidebar-close { display: none; color: var(--side-ink); }
/* The mobile menu's backdrop; never part of the desktop grid. */
.scrim { display: none; }

.role-switch { background: var(--side-2); border-radius: var(--radius); padding: 8px 10px 10px; margin-bottom: 12px; }
.role-label { display: flex; justify-content: space-between; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); margin-bottom: 6px; }
.demo-tag { background: #d9a441; color: #1d2b27; border-radius: 4px; padding: 0 5px; font-weight: 700; letter-spacing: .04em; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: #14201d; border-radius: 7px; padding: 3px; gap: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--side-ink); padding: 6px 8px; border-radius: 5px;
  font: inherit; font-size: .88rem; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: #f4f3ef; color: var(--side); font-weight: 600; }
.segmented button:hover:not([aria-pressed="true"]) { background: rgba(255,255,255,.07); }

.switcher { display: block; margin: 0 0 10px; }
.switcher span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--side-muted); margin: 0 4px 4px; }
.switcher select {
  width: 100%; background: var(--side-2); color: #fff; border: 1px solid #36504a; border-radius: 7px;
  padding: 8px 10px; font: inherit; font-size: .9rem;
}

.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin: 14px 8px 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--side-muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px;
  color: var(--side-ink); text-decoration: none; font-size: .93rem;
}
.nav-link:hover { background: var(--side-2); color: #fff; }
.nav-link.active { background: #f4f3ef; color: var(--side); font-weight: 600; }
.nav-link .ico { opacity: .85; }
.count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700;
  background: #7fb59f; color: #102019;
}
.count.warn { background: #e9b949; color: #2b1d00; }
.count.bad { background: #f08b80; color: #3a0601; }

.sidebar-foot { margin-top: auto; padding: 18px 6px 4px; border-top: 1px solid #2f433d; }
.demo-note { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--side-muted); margin-bottom: 6px; }
.demo-dot { width: 8px; height: 8px; border-radius: 50%; background: #d9a441; }
.link-btn {
  display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 0;
  color: var(--side-ink); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: #4f6b63;
}
.link-btn:hover { color: #fff; }

.client-banner {
  display: flex; gap: 10px; align-items: flex-start; background: #fff7e0; border-bottom: 1px solid #ecd9a2;
  color: #5a4300; padding: 10px 32px; font-size: .88rem;
}
.client-banner .ico { margin-top: 2px; }

/* ---------------------------------------------------------- page furniture */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .subtitle { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.back:hover { color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 1rem; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

.flash {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 12px 10px 16px; border-radius: var(--radius-sm); margin-bottom: 14px;
  border: 1px solid; font-size: .92rem;
}
.flash-ok { background: var(--ok-bg); border-color: #b9dcc4; color: #1c4a30; }
.flash-info { background: var(--info-bg); border-color: #bcd3ea; color: #1d3f5e; }
.flash-warn { background: var(--warn-bg); border-color: #ecd59f; color: #5f3e00; }
.flash-error { background: var(--bad-bg); border-color: #f3c0ba; color: #7a1a12; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--info-bg); color: #1d3f5e; font-size: .92rem; display: flex; gap: 10px; }
.notice.warn { background: var(--warn-bg); color: #5f3e00; }
.notice.bad { background: var(--bad-bg); color: #7a1a12; }
.notice.ok { background: var(--ok-bg); color: #1c4a30; }
.notice .ico { margin-top: 2px; }
.errors { margin: 0 0 16px; padding: 12px 16px 12px 34px; background: var(--bad-bg); color: #7a1a12; border-radius: var(--radius-sm); border: 1px solid #f3c0ba; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; white-space: nowrap; line-height: 1.5;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #ecebe6; color: #555d5a; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-internal { background: var(--internal-bg); color: var(--internal); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 7px; border: 1px solid #cfcbc1; background: var(--surface);
  color: var(--ink); font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; text-decoration: none;
  white-space: nowrap; min-height: 38px;
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: #b9b4a8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #244a40; border-color: #244a40; color: #fff; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); border-color: #e9aaa3; }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #8f1c13; color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #225838; color: #fff; }
.btn-sm { padding: 4px 10px; min-height: 30px; font-size: .84rem; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #ecebe6; border-color: transparent; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; border: 0;
  background: transparent; color: inherit; cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.inline { display: inline; }

/* ------------------------------------------------------------------- forms */
label.field { display: block; }
.field > span { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number],
input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfcbc1; border-radius: 7px; background: #fff;
  font: inherit; font-size: .93rem; color: var(--ink); min-height: 38px;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid #cfe3da; outline-offset: 0; }
input[aria-invalid=true] { border-color: var(--bad); background: #fff8f7; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; }
legend { font-weight: 600; font-size: .88rem; padding: 0 4px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 650; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.row-link { cursor: pointer; }
.table tbody tr.row-link:hover td { background: #fbfaf7; }
.table .num { text-align: right; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.table .cat-row td { background: #f3f1ec; font-weight: 650; font-size: .85rem; color: var(--ink-2); }
.table a.row-title { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a.row-title:hover { color: var(--accent); text-decoration: underline; }

/* totals block */
.totals { margin-left: auto; width: min(100%, 360px); font-size: .95rem; }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; gap: 16px; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; font-weight: 700; font-size: 1.08rem; }
.totals .sub { color: var(--muted); font-size: .86rem; }

/* key figures */
.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
/* Hairlines drawn by each figure rather than by a gap, so a part-empty last row stays white. */
.figure { padding: 14px 16px; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.figure .label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.figure .value { font-size: 1.28rem; font-weight: 650; letter-spacing: -.01em; margin-top: 2px; }
.figure .hint { font-size: .78rem; color: var(--muted); }
.figure.emph { background: var(--accent-soft); }
.figure.bad .value { color: var(--bad); }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .92rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

.action-list { list-style: none; margin: 0; padding: 0; }
.action-list li + li { border-top: 1px solid var(--line-2); }
.action-list a { display: flex; gap: 10px; align-items: center; padding: 10px 20px; text-decoration: none; color: var(--ink); font-size: .92rem; }
.action-list a:hover { background: var(--surface-2); }
.tone-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #b8b4aa; }
.tone-dot.warn { background: #d99a16; } .tone-dot.bad { background: var(--bad); } .tone-dot.info { background: var(--info); }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-title { color: var(--ink); font-weight: 600; font-size: 1rem; }

.progress { height: 6px; background: #e9e6df; border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* --------------------------------------------------------------- dashboard */
.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.project-card { display: flex; flex-direction: column; }
.project-card h2 a { color: var(--ink); text-decoration: none; }
.project-card h2 a:hover { color: var(--accent); }
.project-card .address { color: var(--muted); font-size: .86rem; margin: 2px 0 10px; }
.mini-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.mini-figs div { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; }
.mini-figs b { display: block; font-size: .95rem; }
.mini-figs span { font-size: .72rem; color: var(--muted); }
.project-card ul { margin: 0; padding: 0; list-style: none; font-size: .86rem; }
.project-card li { display: flex; gap: 8px; align-items: center; padding: 3px 0; }

/* ------------------------------------------------------------ line editor */
.line-editor { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 940px; }
.line-editor th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.line-editor td { padding: 5px 4px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.line-editor input, .line-editor select { min-height: 34px; padding: 5px 7px; font-size: .9rem; }
.line-editor .c-cat { width: 150px; } .line-editor .c-qty { width: 82px; } .line-editor .c-unit { width: 84px; }
.line-editor .c-cost { width: 112px; } .line-editor .c-mk { width: 76px; }
.line-editor .c-out { width: 108px; text-align: right; white-space: nowrap; padding-right: 10px; }
.line-editor .c-act { width: 76px; white-space: nowrap; }
.line-editor input.n { text-align: right; }
.line-editor tr.dirty td:first-child { box-shadow: inset 3px 0 0 #d99a16; }
.unsaved { display: none; color: var(--warn); font-weight: 600; font-size: .88rem; }
form.is-dirty .unsaved { display: inline-flex; align-items: center; gap: 6px; }
.sticky-bar {
  position: sticky; bottom: 0; z-index: 5; background: rgba(255,255,255,.96); backdrop-filter: blur(4px);
  border-top: 1px solid var(--line); padding: 12px 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  border-radius: 0 0 var(--radius) var(--radius);
}
.sticky-bar .spacer { flex: 1; }
.live-totals { display: flex; gap: 18px; flex-wrap: wrap; font-size: .9rem; }
.live-totals b { font-size: 1rem; }

/* --------------------------------------------------------------- documents */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 44px; box-shadow: var(--shadow); max-width: 860px; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 3px solid var(--accent); padding-bottom: 18px; margin-bottom: 22px; }
.doc-company strong { font-size: 1.15rem; display: block; }
.doc-company { font-size: .85rem; color: var(--ink-2); }
.doc-title { text-align: right; }
.doc-title h2 { font-size: 1.5rem; color: var(--accent); }
.doc-title p { margin: 2px 0; font-size: .88rem; color: var(--ink-2); }
.doc h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); margin: 22px 0 8px; }
.doc ul { margin: 0; padding-left: 20px; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; font-size: .92rem; }
.doc .items { color: var(--muted); font-size: .84rem; font-weight: 400; display: block; margin-top: 2px; }
.doc-stamp { display: inline-block; border: 2px solid; border-radius: 6px; padding: 4px 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .85rem; }
.doc-stamp.ok { color: var(--ok); } .doc-stamp.bad { color: var(--bad); } .doc-stamp.muted { color: var(--muted); } .doc-stamp.draft { color: var(--warn); }
.doc-foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.watermark { background: var(--warn-bg); color: #5f3e00; border: 1px dashed #d9b866; border-radius: 6px; padding: 8px 12px; font-size: .85rem; margin-bottom: 18px; }

.decision { border: 2px solid var(--accent); }
.decision .card-head { background: var(--accent-soft); }

/* ---------------------------------------------------------------- schedule */
.view-toggle { display: inline-flex; border: 1px solid #cfcbc1; border-radius: 8px; overflow: hidden; }
.view-toggle a { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; text-decoration: none; color: var(--ink-2); font-size: .88rem; }
.view-toggle a[aria-current=page] { background: var(--accent); color: #fff; }
.view-toggle a + a { border-left: 1px solid #cfcbc1; }
.conflict { color: var(--warn); font-size: .82rem; display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; }
.task-name { font-weight: 600; }
.pred { font-size: .8rem; color: var(--muted); }

.gantt { position: relative; font-size: .82rem; min-width: 760px; }
.gantt-row { display: grid; grid-template-columns: 230px 1fr; align-items: center; border-bottom: 1px solid var(--line-2); min-height: 40px; }
.gantt-label { padding: 6px 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-label a { color: var(--ink); text-decoration: none; font-weight: 550; }
.gantt-label a:hover { color: var(--accent); }
.gantt-track { position: relative; height: 40px; }
.gantt-head .gantt-track { height: 30px; }
.gantt-week { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line-2); }
.gantt-head .gantt-week { color: var(--muted); font-size: .72rem; padding: 7px 0 0 4px; white-space: nowrap; }
.gantt-bar {
  position: absolute; top: 10px; height: 20px; border-radius: 5px; background: #9fc3b4; overflow: hidden;
  border: 1px solid #7aa898;
}
.gantt-bar > span { display: block; height: 100%; background: var(--accent); }
.gantt-bar.complete { background: #b9d8c4; border-color: #8cbf9f; }
.gantt-bar.complete > span { background: #4d8a65; }
.gantt-bar.behind { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.gantt-bar.conflict { background: repeating-linear-gradient(45deg, #f6d48d, #f6d48d 5px, #fbe7bd 5px, #fbe7bd 10px); border-color: #d99a16; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 2; }
.gantt-head .gantt-today::before { content: "Today"; position: absolute; top: -18px; left: -14px; font-size: .68rem; color: var(--bad); font-weight: 700; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------------------------------------------------------------- messages */
.threads { list-style: none; margin: 0; padding: 0; }
.threads li + li { border-top: 1px solid var(--line-2); }
.threads a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 18px; text-decoration: none; color: var(--ink); }
.threads a:hover { background: var(--surface-2); }
.threads a.current { background: var(--accent-soft); }
.threads .subject { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.threads .unread .subject::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--info); }
.threads .preview { color: var(--muted); font-size: .86rem; grid-column: 1 / -1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.threads .when { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.chat { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; }
.msg { display: grid; grid-template-columns: 36px 1fr; gap: 10px; max-width: 760px; }
.msg .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.msg.client .avatar { background: #f3e6c9; color: #6b4b00; }
.msg .bubble { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 4px 12px 12px 12px; padding: 10px 14px; }
.msg.client .bubble { background: #fffaf0; border-color: #f0e2bf; }
.msg .who { font-size: .82rem; color: var(--muted); margin-bottom: 3px; }
.msg .who b { color: var(--ink); }
.unread-marker { display: flex; align-items: center; gap: 10px; color: var(--info); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.unread-marker::before, .unread-marker::after { content: ""; flex: 1; height: 1px; background: #bcd3ea; }
.internal-strip { background: var(--internal-bg); color: var(--internal); padding: 8px 20px; font-size: .85rem; display: flex; gap: 8px; align-items: center; }

/* ------------------------------------------------------------------ photos */
.albums { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.albums a { padding: 5px 12px; border-radius: 999px; border: 1px solid #cfcbc1; text-decoration: none; color: var(--ink-2); font-size: .86rem; background: #fff; }
.albums a[aria-current=page] { background: var(--ink); color: #fff; border-color: var(--ink); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.photo { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.photo button.thumb { border: 0; padding: 0; background: #ddd; cursor: zoom-in; display: block; aspect-ratio: 3 / 2; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .info { padding: 10px 12px; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.photo .caption { font-weight: 600; color: var(--ink); }
.photo .by { color: var(--muted); font-size: .78rem; }
.lightbox { max-width: min(1100px, 96vw); width: 100%; padding: 0; border: 0; border-radius: var(--radius); background: #111; color: #eee; }
.lightbox::backdrop { background: rgba(0,0,0,.75); }
.lightbox img { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: #111; }
.lightbox .lb-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 14px; font-size: .9rem; }
.lightbox .icon-btn { color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255,255,255,.12); }
details.edit-photo summary { cursor: pointer; color: var(--accent); font-size: .82rem; }
details.edit-photo[open] summary { margin-bottom: 8px; }
details.edit-photo .stack > * + * { margin-top: 8px; }

/* ----------------------------------------------------------------- dialogs */
.dialog { border: 0; border-radius: 12px; padding: 22px 24px; max-width: 440px; width: calc(100vw - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(20, 28, 25, .45); }
.dialog h2 { margin-bottom: 8px; }
.dialog p { color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ------------------------------------------------------------ login, misc */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.login .card { width: min(420px, 100%); }
.login h1 { font-size: 1.35rem; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; height: 100%;
  }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .brand .sidebar-close { display: inline-grid; }
  .topbar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30;
    background: var(--side); color: #fff; padding: 8px 12px;
  }
  .topbar-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .demo-pill { background: #d9a441; color: #1d2b27; font-size: .7rem; font-weight: 800; border-radius: 4px; padding: 2px 6px; text-transform: uppercase; }
  main { padding: 18px 16px 48px; }
  .client-banner { padding: 10px 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .doc { padding: 22px 18px; }
  .doc-head { flex-direction: column; }
  .doc-title { text-align: left; }
  .doc .parties { grid-template-columns: 1fr; }
  h1 { font-size: 1.3rem; }
  .mini-figs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .project-cards { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .table th, .table td { padding: 8px 8px; }
  .gantt-row { grid-template-columns: 150px 1fr; }
}

/* ------------------------------------------------------------------- print */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .no-print, .sidebar, .topbar, .client-banner, .flash { display: none !important; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .print-page { padding: 0 !important; }
  a { color: inherit; text-decoration: none; }
}
.print-page { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.print-tools { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

/* -------------------------------------------------------------- start here */
.guide { max-width: 860px; }
.guide > .card + .card, .guide > .page-head + .card { margin-top: 16px; }
.guide h2 { margin-bottom: 10px; }
.guide-points { list-style: none; margin: 12px 0 0; padding: 0; }
.guide-points li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.guide-points .ico { margin-top: 3px; color: var(--accent); }
.guide-switch { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: start; }
.guide-demo { background: var(--side); padding: 4px; }
.guide-demo span { text-align: center; padding: 6px 8px; border-radius: 5px; color: var(--side-ink); font-size: .88rem; }
.guide-demo span.on { background: #f4f3ef; color: var(--side); font-weight: 600; }
.steps { counter-reset: step; list-style: none; margin: 14px 0 0; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 16px 46px; }
.steps li + li { border-top: 1px solid var(--line-2); padding-top: 14px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .9rem;
}
.steps li + li::before { top: 14px; }
.steps h3 { font-size: 1rem; margin-bottom: 4px; }
.steps p { margin-bottom: 4px; }
.guide-feedback { border: 2px solid #d9a441; }
.guide-feedback ol { padding-left: 20px; }
.guide-feedback li { margin-bottom: 6px; }
@media (max-width: 860px) {
  .guide-switch { grid-template-columns: 1fr; }
  .guide-demo { max-width: 200px; }
}
