/* ACE Diamond Office back office */
:root {
  --navy: #0b172e; --navy-2: #15264a; --navy-3: #22355c;
  --red: #d0202a; --red-dark: #a8141d;
  --ink: #16202f; --ink-2: #3c4657; --muted: #6b7484;
  --bg: #f4f2ec; --panel: #ffffff; --line: #e3ded2; --line-2: #efebe2; --hover: #faf8f3;
  --good: #1d7a4b; --good-bg: #e2f3ea; --warn: #8a5a00; --warn-bg: #fff0d2; --bad: #b3141e; --bad-bg: #fde4e5; --info: #1e4f9a; --info-bg: #e3ecfb;
  --wa: #1fa855;
  --radius: 8px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Public Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --side: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 400 14px/1.5 var(--body); -webkit-text-size-adjust: 100%; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; line-height: 1.15; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Layout */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #c3cbdb; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; text-decoration: none; }
.side-brand img { width: 118px; }
.side-brand span { font: 600 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #ff6b6b; border: 1px solid rgba(255,107,107,.5); border-radius: 4px; padding: 4px 6px; }
.side nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 1px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; text-decoration: none; font-weight: 500; color: #c3cbdb; }
.side nav a svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.side nav a:hover { background: var(--navy-2); color: #fff; }
.side nav a.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.side .count { margin-left: auto; background: var(--red); color: #fff; font: 700 11px/1 var(--body); padding: 3px 7px; border-radius: 999px; }
.side-label { font: 600 10.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .14em; color: #6f7c96; padding: 16px 10px 6px; }
.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.who { display: flex; gap: 10px; align-items: center; }
.who b { color: #fff; display: block; font-size: 13px; }
.who small { color: #8d99b1; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-3); color: #fff; display: grid; place-items: center; font: 700 12px/1 var(--body); flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; background: rgba(244,242,236,.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 24px; }
.top .menu { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search > svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 40px -16px rgba(11,23,46,.3); max-height: 60vh; overflow: auto; z-index: 40; }
.search-results a { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; text-decoration: none; border-bottom: 1px solid var(--line-2); }
.search-results a:hover, .search-results a:focus { background: var(--hover); }
.search-results .k { font: 600 10.5px/1.6 var(--mono); color: var(--muted); text-transform: uppercase; }
.new-wrap { position: relative; margin-left: auto; }
.new-menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 40px -16px rgba(11,23,46,.3); padding: 4px; min-width: 160px; z-index: 40; display: flex; flex-direction: column; }
.new-menu[hidden], .search-results[hidden], .count[hidden] { display: none; }
.new-menu button { text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 5px; font: inherit; cursor: pointer; }
.new-menu button:hover { background: var(--hover); }
main { padding: 24px; max-width: 1400px; width: 100%; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(11,23,46,.45); }
  .top { padding: 10px 16px; }
  .top .menu { display: grid; }
  main { padding: 16px; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: 600 13px/1.2 var(--body); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s ease, border-color .12s ease; }
.btn:hover { background: var(--hover); border-color: #d2ccbe; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { background: #178c46; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--ink); font-size: 16px; }
.icon-btn:hover { background: rgba(11,23,46,.06); }
.icon-btn svg { width: 22px; height: 22px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font: 600 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--red); text-decoration: none; display: inline-block; margin-bottom: 8px; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.panel > header p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.panel .pad { padding: 14px 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
@media (max-width: 1100px) { .g-main { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 16px; align-content: start; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; display: block; }
a.kpi:hover { border-color: #cfc8b8; }
.kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .v { font: 800 1.7rem/1.1 var(--display); margin: 6px 0 2px; letter-spacing: -.02em; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi .s b { color: var(--bad); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font: 600 11px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fcfbf8; position: sticky; top: 0; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: var(--hover); }
.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.t .sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font: 600 11.5px/1 var(--body); padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.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: #eeebe4; color: #5d6574; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: #eeebe4; color: var(--ink-2); margin: 1px 2px 1px 0; }
.chip.lang { background: var(--navy); color: #fff; font-family: var(--mono); font-size: 10.5px; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 11px; font: 600 12.5px/1 var(--body); cursor: pointer; color: var(--ink-2); border-right: 1px solid var(--line-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }
select, input, textarea { font: inherit; color: var(--ink); }
.filters select, .filters input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

/* Attention list */
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line-2); }
.attn li:last-child { border-bottom: 0; }
.attn .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.attn .ic svg { width: 16px; height: 16px; }
.attn .ic.bad { background: var(--bad-bg); color: var(--bad); }
.attn .ic.warn { background: var(--warn-bg); color: var(--warn); }
.attn .ic.info { background: var(--info-bg); color: var(--info); }
.attn .tx { flex: 1; min-width: 0; }
.attn .tx b { font-weight: 600; }
.attn .tx small { display: block; color: var(--muted); }

/* Agenda (today list) */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda li { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line-2); align-items: center; cursor: pointer; }
.agenda li:hover { background: var(--hover); }
.agenda li:last-child { border-bottom: 0; }
.agenda .time { font: 600 12.5px/1.2 var(--mono); }
.agenda .nm { display: block; }
.agenda small { color: var(--muted); display: block; }

/* Kanban (enquiries) */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #ebe7dd; border-radius: var(--radius); padding: 10px; min-height: 300px; display: flex; flex-direction: column; gap: 8px; }
.col.over { outline: 2px dashed var(--navy); outline-offset: -4px; }
.col > h3 { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 2px 4px 4px; }
.col > h3 span { font: 600 11px/1 var(--mono); color: var(--muted); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 10px 11px; cursor: grab; box-shadow: 0 1px 0 rgba(11,23,46,.04); }
.card:hover { border-color: #cfc8b8; }
.card.dragging { opacity: .4; }
.card .row1 { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.card b { font-weight: 600; }
.card .msg { margin: 6px 0; color: var(--ink-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card .acts { display: flex; gap: 6px; margin-top: 8px; }
.age { font: 500 11px/1 var(--mono); color: var(--muted); }
.age.hot { color: var(--bad); }

/* Schedule */
.sched-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.weekstrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.weekstrip button { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 7px 4px; cursor: pointer; font: inherit; text-align: center; }
.weekstrip button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.weekstrip button .d { font: 600 11px/1 var(--mono); text-transform: uppercase; opacity: .7; }
.weekstrip button .n { font: 700 15px/1.3 var(--display); }
.weekstrip button .c { font-size: 11px; opacity: .75; }
.sched-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .sched-wrap { grid-template-columns: 1fr; } }
.cal { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 230px); }
.cal-grid { display: grid; position: relative; min-width: 100%; }
.cal-h { position: sticky; top: 0; z-index: 3; background: #fcfbf8; border-bottom: 1px solid var(--line); padding: 8px 10px; font-weight: 600; font-size: 12.5px; display: flex; gap: 8px; align-items: center; border-left: 1px solid var(--line-2); min-height: 48px; }
.cal-h small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.cal-h.corner { position: sticky; left: 0; z-index: 4; border-left: 0; }
.cal-times { position: sticky; left: 0; z-index: 2; background: #fff; }
.cal-times div { height: 60px; font: 500 11px/1 var(--mono); color: var(--muted); padding: 4px 8px 0 0; text-align: right; border-top: 1px solid var(--line-2); }
.cal-col { position: relative; border-left: 1px solid var(--line-2); background-image: repeating-linear-gradient(to bottom, var(--line-2) 0 1px, transparent 1px 60px), repeating-linear-gradient(to bottom, transparent 0 30px, #f7f5f0 30px 31px, transparent 31px 60px); }
.cal-col.over { background-color: #f3f7ff; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--red); z-index: 2; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.ev { position: absolute; left: 4px; right: 4px; border-radius: 6px; padding: 5px 7px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; border-left: 3px solid; background: var(--info-bg); border-color: var(--info); color: #102a52; }
.ev:hover { filter: brightness(.97); box-shadow: 0 4px 12px -4px rgba(11,23,46,.25); }
.ev b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .tm { font: 500 10.5px/1.3 var(--mono); opacity: .8; }
.ev .st { font-size: 10.5px; opacity: .85; }
.ev.good { background: var(--good-bg); border-color: var(--good); color: #0f4a2c; }
.ev.warn { background: var(--warn-bg); border-color: #c98a00; color: #5a3b00; }
.ev.muted { background: #eeebe4; border-color: #9aa1ad; color: #444; }
.ev.dragging { opacity: .4; }
.tray { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.tray header { padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.tray header p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.tray .items { padding: 10px; display: grid; gap: 8px; }
.tray .card small { display: block; color: var(--muted); }

/* Drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; z-index: 70; transform: translateX(100%); transition: transform .22s ease; box-shadow: -20px 0 50px -20px rgba(11,23,46,.35); display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-close { position: absolute; right: 10px; top: 10px; z-index: 2; }
.drawer-body { overflow-y: auto; flex: 1; }
.scrim { position: fixed; inset: 0; background: rgba(11,23,46,.35); z-index: 65; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.d-head { padding: 20px 56px 16px 22px; border-bottom: 1px solid var(--line-2); background: #fcfbf8; }
.d-head .k { font: 600 11px/1 var(--mono); color: var(--muted); letter-spacing: .08em; }
.d-head h2 { font-size: 1.35rem; margin: 6px 0 4px; }
.d-sec { padding: 16px 22px; border-bottom: 1px solid var(--line-2); }
.d-sec > h3 { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.steps { display: flex; gap: 4px; }
.steps button { flex: 1; border: 1px solid var(--line); background: #fff; padding: 8px 4px; font: 600 12px/1.2 var(--body); cursor: pointer; border-radius: 6px; color: var(--muted); }
.steps button.done { background: var(--good-bg); border-color: #b9e0c9; color: var(--good); }
.steps button.cur { background: var(--navy); border-color: var(--navy); color: #fff; }
.find-row { display: grid; grid-template-columns: 1fr 130px 28px; gap: 6px; margin-bottom: 6px; }
.find-row input, .find-row select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; width: 100%; background: #fff; }
.find-row .note { grid-column: 1 / 3; }
.find-block { padding: 8px; border: 1px solid var(--line-2); border-radius: 7px; margin-bottom: 8px; background: #fcfbf8; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.photos label { aspect-ratio: 1; border: 1.5px dashed var(--line); border-radius: 6px; display: grid; place-items: center; color: var(--muted); cursor: pointer; font-size: 12px; text-align: center; }
.sig { border: 1.5px dashed var(--line); border-radius: 7px; background: #fcfbf8; width: 100%; height: 130px; touch-action: none; display: block; }
.sig-img { max-height: 90px; border-bottom: 1px solid var(--line); }

/* Forms */
dialog { border: 0; padding: 0; border-radius: 12px; width: min(560px, calc(100vw - 24px)); box-shadow: 0 30px 80px -20px rgba(11,23,46,.5); }
dialog::backdrop { background: rgba(11,23,46,.45); }
.modal-card.wide { width: 100%; }
dialog:has(.modal-card.wide) { width: min(820px, calc(100vw - 24px)); }
.modal-form > header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-body { padding: 16px 20px; display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; }
.modal-form > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line-2); background: #fcfbf8; }
.f { display: grid; gap: 4px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.f input, .f select, .f textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-weight: 400; font-size: 14px; width: 100%; }
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(11,23,46,.1); }
.f small { font-weight: 400; color: var(--muted); }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .f2, .f3 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }

/* Line items editor */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font: 600 11px/1 var(--mono); text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 4px; }
.lines td { padding: 4px; }
.lines input { width: 100%; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; }
.lines .q { width: 70px; } .lines .p { width: 110px; } .lines .x { width: 32px; }
.totals { margin-left: auto; width: min(300px, 100%); display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.totals .g { font: 800 1.2rem/1.3 var(--display); border-top: 1px solid var(--line); padding-top: 6px; }

/* Customer page */
.c-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.c-head .avatar { width: 52px; height: 52px; font-size: 18px; background: var(--navy); }
.c-head .info { flex: 1; min-width: 220px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 16px 10px 36px; position: relative; border-bottom: 1px solid var(--line-2); }
.timeline li::before { content: ""; position: absolute; left: 16px; top: 15px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline li.job::before { background: var(--info); }
.timeline li.inv::before { background: var(--good); }
.timeline li.note::before { background: #c98a00; }
.timeline li.quote::before { background: var(--red); }
.timeline small { color: var(--muted); display: block; }

/* Stock bars */
.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; width: 120px; }
.bar i { display: block; height: 100%; background: var(--navy); border-radius: 3px; }
.bar.low i { background: var(--red); }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gl { stroke: var(--line-2); stroke-width: 1; }
.chart .ax { font: 500 11px var(--mono); fill: var(--muted); stroke: none; }
.chart .val { font: 600 11.5px var(--body); fill: var(--ink-2); stroke: none; }
.chart .mk { fill: var(--navy); stroke: none; transition: fill .12s ease; }
.chart .mk.cur { fill: var(--red); }
.chart .hit { fill: transparent; stroke: none; cursor: default; }
.chart .hit:hover + .mk, .chart .mk:hover { fill: #2a4478; }
.tip { position: fixed; z-index: 90; background: var(--navy); color: #fff; padding: 6px 9px; border-radius: 6px; font-size: 12px; pointer-events: none; opacity: 0; transition: opacity .1s ease; white-space: nowrap; }
.tip.show { opacity: 1; }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: 170px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .track { height: 14px; border-radius: 0 4px 4px 0; background: transparent; }
.hbar .fill { height: 100%; background: var(--navy); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 600px) { .hbar { grid-template-columns: 110px 1fr 70px; } }

/* Team */
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.member { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.member .top-row { display: flex; gap: 12px; align-items: center; }
.member .avatar { width: 42px; height: 42px; background: var(--navy); }
.member .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.member .stats div { background: #fcfbf8; border: 1px solid var(--line-2); border-radius: 6px; padding: 6px; }
.member .stats b { display: block; font: 700 1.1rem/1.2 var(--display); }
.member .stats small { color: var(--muted); font-size: 11px; }
.util { height: 6px; background: var(--line-2); border-radius: 3px; overflow: hidden; }
.util i { display: block; height: 100%; background: var(--navy); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 12px; font: 600 13px/1 var(--body); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--red); }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Printable docs (quote / invoice / report) */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid var(--navy); padding-bottom: 14px; margin-bottom: 16px; }
.doc-head img { width: 150px; }
.tpl { width: 100%; min-height: 80px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font: 13px/1.5 var(--body); resize: vertical; }
@media print {
  .side, .top, .no-print, .drawer, .scrim { display: none !important; }
  .app { display: block; } main { padding: 0; } .doc { border: 0; padding: 0; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ================= Mobile app layout ================= */
.tabbar, .m-brand, .sheet, .sheet-scrim { display: none; }
.m-only { display: none; }
.actbar, .page-actbar { display: none; }
@media (max-width: 900px) {
  :root { --tab-h: 64px; }
  .desk-only { display: none !important; }
  .m-only { display: revert; }
  body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
  .side { display: none; }
  .top { padding: 8px 12px; gap: 10px; }
  .top .menu, .new-wrap { display: none; }
  .m-brand { display: block; flex: none; }
  .m-brand img { height: 34px; width: auto; }
  .search { max-width: none; }
  .search input { padding: 9px 10px 9px 32px; font-size: 16px; } /* 16px stops iOS zoom */
  main { padding: 14px 12px 20px; }
  h1 { font-size: 1.4rem; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-head > .btn, .page-head > .btn-row { width: 100%; }
  .page-head .btn-row .btn { flex: 1; }
  .kpis { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -12px 14px; padding: 0 12px 2px; scrollbar-width: none; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpis > .kpi { flex: 0 0 44%; scroll-snap-align: start; }
  .kpi { padding: 11px 12px; }
  .kpi .v { font-size: 1.3rem; }
  .g-main > :last-child { order: -1; } /* Today: jobs before the attention list */
  .panel > header { padding: 12px 14px; }
  .attn li { padding: 10px 14px; align-items: flex-start; }
  .agenda li { grid-template-columns: 56px 1fr; padding: 11px 14px; }
  .agenda li > .badge { grid-column: 2; justify-self: start; }
  input, select, textarea { font-size: 16px !important; }
  .btn { padding: 10px 14px; }
  .btn.sm { padding: 7px 10px; }

  /* Tables become stacked cards */
  .table-wrap { overflow: visible; }
  table.t, .t tbody, .t tr, .t td { display: block; width: 100%; }
  .t thead { display: none; }
  .t tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); position: relative; }
  .t td { border: 0; padding: 1px 0; }
  .t td:empty { display: none; }
  .t .num { text-align: left; }
  .t td.mono:first-child { font-size: 11px; color: var(--muted); }
  .panel .t tbody tr:last-child { border-bottom: 0; }
  .d-sec .t tr { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 8px 0; }
  .d-sec .t td { width: auto; }

  /* Enquiries board: swipe between columns */
  .board { grid-auto-columns: 86%; scroll-snap-type: x mandatory; margin: 0 -12px; padding: 0 12px 8px; scroll-padding: 12px; }
  .col { scroll-snap-align: start; min-height: 60vh; }
  .filters { flex-wrap: wrap; }
  .filters input[type=search] { min-width: 0 !important; flex: 1 0 100%; }
  .filters select { flex: 1; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg button { white-space: nowrap; }
  .t td:has(> .na:only-child) { display: none; }
  .doc { overflow-x: hidden; }
  .lines { table-layout: fixed; }
  .lines input { min-width: 0; }
  [data-addsvc] { flex: 1 1 0; min-width: 0; max-width: 100%; }
  .doc-head img { width: 120px; }

  /* Drawer = full-screen page */
  .drawer { width: 100vw; padding-top: env(safe-area-inset-top); }
  .d-head { padding: 16px 52px 14px 16px; }
  .d-sec { padding: 14px 16px; }
  .kv { grid-template-columns: 92px 1fr; }
  .steps button { padding: 11px 2px; }
  .drawer .btn-row .btn { flex: 1 1 auto; }

  dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .modal-body { max-height: 66vh; }
  .modal-form > footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .modal-form > footer .btn { flex: 1; }
  .toast { bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); }

  /* Customer page */
  .c-head .btn-row { width: 100%; }
  .c-head .btn-row .btn { flex: 1 1 auto; }
  .doc { padding: 16px; }
  .totals { width: 100%; }
  .lines .p { width: 90px; } .lines .q { width: 56px; }

  /* Bottom tab bar */
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar > button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--tab-h);
    color: #7a8291; text-decoration: none; font: 600 10.5px/1 var(--body); background: none; border: 0; cursor: pointer; }
  .tabbar svg { width: 24px; height: 24px; }
  .tabbar .on { color: var(--navy); }
  .tabbar .on svg { stroke-width: 2.3; }
  .tabbar .on::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--red); }
  .tabbar .tab-plus { align-self: center; justify-self: center; width: 54px; height: 54px; border-radius: 18px; background: var(--red); color: #fff; margin-top: -22px;
    box-shadow: 0 10px 22px -8px rgba(208,32,42,.7); }
  .tabbar .tab-plus svg { width: 28px; height: 28px; stroke-width: 2.6; }
  .tabbar .tab-plus:active { transform: scale(.94); }
  .tabbar .tab-plus { overflow: visible; }
  .plus-label { position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 600 10.5px/1 var(--body); color: var(--red); }
  .tabbar .tab-plus { margin-bottom: 18px; }

  /* Page-level "+ New" buttons move into the contextual + */
  .page-head > .btn.primary { display: none; }

  /* Stacked cards: label/value rows */
  .t tbody td[data-label] { display: grid; grid-template-columns: 38% 1fr; gap: 8px; padding: 3px 0; align-items: baseline; }
  .t tbody td[data-label]::before { content: attr(data-label); font: 600 10.5px/1.5 var(--mono); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .t tbody td[data-label] > * { min-width: 0; }
  .t tbody td[data-label] > .badge { justify-self: start; }
  .doc-head > div:last-child { text-align: left !important; }
  .t tbody td.lead { font-size: 15px; padding-bottom: 6px; }
  .t tbody td[data-label].nowrap { white-space: normal; }

  /* Sticky action bars on detail screens */
  .drawer .actbar { display: flex; position: sticky; bottom: 0; z-index: 3; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
  .actbar .btn { flex: 1; padding: 13px 10px; font-size: 14px; }
  .actbar .btn.icon { flex: 0 0 48px; padding: 0; }
  .actbar .btn.icon svg { width: 20px; height: 20px; }
  .page-actbar { display: flex; flex-wrap: wrap; position: fixed; left: 10px; right: 10px; z-index: 49; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 30px); gap: 8px; padding: 8px; background: rgba(255,255,255,.97); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 30px -12px rgba(11,23,46,.35); }
  .page-actbar .btn { flex: 1 1 auto; padding: 12px 8px; }
  body:has(.page-actbar) main { padding-bottom: 120px; }
  .hide-m { display: none !important; }
  .tabbar .dot { position: absolute; top: 9px; left: calc(50% + 7px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
  .tabbar .dot.num { width: auto; height: auto; min-width: 18px; padding: 2px 5px; font: 700 10px/1 var(--body); color: #fff; font-style: normal; border-radius: 999px; top: 6px; }

  /* Bottom sheets */
  .sheet-scrim { display: block; position: fixed; inset: 0; background: rgba(11,23,46,.45); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  body.sheet-open .sheet-scrim { opacity: 1; pointer-events: auto; }
  .sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; background: #fff; border-radius: 18px 18px 0 0; transform: translateY(105%);
    transition: transform .25s cubic-bezier(.2,.8,.2,1); padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 85vh; overflow-y: auto; }
  body.sheet-open .sheet { transform: none; }
  .sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
  .sheet h2 { font-size: 1.05rem; margin: 2px 2px 12px; }
  .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .sheet-grid a, .sheet-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 14px; background: #f6f4ef;
    border: 0; text-decoration: none; color: var(--ink); font: 600 12.5px/1.2 var(--body); text-align: center; cursor: pointer; position: relative; }
  .sheet-grid a:active, .sheet-grid button:active { background: #ece8df; }
  .sheet-grid .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--navy); color: #fff; }
  .sheet-grid .ic svg { width: 22px; height: 22px; }
  .sheet-grid .ic.red { background: var(--red); }
  .sheet-grid .ic.green { background: var(--wa); }
  .sheet-grid em { position: absolute; top: 8px; right: 10px; font: 700 10px/1 var(--body); font-style: normal; background: var(--red); color: #fff; padding: 3px 6px; border-radius: 999px; }
  .sheet-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); display: flex; align-items: center; gap: 10px; }
  .sheet-foot .avatar { background: var(--navy); }

  /* Mobile schedule agenda */
  .weekstrip { gap: 4px; }
  .weekstrip button { padding: 6px 2px; }
  .weekstrip button .c { display: none; }
  .m-agenda { display: grid; gap: 10px; }
  .m-slot { display: grid; grid-template-columns: 54px 1fr; gap: 10px; }
  .m-slot .t { font: 600 12px/1.2 var(--mono); padding-top: 12px; text-align: right; color: var(--ink-2); }
  .m-slot .t small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }
  .m-job { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 10px; padding: 11px 12px; cursor: pointer; }
  .m-job.good { border-left-color: var(--good); } .m-job.warn { border-left-color: #c98a00; } .m-job.muted { border-left-color: #9aa1ad; }
  .m-job b { font-size: 15px; }
  .m-job .s { color: var(--muted); font-size: 13px; margin: 2px 0 6px; }
  .m-job .r { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
  .m-now { display: flex; align-items: center; gap: 8px; color: var(--red); font: 600 11px/1 var(--mono); }
  .m-now::after { content: ""; flex: 1; height: 2px; background: var(--red); }
  .m-techs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
  .m-techs button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font: 600 12.5px/1 var(--body); cursor: pointer; }
  .m-techs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
  .tray { margin-top: 16px; }
}

/* Language switch */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: #fff; flex: none; }
.lang-switch button { border: 0; background: none; padding: 6px 10px; border-radius: 999px; font: 600 12px/1 var(--body); color: var(--muted); cursor: pointer; }
.lang-switch button.on { background: var(--navy); color: #fff; }
.lang-switch.wide { display: flex; } .lang-switch.wide button { flex: 1; padding: 11px; font-size: 14px; }
#lang-slot { margin-left: auto; }
.top .new-wrap { margin-left: 0; }
@media (max-width: 900px) { .lang-switch:not(.wide) button { padding: 8px 7px; font-size: 11.5px; } }
/* Chinese UI */
:lang(zh-Hans) { --body: "Public Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; --display: "Bricolage Grotesque", "Noto Sans SC", "PingFang SC", sans-serif; }
:lang(zh-Hans) .t th, :lang(zh-Hans) .side-label, :lang(zh-Hans) .d-sec > h3 { letter-spacing: .02em; }

/* Print: last in the file so it beats the phone layout. An A4 page is under 900px wide, so the
   mobile rules (tab bar, floating action bar) would otherwise print too. */
.print-only { display: none; }
@media print {
  .tabbar, .m-brand, .actbar, .page-actbar, .sheet, .sheet-scrim, .toast, .lang-switch { display: none !important; }
  body { padding-bottom: 0 !important; }
  body:has(.page-actbar) main { padding-bottom: 0 !important; }
  .print-only { display: block !important; }
  .doc .hide-m { display: block !important; }
  .doc input, .doc select, .doc textarea { border: 0 !important; background: none !important; padding: 0 !important; min-height: 0 !important; color: inherit !important; -webkit-appearance: none; appearance: none; resize: none; }
  .doc table.t { display: table !important; }
  .doc .t thead { display: table-header-group !important; }
  .doc .t tbody { display: table-row-group !important; }
  .doc .t tr { display: table-row !important; padding: 0 !important; }
  .doc .t td, .doc .t th { display: table-cell !important; padding: 7px 10px !important; }
  .doc .t td::before { content: none !important; }
  .doc .t th { position: static; }
  .q-terms-p { white-space: pre-wrap; font-size: 12.5px; line-height: 1.5; margin-top: 6px; }
}
