/* ============ themes ============ */
:root {
  --bg: #f1f2f5;
  --panel: #ffffff;
  --panel2: #f4f4f5;
  --hover: #f2f3f5;
  --text: #16191d;
  --muted: #707579;
  --line: #e6e7ea;
  --input: #ffffff;
  --accent: #3390ec;
  --accent2: #2a7fd4;
  --accent-soft: rgba(51, 144, 236, .12);
  --on-accent: #ffffff;
  --red: #e53935;
  --orange: #f08c00;
  --green: #2fa84f;
  --yellow: #e0a800;
  --rail: #ffffff;
  --rail-text: #707579;
  --col: #ebedf1;
  --bubble-in: #ffffff;
  --bubble-out: #e3fcd0;
  --meta-in: #9aa3ac;
  --meta-out: #4fae4e;
  --quote-out: #4fae4e;
  --rx-in: rgba(51, 144, 236, .12);
  --rx-out: rgba(79, 174, 78, .18);
  --rx-out-text: #3a8f39;
  --chat-bg: linear-gradient(160deg, #d4e5b9 0%, #a8c9a1 45%, #cbdcae 100%);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' fill='none' stroke='%23000' stroke-opacity='.07' stroke-width='1.6'%3E%3Cpath d='M20 30c0-6 8-6 8 0 0-6 8-6 8 0 0 6-8 11-8 11s-8-5-8-11z'/%3E%3Ccircle cx='100' cy='28' r='9'/%3E%3Cpath d='M60 70l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/%3E%3Crect x='98' y='92' width='24' height='17' rx='5'/%3E%3Cpath d='M104 109l-4 7 9-7'/%3E%3Cpath d='M18 104q8-12 16 0t16 0'/%3E%3Ccircle cx='128' cy='62' r='3'/%3E%3Ccircle cx='40' cy='128' r='4'/%3E%3C/svg%3E");
  --shadow: 0 8px 30px rgba(20, 25, 40, .16);
  --bshadow: 0 1px 2px rgba(16, 35, 47, .15);
  --ov: rgba(10, 14, 20, .45);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1621;
  --panel: #17212b;
  --panel2: #202b36;
  --hover: #202b36;
  --text: #f1f3f5;
  --muted: #7f91a4;
  --line: #0c131b;
  --input: #242f3d;
  --accent: #5a9fe0;
  --accent2: #6aaef0;
  --accent-soft: rgba(90, 159, 224, .16);
  --rail: #0f1923;
  --rail-text: #7f91a4;
  --col: #111b25;
  --bubble-in: #182533;
  --bubble-out: #2b5278;
  --meta-in: #6d7f8f;
  --meta-out: #7da8d3;
  --quote-out: #a6cdf2;
  --rx-in: rgba(90, 159, 224, .18);
  --rx-out: rgba(255, 255, 255, .12);
  --rx-out-text: #d7e8fa;
  --chat-bg: #0e1621;
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' fill='none' stroke='%23fff' stroke-opacity='.035' stroke-width='1.6'%3E%3Cpath d='M20 30c0-6 8-6 8 0 0-6 8-6 8 0 0 6-8 11-8 11s-8-5-8-11z'/%3E%3Ccircle cx='100' cy='28' r='9'/%3E%3Cpath d='M60 70l4 8 9 1-7 6 2 9-8-5-8 5 2-9-7-6 9-1z'/%3E%3Crect x='98' y='92' width='24' height='17' rx='5'/%3E%3Cpath d='M104 109l-4 7 9-7'/%3E%3Cpath d='M18 104q8-12 16 0t16 0'/%3E%3Ccircle cx='128' cy='62' r='3'/%3E%3Ccircle cx='40' cy='128' r='4'/%3E%3C/svg%3E");
  --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  --bshadow: 0 1px 2px rgba(0, 0, 0, .3);
  --ov: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--text); background: var(--bg); overflow: hidden; }
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.ic.sm { width: 18px; height: 18px; }

/* ============ buttons & inputs ============ */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 10px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: rgba(229, 57, 53, .1); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.inp { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; background: var(--input); outline: none; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.inp { resize: vertical; min-height: 70px; }
label.fl { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: .03em; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 5px; }

/* ============ login ============ */
.login-wrap { height: 100vh; display: grid; place-items: center; background: var(--chat-bg); position: relative; }
.login-wrap::before { content: ''; position: absolute; inset: 0; background: var(--pattern); }
.login-card { position: relative; width: 370px; background: var(--panel); border-radius: 18px; padding: 34px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; }
.login-card .inp { text-align: left; }
.login-card label.fl { text-align: left; }
.logo { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; margin-bottom: 14px; }
.logo svg { width: 34px; height: 34px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ============ layout ============ */
.shell { display: flex; height: 100vh; }
.rail { width: 76px; background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 2px; flex-shrink: 0; }
.rail .logo { width: 42px; height: 42px; margin: 0 0 10px; }
.rail .logo svg { width: 22px; height: 22px; }
.rail button { width: 64px; padding: 8px 0 6px; border: 0; background: none; border-radius: 12px; color: var(--rail-text); font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.rail button:hover { background: var(--hover); color: var(--text); }
.rail button.active { color: var(--accent); background: var(--accent-soft); }
.rail .cnt { position: absolute; top: 3px; right: 9px; background: var(--red); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 5px; font-weight: 700; min-width: 17px; line-height: 16px; }
.rail .sp { flex: 1; }
.rail .me { margin-top: 6px; cursor: default; }
.chatlist { width: 340px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.shell.nolist .chatlist { display: none; }
.cl-head { padding: 12px 12px 8px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 22px; padding: 0 14px; color: var(--muted); border: 2px solid transparent; }
.search:focus-within { border-color: var(--accent); background: var(--panel); }
.search input { border: 0; outline: none; background: none; padding: 8px 0; flex: 1; color: var(--text); }
.chats { flex: 1; overflow-y: auto; padding: 2px 6px 8px; }
.cl-sec { padding: 10px 12px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ci { display: flex; gap: 11px; padding: 7px 10px; border-radius: 12px; cursor: pointer; align-items: center; }
.ci:hover { background: var(--hover); }
.ci.active { background: var(--accent); color: var(--on-accent); }
.ci.active .cm, .ci.active .ct { color: rgba(255, 255, 255, .8); }
.ci.active .cbadge { background: #fff; color: var(--accent); }
.ci .cbody { flex: 1; min-width: 0; }
.ci .ctop, .ci .cbot { display: flex; align-items: center; gap: 6px; }
.ci .cn { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.ci .ct { font-size: 12px; color: var(--muted); }
.ci .cm { flex: 1; font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci .cm b { font-weight: 500; color: var(--text); }
.ci.active .cm b { color: #fff; }
.ci .cm.typing { color: var(--accent); }
.ci.active .cm.typing { color: #fff; }
.cbadge { background: var(--accent); color: #fff; border-radius: 12px; font-size: 12px; font-weight: 600; padding: 0 7px; min-width: 22px; text-align: center; line-height: 22px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar { height: 58px; flex-shrink: 0; padding: 0 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h2 { font-size: 16px; margin: 0; }
.content { flex: 1; overflow: auto; }
.page { padding: 20px 24px; max-width: 1200px; }

/* ============ avatars ============ */
.av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 14px; flex-shrink: 0; position: relative; user-select: none; }
.av.lg { width: 50px; height: 50px; font-size: 17px; }
.av.md { width: 42px; height: 42px; font-size: 15px; }
.av.xs { width: 24px; height: 24px; font-size: 10px; border: 2px solid var(--panel); }
.av .on { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: #4fce5d; border: 2.5px solid var(--panel); }
.ci.active .av .on { border-color: var(--accent); }
.av svg { width: 55%; height: 55%; }
.avs { display: flex; }
.avs .av.xs + .av.xs { margin-left: -6px; }

/* ============ chat ============ */
.chat { display: flex; flex-direction: column; height: 100%; position: relative; }
.chat-head { height: 58px; flex-shrink: 0; padding: 0 12px 0 18px; display: flex; align-items: center; gap: 12px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 2; }
.chat-head .t { font-weight: 600; font-size: 15.5px; }
.chat-head .s { font-size: 13px; color: var(--muted); }
.chat-head .s.typing { color: var(--accent); }
.ib { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.ib:hover { background: var(--hover); color: var(--accent); }
.ib.accent { color: var(--accent); }
.chat-body { flex: 1; position: relative; background: var(--chat-bg); overflow: hidden; }
.chat-body::before { content: ''; position: absolute; inset: 0; background: var(--pattern); pointer-events: none; }
.msgs { position: absolute; inset: 0; overflow-y: auto; padding: 8px 0 10px; }
.msgs-in { max-width: 860px; margin: 0 auto; padding: 0 18px; }
.day { position: sticky; top: 6px; z-index: 1; text-align: center; margin: 10px 0; pointer-events: none; }
.day span { background: rgba(0, 0, 0, .22); color: #fff; font-size: 13px; font-weight: 500; padding: 3px 11px; border-radius: 14px; }
.sys { text-align: center; margin: 10px 0; }
.sys span { background: rgba(0, 0, 0, .22); color: #fff; font-size: 13px; padding: 5px 14px; border-radius: 14px; display: inline-block; }
.empty-chat { text-align: center; margin-top: 30vh; }
.empty-chat span { background: rgba(0, 0, 0, .22); color: #fff; padding: 8px 16px; border-radius: 16px; }
.mrow { display: flex; align-items: flex-end; gap: 8px; margin: 2px 0; }
.mrow.ge { margin-bottom: 8px; }
.mrow.out { justify-content: flex-end; }
.mrow .mav { width: 36px; height: 36px; font-size: 13px; }
.mrow .mav.sp { visibility: hidden; }
.mrow.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px var(--accent); } }
.bubble { max-width: min(580px, 78%); min-width: 72px; background: var(--bubble-in); border-radius: 15px; padding: 6px 10px 6px 11px; box-shadow: var(--bshadow); position: relative; overflow-wrap: anywhere; }
.out .bubble { background: var(--bubble-out); }
.mrow.in.ge .bubble { border-bottom-left-radius: 4px; }
.mrow.out.ge .bubble { border-bottom-right-radius: 4px; }
.mrow.in.ge .bubble::before { content: ''; position: absolute; left: -7px; bottom: 0; width: 9px; height: 13px; background: var(--bubble-in); clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.mrow.out.ge .bubble::before { content: ''; position: absolute; right: -7px; bottom: 0; width: 9px; height: 13px; background: var(--bubble-out); clip-path: polygon(0 0, 100% 100%, 0 100%); }
.bname { font-weight: 600; font-size: 13.5px; margin-bottom: 1px; }
.btext { white-space: pre-wrap; font-size: 14.8px; line-height: 1.42; }
.btext a { color: var(--accent); }
.out .btext a { color: inherit; text-decoration: underline; }
.meta { float: right; position: relative; top: 7px; margin-left: 12px; font-size: 11.5px; color: var(--meta-in); display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; line-height: 1; }
.out .meta { color: var(--meta-out); }
.meta svg { width: 17px; height: 12px; }
.bfoot { display: flow-root; height: 12px; }
.bubble.media { padding: 3px; }
.bubble.media .meta { position: absolute; right: 8px; bottom: 8px; top: auto; background: rgba(0, 0, 0, .45); color: #fff; padding: 3px 7px; border-radius: 10px; float: none; }
.bubble.jumbo { background: none !important; box-shadow: none; padding: 0 4px; }
.bubble.jumbo::before { display: none; }
.bubble.jumbo .btext { font-size: 46px; line-height: 1.15; }
.bubble.jumbo .btext { display: flex; align-items: flex-end; gap: 8px; }
.bubble.jumbo .meta { background: rgba(0, 0, 0, .3); color: #fff; padding: 3px 7px; border-radius: 10px; float: none; top: 0; margin: 0 0 6px; }
.bimgs { display: grid; gap: 3px; border-radius: 12px; overflow: hidden; margin: 2px 0 4px; }
.bubble.media .bimgs { margin: 0; }
.bimgs.n2, .bimgs.n4 { grid-template-columns: 1fr 1fr; }
.bimgs.n3 { grid-template-columns: 1fr 1fr 1fr; }
.bimgs img { width: 100%; max-height: 380px; min-height: 90px; object-fit: cover; display: block; cursor: zoom-in; background: rgba(0, 0, 0, .08); }
.bimgs.n1 img { max-width: 440px; object-fit: contain; }
.frow { display: flex; align-items: center; gap: 11px; padding: 4px 2px; cursor: pointer; text-decoration: none; color: inherit; max-width: 360px; }
.frow .fi { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.out .frow .fi { background: var(--meta-out); }
.frow .fn { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .fs { font-size: 12.5px; color: var(--meta-in); }
.out .frow .fs { color: var(--meta-out); }
.rq { display: flex; gap: 8px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 3px 8px 3px 7px; margin: 3px 0 5px; cursor: pointer; font-size: 13.5px; line-height: 1.3; max-width: 100%; }
.out .rq { border-left-color: var(--quote-out); background: var(--rx-out); }
.rq .rqt { min-width: 0; }
.rq b { display: block; font-weight: 600; font-size: 13px; }
.rq span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.rq img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; }
.rxs { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.bubble.jumbo .rxs { margin-top: 2px; }
.rx { border: 0; border-radius: 15px; padding: 2px 8px 2px 6px; font-size: 14px; background: var(--rx-in); color: var(--accent); display: inline-flex; gap: 4px; align-items: center; font-weight: 600; line-height: 22px; }
.rx small { font-size: 12.5px; }
.out .rx { background: var(--rx-out); color: var(--rx-out-text); }
.rx.mine { background: var(--accent); color: #fff; }
.out .rx.mine { background: var(--meta-out); color: #fff; }
.rx:hover { filter: brightness(1.05); }
.macts { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; align-self: center; }
.mrow:hover .macts { opacity: 1; }
.mrow.out .macts { order: -1; }
.macts button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--panel); color: var(--muted); display: grid; place-items: center; box-shadow: var(--bshadow); }
.macts button:hover { color: var(--accent); }
.macts svg { width: 16px; height: 16px; }
.tobottom { position: absolute; right: 22px; bottom: 16px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--panel); color: var(--muted); box-shadow: var(--shadow); display: grid; place-items: center; z-index: 3; }
.tobottom .cbadge { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); }

/* task block inside bubble */
.taskmsg { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; margin: 3px 0 4px; min-width: 260px; }
.out .taskmsg { border-left-color: var(--quote-out); background: var(--rx-out); }
.taskmsg .tt { font-weight: 700; margin: 2px 0 6px; font-size: 15px; }
.taskmsg .tk { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.out .taskmsg .tk { color: var(--meta-out); }
.taskmsg.done { border-left-color: var(--green); }
.taskmsg.overdue { border-left-color: var(--red); }
.taskmsg .btn { background: var(--panel); }
.taskmsg .btn.primary { background: var(--accent); }

/* composer */
.composer { background: var(--panel); border-top: 1px solid var(--line); padding: 4px 10px 6px; position: relative; }
.cprev { display: flex; align-items: center; gap: 12px; padding: 8px 8px 6px 10px; color: var(--accent); }
.cprev .body { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 10px; }
.cprev b { display: block; font-size: 13.5px; }
.cprev span { display: block; color: var(--text); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbar { display: flex; align-items: flex-end; gap: 2px; }
.cbar textarea { flex: 1; border: 0; outline: none; resize: none; padding: 10px 6px; max-height: 200px; min-height: 42px; background: transparent; font-size: 15px; line-height: 1.4; }
.sendb { color: var(--accent) !important; }
.pend { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 8px 0; }
.pchip { font-size: 12.5px; background: var(--accent-soft); border-radius: 10px; padding: 5px 9px; display: flex; gap: 6px; align-items: center; max-width: 260px; }
.pchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pchip button { border: 0; background: none; padding: 0; color: var(--muted); }
.pchip .bar { height: 3px; background: var(--accent); border-radius: 2px; margin-top: 2px; }
.drop-ov { position: absolute; inset: 8px; background: var(--accent-soft); border: 3px dashed var(--accent); border-radius: 16px; display: grid; place-items: center; font-size: 20px; color: var(--accent); font-weight: 700; z-index: 5; pointer-events: none; backdrop-filter: blur(2px); }
.side-panel { position: absolute; right: 0; top: 58px; bottom: 0; width: 350px; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 6; display: flex; flex-direction: column; }
.side-panel .sp-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.side-panel .sp-b { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.side-panel .frow { max-width: none; padding: 6px; border-radius: 10px; }
.side-panel .frow:hover { background: var(--hover); }

/* emoji picker & context menu */
.emp { position: fixed; width: 352px; height: 380px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); z-index: 150; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
.emp-grid { flex: 1; overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); align-content: start; gap: 2px; }
.emp-grid button { border: 0; background: none; font-size: 25px; height: 40px; border-radius: 8px; padding: 0; line-height: 1; }
.emp-grid button:hover { background: var(--hover); }
.emp-grid .emp-h { grid-column: 1 / -1; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 4px 2px; }
.emp-tabs { display: flex; border-top: 1px solid var(--line); padding: 4px; gap: 2px; }
.emp-tabs button { flex: 1; border: 0; background: none; font-size: 19px; border-radius: 8px; height: 36px; opacity: .55; }
.emp-tabs button.on { opacity: 1; background: var(--accent-soft); }
.ctx { position: fixed; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 160; min-width: 230px; border: 1px solid var(--line); animation: pop .1s; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.ctx-rx { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.ctx-rx button { border: 0; background: none; font-size: 23px; width: 34px; height: 36px; border-radius: 50%; padding: 0; transition: transform .1s; }
.ctx-rx button:hover { transform: scale(1.25); background: var(--hover); }
.ctx-it { display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; padding: 8px 12px; border-radius: 8px; text-align: left; font-size: 14px; }
.ctx-it:hover { background: var(--hover); }
.ctx-it.danger { color: var(--red); }
.ctx-it svg { width: 19px; height: 19px; color: var(--muted); }
.ctx-it.danger svg { color: var(--red); }
.ctx-who { padding: 4px 12px 6px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel2); color: var(--muted); font-weight: 600; }
.badge.red { background: rgba(229, 57, 53, .14); color: var(--red); }
.badge.orange { background: rgba(240, 140, 0, .15); color: var(--orange); }
.badge.green { background: rgba(47, 168, 79, .15); color: var(--green); }
.badge.yellow { background: rgba(224, 168, 0, .16); color: var(--yellow); }
.lbl { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; border-radius: 5px; padding: 1px 8px; }

/* ============ board ============ */
.board-wrap { height: 100%; display: flex; flex-direction: column; }
.board-tools { padding: 12px 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: var(--panel); border-radius: 18px; padding: 5px 14px; }
.tabs button:hover { background: var(--hover); }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.board { flex: 1; overflow: auto; display: flex; gap: 14px; padding: 16px 20px; align-items: flex-start; }
.col { width: 290px; flex-shrink: 0; background: var(--col); border-radius: 14px; display: flex; flex-direction: column; max-height: 100%; }
.col-h { padding: 10px 12px 6px; display: flex; align-items: center; gap: 6px; font-weight: 700; }
.col-h .n { background: var(--panel2); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.col-h .donei { color: var(--green); }
.col-b { padding: 4px 8px; overflow-y: auto; min-height: 30px; display: flex; flex-direction: column; gap: 8px; }
.col-f { padding: 6px 8px 10px; }
.col-f .btn { width: 100%; justify-content: flex-start; background: transparent; border-color: transparent; color: var(--muted); }
.col-f .btn:hover { background: var(--hover); }
.card { background: var(--panel); border-radius: 10px; padding: 9px 11px; box-shadow: var(--bshadow); cursor: pointer; border: 1px solid transparent; }
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .4; }
.card .ct { font-weight: 600; margin: 3px 0 6px; overflow-wrap: anywhere; }
.card .cm { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.card .lbls { display: flex; gap: 4px; flex-wrap: wrap; }
.card .lbls .lbl { font-size: 10px; }
.card.done .ct { text-decoration: line-through; color: var(--muted); }
.ph { height: 44px; border: 2px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); }
.add-col { width: 290px; flex-shrink: 0; }

/* ============ tables / lists ============ */
.cardbox { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 18px; overflow-x: auto; }
.cardbox h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.pbar { height: 8px; background: var(--panel2); border-radius: 4px; overflow: hidden; min-width: 80px; }
.pbar i { display: block; height: 100%; background: var(--green); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 800; }
.kpi .k { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.trow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.trow:hover { border-color: var(--accent); }
.trow .tt { font-weight: 600; }
.grp-h { font-weight: 700; margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; }
.empty { color: var(--muted); padding: 30px; text-align: center; }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: middle; }

/* ============ modal ============ */
.ov { position: fixed; inset: 0; background: var(--ov); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 16px; width: 480px; max-width: 100%; box-shadow: var(--shadow); }
.modal.wide { width: 880px; }
.m-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.m-h h3 { margin: 0; font-size: 17px; flex: 1; }
.m-b { padding: 6px 20px 18px; }
.m-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.cm-grid { display: grid; grid-template-columns: 1fr 270px; gap: 22px; }
.chk { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.chk input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.chk.done span { text-decoration: line-through; color: var(--muted); }
.chk .x { margin-left: auto; border: 0; background: none; color: var(--muted); visibility: hidden; }
.chk:hover .x { visibility: visible; }
.people { max-height: 190px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; background: var(--input); }
.lblpick { display: flex; flex-wrap: wrap; gap: 6px; }
.lblpick .lbl { cursor: pointer; opacity: .35; padding: 3px 10px; }
.lblpick .lbl.on { opacity: 1; box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px currentColor; }
.cmt { display: flex; gap: 8px; margin: 10px 0; }
.cmt .body { background: var(--panel2); border-radius: 12px; padding: 7px 11px; flex: 1; }
.cmt .mt { white-space: pre-wrap; }
.cred { background: var(--panel2); border-radius: 12px; padding: 14px 16px; font-family: Consolas, monospace; font-size: 15px; line-height: 1.8; }
.cred b { font-family: "Segoe UI", sans-serif; font-size: 13px; color: var(--muted); display: inline-block; width: 70px; }
.fchip { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--panel2); max-width: 320px; text-decoration: none; color: inherit; cursor: pointer; }
.fchip:hover { border-color: var(--accent); }
.fchip .fi { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.fchip .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.fchip .fs { font-size: 12px; color: var(--muted); }
.mimg { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; }
.mfiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* ============ alarm ============ */
.alarm-ov { position: fixed; inset: 0; z-index: 100; background: rgba(120, 0, 10, .55); display: grid; place-items: center; animation: flashbg 1s infinite; }
@keyframes flashbg { 50% { background: rgba(200, 20, 30, .7); } }
.alarm { background: var(--panel); border-radius: 20px; padding: 30px 34px; width: 440px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.alarm .bell { font-size: 64px; display: inline-block; animation: ring 0.5s infinite; }
@keyframes ring { 0%,100% { transform: rotate(0); } 25% { transform: rotate(18deg); } 75% { transform: rotate(-18deg); } }
.alarm h2 { margin: 8px 0 6px; font-size: 20px; }
.alarm .tt { font-size: 17px; font-weight: 700; margin: 12px 0 4px; }
.alarm .btns { display: flex; gap: 8px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.alarm .btn.primary { background: var(--red); border-color: var(--red); padding: 10px 22px; font-size: 15px; }

/* ============ toasts & popovers ============ */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1f2933; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 360px; cursor: pointer; animation: tin .2s; }
.toast b { display: block; }
.toast.err { background: var(--red); }
@keyframes tin { from { transform: translateY(10px); opacity: 0; } }
.notif-pop { position: fixed; left: 84px; bottom: 16px; width: 370px; max-height: 500px; overflow-y: auto; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); z-index: 40; border: 1px solid var(--line); }
.notif-pop .ni { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.notif-pop .ni:hover { background: var(--hover); }
.notif-pop .ni.unseen { background: var(--accent-soft); }
.imgview { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 120; display: grid; place-items: center; cursor: zoom-out; }
.imgview img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,.35); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
