:root {
  --brand: #5a1e2b; --brand-2: #7a2c3c; --gold: #c8a24a;
  --bg: #efeae2; --panel: #ffffff; --panel-2: #f6f5f3; --line: #e3e0da;
  --text: #1f1a17; --muted: #6f6760; --out: #f3e3c4; --in: #ffffff; --tick: #2f8fd8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14100f; --panel: #1f1918; --panel-2: #29211f; --line: #382e2b;
    --text: #efe7e2; --muted: #a59a93; --out: #5a3a22; --in: #2a2220; --brand: #7a2c3c; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: #c0392b; min-height: 1.2em; margin: 0; }

/* Login */
#login { height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, var(--brand), #2b0e15); }
.card { background: var(--panel); padding: 28px; border-radius: 14px; width: min(380px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
#loginForm { display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: stretch; }
#loginForm img { align-self: center; }
#loginForm h1 { margin: 0; color: var(--brand); }
#loginForm p { margin: 0 0 6px; }
.card input, .card select { padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); width: 100%; }
button.primary { background: var(--brand); color: #fff; border: 0; padding: 11px; border-radius: 8px; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--line); padding: 10px; border-radius: 8px; }

/* Layout */
#app { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; height: 100%; }
#sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; position: relative; }
.bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); min-height: 60px; }
.bar .me { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; }
.bar .me div, .chatInfo { display: flex; flex-direction: column; min-width: 0; }
.bar small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions button, .back, #replyCancel { background: none; border: 0; font-size: 18px; padding: 6px 8px; border-radius: 50%; color: var(--muted); }
.actions button:hover { background: var(--line); }
.dropdown { position: absolute; top: 54px; right: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.15); z-index: 10; display: flex; flex-direction: column; overflow: hidden; }
.dropdown button { background: none; border: 0; text-align: left; padding: 11px 18px; }
.dropdown button:hover { background: var(--panel-2); }
.search { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.search input { width: 100%; padding: 8px 12px; border-radius: 8px; border: 0; background: var(--panel-2); }

.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; position: relative; }
.avatar.on::after { content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; background: #25d366; border: 2px solid var(--panel); border-radius: 50%; }

#chatList { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#chatList li { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line); align-items: center; }
#chatList li:hover, #chatList li.active { background: var(--panel-2); }
#chatList .txt { flex: 1; min-width: 0; }
#chatList .row { display: flex; justify-content: space-between; gap: 8px; }
#chatList .row b, #chatList .row span.prev { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatList time { font-size: 12px; color: var(--muted); flex: none; }
#chatList .badge { background: #25d366; color: #fff; border-radius: 12px; font-size: 12px; padding: 1px 7px; font-weight: 700; flex: none; }
#chatList .sectionTitle { padding: 8px 14px; font-size: 12px; text-transform: uppercase; color: var(--muted); cursor: default; background: var(--panel-2); }

/* Chat */
#main { min-width: 0; height: 100%; }
#chat { display: flex; flex-direction: column; height: 100%; }
.chatInfo { flex: 1; cursor: pointer; }
.back { display: none; }
.emptyState { height: 100%; display: grid; place-content: center; text-align: center; justify-items: center; border-bottom: 6px solid var(--gold); }
#messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 3px;
  background-image: radial-gradient(rgba(90,30,43,.06) 1px, transparent 1px); background-size: 18px 18px; }
.day { align-self: center; background: var(--panel); color: var(--muted); font-size: 12px; padding: 4px 12px; border-radius: 8px; margin: 10px 0; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.sys { align-self: center; background: #fdf3d6; color: #6b5a2a; font-size: 12.5px; padding: 4px 12px; border-radius: 8px; margin: 6px 0; text-align: center; }
@media (prefers-color-scheme: dark) { .sys { background: #3a3220; color: #e2d3a3; } }
.msg { max-width: min(65%, 560px); padding: 6px 9px 6px; border-radius: 8px; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.1); word-wrap: break-word; white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--in); }
.msg.out { align-self: flex-end; background: var(--out); }
.msg.first { margin-top: 6px; }
.msg .who { font-size: 12.5px; font-weight: 700; color: var(--brand-2); display: block; }
@media (prefers-color-scheme: dark) { .msg .who { color: var(--gold); } }
.msg .meta { float: right; font-size: 11px; color: var(--muted); margin: 6px 0 -3px 10px; white-space: nowrap; }
.msg .tick.read { color: var(--tick); }
.msg.deleted .body { font-style: italic; color: var(--muted); }
.msg img { max-width: 100%; max-height: 320px; border-radius: 6px; display: block; margin-bottom: 4px; cursor: zoom-in; }
.msg .file { display: flex; gap: 8px; align-items: center; padding: 8px; background: rgba(0,0,0,.05); border-radius: 6px; color: inherit; text-decoration: none; margin-bottom: 4px; }
.msg .quote { border-left: 4px solid var(--gold); background: rgba(0,0,0,.05); padding: 4px 8px; border-radius: 4px; margin-bottom: 4px; font-size: 13px; cursor: pointer; }
.msg .quote b { display: block; color: var(--brand-2); font-size: 12px; }
.msg .tools { position: absolute; top: 2px; right: 4px; display: none; gap: 2px; background: inherit; border-radius: 6px; }
.msg:hover .tools { display: flex; }
.msg .tools button { border: 0; background: none; font-size: 13px; padding: 2px 4px; color: var(--muted); }
.msg.flash { animation: flash 1.2s; }
@keyframes flash { 0%,60% { box-shadow: 0 0 0 3px var(--gold); } }
.typing { font-style: italic; color: #25a35a !important; }

#replyBar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel-2); border-top: 1px solid var(--line); }
#replyBar div { flex: 1; border-left: 4px solid var(--gold); padding-left: 8px; display: flex; flex-direction: column; font-size: 13px; overflow: hidden; }
#composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; background: var(--panel-2); border-top: 1px solid var(--line); }
#composer textarea { flex: 1; resize: none; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--panel); max-height: 140px; outline: none; }
.attach { font-size: 20px; padding: 8px 4px; cursor: pointer; }
.send { background: var(--brand); color: #fff; border: 0; border-radius: 50%; width: 42px; height: 42px; font-size: 17px; flex: none; }

/* Modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
#modal .card { width: min(480px, 100%); max-height: 85vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
#modal h3 { margin: 0; }
.pick { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick li:hover { background: var(--panel-2); }
.pick li .avatar { width: 34px; height: 34px; font-size: 13px; }
.pick li div { flex: 1; display: flex; flex-direction: column; }
.pick .grp { background: var(--panel-2); font-size: 12px; text-transform: uppercase; color: var(--muted); cursor: default; }
.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: grid; place-items: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }

/* Phone / narrow window */
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #app.inChat #sidebar { display: none; }
  #app:not(.inChat) #main { display: none; }
  .back { display: block; }
  .msg { max-width: 85%; }
  #messages { padding: 12px 10px; }
}

/* External users */
.ext { display: inline-block; font-size: 10.5px; font-weight: 700; color: #8a5a00; background: #fff1cc; border: 1px solid #e8c766; border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: middle; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .ext { color: #f3d27a; background: #3d3112; border-color: #6b5520; } }
#extBanner { background: #fff1cc; color: #6b4a00; font-size: 13px; padding: 7px 14px; border-bottom: 1px solid #e8c766; }
@media (prefers-color-scheme: dark) { #extBanner { background: #3d3112; color: #f3d27a; border-color: #6b5520; } }
#chatTitle .ext { font-size: 11px; }
.pick input[type=checkbox] { width: auto; flex: none; }

/* Login modes */
#otpMode, #pwMode { display: flex; flex-direction: column; gap: 12px; }
.linkBtn { background: none; border: 0; color: var(--brand-2); font-size: 13px; text-decoration: underline; }
/* Alerts prompt */
#alertBar { background: #e7f6ec; color: #1d5c34; padding: 8px 14px; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); }
#alertBar button { background: #25a35a; color: #fff; border: 0; border-radius: 6px; padding: 5px 12px; font-weight: 600; }
@media (prefers-color-scheme: dark) { #alertBar { background: #173322; color: #b6e8c8; } }
/* Voice */
#recBar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--panel-2); border-top: 1px solid var(--line); }
#recBar #recCancel { background: none; border: 0; font-size: 20px; color: #c0392b; }
#recBar .dot { width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: blink 1s infinite; }
#recBar .muted { flex: 1; }
@keyframes blink { 50% { opacity: .2; } }
.msg audio { width: 260px; max-width: 100%; height: 40px; display: block; margin-bottom: 2px; }
/* Cards (PO, etc.) */
.msg.hasCard { width: min(420px, 100%); max-width: 90%; white-space: normal; }
.pcard { border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 8px; background: var(--panel); padding: 10px 12px; margin: 2px 0 4px; }
.pcard h4 { margin: 0 0 2px; font-size: 15px; }
.pcard .sub { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.pcard table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pcard td { padding: 3px 0; vertical-align: top; border-top: 1px dashed var(--line); }
.pcard td:first-child { color: var(--muted); width: 40%; padding-right: 8px; }
.pcard .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pcard .acts button { flex: 1; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 15px; color: var(--text); }
.pcard .acts button.primary { background: #25a35a; border-color: #25a35a; color: #fff; }
.pcard .acts button.danger { background: #fff; border-color: #c0392b; color: #c0392b; }
.pcard .status { margin-top: 8px; font-size: 13px; font-weight: 700; padding: 6px 8px; border-radius: 6px; background: #e7f6ec; color: #1d5c34; }
.pcard .status.neg { background: #fdecea; color: #a12a1e; }
.pcard a.open { display: inline-block; margin-top: 8px; font-size: 13px; color: var(--brand-2); }
.bot { display: inline-block; font-size: 10.5px; font-weight: 700; color: #1e4f8a; background: #e3eefb; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.keybox { font-family: ui-monospace, monospace; font-size: 12.5px; background: var(--panel-2); border: 1px dashed var(--gold); padding: 10px; border-radius: 8px; word-break: break-all; user-select: all; }
pre.code { font-size: 11.5px; background: var(--panel-2); padding: 10px; border-radius: 8px; overflow-x: auto; white-space: pre; margin: 0; }

/* Rate requests */
button.attach { background: none; border: 0; }
.msg.hasRfq { width: min(460px, 100%); max-width: 92%; white-space: normal; }
.rfq { border: 1px solid var(--line); border-left: 4px solid #3b5ba5; border-radius: 8px; background: var(--panel); padding: 10px 12px; margin: 2px 0 4px; }
.rfq h4 { margin: 0; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rfq .vend { font-size: 13px; color: var(--muted); margin: 2px 0 6px; }
.chip { font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 8px; white-space: nowrap; }
.chip.awaiting_rates { background: #fff1cc; color: #8a5a00; } .chip.quoted { background: #e3eefb; color: #1e4f8a; }
.chip.accepted { background: #e7f6ec; color: #1d5c34; } .chip.rejected, .chip.cancelled { background: #fdecea; color: #a12a1e; }
.chip.late { background: #c0392b; color: #fff; margin-left: 4px; }
.rfq table, .cmp table, .hist table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rfq th, .cmp th, .hist th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 4px 4px; border-bottom: 1px solid var(--line); }
.rfq td, .cmp td, .hist td { padding: 5px 4px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.rfq td.r, .rfq th.r, .cmp td.r, .cmp th.r, .hist td.r, .hist th.r { text-align: right; white-space: nowrap; }
.rfq td.rate { font-weight: 700; }
.rfq td.na { color: var(--muted); font-weight: 400; font-style: italic; }
.rfq tr.total td { font-weight: 700; border-bottom: 0; }
.rfq .foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rfq .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.rfq .acts button { flex: 1 1 40%; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 14.5px; color: var(--text); }
.rfq .acts button.primary { background: #25a35a; border-color: #25a35a; color: #fff; }
.rfq .acts button.blue { background: #3b5ba5; border-color: #3b5ba5; color: #fff; }
.rfq .acts button.danger { background: transparent; border-color: #c0392b; color: #c0392b; }
.rfq .acts button.link { flex-basis: 100%; min-height: 0; border: 0; background: none; color: var(--brand-2); font-weight: 600; text-decoration: underline; font-size: 13px; }
.rfq .decision { margin-top: 8px; font-size: 13px; padding: 6px 8px; border-radius: 6px; background: #e7f6ec; color: #1d5c34; }
.rfq .decision.neg { background: #fdecea; color: #a12a1e; }
.formrows { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; }
.formrow { display: grid; grid-template-columns: 1fr 70px 74px 30px; gap: 6px; align-items: center; }
.formrow.quote { grid-template-columns: 1fr 120px; }
.formrow.acc { grid-template-columns: 1fr 76px 90px; }
.formrow input, .formrow select { padding: 9px 8px !important; }
.formrow .lbl { font-size: 14px; }
.formrow .lbl small { display: block; color: var(--muted); }
.formrow .x { background: none; border: 0; color: #c0392b; font-size: 18px; }
.money { display: flex; align-items: center; gap: 4px; } .money span { color: var(--muted); font-size: 13px; }
.cmp { overflow-x: auto; }
.cmp td.best { background: #e7f6ec; color: #1d5c34; font-weight: 700; }
@media (prefers-color-scheme: dark) { .cmp td.best { background: #173322; color: #b6e8c8; } }
.cmp .accBtn { width: 100%; background: #25a35a; color: #fff; border: 0; border-radius: 6px; padding: 7px 4px; font-weight: 700; }
.hist { max-height: 55vh; overflow-y: auto; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; } .chk input { width: auto !important; }
.vlist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; max-height: 22vh; overflow-y: auto; }
.vlist li { padding: 8px 10px; border-bottom: 1px solid var(--line); }

/* Phones with notches / home bars (iPhone, modern Android) when installed full-screen */
#sidebar > .bar, #chat > .bar { padding-top: max(10px, env(safe-area-inset-top)); }
#composer, #recBar { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#chatList { padding-bottom: env(safe-area-inset-bottom); }
#login { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
html, body { overscroll-behavior: none; }
#composer textarea { font-size: 16px; } /* stops iPhone zooming in when typing */

/* Emoji, @mentions, reactions */
#chat { position: relative; }
#emojiPanel { position: absolute; left: 10px; right: 10px; bottom: 70px; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.18); z-index: 20; overflow: hidden; }
#emojiPanel .etabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; }
#emojiPanel .etabs button { border: 0; background: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap; color: var(--muted); }
#emojiPanel .etabs button.on { background: var(--panel-2); color: var(--text); font-weight: 700; }
#emojiPanel .egrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); max-height: 230px; overflow-y: auto; padding: 6px; }
#emojiPanel .egrid button { border: 0; background: none; font-size: 24px; height: 42px; border-radius: 8px; }
#emojiPanel .egrid button:hover { background: var(--panel-2); }
#mentionBox { position: absolute; left: 60px; bottom: 70px; width: min(320px, calc(100% - 80px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.18); z-index: 21; max-height: 300px; overflow-y: auto; }
#mentionBox .mi { display: flex; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; }
#mentionBox .mi.sel, #mentionBox .mi:hover { background: var(--panel-2); }
#mentionBox .mi div { display: flex; flex-direction: column; }
.avatar.sm { width: 32px; height: 32px; font-size: 12px; background: #3b5ba5; }
.mention { color: #1e63c4; font-weight: 700; }
.mention.me { background: #fff1cc; color: #7a4b00; border-radius: 4px; padding: 0 2px; }
@media (prefers-color-scheme: dark) { .mention { color: #8ab8ff; } .mention.me { background: #4a3a12; color: #ffd98a; } }
.msg.mentionsMe { box-shadow: 0 0 0 2px var(--gold), 0 1px 1px rgba(0,0,0,.1); }
#chatList .badge.at { background: var(--gold); margin-right: 4px; }
.rx { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; clear: both; }
.rx button { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 1px 8px; font-size: 14px; line-height: 1.5; color: var(--text); }
.rx button.mine { border-color: #3b5ba5; background: #e3eefb; }
@media (prefers-color-scheme: dark) { .rx button.mine { background: #1d2c47; } }
#rxBar { position: absolute; z-index: 22; display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 4px 6px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
#rxBar button { border: 0; background: none; font-size: 24px; width: 40px; height: 40px; border-radius: 50%; }
#rxBar button:hover { background: var(--panel-2); }
.msg.showTools .tools { display: flex; }
@media (hover: none) { .msg .tools button { font-size: 17px; padding: 4px 7px; } }

#lockedBar { padding: 14px 16px max(14px, env(safe-area-inset-bottom)); background: var(--panel-2); border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; text-align: center; }

/* ---- UI fixes (small phones) ---- */
#modal .card > * { flex-shrink: 0; }                 /* forms no longer squash on short screens */
#modal .card textarea { min-height: 96px; }
#modal .card .formrows { flex-shrink: 0; }
.bar .me b, #meName, #chatTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 100%; }
#meBranch, #chatSub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* message buttons float above the bubble instead of covering it */
.msg .tools { top: -30px; right: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 2px 6px; box-shadow: 0 3px 10px rgba(0,0,0,.12); z-index: 5; }
.msg:hover, .msg.showTools { z-index: 6; }
@media (hover: none) { .msg.showTools { margin-top: 36px; } .msg:hover .tools { display: none; } .msg.showTools .tools { display: flex; } }
@media (max-width: 420px) {
  #composer { gap: 2px; padding-left: 8px; padding-right: 8px; }
  #composer .attach { padding: 8px 3px; font-size: 19px; }
  #composer textarea { padding: 10px 12px; }
  .bar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .actions button { padding: 6px 5px; }
  #alertBar { font-size: 12.5px; }
}
#modal .formrows { max-height: none; overflow: visible; }
.pick li { flex-wrap: wrap; row-gap: 6px; }
.pick li > button.ghost { padding: 6px 10px; font-size: 13px; }
@media (max-width: 420px) {
  .formrow { grid-template-columns: 1fr 1fr 32px; }
  .formrow .n { grid-column: 1 / -1; }
  .formrow.quote, .formrow.acc { grid-template-columns: 1fr 1fr; }
  .formrow.quote .lbl, .formrow.acc .lbl { grid-column: 1 / -1; }
  #modal .row2:has(input), #modal .row2:has(select) { flex-direction: column; }
  #modal .card { padding: 20px 16px; }
  .pick li > div { min-width: 0; flex: 1 1 120px; }
}

/* Tasks */
.tcard { border: 1px solid var(--line); border-left: 4px solid #25a35a; border-radius: 8px; background: var(--panel); padding: 10px 12px; margin: 2px 0 4px; white-space: normal; }
.tcard.od { border-left-color: #c0392b; } .tcard.urg { box-shadow: inset 0 0 0 1px #f3b3ab; }
.tcard .th { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-weight: 700; font-size: 13px; color: var(--muted); }
.tcard .tt { font-size: 16px; font-weight: 700; margin: 4px 0; }
.tcard .td { font-size: 13.5px; margin-bottom: 4px; white-space: pre-wrap; }
.tcard .tm { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tcard .late { color: #c0392b; font-weight: 700; }
.tcard .tw { margin-top: 6px; font-size: 13px; padding: 5px 8px; border-radius: 6px; background: #fff1cc; color: #6b4a00; }
.tcard .tdone { margin-top: 6px; font-size: 13px; padding: 5px 8px; border-radius: 6px; background: #e7f6ec; color: #1d5c34; }
@media (prefers-color-scheme: dark) { .tcard .tw { background: #3d3112; color: #f3d27a; } .tcard .tdone { background: #173322; color: #b6e8c8; } }
.tcard .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tcard .acts button { flex: 1 1 30%; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 14.5px; color: var(--text); }
.tcard .acts button.primary { background: #25a35a; border-color: #25a35a; color: #fff; }
.tcard .acts button.blue { background: #3b5ba5; border-color: #3b5ba5; color: #fff; }
.tcard .acts button.danger { background: transparent; border-color: #c0392b; color: #c0392b; }
.tcard .acts button.link { flex: 0 0 auto; min-height: 0; border: 0; background: none; color: var(--brand-2); font-weight: 600; text-decoration: underline; font-size: 13px; padding: 2px 4px; }
.tcard .thist { margin-top: 6px; font-size: 12px; color: var(--muted); } .tcard .thist div { padding: 2px 0; }
.chip.ts-open { background: #fff1cc; color: #8a5a00; } .chip.ts-accepted { background: #e3eefb; color: #1e4f8a; } .chip.ts-waiting { background: #f1e6fa; color: #6a2c8f; }
.chip.ts-done { background: #e7f6ec; color: #1d5c34; } .chip.ts-verified, .chip.ts-closed { background: #e7f6ec; color: #1d5c34; } .chip.ts-cancelled { background: #eee; color: #666; }
.actions #btnTasks { position: relative; }
.tbadge { position: absolute; top: -2px; right: -6px; background: #25a35a; color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 10px; padding: 1px 5px; white-space: nowrap; }
.tbadge.od { background: #c0392b; }
.duep { display: flex; flex-wrap: wrap; gap: 6px; } .duep button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 16px; padding: 6px 12px; font-size: 13px; color: var(--text); }
.duep button.on { background: var(--brand); color: #fff; border-color: var(--brand); } .duep input { flex: 1 1 100%; }
.lbl2 { font-weight: 700; font-size: 14px; margin-bottom: -6px; }
#modal textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); resize: vertical; width: 100%; }
.proofBtn { display: block; text-align: center; border: 2px dashed var(--line); border-radius: 10px; padding: 16px; font-weight: 700; cursor: pointer; }
.bigopt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 14px; font-size: 18px; color: var(--text); }
.bigopt b { font-size: 16px; } .bigopt small { font-size: 13px; color: var(--muted); }
.qbox { background: var(--panel-2); border-radius: 8px; padding: 10px; font-style: italic; }
.ttabs { display: flex; gap: 6px; flex-wrap: wrap; } .ttabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 18px; padding: 7px 14px; font-weight: 600; color: var(--text); }
.ttabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); } .ttabs.sm button { padding: 5px 12px; font-size: 13px; font-weight: 500; }
.tlist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tlist li { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; } .tlist li:last-child { border-bottom: 0; }
.tlist li.od { border-left: 4px solid #c0392b; } .tlist li:hover { background: var(--panel-2); } .tlist li.empty { text-align: center; color: var(--muted); cursor: default; }
.tlist .r1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; } .tlist .r2 { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tlist .late { color: #c0392b; font-weight: 700; }
.chip.urgchip { background: #c0392b; color: #fff; margin-left: 4px; }

.langs { text-align: center; font-size: 14px; margin: 4px 0 0 !important; } .langs a { color: var(--muted); text-decoration: none; padding: 2px 4px; } .langs a.on { color: var(--brand); font-weight: 700; }
.dropdown .menuLink { display: block; padding: 11px 18px; color: inherit; text-decoration: none; } .dropdown .menuLink:hover { background: var(--panel-2); }
/* Orders */
.ocard { border: 1px solid var(--line); border-left: 4px solid #b5651d; border-radius: 8px; background: var(--panel); padding: 10px 12px; margin: 2px 0 4px; white-space: normal; }
.ocard.od, .ocard.short { border-left-color: #c0392b; }
.ocard .th { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
.ocard .tm { font-size: 12.5px; color: var(--muted); margin-top: 2px; } .ocard .tm.late { color: #c0392b; font-weight: 700; }
.ocard table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
.ocard th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 600; padding: 4px; border-bottom: 1px solid var(--line); }
.ocard td { padding: 5px 4px; border-bottom: 1px dashed var(--line); } .ocard .r { text-align: right; white-space: nowrap; }
.ocard tr.sh td { color: #c0392b; font-weight: 700; } .ocard td.less { color: #b5651d; font-weight: 700; }
.ocard .tdone { margin-top: 6px; font-size: 13px; padding: 5px 8px; border-radius: 6px; background: #e7f6ec; color: #1d5c34; } .ocard .tdone.bad { background: #fdecea; color: #a12a1e; }
.ocard .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ocard .acts button { flex: 1 1 40%; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 700; font-size: 14.5px; color: var(--text); }
.ocard .acts button.primary { background: #25a35a; border-color: #25a35a; color: #fff; } .ocard .acts button.blue { background: #3b5ba5; border-color: #3b5ba5; color: #fff; }
.ocard .acts button.link { flex: 0 0 auto; min-height: 0; border: 0; background: none; color: var(--brand-2); text-decoration: underline; font-size: 13px; }
.chip.os-placed { background: #fff1cc; color: #8a5a00; } .chip.os-accepted { background: #e3eefb; color: #1e4f8a; } .chip.os-dispatched { background: #f1e6fa; color: #6a2c8f; }
.chip.os-received { background: #e7f6ec; color: #1d5c34; } .chip.os-sent { background: #fff1cc; color: #8a5a00; } .chip.os-cancelled { background: #eee; color: #666; }

#updBar { background: #e3eefb; color: #1e4f8a; padding: 8px 14px; font-size: 13.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); font-weight: 600; }
#updBar button { background: #3b5ba5; color: #fff; border: 0; border-radius: 6px; padding: 6px 14px; font-weight: 700; }
@media (prefers-color-scheme: dark) { #updBar { background: #1d2c47; color: #b9cff5; } }
