:root{--bg:#eef2f5;--card:#fff;--ink:#16202a;--muted:#667788;--line:#dde3e9;--brand:#0b6e63;--brand-2:#0e8a7c;--mine:#d9f5ee;--corr:#fff4d6;--corr-line:#e3a008;--radius:10px}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font:15px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;color:var(--ink);background:var(--bg)}
a{color:var(--brand)}
.muted{color:var(--muted)}.small{font-size:.85em}
h2{margin:.2em 0 .6em;font-size:1.25rem}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 16px;background:var(--brand);color:#fff;height:56px}
.topbar a{color:#fff;text-decoration:none}
.topbar nav{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.topbar .muted{color:#bfe3dd}
.brand{display:flex;align-items:center;gap:8px;font-weight:700;font-size:1.05rem;white-space:nowrap}
.brand.big{font-size:1.3rem;margin-bottom:6px;color:var(--brand)}
.logo{display:inline-grid;place-items:center;width:30px;height:30px;border-radius:8px;background:#fff;color:var(--brand);font-weight:800}
.brand.big .logo{background:var(--brand);color:#fff}
.me{display:flex;align-items:center;gap:6px}
.inline{display:inline;margin:0}
.linkbtn{background:none;border:0;color:#fff;cursor:pointer;font:inherit;padding:0;text-decoration:underline}
.btn{display:inline-block;padding:8px 14px;border-radius:8px;border:1px solid var(--line);background:#fff;color:var(--ink);font:inherit;cursor:pointer;text-decoration:none;white-space:nowrap}
.btn:hover{border-color:#b9c4ce}
.btn-primary{background:var(--brand-2);border-color:var(--brand-2);color:#fff !important}
.topbar .btn-primary{background:#fff;color:var(--brand) !important;border-color:#fff;font-weight:600}
.btn.small{padding:4px 9px;font-size:.85em}
.btn.full{width:100%}
.btn[disabled]{opacity:.6;cursor:wait}
input,select,textarea{font:inherit;padding:9px 11px;border:1px solid var(--line);border-radius:8px;background:#fff;width:100%;color:var(--ink)}
textarea{resize:vertical}
input:focus,select:focus,textarea:focus{outline:2px solid #9fd8cf;border-color:var(--brand-2)}
label{display:block;margin:0 0 12px;font-weight:600;font-size:.92em}
label input,label select,label textarea{margin-top:5px;font-weight:400}
label.check{display:flex;align-items:center;gap:8px;font-weight:400;margin:0;padding:7px 10px;border-bottom:1px solid var(--line);cursor:pointer}
label.check input{width:auto;margin:0}
.badge{display:inline-block;font-size:.72em;font-weight:600;padding:1px 7px;border-radius:999px;background:#e7ecf0;color:#3b4b5a;vertical-align:middle}
.role-admin{background:#e9e2fb;color:#4b2fa3}.role-bdo{background:#fde7d3;color:#9a4a07}.role-analyst{background:#dbeafe;color:#1d4ed8}.role-client{background:#e3f4e8;color:#17663a}
.badge.corr{background:var(--corr-line);color:#fff}
.flashes{position:fixed;top:64px;left:50%;transform:translateX(-50%);z-index:50;width:min(720px,94vw)}
.flash{padding:10px 14px;border-radius:8px;margin-bottom:6px;background:#e7f6ee;border:1px solid #9bd5b1;box-shadow:0 4px 14px rgba(0,0,0,.08);cursor:pointer}
.flash-error{background:#fde8e8;border-color:#f3a5a5}
.flash-cred{background:#fff8dc;border-color:#e3c45a;font-family:ui-monospace,Consolas,monospace;user-select:all}
.center-page{display:grid;place-items:center;min-height:100vh}
.card{background:var(--card);border-radius:var(--radius);padding:22px;box-shadow:0 1px 3px rgba(0,0,0,.06)}
.card.narrow{width:min(400px,94vw)}
.card.wide{width:min(980px,96vw);margin:18px auto}
.page{padding:4px 0 30px}
/* layout */
.app{height:100vh;display:flex;flex-direction:column;overflow:hidden}
.app .page{overflow:auto;flex:1}
.layout{flex:1;display:flex;min-height:0}
.sidebar{width:360px;min-width:280px;background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column}
.search{display:flex;gap:6px;padding:10px;border-bottom:1px solid var(--line)}
.search select{width:130px}
.threadlist{overflow-y:auto;flex:1}
.thread-item{display:block;padding:10px 12px;border-bottom:1px solid #eef1f4;text-decoration:none;color:inherit}
.thread-item:hover{background:#f5f8fa}
.thread-item.active{background:#e3f3f0}
.thread-item .row1,.thread-item .row2,.thread-item .row3{display:flex;align-items:center;gap:8px}
.thread-item .subject{font-weight:600;flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.thread-item.has-unread .subject{font-weight:800}
.thread-item .time{font-size:.78em;color:var(--muted)}
.thread-item.has-unread .time{color:var(--brand-2);font-weight:700}
.thread-item .others{flex:1;font-size:.82em;color:var(--muted);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.thread-item .preview{flex:1;font-size:.86em;color:#455565;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.thread-item .files{font-size:.78em;color:var(--muted)}
.unread{background:var(--brand-2);color:#fff;border-radius:999px;font-size:.75em;font-weight:700;padding:1px 7px;min-width:20px;text-align:center}
.empty-list{padding:30px;text-align:center;color:var(--muted)}
.pill,.pill-select{display:inline-block;font-size:.75em;font-weight:600;padding:2px 8px;border-radius:999px;background:#e7ecf0;color:#3b4b5a;white-space:nowrap}
.pill-select{width:auto;font-size:.85em;padding:5px 10px;border:0;cursor:pointer}
.status-open{background:#e0ecff;color:#1d4ed8}.status-under-review{background:#ede4ff;color:#5b21b6}
.status-needs-correction{background:#fff1cc;color:#92400e}.status-approved{background:#d8f5e1;color:#166534}
.status-declined{background:#fde2e2;color:#991b1b}.status-closed{background:#e5e7eb;color:#4b5563}
.pane{flex:1;display:flex;flex-direction:column;min-width:0}
.empty-pane{display:grid;place-items:center;text-align:center;padding:30px}
.chat-head{display:flex;align-items:center;gap:12px;padding:10px 16px;background:#fff;border-bottom:1px solid var(--line)}
.chat-head .titles{flex:1;min-width:0}
.chat-head h2{margin:0;font-size:1.08rem;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.chat-head .members{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.chat-head .back{display:none;font-size:1.4rem;text-decoration:none}
.statusform{margin:0}
.addpeople{position:relative}
.addpeople summary{list-style:none}
.addpeople summary::-webkit-details-marker{display:none}
.dropdown{position:absolute;right:0;top:110%;width:300px;background:#fff;border:1px solid var(--line);border-radius:10px;padding:10px;box-shadow:0 8px 24px rgba(0,0,0,.12);z-index:20}
.checklist{max-height:220px;overflow:auto;border:1px solid var(--line);border-radius:8px;margin:8px 0 10px}
.checklist.tall{max-height:260px}
.messages{flex:1;overflow-y:auto;padding:16px 4%;background:#e9eef1}
.msg{display:flex;margin:6px 0}
.msg.mine{justify-content:flex-end}
.bubble{max-width:min(640px,82%);background:#fff;border-radius:10px;padding:8px 11px 5px;box-shadow:0 1px 1px rgba(0,0,0,.06)}
.msg.mine .bubble{background:var(--mine)}
.msg.correction .bubble{background:var(--corr);border-left:4px solid var(--corr-line)}
.who{font-size:.8em;font-weight:700;color:#334;margin-bottom:2px}
.body{white-space:pre-wrap;word-wrap:break-word}
.bubble .time{font-size:.72em;color:var(--muted);text-align:right;margin-top:2px}
.atts{display:flex;flex-direction:column;gap:6px;margin-top:6px}
.att{display:flex;align-items:center;gap:8px;padding:7px 9px;border-radius:8px;background:rgba(0,0,0,.04);text-decoration:none;color:inherit}
.att:hover{background:rgba(0,0,0,.08)}
.att .ext{display:inline-grid;place-items:center;min-width:38px;height:38px;border-radius:6px;background:#c0392b;color:#fff;font-size:.7em;font-weight:800}
.att .name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;font-size:.9em}
.att .sz{font-size:.78em;color:var(--muted)}
.att.img{flex-direction:column;align-items:flex-start}
.att.img img{max-width:260px;max-height:220px;border-radius:6px;display:block}
.att.img span{font-size:.78em;color:var(--muted)}
.event{text-align:center;margin:10px 0}
.event span{display:inline-block;font-size:.78em;background:#dbe5ea;color:#3d4d5c;padding:3px 10px;border-radius:999px}
.composer{background:#f6f8fa;border-top:1px solid var(--line);padding:8px 12px}
.composer-row{display:flex;align-items:flex-end;gap:8px}
.composer textarea{flex:1;min-height:44px;max-height:200px}
.attach{margin:0;font-size:1.4rem;cursor:pointer;padding:6px}
.attach input{display:none}
.corr-toggle{border:0;padding:4px 0 0 40px}
.filechips{display:flex;flex-wrap:wrap;gap:6px}
.filechips:not(:empty){margin:4px 0 8px}
.chip{font-size:.8em;background:#fff;border:1px solid var(--line);border-radius:999px;padding:3px 10px}
.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:6px}
.grid-form{display:grid;grid-template-columns:repeat(4,1fr) auto;gap:10px;align-items:end}
.grid-form label{margin:0}
.tablewrap{overflow:auto;margin-top:10px}
table{width:100%;border-collapse:collapse;font-size:.92em}
th,td{text-align:left;padding:7px 8px;border-bottom:1px solid var(--line);vertical-align:middle}
td select{padding:5px 8px;width:auto}
td form{margin:0;display:inline}
tr.inactive td{color:#99a}
.filter{margin-bottom:4px}
@media (max-width:760px){
  .topbar{height:auto;flex-wrap:wrap;padding:8px 10px}
  .topbar nav{gap:10px;font-size:.9em}
  .me{display:none}
  .sidebar{width:100%;border-right:0}
  .view-inbox .pane{display:none}
  .view-thread .sidebar{display:none}
  .chat-head .back{display:block}
  .grid-form{grid-template-columns:1fr}
  .messages{padding:10px 8px}
  .bubble{max-width:90%}
}
/* downloads */
.att .name{display:flex;flex-direction:column}
.att .name .sz{font-weight:400}
.dlbtn{flex-shrink:0;font-size:.8em;font-weight:600;padding:5px 10px;border-radius:6px;background:var(--brand-2);color:#fff;text-decoration:none;white-space:nowrap}
.dlbtn:hover{background:var(--brand)}
.att-foot{display:flex;align-items:center;gap:10px;width:100%;justify-content:space-between}
.files-panel{width:340px}
.files-panel .btn{text-align:center}
.file-row{display:flex;align-items:center;gap:8px;padding:8px 10px;border-bottom:1px solid var(--line);text-decoration:none;color:inherit}
.file-row:hover{background:#f5f8fa}
.file-row .name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.9em}
.file-row .dl{color:var(--brand-2);font-weight:700}
#tolist label.check:has(input:checked){background:#e3f3f0}
.sendmode{border:1px solid var(--line);border-radius:8px;padding:4px 0 0;margin:0 0 12px}
.sendmode[hidden]{display:none}
.sendmode legend{font-weight:600;padding:0 6px;margin-left:8px}
.sendmode label.check:last-child{border-bottom:0}
.sendmode label.check:has(input:checked){background:#e3f3f0}
td input{padding:5px 8px;min-width:150px}
.boxtabs{display:flex;border-bottom:1px solid var(--line);background:#fff}
.boxtabs a{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:11px 8px;font-weight:600;color:#5b6b7a;text-decoration:none;border-bottom:3px solid transparent}
.boxtabs a:hover{background:#f3f7f6}
.boxtabs a.on{color:var(--brand);border-bottom-color:var(--brand)}
.tabcount:not(:empty){min-width:20px;padding:0 6px;border-radius:999px;background:var(--brand);color:#fff;font-size:.75em;line-height:20px;text-align:center}
