/* Think Water Margins. Deliberately light only: white page, hairline structure, brand colour for data.
   Palette and type from the thinkwaterdarwin.com.au Elementor kit.
   Layout: sticky app bar; page header with filters; KPI row; 12-month trend; departments; averages;
   data notes. Chat is a right-hand panel (full screen on phones). */
:root {
  color-scheme: light;
  --navy: #002c47; --brand-blue: #019ddc; --brand-green: #72c267; --brand-sky: #b8d9f2;
  --bg: #ffffff; --subtle: #f6f8fa; --hover: #eef3f7;
  --ink: #0e2433; --ink-2: #4a5965; --muted: #7a8792;
  --line: #e6ebf0; --line-2: #d3dbe2;
  --accent: #0a74ad; --accent-ink: #ffffff;
  --series-1: #019ddc; --series-1-soft: #b9e0f3; --series-2: #72c267; --series-3: #d5dde4;
  --good: #1f7a35; --good-bg: #e7f4ea; --bad: #b42318; --bad-bg: #fdecea;
  --warn: #8a5a00; --warn-bg: #fff5e0;
  --shadow: 0 1px 2px rgba(14,36,51,.05), 0 1px 3px rgba(14,36,51,.06);
  --shadow-lg: 0 12px 40px rgba(14,36,51,.16);
  --radius: 10px;
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Poppins", "Roboto", system-ui, sans-serif;
}

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5 }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance }
h1 { font-size: 1.45rem } h2 { font-size: 1rem } h3 { font-size: 0.95rem }
a { color: var(--accent) }
.num { font-variant-numeric: tabular-nums }
.muted { color: var(--muted) }
[hidden] { display: none !important }
button, select, input, textarea { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }

/* ---- buttons and inputs ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); font-weight: 500; white-space: nowrap }
.btn:hover { background: var(--hover) }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff }
.btn.primary:hover { background: #0b3b5c }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2) }
.btn.ghost:hover { background: var(--hover) }
.btn[disabled] { opacity: .5; cursor: default }
.btn svg { width: 16px; height: 16px; flex: none }
.field { display: grid; gap: 4px }
.field label, .field-label { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted) }
#db button { min-height: 34px; padding: 4px 14px; font-size: 0.86rem }
#db button[data-db="training"][aria-pressed="true"] { background: var(--warn); color: #fff }
/* A thin amber rule under the app bar while training data is showing, so nobody mistakes it for live. */
body.on-training .appbar { border-bottom: 3px solid #f0b429 }
select, .input { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg) }
select { min-width: 168px; padding-right: 28px }

/* ---- app bar ---- */
.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(255,255,255,.96); backdrop-filter: saturate(1.4) blur(6px); border-bottom: 1px solid var(--line) }
.appbar-inner { max-width: 1240px; margin-inline: auto; padding-inline: 24px; height: 64px; display: flex; align-items: center; gap: 16px }
.appbar .logo { height: 34px; width: auto; display: block }
.appbar .divider { width: 1px; height: 28px; background: var(--line-2) }
.appbar .product { font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; color: var(--navy) }
.appbar .spacer { flex: 1 }
.appbar .user { color: var(--ink-2); font-size: 0.86rem }
.appbar form { margin: 0 }
.label-short { display: none }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: var(--subtle); color: var(--ink-2); border: 1px solid var(--line) }
.pill.training { background: var(--warn-bg); color: var(--warn); border-color: #f3dfb0 }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor }

/* ---- page ---- */
.page { max-width: 1240px; margin-inline: auto; padding-inline: 24px; padding-block: 28px 56px; display: grid; gap: 20px }
.page-head { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: flex-end; justify-content: space-between }
.page-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 62ch }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end }
.statusline { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 0.82rem; color: var(--muted); min-height: 20px; margin-top: -6px }
.statusline .state { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2) }
.statusline .state i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted) }
.statusline .state.live i { background: var(--good) }
.statusline .state.busy i { background: var(--brand-blue); animation: pulse 1.2s ease-in-out infinite }
.statusline .state.bad i { background: var(--bad) }
@keyframes pulse { 50% { opacity: .35 } }
.banner { background: var(--warn-bg); color: var(--warn); border: 1px solid #f3dfb0; border-radius: var(--radius); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between }

/* ---- cards ---- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; display: grid; gap: 14px; min-width: 0 }
.card-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; justify-content: space-between }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.82rem }
.card-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap }

/* ---- KPI row ---- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px }
.kpi { gap: 6px; padding: 16px 18px; display: flex; flex-direction: column }
.kpi .foot { margin-top: auto }
.kpi .label { font-size: 0.78rem; font-weight: 500; color: var(--ink-2) }
.kpi .value { font-family: var(--font-head); font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; color: var(--navy) }
.kpi .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; min-height: 32px }
.kpi .delta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0 }
.kpi .vs { font-size: 0.76rem; color: var(--muted); white-space: nowrap }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 0.76rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--subtle); color: var(--ink-2) }
.chip.up { background: var(--good-bg); color: var(--good) }
.chip.down { background: var(--bad-bg); color: var(--bad) }
.spark { width: 96px; height: 32px; flex: none; overflow: visible }
.spark path { fill: none; stroke: var(--series-1); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round }
.spark .area { fill: var(--series-1); fill-opacity: .08; stroke: none }
.spark circle { fill: var(--series-1); stroke: var(--bg); stroke-width: 2 }
.kpi.skeleton .value { color: var(--line-2) }
.kpi-note { font-size: 0.74rem; color: var(--warn); background: var(--warn-bg); border-radius: 6px; padding: 2px 8px; justify-self: start }
.warn-text { color: var(--warn); font-weight: 600 }

/* ---- trend chart ---- */
.trend-wrap { position: relative; min-height: 240px }
.trend-svg { display: block; width: 100%; height: 260px; overflow: visible }
.trend-svg .ly { fill: var(--series-3); pointer-events: none }
.trend-svg .hit { fill: transparent; cursor: pointer }
.trend-svg .grid { stroke: var(--line); stroke-width: 1 }
.trend-svg .base { stroke: var(--line-2); stroke-width: 1 }
.trend-svg .tick { fill: var(--muted); font-size: 11px; font-family: var(--font) }
.trend-svg .bar { fill: var(--series-1); cursor: pointer; transition: fill .15s }
.trend-svg .bar.current { fill: var(--accent) }
.trend-svg .bar.neg { fill: #f1b3ad }
.trend-svg .bar:hover, .trend-svg .bar:focus-visible { fill: var(--navy) }
.trend-svg .val { fill: var(--ink); font-size: 11px; font-weight: 600; font-family: var(--font) }

/* ---- department bars ---- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--ink-2) }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px }
.legend .s1 i { background: var(--series-1) } .legend .s2 i { background: var(--series-2) } .legend .s3 i { background: var(--series-3) }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden }
.seg button { border: 0; background: var(--bg); min-height: 30px; padding: 4px 12px; font-size: 0.8rem; font-weight: 500; color: var(--ink-2) }
.seg button + button { border-left: 1px solid var(--line-2) }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff }
.bars { display: grid; gap: 12px }
.row { display: grid; grid-template-columns: minmax(110px, 190px) 1fr; gap: 16px; align-items: center; min-width: 0 }
.row .name { font-weight: 500; overflow-wrap: anywhere; min-width: 0 }
.row .sub { display: block; font-size: 0.74rem; color: var(--muted); font-weight: 400 }
.track { display: grid; gap: 3px; min-width: 0 }
.bar { display: flex; align-items: center; gap: 8px; height: 14px; min-width: 0 }
.bar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; transition: width .35s ease }
.bar.cmp { height: 8px } .bar.cmp .fill { background: var(--series-2) }
.bar.neg .fill { background: var(--bad) }
.bar .lbl { font-size: 0.78rem; font-weight: 600; color: var(--ink) ; white-space: nowrap }
.bar.cmp .lbl { color: var(--muted); font-weight: 400; font-size: 0.72rem }
@media (prefers-reduced-motion: reduce) { .bar .fill, .trend-svg .bar { transition: none } .statusline .state.busy i { animation: none } }

/* ---- tables ---- */
.tablewrap { overflow-x: auto }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap }
th { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: var(--subtle) }
th:first-child, td:first-child { text-align: left }
tbody tr:hover td { background: #fafbfc }
tr.total td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0 }

.notes { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); font-size: 0.84rem }
.empty { color: var(--muted); padding: 24px 0; text-align: center }
.tip { position: fixed; z-index: 40; pointer-events: none; background: var(--navy); color: #fff; font-size: 0.78rem; padding: 8px 10px; border-radius: 8px; max-width: 260px; display: grid; gap: 2px; box-shadow: var(--shadow-lg) }
.tip b { font-weight: 600 }
.page-foot { border-top: 1px solid var(--line); padding-top: 16px; font-size: 0.78rem; color: var(--muted); display: grid; gap: 4px }

/* ---- chat panel ---- */
.chat { position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: grid; grid-template-rows: auto 1fr auto; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px) }
.chat-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line) }
.chat-head p { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem }
.chat-log { overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain }
.msg { max-width: 100%; min-width: 0 }
.msg.user { align-self: flex-end; max-width: 85%; background: var(--navy); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere }
.msg.bot { align-self: stretch; color: var(--ink); overflow-wrap: anywhere }
.msg.bot p { margin: 0 0 8px } .msg.bot p:last-child { margin-bottom: 0 }
.msg.bot h4 { font-size: 0.9rem; margin: 10px 0 4px }
.msg.bot ul, .msg.bot ol { margin: 0 0 8px; padding-left: 20px }
.msg.bot code { font-size: 0.85em; background: var(--subtle); padding: 1px 4px; border-radius: 4px }
.msg.bot .tablewrap { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 8px }
.msg.bot table { font-size: 0.8rem } .msg.bot th, .msg.bot td { padding: 6px 9px }
.msg.bot .err { color: var(--bad); background: var(--bad-bg); border-radius: 8px; padding: 8px 10px; margin-top: 6px }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px }
.step { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--ink-2); background: var(--subtle); border: 1px solid var(--line); padding: 2px 9px; border-radius: 999px }
.step::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--good) }
.step.running::before { background: var(--brand-blue); animation: pulse 1.2s ease-in-out infinite }
.typing { display: inline-flex; gap: 4px; padding: 4px 0 }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); animation: pulse 1s ease-in-out infinite }
.typing span:nth-child(2) { animation-delay: .15s } .typing span:nth-child(3) { animation-delay: .3s }
.chat-empty { display: grid; gap: 12px; color: var(--ink-2); font-size: 0.86rem }
.suggest { display: grid; gap: 8px }
.suggest button { text-align: left; border: 1px solid var(--line-2); background: var(--bg); border-radius: 10px; padding: 9px 12px; color: var(--ink) }
.suggest button:hover { background: var(--hover); border-color: var(--brand-sky) }
.chat-form { border-top: 1px solid var(--line); padding: 12px 16px 10px; display: grid; gap: 6px }
.composer { display: flex; gap: 8px; align-items: flex-end; border: 1px solid var(--line-2); border-radius: 12px; padding: 6px 6px 6px 12px; background: var(--bg) }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,116,173,.12) }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; min-height: 24px; max-height: 140px; padding: 6px 0; background: transparent; line-height: 1.4 }
.composer .btn { min-height: 34px; padding: 6px 12px }
.chat-foot { margin: 0; font-size: 0.72rem; color: var(--muted) }
.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(14,36,51,.18) }
.btn.icon { padding: 6px 8px; min-width: 36px; justify-content: center }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 0.8rem }
.btn.stop { background: var(--bad); border-color: var(--bad) }
.btn.stop:hover { background: #8f1c13 }
.chat-tools { display: flex; gap: 2px; align-items: center; flex: none }
.chat-title { min-width: 0 }
#fullChat .i-shrink, #fullChat[aria-pressed="true"] .i-expand { display: none }
#fullChat[aria-pressed="true"] .i-shrink { display: block }
#chatMic.on { color: var(--bad); background: var(--bad-bg) }
#chatMic.on svg { animation: pulse 1.2s ease-in-out infinite }
.chat-empty .hello h3 { font-size: 1.05rem; color: var(--navy); margin-bottom: 4px }
.chat-empty .hello p { margin: 0 }
.msg-actions { display: flex; gap: 6px; margin-top: 6px }
.msg-actions button, .ttools button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 2px 10px; font-size: 0.74rem; color: var(--ink-2) }
.msg-actions button:hover, .ttools button:hover { background: var(--hover); border-color: var(--line-2) }
.ttools button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff }
.answer-table { margin: 8px 0 10px; display: grid; gap: 6px }
.answer-table .tablewrap { margin: 0 }
.ttools { display: flex; flex-wrap: wrap; gap: 6px }
.mini-chart { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; background: var(--subtle) }
.mini-title { font-size: 0.72rem; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--muted) }
.mini-row { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 0.8rem }
.mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.mini-track { height: 12px; background: var(--bg); border-radius: 3px; overflow: hidden }
.mini-track i { display: block; height: 100%; background: var(--series-1); border-radius: 3px }
.mini-track i.neg { background: var(--bad) }
.mini-val { color: var(--ink-2); white-space: nowrap }
kbd { font: 500 0.7rem var(--font); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--subtle) }
.ask-hint { color: var(--accent) }
#servicesTable td .sub { display: block; font-size: 0.74rem; color: var(--muted) }
#servicesTable tr.overdue td:first-child { color: var(--bad); font-weight: 500 }
#servicesTable td { vertical-align: top }
#servicesTable th, #servicesTable td:not(.num) { text-align: left }
.bars .row[data-dept], #deptTable tr[data-dept] { cursor: pointer }
.bars .row[data-dept]:hover .name { color: var(--accent) }
#deptTable tr[data-dept]:hover td { background: var(--hover) }

/* Full-screen chat: the whole window, answers in a comfortable reading column. */
.chat.full { width: 100vw; border-left: 0; box-shadow: none; z-index: 40 }
.chat.full .chat-head { padding-inline: max(20px, calc((100vw - 880px) / 2)) }
.chat.full .chat-log { padding-inline: max(20px, calc((100vw - 880px) / 2)); padding-block: 28px; gap: 20px; font-size: 0.95rem }
.chat.full .chat-form { padding-inline: max(16px, calc((100vw - 880px) / 2)); padding-bottom: 16px }
.chat.full .msg.bot table { font-size: 0.86rem }
.chat.full .suggest { grid-template-columns: repeat(2, minmax(0, 1fr)) }
body.chat-full { overflow: hidden }
.print-head { display: none }

/* ---- section tabs (Margins / Project) ---- */
.tabs { display: flex; gap: 4px; align-items: center }
.tabs a { font-family: var(--font-head); font-weight: 600; font-size: 0.92rem; color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px }
.tabs a:hover { background: var(--hover); color: var(--navy) }
.tabs a[aria-current="page"] { color: var(--navy); background: var(--subtle); box-shadow: inset 0 -2px 0 var(--brand-blue) }

/* ---- project board ---- */
.board-wrap { max-width: 1400px }
.board-stats { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; display: grid; min-width: 92px; background: var(--bg) }
.stat b { font-family: var(--font-head); font-size: 1.3rem; color: var(--navy); line-height: 1.2 }
.stat span { font-size: 0.74rem; color: var(--muted) }
.stat.wide { display: flex; gap: 10px; align-items: center }
.ring { --p: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand-green) calc(var(--p) * 1%), var(--line) 0) }
.ring b { width: 34px; height: 34px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 0.72rem !important }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start }
.col { background: var(--subtle); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; min-width: 0 }
.col header { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: center; padding: 2px 4px }
.col header h2 { font-size: 0.95rem }
.col header p { grid-column: 1 / -1; margin: 0; font-size: 0.74rem; color: var(--muted) }
.col .count { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px }
.col-doing header h2 { color: var(--accent) }
.col-done header h2 { color: var(--good) }
.col-feedback { background: #f3f9fd }
.col-list { display: grid; gap: 8px }
.col-empty { font-size: 0.8rem; color: var(--muted); padding: 10px 6px; border: 1px dashed var(--line-2); border-radius: 8px; text-align: center }
.ticket { text-align: left; display: grid; gap: 6px; width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); color: var(--ink) }
.ticket:hover { border-color: var(--brand-sky); box-shadow: 0 2px 8px rgba(14,36,51,.08) }
.ticket.done { box-shadow: none }
.ticket.done .t-title { color: var(--ink-2) }
.t-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center }
.tid { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums }
.t-title { font-weight: 500; line-height: 1.35; display: flex; gap: 6px; align-items: flex-start }
.t-title .tick { width: 16px; height: 16px; flex: none; color: var(--good); margin-top: 1px }
.t-latest { font-size: 0.8rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden }
.t-bar, .d-progress { display: flex; gap: 8px; align-items: center }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden }
.progress i { display: block; height: 100%; background: var(--brand-blue); border-radius: 999px; transition: width .3s ease }
.col-done .progress i, .d-progress .progress i[style*="100%"] { background: var(--brand-green) }
.pct { font-size: 0.74rem; color: var(--ink-2); min-width: 32px; text-align: right }
.t-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 0.72rem; color: var(--muted) }
.t-comments { display: inline-flex; gap: 4px; align-items: center }
.t-comments svg { width: 12px; height: 12px }
.tag { font-size: 0.7rem; font-weight: 500; border-radius: 999px; padding: 1px 8px; border: 1px solid transparent; white-space: nowrap }
.tag.wait { background: var(--warn-bg); color: var(--warn); border-color: #f3dfb0 }
.tag.fb { background: #e6f4fb; color: var(--accent); border-color: var(--brand-sky) }
.tag.where { background: var(--subtle); color: var(--ink-2); border-color: var(--line-2) }

.drawer { position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); display: grid; grid-template-rows: auto 1fr auto; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px) }
.drawer-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line) }
.drawer-title { display: grid; gap: 6px; min-width: 0 }
.drawer-title h2 { font-size: 1.1rem; overflow-wrap: anywhere }
.drawer-title .tags { display: flex; flex-wrap: wrap; gap: 6px }
.drawer-body { overflow-y: auto; padding: 16px 20px; display: grid; gap: 14px; align-content: start }
.drawer-body h3 { font-size: 0.85rem; color: var(--ink-2); margin-top: 4px }
.d-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere }
.manage { display: grid; gap: 10px; border: 1px solid var(--line); background: var(--subtle); border-radius: 10px; padding: 12px }
.manage label { display: grid; gap: 4px }
.manage-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end }
.manage-row .grow { flex: 1; min-width: 160px }
.manage select { min-width: 140px }
.manage input[type=range] { width: 100%; accent-color: var(--brand-blue) }
.manage .input, .drawer-form textarea, .modal .input { width: 100%; font: inherit }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px }
.timeline li { border-left: 2px solid var(--line-2); padding: 0 0 0 12px }
.timeline li.u-comment { border-left-color: var(--brand-blue) }
.timeline li.u-note { border-left-color: var(--brand-green) }
.u-head { display: flex; gap: 8px; align-items: baseline; font-size: 0.78rem; color: var(--muted) }
.u-head b { color: var(--ink); font-weight: 500 }
.u-del { margin-left: auto; border: 0; background: none; padding: 0 2px; font-size: 0.74rem; color: var(--muted); opacity: 0; transition: opacity .15s }
.timeline li:hover .u-del, .u-del:focus-visible { opacity: 1 }
.u-del:hover { color: var(--bad); text-decoration: underline }
@media (hover: none) { .u-del { opacity: 1 } }
.danger-row { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 12px }
.btn.danger { color: var(--bad) }
.btn.danger:hover { background: var(--bad-bg) }
.u-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.88rem }
.timeline li.u-created .u-text, .timeline li.u-moved .u-text, .timeline li.u-progress .u-text { color: var(--ink-2); font-size: 0.82rem }
.drawer-form { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 6px }
.drawer-form textarea { border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; resize: vertical; min-height: 44px }
.row-end { display: flex; gap: 10px; align-items: center; justify-content: flex-end }
.form-msg { font-size: 0.8rem; color: var(--ink-2); margin-right: auto }
.modal { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink) }
.modal::backdrop { background: rgba(14,36,51,.28) }
.modal form { display: grid; gap: 8px; padding: 22px }
.modal h2 { font-size: 1.15rem }
.modal p { margin: 0 0 6px }
.modal .row-end { margin-top: 8px }
.modal select { width: 100% }
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)) } }

/* ---- navigation, overview and polish (Oct 2026 redesign) ---- */
.stepper { display: flex; align-items: stretch; gap: 4px }
.stepper .btn.icon { min-height: 36px; padding: 6px 8px }
.stepper select { min-width: 150px }
.sectionnav { position: sticky; top: calc(64px + env(safe-area-inset-top, 0px)); z-index: 15; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 8px 0; margin: -8px 0 -6px; background: linear-gradient(var(--bg) 78%, rgba(255,255,255,0)) }
.sectionnav::-webkit-scrollbar { display: none }
.sectionnav a { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 500; color: var(--ink-2); text-decoration: none; border: 1px solid var(--line); background: var(--bg) }
.sectionnav a:hover { border-color: var(--line-2); color: var(--navy) }
.sectionnav a[aria-current="true"] { background: var(--navy); border-color: var(--navy); color: #fff }
.sectionnav .count { background: var(--warn); color: #fff; border-radius: 999px; font-size: 0.68rem; padding: 0 6px; line-height: 1.5 }
.sectionnav a[aria-current="true"] .count { background: #fff; color: var(--navy) }
main.page > section[id], .overview { scroll-margin-top: 124px }
.overview { display: grid; gap: 14px }
.glance { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px }
.insight { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 0.86rem; line-height: 1.4; box-shadow: var(--shadow); transition: border-color .15s, transform .15s }
.insight:hover { border-color: var(--brand-sky); transform: translateY(-1px) }
.insight svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: currentColor; padding: 3px; border-radius: 6px; box-sizing: content-box }
.insight b { font-weight: 600; color: var(--navy) }
.insight.good svg { color: var(--good); background: var(--good-bg) }
.insight.bad svg { color: var(--bad); background: var(--bad-bg) }
.insight.warn svg { color: var(--warn); background: var(--warn-bg) }
.insight.neutral svg { color: var(--accent); background: #e6f4fb }
.card-foot { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted) }
.tag.new { background: var(--good-bg); color: var(--good); border-color: #bfe3c7; font-size: 0.66rem; padding: 0 6px }
.linklike { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 0.8rem; color: var(--ink-2); cursor: pointer }
.check input { accent-color: var(--navy); width: 15px; height: 15px }
#servicesTable td.wrap { white-space: normal; min-width: 140px }
#servicesTable td.wrap:nth-child(4) { min-width: 220px }
select.follow { min-width: 132px; min-height: 30px; padding: 3px 26px 3px 8px; font-size: 0.8rem }
#servicesTable tr.done td { color: var(--muted) }
#servicesTable tr.done td a { color: var(--muted) }
#servicesTable a { color: var(--accent); text-decoration: none }
#servicesTable a:hover { text-decoration: underline }
#deptTable th, #avgTable th { cursor: pointer; user-select: none }
#deptTable th:hover, #avgTable th:hover { color: var(--navy) }
th[aria-sort="descending"]::after { content: " ↓" }
th[aria-sort="ascending"]::after { content: " ↑" }

/* Loading skeletons: a soft shimmer in the shape of what is coming. */
.skel { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--subtle) 25%, #e9eef3 37%, var(--subtle) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite }
@keyframes shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }
.skel-num { width: 60%; height: 30px; margin: 2px 0 }
.skel-line { width: 45%; height: 14px }
.skel-chart { height: 240px; border-radius: 10px }
.skel-chip { height: 56px; border-radius: var(--radius) }
.skel-bars { display: grid; gap: 14px; padding: 6px 0 }
.skel-bar { height: 22px }
.skel-bar:nth-child(2) { width: 82% } .skel-bar:nth-child(3) { width: 64% } .skel-bar:nth-child(4) { width: 41% }
.skel-note { margin: 4px 0 0; font-size: 0.78rem; color: var(--muted) }
@media (prefers-reduced-motion: reduce) { .skel { animation: none } .insight { transition: none } }

/* Toasts */
.toasts { position: fixed; z-index: 60; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none }
.toast { background: var(--navy); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 0.86rem; box-shadow: var(--shadow-lg); animation: toast-in .2s ease-out; transition: opacity .3s, transform .3s }
.toast.bad { background: var(--bad) }
.toast.out { opacity: 0; transform: translateY(8px) }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) } }

/* Keyboard shortcuts */
.keylist { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; margin: 6px 0 4px; align-items: center }
.keylist dt { text-align: right } .keylist dd { margin: 0; color: var(--ink-2) }
.keylist kbd { font-size: 0.8rem; padding: 1px 6px }

/* ---- sign-in ---- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--subtle) }
.signin-card { width: min(420px, 100%); background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 26px; display: grid; gap: 16px }
.signin-card .logo { height: 40px; width: auto }
.signin-card p { margin: 0; color: var(--ink-2) }
.signin-card form { display: grid; gap: 12px }
.signin-card .input { width: 100%; min-height: 42px }
.signin-card .btn { justify-content: center; min-height: 42px }
.signin-foot { width: min(420px, 100%); margin-top: 14px; font-size: 0.78rem; color: var(--muted); display: grid; gap: 2px; text-align: center }
.form-error { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; margin: 0 }

/* ---- responsive ---- */
@media (max-width: 980px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
@media (max-width: 640px) {
  .appbar-inner, .page { padding-inline: 16px }
  .appbar-inner { gap: 8px }
  .appbar .divider, .appbar .product, .appbar .user { display: none }
  /* Tabs drop to their own full-width row under the logo and actions. */
  .appbar-inner { flex-wrap: wrap; height: auto; padding-block: 8px 0; row-gap: 4px }
  .tabs { order: 10; width: 100%; gap: 0; border-top: 1px solid var(--line) }
  .tabs a { flex: 1; text-align: center; padding: 9px 8px; border-radius: 0 }
  .tabs a[aria-current="page"] { background: transparent; box-shadow: inset 0 -2px 0 var(--brand-blue) }
  .kanban { grid-template-columns: 1fr }
  .sectionnav { top: calc(100px + env(safe-area-inset-top, 0px)) }
  main.page > section[id], .overview { scroll-margin-top: 160px }
  .glance { grid-template-columns: 1fr }
  /* Service reminders as stacked cards: one per machine, labels beside the values. */
  #servicesTable table, #servicesTable tbody, #servicesTable tr, #servicesTable td { display: block; width: 100% }
  #servicesTable thead { display: none }
  #servicesTable tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px }
  #servicesTable td { border: 0; padding: 4px 0; text-align: left !important; display: grid; grid-template-columns: 84px 1fr; gap: 8px; white-space: normal; min-width: 0 }
  #servicesTable td::before { content: attr(data-label); font-size: 0.7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding-top: 2px }
  #servicesTable .tablewrap, #servicesTable { overflow: visible }
  .stepper select { min-width: 0; flex: 1 }
  .filters .field { flex: 1 1 100% }
  .filters > .btn { flex: 1 }
  .board-page .appbar .btn.primary span { display: none }
  .board-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100% }
  .stat { min-width: 0 }
  .stat.wide { grid-column: 1 / -1 }
  .label-long { display: none } .label-short { display: inline }
  .appbar .btn { padding-inline: 10px }
  .appbar .logo { height: 28px }
  .kpis { gap: 10px }
  .kpi { padding: 14px }
  .kpi .value { font-size: 1.35rem }
  .spark { display: none }
  .row { grid-template-columns: minmax(92px, 120px) 1fr; gap: 10px }
  select { min-width: 140px }
  .chat { width: 100vw; border-left: 0 }
  #fullChat, .kbd-hint, #deptCsv { display: none }
  .chat.full .suggest { grid-template-columns: 1fr }
}

/* ---- printed report (Report button, or Save as PDF) ---- */
@media print {
  @page { size: A4; margin: 14mm }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact }
  body { font-size: 11px }
  .appbar, .filters, .statusline, .banner, .chat, .scrim, .tip, .card-tools .seg, #deptCsv, #servicesCsv, .check, .ask-hint, .page-head p, .sectionnav, .toasts { display: none !important }
  .insight { box-shadow: none; transform: none }
  .skel { animation: none }
  .page { padding: 0; max-width: none; gap: 12px }
  .print-head { display: flex; gap: 16px; align-items: center; border-bottom: 2px solid var(--navy); padding-bottom: 10px }
  .print-head img { height: 30px; width: auto }
  .print-head strong { display: block; font-family: var(--font-head); font-size: 1.2rem; color: var(--navy) }
  .print-head span { color: var(--ink-2) }
  .page-head { display: none }
  .card { box-shadow: none; break-inside: avoid; padding: 12px 14px }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 8px }
  #deptChart[hidden] { display: grid !important }
  #deptTable[hidden] { display: block !important; margin-top: 8px }
  .bars .row { cursor: default }
  .page-foot { font-size: 9px }
}

/* ---- contacts (CRM preview) ---- */
.crm-wrap { max-width: 1040px }
.crm-wrap h1 .pill { vertical-align: middle; margin-left: 6px }
.capture-form { display: grid; gap: 10px }
.capture-form textarea { width: 100%; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; resize: vertical; min-height: 72px }
.capture-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center }
.capture-actions label.btn { cursor: pointer }
.capture-actions .form-msg { flex: 1; min-width: 140px }
.review { display: grid; gap: 12px; border: 1px solid var(--brand-sky); background: #f3f9fd; border-radius: 10px; padding: 14px }
.review-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap }
.review-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px }
.review label { display: grid; gap: 4px; min-width: 0 }
.review label span { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted) }
.review .input, .review select { width: 100% }
.review textarea.input { resize: vertical; min-height: 56px }
.card-photo { max-width: min(320px, 100%); border-radius: 8px; border: 1px solid var(--line) }
.crm-tabs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between }
.crm-tabs .input { width: min(280px, 100%) }
.crm-view { display: grid; gap: 14px }
.count { font-size: 0.74rem; font-weight: 600; color: var(--ink-2); background: var(--subtle); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: 4px }
.seg button[aria-pressed="true"] .count { background: rgba(255,255,255,.15); color: #fff; border-color: transparent }
.fu-list { list-style: none; margin: 0; padding: 0; display: grid }
.fu { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line) }
.fu:first-child { border-top: 0 }
.fu input[type=checkbox] { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand-green) }
.fu-main { display: grid; gap: 2px; min-width: 0 }
.fu-action { font-weight: 500; overflow-wrap: anywhere }
.fu .sub { font-size: 0.8rem; color: var(--muted) }
.fu .late { color: var(--bad); font-weight: 500 }
.fu.done .fu-action { text-decoration: line-through; color: var(--muted) }
.done-list summary { list-style: none; cursor: pointer }
.done-list summary::-webkit-details-marker { display: none }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px }
.contact { text-align: left; gap: 6px; cursor: pointer; font: inherit; color: inherit }
.contact:hover { border-color: var(--line-2); background: var(--subtle) }
.c-name { font-family: var(--font-head); font-weight: 600 }
.contact .sub { color: var(--ink-2); font-size: 0.82rem }
.contact .tags, .trip-people { display: flex; flex-wrap: wrap; gap: 6px }
.c-next { font-size: 0.8rem; color: var(--ink-2) }
.trip-people .chip { border: 1px solid var(--line); cursor: pointer }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 }
.kv dt { color: var(--muted); font-size: 0.8rem }
.kv dd { margin: 0; overflow-wrap: anywhere }
.row-start { display: flex; gap: 8px; flex-wrap: wrap }
.add-fu { display: flex; flex-wrap: wrap; gap: 8px }
.add-fu #fuAction { flex: 1 1 180px }
@media (max-width: 640px) { .crm-tabs .input { width: 100% } .capture-actions .btn.primary { margin-left: auto } }

/* ---- Jim2 monthly reports (laid out like the exports) ---- */
.kpis.official { grid-template-columns: repeat(5, minmax(0, 1fr)) }
.kpis.official .kpi .value { font-size: 1.4rem }
.kpis.official .kpi .foot { min-height: 0; font-size: 0.76rem }
.kpis.official:empty { display: none }
.reports .card-tools label.btn { cursor: pointer }
.reports .form-msg { margin-right: 0; max-width: 46ch }
.report-basis { margin: 0 0 8px; color: var(--accent); font-size: 0.86rem }
.report-foot { margin: 8px 0 0; color: var(--muted); font-size: 0.76rem }
.reports table td:first-child, .reports table th:first-child, table.sp td:nth-child(2), table.sp th:nth-child(2) { text-align: left }
table.pl { max-width: 760px }
table.pl td { padding-block: 5px; border-bottom-color: transparent }
table.pl tr.lvl1 td:first-child { padding-left: 28px }
table.pl tr.lvl2 td:first-child { padding-left: 44px }
table.pl tr.lvl3 td:first-child { padding-left: 60px }
table.pl tr.pl-heading.lvl0 td, table.pl tr.pl-total.lvl0 td, table.pl tr.pl-result td { font-weight: 600 }
table.pl tr.pl-total.lvl0 td, table.pl tr.pl-result td { border-bottom-color: var(--line) }
table.pl tr.pl-result td { padding-block: 12px; color: var(--navy) }
table.sp tr.below td { border: 0; padding-top: 0; font-weight: 600 }
.live-note { margin: 0; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); border: 1px solid #f3dfb0; font-size: 0.84rem }
@media (max-width: 980px) { .kpis.official { grid-template-columns: repeat(2, minmax(0, 1fr)) } }
.reports .seg { justify-self: start }
