/* ============ Design tokens ============ */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface2: #f1f3f6; --surface3: #e8ebf0; --col: #eef0f4;
  --text: #0f172a; --text2: #334155; --muted: #64748b; --line: #e4e7ec; --line2: #d5dae1;
  --accent: #4f46e5; --accent-2: #6366f1; --accent-weak: #eef0ff; --accent-text: #4338ca;
  --danger: #dc2626; --danger-weak: #fee2e2; --ok: #16a34a; --ok-weak: #dcfce7; --warn: #d97706; --warn-weak: #fef3c7;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 4px 12px -2px rgba(15,23,42,.10), 0 2px 4px rgba(15,23,42,.05);
  --shadow-lg: 0 24px 48px -12px rgba(15,23,42,.28), 0 6px 12px rgba(15,23,42,.06);
  --ring: 0 0 0 3px rgba(79,70,229,.22);
  --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --topbar: rgba(255,255,255,.82);
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #161b22; --surface2: #1c232d; --surface3: #252d39; --col: #11161d;
  --text: #e6edf3; --text2: #c4ccd6; --muted: #8b96a5; --line: #252c37; --line2: #313a47;
  --accent: #818cf8; --accent-2: #a5b4fc; --accent-weak: rgba(129,140,248,.14); --accent-text: #a5b4fc;
  --danger: #f87171; --danger-weak: rgba(248,113,113,.15); --ok: #4ade80; --ok-weak: rgba(74,222,128,.13); --warn: #fbbf24; --warn-weak: rgba(251,191,36,.15);
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 16px -4px rgba(0,0,0,.55);
  --shadow-lg: 0 28px 56px -12px rgba(0,0,0,.7); --ring: 0 0 0 3px rgba(129,140,248,.3);
  --topbar: rgba(22,27,34,.85);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #161b22; --surface2: #1c232d; --surface3: #252d39; --col: #11161d;
    --text: #e6edf3; --text2: #c4ccd6; --muted: #8b96a5; --line: #252c37; --line2: #313a47;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-weak: rgba(129,140,248,.14); --accent-text: #a5b4fc;
    --danger: #f87171; --danger-weak: rgba(248,113,113,.15); --ok: #4ade80; --ok-weak: rgba(74,222,128,.13); --warn: #fbbf24; --warn-weak: rgba(251,191,36,.15);
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 16px -4px rgba(0,0,0,.55);
    --shadow-lg: 0 28px 56px -12px rgba(0,0,0,.7); --ring: 0 0 0 3px rgba(129,140,248,.3);
    --topbar: rgba(22,27,34,.85);
  }
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13.5px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }
.spacer { flex: 1; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; } a:hover { text-decoration: underline; }
a.btn, a.btn:hover { color: inherit; text-decoration: none; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; } svg.i.lg { width: 20px; height: 20px; }
::selection { background: var(--accent-weak); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }
.muted { color: var(--muted); }
.nw { white-space: nowrap; }

/* inputs */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--surface); padding: 6px 9px;
  transition: border-color .12s, box-shadow .12s; outline: none; }
input:not([type=checkbox]):not([type=radio]):hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { border-color: var(--accent) !important; box-shadow: var(--ring); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
textarea { width: 100%; resize: vertical; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: var(--surface); padding: 6px 12px; height: 34px;
  border-radius: var(--r-sm); cursor: pointer; white-space: nowrap; font-weight: 500; color: var(--text2); transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface2); color: var(--text); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface2); }
.btn.primary { background: linear-gradient(180deg, #6d6ff5, #4f46e5); color: #fff; border-color: transparent; font-weight: 600; box-shadow: 0 1px 2px rgba(79,70,229,.35), inset 0 1px 0 rgba(255,255,255,.15); }
.btn.primary:hover { filter: brightness(1.07); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-weak); }
.btn.small { padding: 3px 9px; font-size: 12px; height: 26px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; line-height: 17px; }

/* switch */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; padding: 6px 0; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .tr { position: relative; width: 36px; height: 20px; flex: none; border-radius: 20px; background: var(--surface3); transition: background .18s; box-shadow: inset 0 0 0 1px var(--line2); }
.switch .tr::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s cubic-bezier(.3,.7,.4,1.3); }
.switch input:checked + .tr { background: var(--accent); box-shadow: none; }
.switch input:checked + .tr::after { transform: translateX(16px); }
.switch input:focus-visible + .tr { box-shadow: var(--ring); }
.switch .sl { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.switch .sl b { font-weight: 500; }
.switch .sl small { color: var(--muted); font-size: 12px; }

/* ============ Top bar ============ */
.topbar { position: relative; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--topbar);
  backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 9px; margin-right: 10px; white-space: nowrap; letter-spacing: -.01em; }
.logo { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #ec4899); box-shadow: 0 2px 6px rgba(99,102,241,.4); font-size: 0; }
.logo svg.i { width: 16px; height: 16px; }
.presets { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.presets button { border: 0; background: none; padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; color: var(--muted); white-space: nowrap; font-weight: 500; transition: background .12s, color .12s; }
.presets button:hover { background: var(--surface2); color: var(--text); }
.presets button.active { color: var(--accent-text); background: var(--accent-weak); font-weight: 600; }
.presets button.dirty::after { content: " •"; }
.search { position: relative; display: flex; align-items: center; }
.search svg.i { position: absolute; left: 9px; color: var(--muted); pointer-events: none; }
.search input { width: 240px; height: 34px; padding-left: 32px !important; background: var(--surface2); border-color: transparent; }
.search input:focus { background: var(--surface); }
.tbtn { height: 36px; min-width: 36px; }
.tbtn svg.i { width: 19px; height: 19px; }
.timer { display: flex; align-items: center; gap: 6px; background: var(--danger-weak); color: var(--danger); padding: 4px 6px 4px 12px; border-radius: 20px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.timer .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.userbtn { padding: 0 2px; width: 36px; justify-content: center; }
.userbtn .avatar { width: 28px; height: 28px; font-size: 11px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line2); }

/* segmented */
.seg { display: inline-flex; background: var(--surface2); border-radius: var(--r); padding: 3px; margin-right: 6px; gap: 2px; border: 1px solid var(--line); }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; transition: background .12s, color .12s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg svg.i { width: 15px; height: 15px; }

/* ============ Filters ============ */
.filters { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); position: relative; z-index: 5; }
.frow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fsecond label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.fsecond select, .fsecond input[type=date] { height: 32px; padding: 4px 8px; }
.chipbtn { display: inline-flex; gap: 6px; align-items: center; height: 32px; border: 1px dashed var(--line2); background: var(--surface); padding: 4px 11px; border-radius: 16px; cursor: pointer; color: var(--text2); transition: all .12s; }
.chipbtn:hover { border-color: var(--muted); background: var(--surface2); }
.chipbtn.on { border-style: solid; border-color: transparent; background: var(--accent-weak); color: var(--accent-text); font-weight: 600; }
.chipbtn .x { opacity: .6; }
.coltoggles { display: flex; gap: 8px; flex-wrap: wrap; }
.coltoggles label { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; }

/* ============ Board ============ */
.board { flex: 1; overflow: auto; padding: 14px 16px; }
.lane { margin-bottom: 14px; }
.lanehead { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 6px 4px; cursor: pointer; position: sticky; left: 0; width: max-content; border-radius: var(--r-sm); }
.lanehead:hover { color: var(--accent-text); }
.lanehead .cnt { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface2); padding: 0 7px; border-radius: 10px; }
.lane.collapsed .cols { display: none; }
.lane.collapsed .lanehead .chev { transform: rotate(-90deg); }
.chev { transition: transform .15s; display: inline-block; color: var(--muted); }
.colheads, .cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; }
.colheads { position: sticky; top: -14px; z-index: 3; background: var(--bg); padding: 0 0 8px; }
.colhead { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 9px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; gap: 6px; align-items: center; box-shadow: var(--shadow); }
.colhead .n { background: var(--surface2); color: var(--text2); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.colhead .h { margin-left: auto; font-weight: 500; text-transform: none; }
.col { background: var(--col); border-radius: var(--r-lg); padding: 7px; min-height: 64px; display: flex; flex-direction: column; gap: 7px; transition: background .12s, box-shadow .12s; }
.col.over { background: var(--accent-weak); box-shadow: inset 0 0 0 2px var(--accent); }
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); border-left: 3px solid transparent; padding: 9px 11px 8px; cursor: pointer; position: relative;
  transition: box-shadow .15s, transform .15s, border-color .15s; }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--line2); }
.card:active { transform: translateY(0); }
.card.dragging { opacity: .4; transform: rotate(1.5deg); }
.card.closed { opacity: .6; }
.card .ttl { margin: 3px 0 7px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; color: var(--text); line-height: 1.4; }
.card .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.card .top { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 0; }
.card .top > * { flex: none; }
.card .top > .spacer { flex: 1; }
.card .top .type { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.card .top .partner { flex: 0 1 auto; }
.card .key { font-weight: 600; color: var(--text2); font-variant-numeric: tabular-nums; }
.card .partner { font-weight: 600; color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.card .running { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s infinite; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9.5px; font-weight: 700; color: #fff; flex: none; letter-spacing: .02em; }
.avatar.none { background: var(--surface2); color: var(--muted); border: 1px dashed var(--muted); }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; background: var(--surface2); color: var(--text); }
.type { font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.prio { font-weight: 800; font-size: 12px; }
.p5 { color: #dc2626; } .p4 { color: #ef4444; } .p3 { color: #d97706; } .p2 { color: #3b82f6; } .p1, .p0 { color: var(--muted); }
.overdue { color: var(--danger); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 40px; }
.statusbar { font-size: 12px; color: var(--muted); padding: 5px 16px; border-top: 1px solid var(--line); background: var(--surface); }

/* ============ Popover ============ */
.pop { position: fixed; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: 280px; max-height: 400px; display: flex; flex-direction: column; overflow: hidden; animation: popin .14s ease-out; }
@keyframes popin { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.pop input.ps { margin: 8px; }
.pop .list { overflow: auto; padding: 0 6px 6px; }
.pop .opt { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--text); }
.pop a.opt:hover { text-decoration: none; }
.pop .opt:hover { background: var(--surface2); }
.pop .opt.sel { color: var(--accent-text); font-weight: 600; }
.pop .hdr { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.pop .foot { display: flex; justify-content: space-between; padding: 6px 8px; border-top: 1px solid var(--line); }

/* ============ Drawer (request card) ============ */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(960px, 100vw); background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 30; display: flex; flex-direction: column; animation: slidein .2s cubic-bezier(.2,.8,.2,1); }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
.drawer.center { top: 3vh; bottom: 3vh; left: 50%; right: auto; transform: translateX(-50%); width: min(1260px, 96vw); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; animation: zoomin .18s cubic-bezier(.2,.8,.2,1); }
@keyframes zoomin { from { transform: translateX(-50%) scale(.97); opacity: 0; } }
.dback { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 29; backdrop-filter: blur(3px); animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.dhead { padding: 10px 14px 10px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; background: var(--surface); }
.dhead .key { font-weight: 700; cursor: copy; font-variant-numeric: tabular-nums; }
.dhead .key:hover { color: var(--accent-text); }
.dhead .spacer { flex: 1; }
.dbody { flex: 1; overflow: auto; padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-content: start; }
.drawer.center .dbody { grid-template-columns: minmax(0, 1fr) 330px; padding: 24px 28px; gap: 22px; }
.dmain { min-width: 0; }
.dside { display: flex; flex-direction: column; position: sticky; top: 0; align-self: start; }
.dtitle { margin: 2px 2px 14px; }
.dsum { font-size: 20px; font-weight: 650; line-height: 1.3; letter-spacing: -.015em; }
.drawer.center .dsum { font-size: 24px; }
.dmeta { margin-top: 8px; color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dmeta b { color: var(--text); }
.dsec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.dsec > h3:first-child { margin-top: 0; }
.dsec h3 { display: flex; align-items: center; gap: 8px; }
.dsec h3 .cnt { background: var(--surface2); color: var(--text2); border-radius: 10px; padding: 0 8px; font-size: 11px; text-transform: none; letter-spacing: 0; }
.dsec h3 .hlink { font-size: 12px; text-transform: none; font-weight: 500; margin-left: auto; letter-spacing: 0; }
.dside .dsec { display: flex; flex-direction: column; gap: 12px; }
.dside .dsec h3 { margin-bottom: 0; }
.tagrow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.kv span { color: var(--muted); } .kv b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.tlform { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line2); }
.tlform .field { flex: 1; min-width: 90px; } .tlform .field.wide { flex-basis: 100%; }
.cmtbox { border: 1px solid var(--line2); border-radius: var(--r); padding: 8px; background: var(--surface); margin-bottom: 10px; transition: border-color .12s, box-shadow .12s; }
.cmtbox:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.cmtbox textarea { border: 0 !important; box-shadow: none !important; background: transparent; padding: 4px; outline: none; }
.cmtbtns { display: flex; gap: 6px; justify-content: flex-end; }
.feed .msg { border-top: 1px solid var(--line); padding: 11px 4px; }
.feed .msg:first-child { border-top: 0; }
.feed .msg.sys { padding: 6px 4px; }
.feed .msg.sys .mh { margin-bottom: 2px; }
.feed .trk { font-size: 12px; color: var(--muted); margin-left: 30px; }
.feed .trk b { color: var(--text); font-weight: 600; } .feed .trk s { opacity: .7; }
.feed .msg .html { margin-left: 30px; }
.notechip { background: var(--warn-weak); color: var(--warn); border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 600; }
body.solo .topbar, body.solo #filters, body.solo #board, body.solo #status { display: none !important; }
body.solo .drawer.center { top: 0; bottom: 0; left: 0; right: 0; transform: none; width: auto; border: 0; border-radius: 0; box-shadow: none; animation: none; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.field select, .field input { width: 100%; }
.routes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.stagepill { background: var(--accent-weak); color: var(--accent-text); font-weight: 700; padding: 3px 10px; border-radius: 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; }
.stagepill.closed { background: var(--ok-weak); color: var(--ok); }
h3 { font-size: 11.5px; text-transform: uppercase; color: var(--muted); margin: 18px 0 10px; letter-spacing: .06em; font-weight: 700; }
.html { word-break: break-word; color: var(--text2); }
.html img { max-width: 100%; border-radius: var(--r-sm); }
.html p { margin: 0 0 6px; }
.editor { min-height: 100px; border: 1px solid var(--accent); border-radius: var(--r-sm); padding: 8px; background: var(--surface); outline: none; box-shadow: var(--ring); }
.msg .mh { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg .mh b { color: var(--text); }
.msg.note { background: var(--warn-weak); border-radius: var(--r-sm); }
table.ts { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ts td, table.ts th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.ts tr:last-child td { border-bottom: 0; }
table.ts th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
table.ts tbody tr:hover td, table.ts tr:hover td { background: var(--surface2); }
.inline { display: flex; gap: 6px; flex-wrap: wrap; align-items: end; }
.inline .field { flex: 1; min-width: 90px; }

/* ============ Modal / toast ============ */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(3px); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px; overflow: auto; animation: fadein .15s; }
.mbox { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(640px, 100%); padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; animation: popin .16s ease-out; }
.mbox h2 { margin: 0 0 2px; font-size: 18px; letter-spacing: -.01em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.check { display: flex; gap: 8px; align-items: center; }
.box { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.toasts { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 80; align-items: center; }
.toast { background: #111827; color: #f9fafb; padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 520px; font-weight: 500; animation: popin .16s ease-out; }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .search input { width: 150px; }
  .dbody, .drawer.center .dbody { grid-template-columns: 1fr; }
  .dside { position: static; }
}

/* source icons */
.src { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px; flex: none; }
.src-phone { color: var(--ok); background: var(--ok-weak); }
.src-manual { color: var(--accent-text); background: var(--accent-weak); }
.src-telegram { width: 16px; height: 16px; }
.src-email, .src-web, .src-api { color: var(--muted); background: var(--surface2); }

/* ============ List view ============ */
.listbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sumchip { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; font-size: 13px; color: var(--muted); box-shadow: var(--shadow); }
.sumchip b { color: var(--text); }
.sumchip.mine { border-color: var(--accent); background: var(--accent-weak); }
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 210px); }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; min-width: 900px; }
table.list th { position: sticky; top: 0; background: var(--surface); z-index: 1; text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; user-select: none; }
table.list th.sortable { cursor: pointer; }
table.list th.sortable:hover { color: var(--text); }
table.list td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
table.list tr[data-id] { cursor: pointer; }
table.list tbody tr:hover td { background: var(--surface2); }
table.list tr.isclosed td { color: var(--muted); }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
table.list .sum { color: var(--text); }
table.list .who { display: inline-flex; align-items: center; gap: 6px; }
table.list .stagepill { font-size: 10.5px; padding: 2px 8px; }
.more { text-align: center; padding: 12px; }
table.list td:first-child { text-overflow: clip; }

/* ============ SLA ============ */
.sla { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.sla-ok { color: var(--ok); background: var(--ok-weak); }
.sla-warn { color: var(--warn); background: var(--warn-weak); }
.sla-bad { color: #fff; background: var(--danger); }
.card.slabad { box-shadow: var(--shadow), 0 0 0 1px var(--danger); }
.colhead .ct { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slachip { text-transform: none; font-weight: 600; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--accent-weak); color: var(--accent-text); cursor: pointer; white-space: nowrap; letter-spacing: 0; }
.slachip.empty { background: none; color: var(--muted); opacity: .55; }
.slachip.empty:hover { opacity: 1; }
.slacnt { font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 6px; color: #fff; }
.slacnt.bad { background: var(--danger); }
.slacnt.warn { background: var(--warn); }

/* SLA errors view */
.errhead { display: flex; gap: 12px; align-items: stretch; margin-bottom: 14px; flex-wrap: wrap; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 12px 18px; min-width: 160px; }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.bad .v { color: var(--danger); }
.kpi.warn .v { color: var(--warn); }
.errhead .per { align-self: center; color: var(--muted); font-size: 13px; }
.errgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 14px; margin-bottom: 14px; }
.errcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 4px 16px 14px; margin-bottom: 14px; }
.errgrid .errcard { margin-bottom: 0; }
.errt tr[data-errf] { cursor: pointer; }
.errt tr[data-errf]:hover td { background: var(--surface2); }
.errt .num, table.ts .num { text-align: right; font-variant-numeric: tabular-nums; }
.redt { color: var(--danger); }
.bar { height: 5px; background: var(--surface2); border-radius: 3px; margin-top: 5px; display: flex; overflow: hidden; }
.bar .bf { background: var(--danger); } .bar .bw { background: var(--warn); }
.livecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
table.list tr.warnrow td { color: var(--muted); }

/* ============ Calls ============ */
table.calls td { vertical-align: middle; }
table.calls { font-size: 12.5px; }
table.calls audio { height: 32px; width: calc(100% - 70px); vertical-align: middle; }
table.calls tr.audrow td { padding-top: 0; }
.cdir { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; }
.cdir svg.i { width: 14px; height: 14px; }
.cdir.in { color: var(--accent-text); background: var(--accent-weak); } .cdir.out { color: var(--ok); background: var(--ok-weak); }
.cdir.missed { color: #fff; background: var(--danger); }
.cst { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--surface2); white-space: nowrap; }
.cst.ok { color: var(--ok); background: var(--ok-weak); } .cst.bad { color: #fff; background: var(--danger); } .cst.warn { color: var(--warn); background: var(--warn-weak); } .cst.live { color: #fff; background: var(--accent); }
.callpops { position: fixed; right: 18px; bottom: 44px; display: flex; flex-direction: column; gap: 10px; z-index: 70; width: 340px; max-width: calc(100vw - 32px); }
.callpop { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 14px 16px; font-size: 13px; position: relative; overflow: hidden; animation: popin .2s ease-out; }
.callpop::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent), #8b5cf6, #ec4899); }
.callpop.ended::before { background: var(--line2); }
.callpop.ended { opacity: .95; }
.callpop .cph { display: flex; align-items: center; gap: 10px; }
.callpop .cph .spacer { flex: 1; }
.callpop .x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; }
.callpop .x:hover { background: var(--surface2); color: var(--text); }
.callpop .muted { font-size: 12px; }
.callpop .cpnum { font-size: 22px; font-weight: 700; margin: 8px 0 2px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.callpop .cpreq { margin-top: 10px; padding: 10px 12px; background: var(--surface2); border-radius: var(--r); }
.callpop .cptext { margin-top: 4px; color: var(--muted); font-size: 12px; }
.callpop .cpbtns { display: flex; gap: 6px; margin-top: 12px; }
.cpicon { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-weak); color: var(--accent-text); flex: none; }
.cpicon svg.i { width: 17px; height: 17px; }
.callpop.ringing .cpicon { background: var(--accent); color: #fff; box-shadow: 0 0 0 0 rgba(99,102,241,.5); animation: ringpulse 1.4s infinite; }
.callpop.ringing .cpicon svg { animation: ring 1s infinite; }
@keyframes ring { 0%,100% { transform: rotate(0) } 20% { transform: rotate(-16deg) } 40% { transform: rotate(16deg) } 60% { transform: rotate(-10deg) } 80% { transform: rotate(6deg) } }
@keyframes ringpulse { 70% { box-shadow: 0 0 0 10px rgba(99,102,241,0); } 100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); } }

/* ============ Bell + notifications panel ============ */
.nbtn { position: relative; }
.nbtn.muted { opacity: .5; }
.nbadge { position: absolute; top: 1px; right: 0; font-size: 10px; padding: 0 5px; line-height: 16px; min-width: 16px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.nbadge.red { background: var(--danger); }
.npanel { position: fixed; z-index: 55; width: min(480px, calc(100vw - 16px)); max-height: 78vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: popin .15s ease-out; }
.npanel .nph { display: flex; align-items: center; gap: 8px; padding: 14px 16px 12px; }
.npanel .nph b { font-size: 15px; }
.npanel .nph .spacer { flex: 1; }
.npanel .nph .seg { margin: 0; } .npanel .nph .seg button { padding: 3px 10px; font-size: 12px; }
.npanel .npset { padding: 4px 16px 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); font-size: 13px; }
.npanel .npset .switch + .switch { border-top: 1px solid var(--line); }
.npanel .npset .perm { margin-left: 48px; margin-top: -4px; margin-bottom: 6px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.npanel .nplist { overflow: auto; padding: 4px 0; }
.nitem { display: flex; gap: 12px; padding: 10px 16px; font-size: 13px; position: relative; }
.nitem + .nitem { border-top: 1px solid var(--line); }
.nitem[data-req] { cursor: pointer; } .nitem[data-req]:hover { background: var(--surface2); }
.nitem.new::before { content: ""; position: absolute; left: 6px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--accent); }
.nitem .nic { width: 34px; height: 34px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface2); color: var(--muted); }
.nitem .nic svg.i { width: 16px; height: 16px; }
.nitem .nic.ok { color: var(--ok); background: var(--ok-weak); } .nitem .nic.bad { background: var(--danger-weak); color: var(--danger); } .nitem .nic.live { background: var(--accent); color: #fff; } .nitem .nic.warn { background: var(--warn-weak); color: var(--warn); }
.nitem .nbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nitem .nt { display: flex; gap: 8px; align-items: center; } .nitem .nt .spacer { flex: 1; }
.nitem .nt b { font-variant-numeric: tabular-nums; font-size: 14px; }
.nitem .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* notification types */
.nitem .nic.tg, .cpicon.tg { background: #e0f2fe; color: #0284c7; }
.nitem .nic.req, .cpicon.req { background: var(--accent-weak); color: var(--accent-text); }
.cpicon.warn { background: var(--warn-weak); color: var(--warn); }
:root[data-theme="dark"] .nitem .nic.tg, :root[data-theme="dark"] .cpicon.tg { background: rgba(56,189,248,.15); color: #38bdf8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nitem .nic.tg, :root:not([data-theme="light"]) .cpicon.tg { background: rgba(56,189,248,.15); color: #38bdf8; } }
.cst.tg { color: #0284c7; background: #e0f2fe; } .cst.acc { color: var(--accent-text); background: var(--accent-weak); }
.ntabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ntabs button { border: 0; background: none; padding: 9px 8px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.ntabs button:hover { color: var(--text); }
.ntabs button.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.ntabs button span { background: var(--surface2); color: var(--muted); border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 600; }
.ntabs button.active span { background: var(--accent-weak); color: var(--accent-text); }
.npanel .nph .btn.icon.small { width: 28px; height: 28px; }
.npanel .npset { border-bottom: 1px solid var(--line); }
.evpop .evsub { margin-top: 10px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.evpop .cph .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.ev-tg::before { background: linear-gradient(90deg, #0ea5e9, #38bdf8) !important; }
.ev-bot::before { background: linear-gradient(90deg, #f59e0b, #fbbf24) !important; }
.npanel .nph, .npanel .npset, .npanel .ntabs { flex: none; }
.npanel .nplist { flex: 1; min-height: 0; }

/* topbar: nothing but presets/search may shrink */
.topbar > * { flex-shrink: 0; }
.topbar .presets { flex-shrink: 1; min-width: 60px; }
.topbar .search { flex-shrink: 1; min-width: 140px; width: 240px; }
.topbar .search input { width: 100%; }
#btnNew { padding: 0 14px; }

/* priority (Jira-like) */
svg.pi { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.prio { display: inline-flex; align-items: center; }
.prio-inline { display: inline-flex; align-items: center; gap: 4px; color: var(--text2); }
.prio-sel { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; text-align: left; transition: border-color .12s, box-shadow .12s; }
.prio-sel:hover { border-color: var(--muted); }
.prio-sel:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.prio-sel span { flex: 1; }
.prio-sel .chev2 { color: var(--muted); }
.pop .opt svg.pi { margin-right: 2px; }

/* activity: tame Odoo HTML */
.feed .html { overflow-x: auto; }
.feed .html table { border-collapse: collapse; max-width: 100%; font-size: 12.5px; }
.feed .html td, .feed .html th { padding: 3px 8px 3px 0; vertical-align: top; text-align: left; }
.feed .html div[style*="width"] { width: auto !important; }

/* Telegram chat viewer */
.mbox.wide { width: min(760px, 100%); padding: 0; gap: 0; overflow: hidden; }
.tgv { display: flex; flex-direction: column; height: min(78vh, 820px); }
.tgvh { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.tgvh .muted { font-size: 12px; }
.tgvbody { flex: 1; overflow: auto; padding: 16px 18px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.tgvfoot { padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.tgm { display: flex; }
.tgm.op { justify-content: flex-end; }
.tgb { max-width: 76%; padding: 7px 11px 5px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.tgm.cl .tgb { border-bottom-left-radius: 4px; }
.tgm.op .tgb { background: var(--accent-weak); border-color: transparent; border-bottom-right-radius: 4px; }
.tgb .html { color: var(--text); margin: 0 !important; }
.tgb .html p { margin: 0 0 2px; }
.tga { font-size: 11px; font-weight: 600; color: var(--accent-text); margin-bottom: 2px; }
.tgt { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.tgsys { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--surface2); padding: 2px 10px; border-radius: 10px; max-width: 90%; text-align: center; }
.tgday { align-self: center; margin: 8px 0 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
.tgside .btn { justify-content: center; }

.tgreqs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tgreq { border: 1px solid var(--line2); background: var(--surface); border-radius: 14px; padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.tgreq:hover { border-color: var(--muted); color: var(--text); }
.tgreq.open { border-color: transparent; background: var(--accent-weak); color: var(--accent-text); }
.tgnoreq { display: inline-flex; gap: 6px; align-items: center; color: var(--warn); font-size: 12.5px; font-weight: 600; }
