/* CRM TWIN: an operator tool in the TWIN brand (skills/twin-brand/reference.md). Dense layout
   on a 4/8 px grid: sidebar + topbar + content, tables as the main surface, one accent (TWIN
   violet, for active and primary), semantic colours only for status dots. The CSP allows no
   third-party fonts or inline styles: Inter where installed, then Helvetica Neue / Arial. */
:root {
  --ink: #1D1D1F; --ink-2: #424245; --grey: #6E6E73; --silver: #A3A3A3; --line: #E8E8ED; --line-2: #D2D2D7;
  --cloud: #F5F5F7; --bg: #FFFFFF; --side: #F7FAFC; --hover: #F5F7FA;
  --air: #ECF4F8; --sky: #DCEBF2; --mist: #89D3DE; --cyan: #3DC4DC;
  --accent: #6C47FF; --accent-ink: #5534E0; --accent-soft: #F2EEFF; --accent-line: #CFC3FF;
  /* semantic, subdued: dots and short labels only */
  --success: #1F9D55; --warning: #C48A05; --danger: #D1344B; --info: #2E6CF6; --neutral: #A3A3A3;
  --warn-bg: #FFF4CC; --warn-ink: #8A6D00; --danger-bg: #FDECEF;
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --pill: 999px;
  --shadow-1: 0 1px 2px rgba(29, 29, 31, .06);
  --shadow-2: 0 1px 2px rgba(29, 29, 31, .06), 0 12px 32px rgba(30, 20, 90, .12);
  --font: Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --side-w: 232px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font: 14px/1.45 var(--font); letter-spacing: -.005em; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -48px; z-index: 50; padding: 8px 12px; background: var(--ink); color: #fff; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums slashed-zero; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--grey); }
.small, small { font-size: 12px; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 46ch; }
h1, h2, h3 { font-weight: 500; letter-spacing: -.02em; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--grey); }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 12px; padding: 16px 12px; background: var(--side); border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px; color: var(--grey); font-weight: 500; font-size: 12px; }
.side-brand:hover { text-decoration: none; }
.side-brand img { height: 22px; width: auto; }
.search-trigger { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); color: var(--grey); cursor: pointer; text-align: left; }
.search-trigger span { flex: 1; }
.search-trigger:hover { border-color: var(--line-2); color: var(--ink-2); }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; color: var(--grey); background: var(--bg); }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { margin: 12px 8px 4px; font-size: 11px; font-weight: 500; color: var(--silver); }
.side nav a { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
.side nav a:hover { background: rgba(29, 29, 31, .04); text-decoration: none; }
.side nav a[aria-current=page] { background: var(--accent-soft); color: var(--accent-ink); }
.side-user { display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--line); margin: 0 -4px; }
.side-user > div, .side-user-link { flex: 1; min-width: 0; color: var(--ink); }
.side-user-link:hover { text-decoration: none; }
.side-user-link small { display: block; }
.side-user b { display: block; font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { color: var(--grey); }
.scrim { display: none; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 24px;
  background: rgba(255, 255, 255, .86); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.topbar > .btn:first-child { display: none; }
.crumbs { flex: 1; min-width: 0; }
.crumbs ol { display: flex; gap: 8px; list-style: none; font-size: 13px; color: var(--grey); }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--line-2); }
.crumbs a { color: var(--grey); }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }
.top-actions { display: flex; gap: 8px; }
main { outline: none; }
.content { padding: 24px; max-width: 1360px; }
.page-title { font-size: 22px; line-height: 1.2; margin-bottom: 4px; }
.lead { color: var(--grey); margin-bottom: 16px; max-width: 72ch; }
.section-title { font-size: 15px; margin: 24px 0 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-head .section-title { margin-bottom: 4px; }

/* ------------------------------------------------------------ buttons and chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--r-sm);
  font-weight: 500; font-size: 13px; white-space: nowrap; cursor: pointer; transition: background-color .08s, border-color .08s, color .08s; }
.btn:hover { text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.secondary { background: var(--bg); border-color: var(--line-2); color: var(--ink); box-shadow: var(--shadow-1); }
.btn.secondary:hover { background: var(--cloud); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(29, 29, 31, .05); color: var(--ink); }
.btn.small { height: 28px; padding: 0 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn .icon { width: 15px; height: 15px; }
.chips { display: inline-flex; padding: 2px; gap: 2px; background: var(--cloud); border-radius: var(--r-sm); }
.chip { height: 28px; padding: 0 10px; border: 0; border-radius: var(--r-xs); background: transparent; color: var(--grey); font-size: 13px; font-weight: 500; cursor: pointer; }
.chip:hover { color: var(--ink); }
.chip[aria-pressed=true] { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-1); }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
.toolbar .field { min-width: 0; }
.count-note { margin-left: auto; font-size: 12px; align-self: center; }
.row-actions { display: inline-flex; gap: 4px; align-items: center; }
.row-actions.wrap { flex-wrap: wrap; }

/* ------------------------------------------------------------ status, avatar */
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 500; font-size: 13px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); flex: none; }
.status.success i { background: var(--success); } .status.warning i { background: var(--warning); }
.status.danger i { background: var(--danger); } .status.info i { background: var(--info); }
.status.danger { color: var(--danger); }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--air); color: #1E6E7E; font-size: 11px; font-weight: 600; letter-spacing: 0; }
.who-cell { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.who-cell > span { display: flex; flex-direction: column; min-width: 0; }
.who-cell a { color: var(--ink); font-weight: 500; }
.who-cell small { color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; scrollbar-gutter: stable; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; text-align: left; font-size: 12px; font-weight: 500; color: var(--grey); background: var(--cloud); padding: 8px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--hover); }
tr.link { cursor: pointer; }
tr.link:focus-visible { outline: none; }
tr.link:focus-visible td { background: var(--accent-soft); }
tr.link:focus-visible td:first-child { box-shadow: inset 2px 0 var(--accent); }
.bone { display: block; height: 10px; width: 70%; border-radius: 4px; background: linear-gradient(90deg, var(--cloud), #ECECF0, var(--cloud)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.bone.wide { width: 40%; height: 28px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 24px 16px; border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--grey); }
.error-state { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-md); background: var(--danger-bg); color: #9B1C31; }
.notice { padding: 8px 12px; border-radius: var(--r-sm); background: var(--air); color: var(--ink-2); margin-bottom: 12px; }
.more { margin-top: 12px; }

/* ------------------------------------------------------------ metrics and charts */
.metrics { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 8px; margin: 8px 0 16px; }
.metrics.two { grid-template-columns: 1.4fr 1fr; }
.metric { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); min-width: 0; }
.metric.hero { background: linear-gradient(180deg, var(--accent-soft), var(--bg)); border-color: var(--accent-line); }
.metric.wide { grid-row: span 1; }
.metric-label { font-size: 12px; font-weight: 500; color: var(--grey); }
.metric-value { font-size: 24px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric.hero .metric-value { font-size: 32px; color: var(--accent-ink); }
.metric-note { font-size: 12px; color: var(--grey); }
.chart { display: block; width: 100%; height: 56px; margin-top: 8px; color: var(--accent); overflow: visible; }
.chart .line { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
.bars { list-style: none; display: grid; gap: 6px; margin-top: 4px; }
.bars li { display: grid; grid-template-columns: minmax(80px, 110px) 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.bar-track { position: relative; height: 8px; border-radius: 4px; background: var(--cloud); overflow: hidden; min-width: 60px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); opacity: .75; }
.bar-inline { display: grid; grid-template-columns: 120px auto; align-items: center; gap: 8px; }

/* ------------------------------------------------------------ client page */
.client-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.client-head > .avatar { width: 48px; height: 48px; font-size: 16px; }
.client-id { flex: 1; min-width: 260px; }
.client-id h1 { font-size: 22px; line-height: 1.2; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; color: var(--grey); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current=page] { color: var(--ink); border-bottom-color: var(--accent); }
.tab-count { font-size: 11px; padding: 0 6px; border-radius: var(--pill); background: var(--cloud); color: var(--grey); font-variant-numeric: tabular-nums; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.split .section-title:first-child { margin-top: 0; }
.split > div > section + section { margin-top: 8px; }
.rail { display: flex; flex-direction: column; gap: 16px; padding: 16px; border-radius: var(--r-lg); background: var(--side); border: 1px solid var(--line); }
.rail .section-title { margin: 0; }
.deflist { display: grid; gap: 8px; margin-top: 8px; }
.deflist > div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; }
.rail .deflist > div { grid-template-columns: 1fr; gap: 0; }
.deflist dt { color: var(--grey); font-size: 13px; }
.deflist dd { white-space: pre-wrap; word-break: break-word; }
.note { margin-top: 8px; padding: 8px 12px; border-left: 2px solid var(--mist); color: var(--ink-2); white-space: pre-wrap; }
.list { list-style: none; border: 1px solid var(--line); border-radius: var(--r-md); }
.list li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.list li + li { border-top: 1px solid var(--line); }
.list li .clip { flex: 1; }
.contacts { list-style: none; display: grid; gap: 12px; margin-top: 8px; }
.contacts li { display: flex; flex-direction: column; gap: 2px; }
.contacts b { font-weight: 500; }
.checklist { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; margin: 8px 0 8px; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--grey); }
.checklist li > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.checklist li b { font-weight: 500; }
.checklist li.done { border-style: solid; border-color: var(--line); color: var(--ink); }
.check-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px dashed var(--line-2); flex: none; }
.done .check-mark { border: 0; background: var(--accent); color: #fff; }
.done .check-mark .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.checklist.releases { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.releases li > span:nth-child(2) small { display: block; }
.danger-text { color: var(--danger); }
.keylist { list-style: none; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
.keylist > li { display: grid; grid-template-columns: minmax(240px, 2fr) 120px 110px minmax(140px, 1fr) 40px; align-items: center; gap: 16px; padding: 12px 16px; }
.keylist > li + li { border-top: 1px solid var(--line); }
.keylist > li > .btn { justify-self: end; }
.facts-list .status { white-space: normal; align-items: flex-start; }
.facts-list .status i { margin-top: 6px; }
.keylist > li:hover { background: var(--hover); }
.key-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.key-name b { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-hint { font: 11px var(--mono); padding: 1px 6px; border-radius: var(--r-xs); background: var(--cloud); color: var(--grey); }
.key-tag { justify-self: start; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: var(--pill); border: 1px solid var(--line); color: var(--ink-2); }
.key-who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); min-width: 0; }
.key-who .avatar { width: 22px; height: 22px; font-size: 9px; }
.menu-wrap { position: relative; justify-self: end; }
.btn.icon-only { width: 28px; padding: 0; }
.btn.icon-only .icon { stroke-width: 3; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 160px; list-style: none; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); box-shadow: var(--shadow-2); }
.menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-xs); background: none; text-align: left; font-size: 13px; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--cloud); outline: none; }
.menu button.danger { color: var(--danger); }
@media (max-width: 860px) { .keylist > li { grid-template-columns: 1fr auto; } .keylist .key-tag, .keylist .key-who { display: none; } }
.key-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }

/* ------------------------------------------------------------ kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kcol { display: flex; flex-direction: column; gap: 8px; min-height: 240px; padding: 8px; border-radius: var(--r-lg); background: var(--side); border: 1px solid var(--line); transition: background-color .08s, border-color .08s; }
.kcol.over { background: var(--accent-soft); border-color: var(--accent-line); }
.kcol > header { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; }
.kcount { font-size: 12px; color: var(--grey); font-variant-numeric: tabular-nums; }
.kcol ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.kempty { padding: 16px 8px; text-align: center; font-size: 13px; color: var(--silver); }
.kcard { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); box-shadow: var(--shadow-1); cursor: grab; }
.kcard:hover { border-color: var(--line-2); }
.kcard.dragging { opacity: .5; cursor: grabbing; }
.kcard-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kcard-head a { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-meta { font-size: 12px; color: var(--grey); }
.kcard-badges { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.kcard-badges .status { font-size: 12px; }
.kcard-move { height: 28px !important; font-size: 12px; color: var(--grey); background-color: var(--side) !important; border-color: var(--line) !important; }

/* ------------------------------------------------------------ the next call */
.callbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--side); }
.callbar.booked { background: var(--accent-soft); border-color: var(--accent-line); }
.callbar-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bg); color: var(--accent-ink); flex: none; }
.callbar small { display: block; color: var(--grey); font-size: 12px; }
.callbar b { font-weight: 600; }
.callbar b::first-letter { text-transform: uppercase; }
.client-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.rail-fields { display: grid; gap: 12px; margin: 8px 0 16px; }
.rail .field { min-width: 0; }
.rail h3 { margin: 0; }
.rail p { margin-top: 4px; }
.facts-list { list-style: none; display: grid; gap: 6px; margin-top: 8px; }
.form-grid.one { grid-template-columns: 1fr; }

/* ------------------------------------------------------------ my area */
.area-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.area-head > .avatar { width: 48px; height: 48px; font-size: 16px; }
.area-head h1 { font-size: 22px; }
.area-switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--grey); }
.area-switch select { width: auto; min-width: 200px; }
.stage-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stage-col { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--side); }
.stage-col > p:first-child { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.stage-col ul { list-style: none; display: grid; gap: 4px; font-size: 13px; }
.stage-col a { color: var(--ink); }
.call-list { list-style: none; display: grid; gap: 10px; margin-top: 8px; }
.call-list li { display: flex; align-items: center; gap: 12px; }
.call-list a { display: block; color: var(--ink); font-weight: 500; }
.call-list small { display: block; }
.call-list small::first-letter { text-transform: uppercase; }
.call-date { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-ink); line-height: 1.1; }
.call-date b { font-size: 16px; }
.call-date small { font-size: 11px; text-transform: uppercase; }
@media (max-width: 860px) { .stage-strip { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------ WhatsApp */
.chat-pane { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0; height: calc(100vh - 260px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--bg); }
.chat-list { overflow-y: auto; border-right: 1px solid var(--line); background: var(--side); }
.chat-list > .empty, .chat-list > .table-wrap { margin: 8px; }
.chat-list ul { list-style: none; }
.chat-item { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.chat-item:hover { background: var(--hover); }
.chat-item[aria-current=true] { background: var(--accent-soft); box-shadow: inset 2px 0 var(--accent); }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; }
.chat-item-top b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-body { font-size: 13px; color: var(--grey); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .status { font-size: 12px; }
.chat-view { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-view > .empty { margin: 16px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.chat-head b { display: block; font-weight: 600; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 16px; background: #F4F6F5; }
.chat-day { align-self: center; font-size: 11px; color: var(--grey); padding: 2px 10px; border-radius: var(--pill); background: var(--bg); margin: 8px 0; }
.bubble { max-width: 72%; padding: 8px 10px; border-radius: 12px; background: var(--bg); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 2px; }
.bubble.in { align-self: flex-start; border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #E7F7EE; border-top-right-radius: 4px; }
.bubble.failed { border: 1px solid var(--danger); }
.bubble p { white-space: pre-wrap; word-break: break-word; }
.bubble-who { font-size: 11px; font-weight: 600; color: var(--accent-ink); }
.bubble-meta { align-self: flex-end; font-size: 11px; color: var(--grey); }
.chat-media { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.chat-foot { padding: 8px 16px; border-top: 1px solid var(--line); }
@media (max-width: 860px) { .chat-pane { grid-template-columns: 1fr; height: auto; } .chat-list { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); } .chat { max-height: 60vh; } }

/* ------------------------------------------------------------ activity feed */
.toolbar select { width: auto; min-width: 200px; }
.feed-day + .feed-day { margin-top: 16px; }
.feed-date { font-size: 13px; font-weight: 600; margin: 8px 0; }
.feed-date::first-letter { text-transform: uppercase; }
.feed { list-style: none; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); }
.feed li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.feed li + li { border-top: 1px solid var(--line); }
.feed .status { flex: none; }
.feed-text { flex: 1; min-width: 0; }
.feed-text p a { color: var(--ink); font-weight: 600; }
.feed-text p b { font-weight: 600; }
.feed-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-time { font-size: 12px; color: var(--grey); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ forms */
input[type=email], input[type=text], input[type=tel], input[type=url], input[type=password], input[type=number], input[type=date], input[type=month], input[type=datetime-local], input[type=search], select, textarea {
  height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--bg); min-width: 0; width: 100%; transition: border-color .08s, box-shadow .08s; }
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
::placeholder { color: var(--silver); }
select { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236E6E73' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center; }
input.search { width: 280px; padding-left: 30px;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath d='M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20 20l-4-4' fill='none' stroke='%23A3A3A3' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 10px center; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=file] { font-size: 13px; color: var(--grey); }
input[type=file]::file-selector-button { margin-right: 8px; height: 28px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--bg); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.field label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.field .hint { color: var(--grey); }
.field.wide, .check.wide { grid-column: 1 / -1; }
.toolbar .field input[type=date], .toolbar .field input[type=month] { width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 16px; padding: 12px; border-radius: var(--r-md); background: var(--cloud); }
.inline-form .field { flex: 1; }

/* ------------------------------------------------------------ dialog, palette, toast */
.dialog { margin: auto; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--bg); color: var(--ink); box-shadow: var(--shadow-2); }
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(29, 29, 31, .32); }
.dialog[open] { display: flex; flex-direction: column; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.99); } }
.dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.dialog > header h2 { font-size: 16px; }
.dialog-body { padding: 16px 20px; overflow: auto; }
.dialog > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--side); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.media { display: block; max-width: 100%; max-height: 60vh; margin: 0 auto 8px; border-radius: var(--r-md); }
pre.doc, p.doc { white-space: pre-wrap; word-break: break-word; font: 14px/1.6 var(--font); padding: 12px 16px; border-radius: var(--r-sm); background: var(--cloud); max-height: 50vh; overflow: auto; }
.palette { top: 12vh; margin-top: 0; }
.palette > header { display: none; }
.palette .dialog-body { padding: 0; }
.palette-input { height: 48px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; box-shadow: none !important; padding: 0 16px !important; font-size: 15px; }
.palette-list { list-style: none; padding: 6px; max-height: 50vh; overflow: auto; }
.palette-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.palette-list li > span { display: flex; flex-direction: column; }
.palette-list li b { font-weight: 500; }
.palette-list li small { color: var(--grey); }
.palette-list li[aria-selected=true] { background: var(--accent-soft); }
.palette-list .icon { width: 28px; color: var(--grey); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--r-md); background: var(--ink); color: #fff; font-weight: 500;
  box-shadow: var(--shadow-2); opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity .15s, transform .15s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9B1C31; }
.toast .icon { color: #7CE3A3; }

/* ------------------------------------------------------------ gate pages (login, not staff) */
body.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, var(--air), #F6FCFD 55%, var(--bg)); }
.gate-card { width: min(420px, 100%); padding: 32px; text-align: center; background: var(--bg); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-2); }
.gate-card img { height: 30px; width: auto; margin-bottom: 20px; }
.gate-card h1 { font-size: 22px; margin-bottom: 8px; }
.gate-card p { color: var(--grey); margin-bottom: 20px; }
.gate-card .btn { height: 40px; padding: 0 20px; font-size: 14px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .18s ease-out; box-shadow: var(--shadow-2); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(29, 29, 31, .28); }
  .topbar { padding: 0 12px; }
  .topbar > .btn:first-child { display: inline-flex; }
  .content { padding: 16px; }
  input.search { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  }
@media (max-width: 520px) {
  .metrics, .metrics.two { grid-template-columns: 1fr 1fr; }
  .metric.hero { grid-column: 1 / -1; }
  .metric-value { font-size: 20px; }
  .deflist > div { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
