/* Xpace Chat — one stylesheet. Blue + white, Inter. Desktop ≥1024 three columns; phone <768 stacked with bottom bar. */
:root{
  --blue:#1657D6;--blue-dk:#0F3FA3;--blue-bg:#EAF0FF;--blue-line:#C9D7F6;--blue-soft:#DCEBFF;--blue-ava:#D7E2FA;
  --ink:#141A2B;--ink2:#3B4252;--muted:#5B6475;--line:#E3E8F0;--line2:#F0F2F6;--ground:#F3F5F9;--card:#FFFFFF;--soft:#F7F9FC;
  --green-bg:#E9F9EE;--green:#0B6B33;--green-dot:#1C9A4F;--red-bg:#FDE8E8;--red:#A3261F;--amber-bg:#FFF4E0;--amber:#8A5A00;--amber-dot:#E0A100;
  --grey-bg:#E3E8F0;--purple-bg:#F3E8FF;--purple:#6B2FB3;--orange-bg:#FFF1E6;--orange:#9A4B00;--teal-bg:#E6F4EA;
  --r:12px;--r-lg:16px;--font:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font:14px/1.45 var(--font);color:var(--ink);background:var(--ground);-webkit-font-smoothing:antialiased}
a{color:var(--blue);text-decoration:none}a:hover{color:var(--blue-dk)}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none;padding:0}
button:disabled{opacity:.5;cursor:default}
:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
h1,h2,h3{margin:0}
.boot{padding:40px;color:var(--muted);text-align:center}

/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:40px;padding:0 16px;border-radius:10px;font-weight:600;border:1px solid var(--line);background:var(--card);color:var(--ink);white-space:nowrap}
.btn:hover{background:var(--soft)}
.btn.primary{background:var(--blue);color:#fff;border-color:var(--blue)}.btn.primary:hover{background:var(--blue-dk)}
.btn.outline{border-color:var(--blue);color:var(--blue)}.btn.outline:hover{background:var(--blue-bg)}
.btn.ghost{border-color:transparent;color:var(--muted)}.btn.ghost:hover{background:var(--soft)}
.btn.sm{height:32px;padding:0 12px;font-size:12px;border-radius:8px}
.btn.lg{height:46px;font-size:15px;font-weight:700;border-radius:12px}
.btn.fb{background:#1877F2;color:#fff;border-color:#1877F2;height:44px}
.btn.block{width:100%}
.pill{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 10px;border-radius:999px;border:1px solid var(--line);background:var(--card);color:var(--muted);font-weight:600;font-size:12px;white-space:nowrap}
.pill.on{border-color:var(--blue);background:var(--blue-bg);color:var(--blue)}
.pill.green{border-color:var(--green-dot);background:var(--green-bg);color:var(--green)}
.tag{display:inline-flex;align-items:center;gap:4px;font-size:11px;padding:2px 8px;border-radius:999px;font-weight:600;white-space:nowrap}
.tag.red{background:var(--red-bg);color:var(--red)}.tag.amber{background:var(--amber-bg);color:var(--amber)}
.tag.blue{background:var(--blue-bg);color:var(--blue)}.tag.green{background:var(--green-bg);color:var(--green)}
.tag.grey{background:var(--grey-bg);color:var(--ink2)}.tag.strong{font-weight:700}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block;background:var(--green-dot)}
.dot.amber{background:var(--amber-dot)}.dot.grey{background:#C9D1DE}
.ava{width:40px;height:40px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:600;flex-shrink:0;background:var(--blue-ava);color:var(--blue);font-size:13px}
.ava.sm{width:32px;height:32px;font-size:12px}.ava.ink{background:var(--ink);color:#fff}.ava.blue{background:var(--blue);color:#fff}
.ava.c1{background:var(--teal-bg);color:var(--green)}.ava.c2{background:var(--purple-bg);color:var(--purple)}.ava.c3{background:var(--orange-bg);color:var(--orange)}.ava.c4{background:var(--grey-bg);color:var(--ink2)}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r-lg)}
.card.pad{padding:18px 20px}
.kicker{font-size:12px;font-weight:700;color:var(--muted);letter-spacing:.04em;text-transform:uppercase}
.kicker.blue{color:var(--blue)}
.muted{color:var(--muted)}.small{font-size:12px}.b{font-weight:600}.bb{font-weight:700}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.col{display:flex;flex-direction:column;gap:10px}
.sb{display:flex;justify-content:space-between;align-items:center;gap:8px}
.input,textarea.input,select.input{width:100%;height:42px;border:1px solid var(--line);border-radius:10px;padding:0 12px;background:#fff}
textarea.input{height:auto;padding:10px 12px;line-height:1.5;resize:vertical}
label.f{display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--muted);font-weight:600}
label.f .input{font-weight:400;color:var(--ink);font-size:14px}
.table{width:100%;border-collapse:collapse;font-size:13px}
.table th{text-align:left;font-weight:600;color:var(--muted);padding:10px 12px;background:var(--soft)}
.table td{padding:12px;border-top:1px solid var(--line2);vertical-align:middle}
.empty{padding:28px 20px;color:var(--muted);text-align:center;line-height:1.5}
.banner{padding:10px 14px;border-radius:10px;font-size:13px}
.banner.amber{background:var(--amber-bg);color:var(--amber)}.banner.red{background:var(--red-bg);color:var(--red)}.banner.blue{background:var(--blue-bg);color:var(--blue)}.banner.grey{background:var(--soft);color:var(--muted)}

/* shell */
.app{min-height:100%;display:flex;flex-direction:column}
.topbar{height:56px;background:var(--card);border-bottom:1px solid var(--line);display:flex;align-items:center;gap:16px;padding:0 20px;position:sticky;top:0;z-index:20}
.brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:16px;color:var(--ink)}
.logo{width:28px;height:28px;border-radius:8px;background:var(--blue);color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:700}
.topnav{display:flex;gap:4px;margin-left:16px}
.topnav a{padding:8px 12px;border-radius:8px;color:var(--muted);font-weight:500}
.topnav a.on{background:var(--blue-bg);color:var(--blue);font-weight:600}
.topright{margin-left:auto;display:flex;align-items:center;gap:12px}
.main{flex:1;display:flex;flex-direction:column;min-height:0}
.page{max-width:1240px;width:100%;margin:0 auto;padding:28px 24px 48px;display:flex;flex-direction:column;gap:22px}
.page.narrow{max-width:900px}
.three{display:flex;flex:1;min-height:0;height:calc(100vh - 56px)}
.three>.left{flex:0 0 340px;background:var(--card);border-right:1px solid var(--line);display:flex;flex-direction:column;overflow:auto}
.three>.mid{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--ground)}
.three>.right{flex:0 0 320px;background:var(--card);border-left:1px solid var(--line);padding:18px;display:flex;flex-direction:column;gap:18px;overflow:auto}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.grid3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}
.grid4{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.kpi{padding:16px 18px}.kpi .v{font-size:28px;font-weight:700;margin-top:6px}

/* chat list */
.chatlist .item{display:flex;gap:12px;padding:12px 16px;border-top:1px solid var(--line2);color:var(--ink);width:100%;text-align:left;border-left:3px solid transparent}
.chatlist .item:first-child{border-top:0}
.chatlist .item.on{background:var(--blue-bg);border-left-color:var(--blue)}
.chatlist .item:hover{background:var(--soft)}
.chatlist .body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.chatlist .t{display:flex;justify-content:space-between;gap:8px}
.chatlist .prev{font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chatlist .tags{display:flex;gap:6px;margin-top:3px;flex-wrap:wrap}
.filters{padding:14px 16px 10px;display:flex;flex-direction:column;gap:10px;border-bottom:1px solid var(--line2)}
.filters .row{overflow-x:auto;flex-wrap:nowrap}
.group-h{padding:10px 16px 4px;font-size:11px;font-weight:700;color:var(--muted);letter-spacing:.04em}
.group-h.red{color:var(--red)}

/* conversation */
.convo-h{min-height:56px;background:var(--card);border-bottom:1px solid var(--line);display:flex;align-items:center;gap:12px;padding:8px 20px;flex-wrap:wrap}
.back svg,.btn svg{width:20px;height:20px}
.convo{flex:1;overflow:auto;padding:20px;display:flex;flex-direction:column;gap:12px}
.daysep{align-self:center;font-size:12px;color:var(--muted)}
.sys{align-self:center;font-size:12px;color:var(--muted);background:var(--grey-bg);padding:4px 12px;border-radius:999px;text-align:center}
.msg{max-width:70%;display:flex;flex-direction:column;gap:4px}
.msg.in{align-self:flex-start}.msg.out{align-self:flex-end;align-items:flex-end}
.msg .who{font-size:11px;color:var(--muted);display:flex;gap:6px;align-items:center}
.msg .who b{color:var(--ink)}
.bubble{padding:10px 14px;border-radius:14px;background:var(--card);border:1px solid var(--line);white-space:pre-wrap;word-break:break-word}
.msg.in .bubble{border-bottom-left-radius:4px}
.msg.out .bubble{background:var(--blue-soft);border-color:var(--blue-soft);border-bottom-right-radius:4px}
.bubble.team{border-style:dashed;border-color:#B8C2D3}
.bubble .meta{font-size:11px;color:var(--muted);margin-top:4px}
.msg.out .bubble .meta{text-align:right}
.bubble .tr{font-size:11px;color:var(--muted);margin-top:6px;border-top:1px solid var(--line2);padding-top:6px}
.draftcard{background:var(--card);border:1px solid var(--blue-line);border-radius:14px;padding:14px 16px;display:flex;flex-direction:column;gap:10px;box-shadow:0 1px 2px rgba(20,26,43,.04)}
.draftcard p{margin:0;line-height:1.5}
.composer{padding:12px 20px 16px;background:var(--card);border-top:1px solid var(--line);display:flex;flex-direction:column;gap:10px}
.composer .line{display:flex;gap:10px;align-items:center}
.composer .line label{flex:1;min-width:0}
.composer .input{height:44px;border-radius:12px}
.popover{position:absolute;bottom:64px;left:20px;right:20px;max-width:520px;background:var(--card);border:1px solid var(--line);border-radius:12px;box-shadow:0 8px 24px rgba(20,26,43,.12);padding:8px;z-index:5;max-height:300px;overflow:auto}
.popover button{display:block;width:100%;text-align:left;padding:10px 12px;border-radius:8px}
.popover button:hover{background:var(--soft)}
.kv{display:grid;grid-template-columns:auto 1fr;gap:10px 12px;font-size:13px}
.kv .k{color:var(--muted)}
.panel-box{border:1px solid var(--line);border-radius:12px;padding:12px;display:flex;flex-direction:column;gap:8px}

/* connect tiles */
.tile{padding:22px;display:flex;flex-direction:column;gap:14px;min-width:0}
.tile.req{border:2px solid var(--blue)}
.qrbox{border:1px solid var(--line);border-radius:12px;padding:14px;display:flex;gap:14px;align-items:center}
.qr{width:112px;height:112px;border-radius:8px;flex-shrink:0;border:6px solid #fff;outline:1px solid var(--line);background:#fff;display:flex;align-items:center;justify-content:center;overflow:hidden}
.qr img{width:100%;height:100%}
.qr.ph{background:repeating-conic-gradient(#141A2B 0 25%,#fff 0 50%) 0 0/16px 16px}
.acct{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;border-radius:10px;background:var(--soft);gap:8px;flex-wrap:wrap}
.acct .row{gap:6px}
.sb>.muted{white-space:nowrap;margin-right:8px}
.steps{display:flex;gap:10px;flex-wrap:wrap}
.step{display:inline-flex;align-items:center;gap:6px;padding:8px 12px;border-radius:10px;font-weight:600;font-size:13px;background:var(--amber-bg);color:var(--amber)}
.step.done{background:var(--green-bg);color:var(--green)}
.radio{border:1px solid var(--line);border-radius:12px;padding:12px;display:flex;gap:10px;align-items:flex-start;cursor:pointer}
.radio.on{border:2px solid var(--blue);background:#F8FAFF}
.radio input{margin-top:3px}

/* internal */
.sugg{border:1px solid var(--blue-line);background:#F8FAFF;border-radius:12px;padding:10px 12px;display:flex;flex-direction:column;gap:8px;font-size:13px;margin-top:4px}
.task{display:flex;gap:10px;align-items:flex-start;padding:10px;border:1px solid var(--line);border-radius:10px}
.task.done .tt{text-decoration:line-through;color:var(--muted)}

/* toasts */
.toasts{position:fixed;right:16px;bottom:16px;display:flex;flex-direction:column;gap:8px;z-index:50}
.toast{background:var(--ink);color:#fff;padding:10px 14px;border-radius:10px;font-size:13px;box-shadow:0 8px 24px rgba(0,0,0,.2);max-width:360px}
.toast.err{background:var(--red)}.toast.ok{background:var(--green)}

/* login */
.login{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:24px}
.login .card{width:100%;max-width:400px;padding:28px;display:flex;flex-direction:column;gap:14px}

/* mobile */
.bottombar{display:none}
.back{display:none}
.phone-only{display:none}
@media (max-width:1023px){
  .three>.right{display:none}
  .three>.right.open{display:flex;position:fixed;inset:56px 0 0 0;z-index:30;overflow:auto}
  .three>.left{flex:0 0 300px}
  .grid3{grid-template-columns:1fr}.grid4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .phone-only{display:inline-flex}
}
@media (max-width:767px){
  .topnav,.topright .hide-m{display:none}
  .topbar{padding:0 16px}
  .main{padding-bottom:84px}
  .three{height:auto;min-height:calc(100vh - 140px);flex-direction:column}
  .three>.left{flex:1;border-right:0}
  .three>.mid{display:none}
  .three.showmid>.left{display:none}
  .three.showmid>.mid{display:flex;position:fixed;left:0;right:0;top:56px;bottom:84px;z-index:15}
  .three.showmid>.right.open{inset:56px 0 84px 0}
  .hide-m{display:none !important}
  .convo-h{padding:8px 12px;gap:8px}
  .convo-h .tag{font-size:11px}
  .back{display:inline-flex}
  .msg{max-width:86%}
  .page{padding:16px 16px 40px;gap:16px}
  .grid2{grid-template-columns:1fr}.grid4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .bottombar{display:grid;position:fixed;left:0;right:0;bottom:0;height:84px;background:var(--card);border-top:1px solid var(--line);grid-template-columns:repeat(4,minmax(0,1fr));padding:8px 8px calc(16px + env(safe-area-inset-bottom));z-index:20}
  .bottombar a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:11px;font-weight:600;color:var(--muted);border-radius:10px;min-height:44px}
  .bottombar a.on{color:var(--blue);background:var(--blue-bg);font-weight:700}
  .bottombar svg{width:22px;height:22px}
  .draftcard .row .btn{flex:1}
  .composer{padding:10px 14px 14px}
  .composer .line{flex-wrap:wrap}
  .composer .line label{flex:1 1 100%}
  .composer .line .btn{flex:1}
  .popover{left:12px;right:12px}
  .table-wrap{overflow-x:auto}
}
