/* Relay agent app ("Postmark"): warm stone, white sheets, plum as the one accent. */

:root {
  --bg: #f1eee9;
  --card: #fff;
  --sheet: #f8f5f1;
  --line: #e6e0d9;
  --line2: #efe9e3;
  --ink: #2a2128;
  --ink2: #5c5258;
  --mute: #857a80;
  --mute2: #a1959b;
  --plum: #8a2f6f;
  --plum-d: #6f2358;
  --plum-bg: #f4e8f0;
  --amber: #d99512;
  --amber-bg: #fdf6e3;
  --red: #b3261e;
  --red-bg: #fbeceb;
  --green: #2f7a4f;
  --head: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
  --body: "Hanken Grotesk", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--plum); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.nav { padding: 18px 12px 14px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; }
.brand { font: 700 23px/1 var(--head); letter-spacing: -.03em; padding: 0 10px; text-decoration: none; color: var(--ink); }
.brand span { color: var(--plum); }
.ws-name { font-size: 12px; color: var(--mute); padding: 4px 10px 16px; }
.nav h6 { margin: 14px 10px 4px; font: 600 11px var(--body); color: var(--mute2); letter-spacing: .02em; }
.nav a.v { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.nav a.v:hover { background: #e9e4dd; }
.nav a.v span { color: var(--mute2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.nav a.v.on { background: var(--ink); color: #fff; }
.nav a.v.on span { color: #d9c4d1; }
.nav a.v.hot span { color: var(--red); font-weight: 600; }
.nav a.v.on.hot span { color: #ffb4ae; }

.demo { margin-top: auto; padding: 12px; border: 1px dashed #d4cbc1; border-radius: 12px; font-size: 12.5px; color: var(--ink2); display: grid; gap: 8px; }
.demo b { font: 700 13px var(--head); color: var(--ink); }
.demo .addr { font: 500 11.5px ui-monospace, "SF Mono", Menlo, monospace; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; word-break: break-all; cursor: copy; }
.demo .row2 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.demo button.link { background: none; border: 0; padding: 0; color: var(--mute); text-decoration: underline; font-size: 12px; }
.demo a.cta { display: block; text-align: center; background: var(--plum); color: #fff; text-decoration: none; padding: 7px 10px; border-radius: 999px; font-weight: 600; }
.demo a.cta:hover { background: var(--plum-d); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; }
.switch input { appearance: none; width: 28px; height: 16px; border-radius: 8px; background: #d4cbc1; position: relative; margin: 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--plum); }
.switch input:checked::after { left: 14px; }
.conn { width: 7px; height: 7px; border-radius: 50%; background: var(--mute2); display: inline-block; }
.conn.on { background: var(--green); box-shadow: 0 0 0 3px #2f7a4f22; }

/* ---------- desk: list + ticket + side ---------- */
.desk { display: grid; grid-template-columns: 340px minmax(0, 1fr) 286px; min-height: 0; }
.list { display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 0 0; }
.lh { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 10px; gap: 8px; }
.lh h1 { margin: 0; font: 700 21px var(--head); letter-spacing: -.02em; }
.lh span { font-size: 12px; color: var(--mute); }
.search { margin: 0 0 10px; position: relative; }
.search input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px 8px 30px; outline: none; }
.search input:focus { border-color: var(--ink2); }
.search svg { position: absolute; left: 10px; top: 10px; color: var(--mute2); }
.rows { overflow-y: auto; min-height: 0; padding: 0 2px 16px 0; flex: 1; }
.row { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 6px; padding: 10px 12px 9px; transition: border-color .12s, box-shadow .12s; position: relative; }
.row:hover { border-color: #cfc5bb; }
.row.on { border-color: var(--ink); box-shadow: 0 2px 0 var(--ink); }
.row.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { 0% { background: var(--plum-bg); } 100% { background: #fff; } }
.row .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.row .who .cc { font: 500 10.5px ui-monospace, Menlo, monospace; color: var(--mute2); }
.row .who .unread { width: 7px; height: 7px; border-radius: 50%; background: var(--plum); flex: none; align-self: center; }
.row time { font-size: 11.5px; color: var(--mute2); flex: none; }
.row .subj { margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .prev { color: var(--mute); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row .meta { display: flex; gap: 6px; align-items: center; margin-top: 7px; font-size: 11.5px; flex-wrap: wrap; }
.row .meta .avs { margin-left: auto; display: flex; gap: 2px; align-items: center; }
.row .eye { position: absolute; top: -7px; right: 10px; display: flex; gap: 2px; }
.empty { text-align: center; color: var(--mute); padding: 40px 16px; font-size: 13px; }

.sla { font-size: 11.5px; font-weight: 600; color: var(--ink2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sla::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #c9bfc5; margin-right: 5px; vertical-align: 0; }
.sla.warn::before { background: var(--amber); }
.sla.late { color: var(--red); }
.sla.late::before { background: var(--red); animation: pulse 1.6s infinite; }
.sla.met::before { background: var(--green); }
.sla.met, .sla.missed { font-weight: 500; color: var(--mute); }
@keyframes pulse { 50% { opacity: .35; } }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--plum-bg); color: var(--plum); white-space: nowrap; }
.chip.gray { background: #f1ece6; color: var(--ink2); }
.pri { font-size: 11px; font-weight: 600; text-transform: capitalize; }
.pri.urgent { color: var(--red); }
.pri.high { color: #b4590e; }
.pri.normal, .pri.low { color: var(--mute); font-weight: 500; }
.st { font-size: 11px; font-weight: 600; text-transform: capitalize; color: var(--mute); }
.st.pending { color: #6b5aa6; }
.st.solved { color: var(--green); }

.av { --c: #888; --s: 22px; width: var(--s); height: var(--s); border-radius: 50%; background: var(--c); color: #fff; display: inline-grid; place-items: center; font: 700 calc(var(--s) * .42) / 1 var(--body); letter-spacing: .02em; flex: none; border: 2px solid #fff; }

/* ticket sheet */
.tk { background: #fff; margin: 12px 0 12px 10px; border-radius: 16px 0 0 16px; border: 1px solid var(--line); border-right: 0; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.tk-empty { margin: auto; text-align: center; color: var(--mute); max-width: 280px; }
.tk-empty b { display: block; font: 700 18px var(--head); color: var(--ink); margin-bottom: 4px; }
.tk header { padding: 16px 22px 12px; border-bottom: 1px solid var(--line2); }
.tk .back { display: none; }
.tk h2 { margin: 0; font: 700 21px/1.18 var(--head); letter-spacing: -.02em; }
.tk .sub-en { color: var(--mute); margin-top: 2px; font-size: 13.5px; }
.tk .hm { display: flex; gap: 6px 10px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--mute); margin-top: 8px; }
.tk .hm a { color: var(--mute); }
.statusbar { display: flex; gap: 0; margin-left: auto; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.statusbar button { border: 0; background: #fff; padding: 4px 11px; font-size: 12px; font-weight: 600; color: var(--ink2); }
.statusbar button + button { border-left: 1px solid var(--line); }
.statusbar button.on { background: var(--ink); color: #fff; }
.presence { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--plum); min-height: 18px; margin-top: 8px; }
.presence:empty { display: none; }
.dots i { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: currentColor; margin-right: 2px; animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.thread { flex: 1; overflow-y: auto; padding: 16px 22px 8px; display: grid; gap: 16px; align-content: start; min-height: 0; }
.msg { padding: 0 0 0 14px; border-left: 3px solid var(--line); max-width: 720px; }
.msg.reply { border-left-color: var(--plum); }
.msg .by { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin-bottom: 4px; color: var(--mute); }
.msg .by b { color: var(--ink); font-weight: 600; }
.msg .body { overflow-wrap: anywhere; }
.msg .tr { margin-top: 7px; background: var(--sheet); border-radius: 8px; padding: 8px 11px; color: var(--ink2); font-size: 13px; overflow-wrap: anywhere; }
.msg .tr em { font-style: normal; font-weight: 600; font-size: 11px; color: var(--plum); display: block; margin-bottom: 2px; }
.msg .tr.pending em { color: var(--mute); }
.msg .flip { background: none; border: 0; padding: 0; margin-top: 6px; font-size: 11.5px; color: var(--mute); text-decoration: underline; }
.msg.note { border-left-color: var(--amber); background: var(--amber-bg); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.msg .ai { font-size: 10.5px; font-weight: 600; color: var(--plum); background: var(--plum-bg); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.event { font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.event::before, .event::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.typing-line { font-size: 12.5px; color: var(--mute); padding: 0 22px 6px; min-height: 22px; }

.compose { margin: 0 22px 18px; background: var(--sheet); border-radius: 14px; border: 1px solid transparent; transition: border-color .15s; }
.compose.note { background: var(--amber-bg); }
.compose:focus-within { border-color: #d8cfc6; }
.compose .tabs { display: flex; gap: 2px; padding: 8px 10px 0; align-items: center; }
.compose .tabs button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--mute); }
.compose .tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.compose .tabs .hint { margin-left: auto; font-size: 11.5px; color: var(--mute); }
.compose textarea { display: block; width: 100%; border: 0; background: transparent; resize: none; padding: 10px 14px; min-height: 92px; max-height: 200px; outline: none; line-height: 1.5; }
.compose .drafted { margin: 0 14px; border-top: 1px dashed #d8cfc6; padding: 8px 0 2px; font-size: 12.5px; color: var(--ink2); }
.compose .drafted em { font-style: normal; font-weight: 600; font-size: 11px; color: var(--plum); display: block; margin-bottom: 2px; }
.compose .drafted .stale { color: var(--mute); font-weight: 500; }
.compose .drafted .local { max-height: 92px; overflow-y: auto; }
.compose .bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px 10px 12px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: #cfc5bb; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.plum { background: var(--plum); border-color: var(--plum); color: #fff; }
.btn.plum:hover { background: var(--plum-d); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ai-btn { border-color: #e3cfdc; color: var(--plum); }
.btn.ai-btn.busy { background: var(--plum-bg); }
.send { margin-left: auto; display: inline-flex; }
.send .btn.plum { border-radius: 999px 0 0 999px; }
.send select { border: 1px solid var(--plum); border-left: 1px solid #a8578f; background: var(--plum); color: #fff; border-radius: 0 999px 999px 0; padding: 0 8px; font-size: 12px; font-weight: 600; outline: none; }
.macro-menu { position: relative; }
.macro-menu ul { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 5; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(42,33,40,.14); list-style: none; margin: 0; padding: 6px; width: 260px; }
.macro-menu li button { width: 100%; text-align: left; border: 0; background: none; padding: 7px 9px; border-radius: 8px; font-size: 13px; }
.macro-menu li button:hover { background: var(--sheet); }
.kbd { font-size: 11px; color: var(--mute2); }

/* side */
.side { padding: 14px 16px 24px; overflow-y: auto; min-height: 0; display: grid; gap: 18px; align-content: start; background: #fff; margin: 12px 0; border: 1px solid var(--line); border-left: 1px solid var(--line2); }
.side h4 { margin: 0 0 8px; font: 700 14px var(--head); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.side h4 small { font: 500 11px var(--body); color: var(--mute); }
.kv { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 6px 8px; font-size: 12.5px; margin: 0; align-items: center; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv select { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 2px 4px; margin-left: -5px; text-transform: capitalize; cursor: pointer; }
.kv select:hover { border-color: var(--line); background: #fff; }
.summary { font-size: 13px; color: var(--ink2); background: var(--sheet); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.triaging { font-size: 12.5px; color: var(--plum); display: flex; gap: 8px; align-items: center; }
.meter { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 6px; border-radius: 3px; background: var(--mute2); }
.meter.warn i { background: var(--amber); }
.meter.late i { background: var(--red); }
.meter.met i { background: var(--green); }
.others { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.others li { display: flex; justify-content: space-between; gap: 8px; }
.others li span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art { border: 1px solid var(--line2); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; }
.art + .art { margin-top: 6px; }
.art summary { cursor: pointer; font-weight: 600; list-style: none; }
.art summary::-webkit-details-marker { display: none; }
.art p { margin: 6px 0 0; color: var(--ink2); }
.art.used summary::after { content: "used in draft"; font-size: 10.5px; color: var(--plum); background: var(--plum-bg); padding: 0 5px; border-radius: 4px; margin-left: 6px; font-weight: 600; }
.mini { background: none; border: 0; padding: 0; color: var(--mute); font-size: 11.5px; text-decoration: underline; }

/* toasts */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 12px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2); display: flex; gap: 12px; align-items: center; animation: up .2s ease-out; }
.toast.bad { background: var(--red); }
.toast button { background: none; border: 0; color: #f0c6e2; font-weight: 700; padding: 0; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

/* ---------- reports ---------- */
.rep { overflow-y: auto; padding: 18px 28px 40px 10px; }
.rep-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.rep h1 { margin: 0; font: 700 26px var(--head); letter-spacing: -.02em; }
.rep .lede { color: var(--mute); margin: 2px 0 0; }
.figs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 20px 0 16px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.fig { padding: 12px 14px 12px 0; }
.fig + .fig { padding-left: 14px; border-left: 1px solid var(--line); }
.fig b { display: block; font: 700 30px/1.1 var(--head); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fig span { font-size: 12.5px; color: var(--mute); }
.fig small { display: block; font-size: 11.5px; color: var(--ink2); margin-top: 2px; }
.panels { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { margin: 0 0 2px; font: 700 16px var(--head); }
.panel .note { font-size: 12px; color: var(--mute); margin: 0 0 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font: 11px var(--body); fill: var(--mute); }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: 96px minmax(0, 1fr) 34px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar .track { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; }
.hbar .track i { display: block; height: 10px; border-radius: 5px; background: var(--plum); }
.hbar span:last-child { text-align: right; color: var(--mute); font-variant-numeric: tabular-nums; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--mute); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line2); font-variant-numeric: tabular-nums; }
.tbl td:first-child { display: flex; gap: 8px; align-items: center; }
.csat-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 6px 0 8px; }
.csat-bar i { display: block; height: 12px; }

/* ---------- narrow screens ---------- */
.side-toggle { display: none !important; }
@media (max-width: 1180px) {
  .desk { grid-template-columns: 300px minmax(0, 1fr); }
  .desk .side { display: none; }
  .desk.with-side .side { display: grid; position: fixed; right: 0; top: 0; bottom: 0; width: min(320px, 100vw); margin: 0; z-index: 20; box-shadow: -10px 0 30px rgba(42,33,40,.15); }
  .side-toggle { display: inline-flex !important; }
  .tk { border-right: 1px solid var(--line); border-radius: 16px; margin-right: 12px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .nav { min-width: 0; flex-direction: row; align-items: center; padding: 10px 12px; gap: 6px; overflow-x: auto; overflow-y: hidden; border-bottom: 1px solid var(--line); }
  .nav .brand { font-size: 20px; padding: 0 8px 0 2px; }
  .nav .ws-name, .nav h6, .nav .demo { display: none; }
  .nav a.v { flex: none; padding: 5px 10px; gap: 6px; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .list { padding: 12px 12px 0; }
  .desk.has-ticket .list { display: none; }
  .desk:not(.has-ticket) .tk { display: none; }
  .tk { margin: 0; border-radius: 0; border: 0; }
  .tk .back { display: inline-flex; margin-bottom: 8px; }
  .tk header { padding: 12px 16px 10px; }
  .thread { padding: 12px 16px 8px; }
  .compose { margin: 0 10px 10px; }
  .compose .tabs .hint, .compose .kbd { display: none; }
  .compose .tabs button { white-space: nowrap; }
  .statusbar { margin-left: 0; }
  .rep { padding: 16px; }
  .figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fig:nth-child(odd) { padding-left: 0; border-left: 0; }
  .fig { border-bottom: 1px solid var(--line2); }
  .panels { grid-template-columns: 1fr; }
}
.mobile-demo { display: none; }
@media (max-width: 860px) { .mobile-demo { display: block; margin: 0 0 10px; font-size: 12.5px; color: var(--ink2); background: #fff; border: 1px dashed #d4cbc1; border-radius: 10px; padding: 8px 10px; } }
