/* MSP Tracker — Chahwan IT
   Flat, bordered, no gradients or glow. IBM Plex Sans for UI, Condensed for headings,
   Mono for ticket numbers, durations and money. */

:root {
	--ink: #17212b;
	--ink-2: #44525f;
	--ink-3: #6b7884;
	--paper: #f3f5f4;
	--surface: #ffffff;
	--line: #d6dce0;
	--line-2: #e7ebed;
	--hover: #f6f8f8;
	--teal: #0e6b66;
	--teal-ink: #0a4f4b;
	--teal-wash: #e2efed;
	--amber: #8a5a00;
	--amber-wash: #fbf0d9;
	--amber-line: #ecd6a6;
	--red: #a8261b;
	--red-wash: #fbe7e4;
	--green: #2d6a35;
	--green-wash: #e4f1e5;
	--violet: #4b4f8c;
	--violet-wash: #ecedf7;
	--side: #17212b;
	--side-2: #24323e;
	--side-text: #c3ccd4;
	--side-mute: #7d8b97;
	--sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--cond: "IBM Plex Sans Condensed", "IBM Plex Sans", "Arial Narrow", sans-serif;
	--mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	--r: 6px;
	--r-lg: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	font-family: var(--sans);
	font-size: 14px;
	line-height: 1.45;
	color: var(--ink);
	background: var(--paper);
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-ink); text-decoration: underline; }
h1, h2, h3 { font-family: var(--cond); margin: 0; line-height: 1.2; }
p { margin: 0 0 10px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.ic { flex: none; display: inline-block; vertical-align: middle; }
.mono, .num { font-family: var(--mono); font-feature-settings: "tnum"; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
kbd {
	font-family: var(--mono);
	font-size: 11px;
	color: var(--ink-3);
	border: 1px solid var(--line);
	border-radius: 4px;
	padding: 1px 5px;
	background: var(--surface);
}

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; position: relative; }
/* Keeps the sidebar colour running the full height on long pages. */
.app::before { content: ""; position: fixed; left: 0; top: 0; bottom: 0; width: 224px; background: var(--side); }
.side { z-index: 1; }
.side {
	background: var(--side);
	color: var(--side-text);
	display: flex;
	flex-direction: column;
	position: sticky;
	top: 0;
	height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark {
	width: 32px; height: 32px; border-radius: 6px;
	background: var(--teal); color: #fff;
	display: grid; place-items: center;
	font: 600 11px/1 var(--mono); letter-spacing: .5px;
}
.brand-text { font: 600 16px/1.15 var(--cond); display: flex; flex-direction: column; }
.brand-text small { font: 400 11px/1.3 var(--sans); color: var(--side-mute); }
.side-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.side-group { margin-bottom: 14px; }
.side-label { font-size: 11px; font-weight: 600; color: var(--side-mute); padding: 6px 10px; }
.side-link {
	display: flex; align-items: center; gap: 10px;
	padding: 8px 10px; border-radius: var(--r);
	color: var(--side-text); font-weight: 500;
}
.side-link:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.side-link.is-active { background: var(--side-2); color: #fff; }
.side-link.is-active .ic { color: #7fd1c7; }
.side-count {
	margin-left: auto; font: 500 11px/1 var(--mono); font-style: normal;
	background: #31414e; color: #e4ebf0; padding: 3px 6px; border-radius: 4px;
}
.side-foot {
	display: flex; align-items: center; gap: 10px;
	padding: 12px 14px; border-top: 1px solid #2a3946;
}
.side-foot .icon-btn { color: var(--side-mute); margin-left: auto; }
.side-foot .icon-btn:hover { color: #fff; background: var(--side-2); }
.side-user { display: flex; flex-direction: column; font-weight: 500; color: #fff; font-size: 13px; min-width: 0; }
.side-user small { color: var(--side-mute); font-weight: 400; font-size: 11px; }
.avatar {
	width: 30px; height: 30px; border-radius: 50%;
	background: #31414e; color: #e4ebf0;
	display: grid; place-items: center;
	font: 600 11px/1 var(--sans); flex: none;
}

.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
	position: sticky; top: 0; z-index: 30;
	display: flex; align-items: center; gap: 12px;
	padding: 10px 24px;
	background: var(--surface);
	border-bottom: 1px solid var(--line);
}
.topbar .side-toggle { display: none; }
.searchbox {
	display: flex; align-items: center; gap: 10px;
	width: min(440px, 100%); height: 38px; padding: 0 10px 0 12px;
	border: 1px solid var(--line); border-radius: var(--r);
	background: var(--paper); color: var(--ink-3);
	font: inherit; cursor: text; text-align: left;
}
.searchbox span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.searchbox:hover { border-color: #b9c2c8; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Punch clock — the running timer */
.punch {
	display: flex; align-items: center; gap: 10px;
	height: 38px; padding: 0 6px 0 12px;
	border: 1px solid var(--line); border-radius: var(--r);
	background: var(--surface); color: var(--ink-3);
	max-width: 420px;
}
.punch-dot { width: 8px; height: 8px; border-radius: 50%; background: #c2cad0; flex: none; }
.punch-time { font: 600 15px/1 var(--mono); color: var(--ink-3); font-feature-settings: "tnum"; min-width: 64px; }
.punch-label { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; pointer-events: none; }
.punch.is-running { border-color: var(--teal); background: var(--teal-wash); }
.punch.is-running .punch-dot { background: var(--teal); animation: punch 1.6s ease-in-out infinite; }
.punch.is-running .punch-time { color: var(--ink); }
.punch.is-running .punch-label { color: var(--teal-ink); pointer-events: auto; }
.punch:not(.is-running) { padding-right: 12px; }
.punch-stop {
	display: inline-flex; align-items: center; gap: 5px;
	height: 28px; padding: 0 10px; border-radius: 5px;
	border: 1px solid var(--teal); background: var(--surface); color: var(--teal-ink);
	font: 600 12px/1 var(--sans); cursor: pointer;
}
.punch-stop:hover { background: var(--teal); color: #fff; }
@keyframes punch { 50% { opacity: .35; } }

.content { padding: 24px 28px 64px; max-width: 1360px; width: 100%; }

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	height: 36px; padding: 0 14px;
	border: 1px solid transparent; border-radius: var(--r);
	font: 600 13px/1 var(--sans); cursor: pointer; white-space: nowrap;
	text-decoration: none !important;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-ink); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--hover); border-color: #b9c2c8; color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #e7c3be; }
.btn-danger:hover { background: var(--red-wash); color: var(--red); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
	display: inline-grid; place-items: center;
	width: 32px; height: 32px; border-radius: var(--r);
	border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.play-btn {
	display: inline-grid; place-items: center;
	width: 28px; height: 28px; border-radius: 50%;
	border: 1px solid var(--line); background: var(--surface); color: var(--teal);
	cursor: pointer; padding: 0;
}
.play-btn:hover { border-color: var(--teal); background: var(--teal-wash); }
.play-btn.is-running { background: var(--teal); border-color: var(--teal); color: #fff; }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red); }
.link-btn.small { font-size: 12px; margin-left: 6px; }

.menu-wrap { position: relative; }
.menu {
	position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
	min-width: 200px; padding: 6px;
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--ink); font-weight: 500; }
.menu a:hover { background: var(--hover); text-decoration: none; }
.menu a .ic { color: var(--ink-3); }
.menu kbd { margin-left: auto; }

/* ---------- Page structure ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 27px; font-weight: 600; letter-spacing: -.2px; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 13px; margin-bottom: 10px; }
.back:hover { color: var(--ink); text-decoration: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 16px; font-weight: 600; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--line-2); }

.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* Queue strip */
.strip {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
	margin-bottom: 18px; overflow: hidden;
}
.strip-item {
	display: block; padding: 14px 16px; color: var(--ink);
	border-right: 1px solid var(--line-2);
}
.strip-item:last-child { border-right: 0; }
a.strip-item:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.strip-num { display: block; font: 600 26px/1.1 var(--cond); font-feature-settings: "tnum"; }
.strip-num small { font: 500 13px var(--sans); color: var(--ink-3); margin-left: 3px; }
.strip-label { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.strip-item.warn .strip-num { color: var(--red); }
.strip-item.zero .strip-num { color: var(--ink-3); }

/* ---------- Filters & inputs ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters .grow { flex: 1 1 240px; }
.filters .cb { min-width: 180px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.seg a {
	padding: 8px 12px; color: var(--ink-2); font-weight: 500; font-size: 13px;
	border-right: 1px solid var(--line-2); white-space: nowrap;
}
.seg a:last-child { border-right: 0; }
.seg a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.seg a.is-on { background: var(--ink); color: #fff; }
.seg a em { font: 500 11px var(--mono); font-style: normal; color: var(--ink-3); margin-left: 4px; }
.seg a.is-on em { color: #b9c4cc; }

.input, .field input, .field textarea, .field select:not([data-combo]) {
	width: 100%; height: 36px; padding: 0 11px;
	border: 1px solid var(--line); border-radius: var(--r);
	background: var(--surface); color: var(--ink);
	font: inherit;
}
.field textarea, textarea.input { height: auto; padding: 9px 11px; line-height: 1.5; resize: vertical; }
.input:hover, .field input:hover, .field textarea:hover { border-color: #b9c2c8; }
.input:focus, .field input:focus, .field textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-wash); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-icon .input { padding-left: 34px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field > span em { font-style: normal; font-weight: 400; color: var(--ink-3); }
.field .hint { display: block; font-size: 12px; font-weight: 400; color: var(--ink-3); margin-top: 5px; margin-bottom: 0; }
.gst-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.gst-cell { position: relative; display: block; }
.field .gst-cell .input { padding-left: 24px; padding-right: 58px; font-family: var(--mono); font-size: 13px; }
.gst-cur { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-family: var(--mono); font-size: 13px; pointer-events: none; }
.gst-tag { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--ink-3); pointer-events: none; }
.neg { color: var(--red); }
/* Renewals list: cells you can edit in place */
.tbl-hint { padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.tbl.tbl-edit td { vertical-align: top; padding: 8px 6px; }
.tbl.tbl-edit th { padding-left: 6px; padding-right: 6px; }
.tbl.tbl-edit th:first-child, .tbl.tbl-edit td:first-child { padding-left: 14px; }
.tbl-edit td.mono, .tbl-edit td[data-cell] { padding-top: 13px; }
.tbl-edit .chk { padding-top: 14px; }
.tbl-edit tr.is-muted .cell-title, .tbl-edit tr.is-muted td.mono { color: var(--ink-3); }
.cell-input { display: block; width: 100%; border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 4px 6px; font: inherit; font-size: 13px; color: inherit; line-height: 1.4; }
.cell-input:hover { border-color: var(--line); background: var(--surface); }
.cell-input:focus { outline: none; border-color: var(--teal); background: var(--surface); box-shadow: 0 0 0 3px var(--teal-wash); }
.cell-input.is-saved, .cb.is-saved .cb-trigger { border-color: var(--green); background: var(--green-wash); transition: background .6s, border-color .6s; }
.cell-input.is-bad, .cb.is-bad .cb-trigger { border-color: var(--red); background: var(--red-wash); }
.cell-service { min-width: 220px; }
.cell-title { font-weight: 600; resize: none; overflow: hidden; min-height: 28px; }
.cell-notes { resize: none; overflow: hidden; font-size: 12px; color: var(--ink-3); min-height: 26px; }
.cell-notes::placeholder { color: #a3adb5; }
.cell-service .tag, .cell-service .sub { margin-left: 6px; }
.cell-qty { width: 52px; text-align: right; font-family: var(--mono); margin-left: auto; }
.cell-client { min-width: 150px; max-width: 170px; }
.cell-cycle { width: 100px; }
.cell-cycle .cb, .cell-client .cb { min-width: 0; width: 100%; }
.cell-date { min-width: 128px; }
.cell-date .cell-input { width: 124px; font-family: var(--mono); font-size: 12px; }
.cell-date .link-btn { display: inline-flex; align-items: center; gap: 3px; margin: 3px 0 0 6px; }
.cell-fig .sub { white-space: nowrap; }
.cell-date .due { display: inline-block; margin: 3px 0 0 6px; }
.gst-mini { grid-template-columns: 1fr; gap: 2px; width: 100px; margin-left: auto; }
.gst-mini .cell-input { padding-left: 18px; padding-right: 28px; text-align: right; font-family: var(--mono); font-size: 12px; }
.gst-mini .gst-cur { left: 7px; font-size: 12px; }
.gst-mini .gst-tag { right: 6px; font-size: 10px; }
.gst-mini .gst-cell + .gst-cell .cell-input { color: var(--ink-3); }
.tbl-edit .act { padding-top: 9px; padding-right: 10px; }
.tbl-edit .act .icon-btn { display: inline-flex; vertical-align: middle; width: 28px; height: 28px; }
.bulkbar .bulk-date { height: 32px; border: 1px solid #3a4a57; background: #26343f; color: #fff; border-radius: var(--r); padding: 0 8px; font: inherit; font-size: 13px; color-scheme: dark; }
.bulkbar .bulk-danger { color: #ffb4ab; border-color: #6b3a35; }
.bulkbar .bulk-danger:hover { background: #3a2624; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--teal); margin: 0; }
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 4px; flex-wrap: wrap; }
.form-actions .push { margin-left: auto; }
.dur-preview { font: 500 12px var(--mono); color: var(--teal-ink); margin-left: 4px; }
.dur-preview.bad { color: var(--red); }

/* ---------- Searchable picker (replaces every <select data-combo>) ---------- */
select[data-combo].cb-native { display: none; }
.cb { position: relative; min-width: 0; }
.cb-trigger {
	display: flex; align-items: center; gap: 8px;
	width: 100%; height: 36px; padding: 0 9px 0 11px;
	border: 1px solid var(--line); border-radius: var(--r);
	background: var(--surface); color: var(--ink);
	font: inherit; text-align: left; cursor: pointer;
}
.cb-trigger:hover { border-color: #b9c2c8; }
.cb.is-open .cb-trigger { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-wash); }
.cb-label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cb-label.is-empty { color: var(--ink-3); }
.cb-trigger .ic-chevdown { color: var(--ink-3); }
.cb.is-invalid .cb-trigger { border-color: var(--red); }
.cb-pop {
	position: absolute; left: 0; top: calc(100% + 4px); z-index: 60;
	min-width: 100%; width: max-content; max-width: 380px;
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
	padding: 6px;
}
.cb.cb-up .cb-pop { top: auto; bottom: calc(100% + 4px); }
.cb.cb-right .cb-pop { left: auto; right: 0; }
.cb-search {
	width: 100%; height: 34px; padding: 0 10px; margin-bottom: 6px;
	border: 1px solid var(--line); border-radius: var(--r);
	font: inherit; background: var(--paper);
}
.cb-search:focus { outline: none; border-color: var(--teal); background: var(--surface); }
.cb-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; min-width: 200px; }
.cb-opt {
	display: flex; align-items: baseline; gap: 10px;
	padding: 7px 9px; border-radius: 5px; cursor: pointer;
}
.cb-opt.is-active { background: var(--hover); }
.cb-opt.is-selected { font-weight: 600; }
.cb-opt.is-selected::after {
	content: ""; width: 6px; height: 10px; margin-left: auto; align-self: center;
	border: solid var(--teal); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px);
}
.cb-opt-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-opt-hint { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.cb-opt mark { background: var(--amber-wash); color: inherit; padding: 0; }
.cb-none { padding: 10px; color: var(--ink-3); font-size: 13px; }
/* Compact pill variant for inline status/priority changes in tables */
.cb-pill { display: inline-block; }
.cb-pill .cb-trigger { height: 26px; padding: 0 6px 0 9px; border-radius: 4px; font-size: 12px; font-weight: 600; width: auto; gap: 4px; }
.cb-pill .cb-trigger .ic-chevdown { width: 12px; height: 12px; }
.cb-pill .cb-pop { min-width: 180px; font-size: 13px; }
.cb-pill.st-open .cb-trigger { background: #e6eef7; color: #1d4f86; border-color: #c9d9ec; }
.cb-pill.st-in_progress .cb-trigger { background: var(--amber-wash); color: var(--amber); border-color: var(--amber-line); }
.cb-pill.st-waiting .cb-trigger { background: var(--violet-wash); color: var(--violet); border-color: #d3d5ec; }
.cb-pill.st-done .cb-trigger { background: var(--green-wash); color: var(--green); border-color: #c5dfc8; }
.cb-quiet .cb-trigger { border-color: transparent; background: transparent; padding-left: 6px; }
.cb-quiet .cb-trigger:hover { border-color: var(--line); background: var(--surface); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
	text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3);
	padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
	background: var(--surface);
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tr[data-href] { cursor: pointer; }
.tbl .chk { width: 34px; padding-right: 0; }
.tbl .chk input { width: 16px; height: 16px; accent-color: var(--teal); margin: 0; vertical-align: middle; }
.tbl .ref { font: 500 12px var(--mono); color: var(--ink-3); white-space: nowrap; width: 1%; }
.tbl .title { font-weight: 600; color: var(--ink); }
.tbl .title:hover { color: var(--teal); }
.tbl .sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; font-weight: 400; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl th.num { font-family: var(--sans); }
.tbl .act { width: 1%; white-space: nowrap; text-align: right; }
.tbl tr.is-selected td { background: var(--teal-wash); }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.tbl-compact td { padding: 8px 12px; }

/* ---------- Pills & tags ---------- */
.pill { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-open { background: #e6eef7; color: #1d4f86; }
.pill-in_progress { background: var(--amber-wash); color: var(--amber); }
.pill-waiting { background: var(--violet-wash); color: var(--violet); }
.pill-done { background: var(--green-wash); color: var(--green); }
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.prio i { width: 8px; height: 8px; border-radius: 2px; background: #c2cad0; }
.prio-urgent { color: var(--red); font-weight: 600; }
.prio-urgent i { background: var(--red); }
.prio-high { color: var(--amber); font-weight: 600; }
.prio-high i { background: #d08b12; }
.prio-medium i { background: #7d8b97; }
.prio-low { color: var(--ink-3); }
.tag {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600;
	background: var(--paper); color: var(--ink-2); border: 1px solid var(--line-2);
	vertical-align: middle; white-space: nowrap;
}
.tag .ic { width: 11px; height: 11px; }
.tag-portal { background: #e6eef7; color: #1d4f86; border-color: #d3e0ef; }
.tag-private { background: var(--red-wash); color: var(--red); border-color: #efcdc8; }
.tag-internal { background: var(--amber-wash); color: var(--amber); border-color: var(--amber-line); }
.tag-billed { background: var(--green-wash); color: var(--green); border-color: #cfe4d1; }
.tag-nb { color: var(--ink-3); }
.due { font-size: 12px; font-weight: 600; white-space: nowrap; }
.due-overdue { color: var(--red); }
.due-soon { color: var(--amber); }
.due-later { color: var(--ink-3); font-weight: 500; }

/* ---------- Bulk bar ---------- */
.bulkbar {
	position: sticky; bottom: 16px; z-index: 25;
	display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
	margin-top: 12px; padding: 10px 12px;
	background: var(--ink); color: #fff; border-radius: var(--r-lg);
}
.bulkbar .count { font-weight: 600; margin-right: 6px; }
.bulkbar .cb { min-width: 160px; }
.bulkbar .cb-trigger { background: #26343f; color: #fff; border-color: #3a4a57; height: 32px; }
.bulkbar .cb-trigger .ic-chevdown, .bulkbar .cb-label.is-empty { color: #a9b6c0; }
.bulkbar .cb-pop { color: var(--ink); }
.bulkbar .btn-ghost { background: transparent; color: #fff; border-color: #3a4a57; height: 32px; }
.bulkbar .btn-ghost:hover { background: #26343f; }
.bulkbar .btn-primary { height: 32px; }
.bulkbar .close { margin-left: auto; color: #a9b6c0; }
.bulkbar .close:hover { background: #26343f; color: #fff; }

/* ---------- Lists (dashboard) ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--hover); }
.list .ref { font: 500 12px var(--mono); color: var(--ink-3); width: 44px; flex: none; }
.list .main { flex: 1; min-width: 0; }
.list .main a { font-weight: 600; color: var(--ink); display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.list .main a:hover { color: var(--teal); text-decoration: none; }
.list .meta { font-size: 12px; color: var(--ink-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.list .side-val { font: 500 13px var(--mono); white-space: nowrap; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; padding: 0 2px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-bar { width: 100%; max-width: 34px; background: var(--teal-wash); border: 1px solid #bcd9d5; border-radius: 3px 3px 0 0; min-height: 2px; }
.week-day.is-today .week-bar { background: var(--teal); border-color: var(--teal); }
.week-day span { font-size: 11px; color: var(--ink-3); }
.week-day b { font: 500 11px var(--mono); color: var(--ink-2); }
.week-total { display: flex; gap: 20px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.week-total div { font-size: 12px; color: var(--ink-3); }
.week-total b { display: block; font: 600 18px var(--cond); color: var(--ink); }

/* ---------- Ticket detail ---------- */
.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.ticket-head { margin-bottom: 16px; }
.ticket-ref { font: 500 13px var(--mono); color: var(--ink-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ticket-ref .tag { font-family: var(--sans); }
.ticket-title {
	display: block; width: 100%; margin: 6px 0 6px; padding: 2px 6px; margin-left: -7px;
	font: 600 26px/1.25 var(--cond); color: var(--ink);
	border: 1px solid transparent; border-radius: var(--r); background: transparent;
}
.ticket-title:hover { border-color: var(--line); background: var(--surface); }
.ticket-title:focus { outline: none; border-color: var(--teal); background: var(--surface); }
.ticket-meta { color: var(--ink-3); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ticket-meta a { color: var(--ink-2); font-weight: 500; }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; }
.msg .avatar { width: 32px; height: 32px; background: #e3e8eb; color: var(--ink-2); }
.msg-staff .avatar { background: var(--teal-wash); color: var(--teal-ink); }
.msg-client .avatar { background: #e6eef7; color: #1d4f86; }
.msg-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.msg-head b { font-weight: 600; }
.msg-head time { color: var(--ink-3); font-size: 12px; }
.msg-head .link-btn { margin-left: auto; font-size: 12px; }
.msg-body { padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-internal .msg-box { background: #fffaf0; border-color: var(--amber-line); }
.msg-internal .msg-head { border-bottom-color: #f3e5c4; }
.msg-system { grid-template-columns: 32px minmax(0, 1fr); align-items: center; }
.msg-system .sys-dot { width: 32px; display: grid; place-items: center; color: var(--ink-3); }
.msg-system .sys-text { font-size: 12px; color: var(--ink-3); }
.msg-system .sys-text b { color: var(--ink-2); font-weight: 600; }
.msg-desc .msg-box { border-color: var(--line); }

.composer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-top: 16px; scroll-margin-top: 80px; }
.composer.is-internal { border-color: var(--amber-line); background: #fffaf0; }
.composer-tabs { display: flex; border-bottom: 1px solid var(--line-2); }
.composer-tabs button {
	display: inline-flex; align-items: center; gap: 7px;
	padding: 11px 14px; border: 0; background: none; cursor: pointer;
	font: 600 13px var(--sans); color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.composer-tabs button.is-on { color: var(--ink); border-bottom-color: var(--ink); }
.composer.is-internal .composer-tabs { border-bottom-color: #f3e5c4; }
.composer.is-internal .composer-tabs button.is-on { color: var(--amber); border-bottom-color: var(--amber); }
.composer textarea { display: block; width: 100%; min-height: 110px; padding: 12px 14px; border: 0; resize: vertical; font: inherit; line-height: 1.5; background: transparent; color: var(--ink); }
.composer textarea:focus { outline: none; }
.composer-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line-2); }
.composer.is-internal .composer-foot { border-top-color: #f3e5c4; }
.composer-foot .time-in { width: 92px; height: 32px; }
.composer-foot .cb { min-width: 170px; }
.composer-foot .cb-trigger { height: 32px; }
.composer-foot .push { margin-left: auto; }
.composer-hint { font-size: 12px; color: var(--ink-3); padding: 0 14px 10px; }

.props { padding: 6px 0; }
.prop { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 8px; padding: 5px 14px; }
.prop > label { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.prop .cb-trigger, .prop .input { height: 32px; }
.prop .cb-quiet .cb-trigger { height: 32px; }
.time-total { display: flex; align-items: baseline; gap: 8px; }
.time-total b { font: 600 24px var(--cond); }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--line-2); font-size: 13px; }
.entries li .d { color: var(--ink-3); font-size: 12px; width: 52px; flex: none; }
.entries li .t { margin-left: auto; font: 500 12px var(--mono); white-space: nowrap; }
.entries li .x { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Client detail ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-3); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.is-on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs a em { font: 500 11px var(--mono); font-style: normal; color: var(--ink-3); margin-left: 4px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 13px; margin-top: 6px; }
.facts span { display: inline-flex; align-items: center; gap: 6px; }
.facts .ic { color: var(--ink-3); }
.codebox {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: var(--r);
	background: var(--paper); font: 12px/1.4 var(--mono); color: var(--ink-2);
}
.codebox code { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.codebox textarea { flex: 1; border: 0; background: transparent; font: inherit; color: inherit; resize: none; min-height: 52px; }

/* ---------- Time page ---------- */
.quick-add {
	display: grid; grid-template-columns: 136px minmax(150px, 1fr) minmax(170px, 1.2fr) 100px minmax(160px, 1.6fr) auto auto;
	gap: 8px; align-items: center; padding: 12px;
}
.quick-add .input, .quick-add .cb-trigger { height: 36px; }
.week-nav { display: inline-flex; align-items: center; gap: 4px; }
.week-nav .label { font-weight: 600; padding: 0 8px; white-space: nowrap; }
.day-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 8px; border-top: 1px solid var(--line); background: var(--paper); }
.day-head:first-child { border-top: 0; }
.day-head b { font: 600 14px var(--cond); }
.day-head .total { margin-left: auto; font: 600 13px var(--mono); }
.totals-row { display: flex; gap: 28px; flex-wrap: wrap; }
.totals-row div { font-size: 12px; color: var(--ink-3); }
.totals-row b { display: block; font: 600 20px var(--cond); color: var(--ink); font-feature-settings: "tnum"; }

/* ---------- Notices, empty states ---------- */
.notice { padding: 10px 14px; border-radius: var(--r); border: 1px solid; margin-bottom: 14px; font-size: 13px; }
.notice-warn { background: var(--amber-wash); border-color: var(--amber-line); color: #6c4700; }
.notice-error { background: var(--red-wash); border-color: #efcdc8; color: var(--red); }
.notice-ok { background: var(--green-wash); border-color: #cfe4d1; color: var(--green); }
.notice-info { background: var(--paper); border-color: var(--line); color: var(--ink-2); }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.empty-title { font: 600 16px var(--cond); color: var(--ink-2); margin-bottom: 4px; }
.empty .btn { margin-top: 10px; }

/* ---------- Palette, modal, toasts ---------- */
.palette, .modal {
	position: fixed; inset: 0; z-index: 100;
	background: rgba(23, 33, 43, .45);
	display: flex; align-items: flex-start; justify-content: center;
	padding: 12vh 16px 16px;
}
.palette-box, .modal-box {
	width: 100%; max-width: 600px;
	background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
	overflow: hidden;
}
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--line-2); color: var(--ink-3); }
.palette-input input { flex: 1; height: 52px; border: 0; font: 16px var(--sans); color: var(--ink); background: transparent; }
.palette-input input:focus { outline: none; }
.palette-results { max-height: 52vh; overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 8px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); color: var(--ink); cursor: pointer; }
.pal-item:hover { text-decoration: none; color: var(--ink); }
.pal-item.is-active { background: var(--hover); }
.pal-item .ic { color: var(--ink-3); }
.pal-item .ref { font: 500 12px var(--mono); color: var(--ink-3); }
.pal-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.pal-item .h { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.pal-empty { padding: 18px 12px; color: var(--ink-3); font-size: 13px; }

.modal-box { max-width: 460px; padding: 18px 20px 20px; overflow: visible; }
.modal-head { display: flex; align-items: center; margin-bottom: 8px; }
.modal-head h2 { font-size: 19px; font-weight: 600; }
.modal-head .icon-btn { margin-left: auto; }
.modal-note { font-size: 13px; color: var(--amber); margin-bottom: 10px; }
.modal-note:empty { display: none; }
.timer-readout { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.timer-readout span { font: 600 30px var(--mono); font-feature-settings: "tnum"; }
.timer-readout small { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
	display: flex; align-items: center; gap: 8px;
	padding: 10px 14px; border-radius: var(--r);
	background: var(--ink); color: #fff; font-size: 13px; font-weight: 500;
	max-width: 420px;
}
.toast .ic { color: #7fd1c7; }
.toast.is-error { background: var(--red); }
.toast.is-error .ic { color: #fff; }

/* ---------- Login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login-box .brand { padding: 0 0 22px; color: var(--ink); }
.login-box .brand-text small { color: var(--ink-3); }
.login-box h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-box .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 18px; }

/* ---------- Client portal (embedded in client sites) ---------- */
.portal-body { background: var(--paper); padding: 16px; }
.portal-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; max-width: 520px; margin: 0 auto; }
.portal-wide { max-width: 980px; }
.portal-box h1 { font-size: 20px; font-weight: 600; margin-bottom: 2px; }
.portal-box .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 14px; }
.portal-box .field { margin-bottom: 11px; }
.portal-box .field textarea { min-height: 84px; }
.portal-hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
.portal-summary { font-size: 13px; color: var(--ink-2); margin-bottom: 10px; }
.portal-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.portal-thread { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; margin-bottom: 12px; }
.portal-msg { border: 1px solid var(--line); border-radius: var(--r); padding: 9px 12px; }
.portal-msg.from-us { background: var(--teal-wash); border-color: #c4dfdb; }
.portal-msg .who { font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.portal-msg .who b { color: var(--ink); }
.portal-msg .body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.portal-latest { font-size: 12px; color: var(--ink-2); max-width: 260px; }
.portal-latest b { display: block; color: var(--ink-3); font-weight: 500; font-size: 11px; }
.portal-body .modal-box { max-width: 560px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
	.quick-add { grid-template-columns: 1fr 1fr 1fr; }
	.quick-add .qa-desc { grid-column: span 2; }
}
@media (max-width: 1080px) {
	.ticket-grid, .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
	.app { grid-template-columns: minmax(0, 1fr); }
	.app::before { display: none; }
	.side {
		position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 90;
		transform: translateX(-100%); transition: transform .2s ease;
	}
	.side.is-open { transform: none; }
	.topbar .side-toggle { display: inline-grid; }
	.topbar { padding: 8px 12px; gap: 8px; }
	.searchbox kbd, .searchbox span { display: none; }
	.searchbox { width: 38px; padding: 0; justify-content: center; }
	.punch-label { display: none; }
	.content { padding: 18px 14px 56px; }
	.form-grid, .form-grid-3 { grid-template-columns: 1fr; }
	.quick-add { grid-template-columns: 1fr 1fr; }
	.quick-add .qa-desc { grid-column: 1 / -1; }
	.page-head h1 { font-size: 23px; }
}
@media (max-width: 560px) {
	.punch:not(.is-running) { display: none; }
	.list li { flex-wrap: wrap; row-gap: 6px; }
	.list .main { flex-basis: calc(100% - 56px); }
	.list li > .prio { margin-left: 56px; }
	.page-head .actions { margin-left: 0; }
	.filters .cb { flex: 1 1 calc(50% - 4px); min-width: 0; }
	.seg { max-width: 100%; overflow-x: auto; }
	.topbar .btn-primary { padding: 0 10px; }
	.strip { grid-template-columns: repeat(2, 1fr); }
	.strip-item { border-bottom: 1px solid var(--line-2); }
	.tbl .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
	.side, .topbar, .bulkbar, .filters, .no-print, .composer, .toasts { display: none !important; }
	.app { display: block; }
	body, .portal-body { background: #fff; padding: 0; }
	.card, .portal-box { border-color: #ccc; max-width: none; }
}

/* ---------- Leads ---------- */
.pill-l-new { background: #e6eef7; color: #1d4f86; }
.pill-l-contacted { background: var(--amber-wash); color: var(--amber); }
.pill-l-quoted { background: var(--violet-wash); color: var(--violet); }
.pill-l-won { background: var(--green-wash); color: var(--green); }
.pill-l-lost { background: var(--paper); color: var(--ink-3); }
.cb-pill.ls-new .cb-trigger { background: #e6eef7; color: #1d4f86; border-color: #c9d9ec; }
.cb-pill.ls-contacted .cb-trigger { background: var(--amber-wash); color: var(--amber); border-color: var(--amber-line); }
.cb-pill.ls-quoted .cb-trigger { background: var(--violet-wash); color: var(--violet); border-color: #d3d5ec; }
.cb-pill.ls-won .cb-trigger { background: var(--green-wash); color: var(--green); border-color: #c5dfc8; }
.cb-pill.ls-lost .cb-trigger { background: var(--paper); color: var(--ink-3); border-color: var(--line); }
.tbl tr.is-muted td { color: var(--ink-3); }
.cell-input.is-late { color: var(--red); }
.lead-name { font: 600 26px/1.2 var(--cond); margin: 6px 0 4px; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; margin: 0 0 4px; font-size: 14px; }
.kv dt { color: var(--ink-3); font-size: 13px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.lead-msg { margin-top: 14px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r); white-space: pre-wrap; font-size: 14px; line-height: 1.55; }
.lead-actions { display: flex; flex-direction: column; gap: 8px; }
.lead-actions form { margin: 0; }
.btn-block { width: 100%; justify-content: center; }
.email-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.email-list li { display: flex; align-items: center; gap: 8px; }
.email-list .ic { color: var(--ink-3); }
@media (max-width: 720px) {
	.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
	.kv dd { margin-bottom: 8px; }
}
.list .sys-dot { width: 24px; flex: none; display: grid; place-items: center; color: var(--ink-3); }