:root {
  --blue: #1b93e8; --blue-d: #1478c4; --bg: #e9e9ea; --panel: #fff; --line: #e3e3e3;
  --txt: #1f1f1f; --muted: #8a8a8a; --out: #ececec; --in: #dcf5c3; --chip: #a7e8a9;
  --ok: #2ecc71; --warn: #f5a623; --bad: #d9534f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.35 Roboto, "Segoe UI", Arial, sans-serif; color: var(--txt); background: var(--bg); }
a { color: var(--blue); }
button, select, input, textarea { font: inherit; }
button { background: var(--blue); color: #fff; border: 0; border-radius: 4px; padding: 8px 14px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
button:hover { background: var(--blue-d); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: #fff; color: var(--blue); border: 1px solid var(--blue); box-shadow: none; }
button.danger { background: var(--bad); }
button.small { padding: 4px 10px; font-size: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--bad); }

/* auth pages */
body.auth { display: flex; min-height: 100%; align-items: center; justify-content: center; }
.authbox { background: #fff; padding: 28px; width: min(380px, 92vw); border-radius: 6px; box-shadow: 0 2px 12px rgba(0,0,0,.15); display: grid; gap: 12px; }
.authbox h1 { margin: 0 0 4px; font-size: 22px; }
.authbox label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.authbox input { padding: 9px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; color: var(--txt); }
.authbox div.err { background: #fdecea; padding: 8px 10px; border-radius: 4px; }

/* shell */
#app { display: flex; flex-direction: column; height: 100vh; }
.topbar { background: var(--blue); color: #fff; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; flex: none; }
.topbar .brand { font-size: 16px; font-weight: 500; }
.topbar .sp { flex: 1; }
.topbar .logout { color: #fff; opacity: .9; }
.topbar select.status { border: 0; border-radius: 4px; padding: 6px 8px; font-weight: 500; }
.topwarn { background: var(--warn); padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.body { flex: 1; display: flex; min-height: 0; }

.side { width: 190px; background: #f4f4f4; flex: none; padding-top: 10px; overflow-y: auto; }
.side .cap { padding: 10px 16px 4px; color: var(--muted); font-size: 13px; }
.side a.nav { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; color: var(--txt); text-decoration: none; }
.side a.nav:hover { background: #e8e8e8; }
.side a.nav.on { background: #dcdcdc; }
.shiftbox { margin: 12px 10px; padding: 10px; background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.2); display: grid; gap: 8px; }
.shiftbox .cap { padding: 0; }
.badge { background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; margin-left: 6px; }

.chip { display: inline-block; border-radius: 12px; padding: 1px 10px; font-size: 12px; background: #ddd; }
.chip.available { background: var(--ok); color: #fff; } .chip.busy { background: var(--warn); color: #fff; } .chip.offline { background: #bbb; color: #fff; }
.chip.agentchip { background: var(--chip); margin-left: 8px; } .chip.queue { background: #ffd9a0; } .chip.wait { background: #cfe8fb; } .chip.prem { background: #ffe08a; margin-left: 8px; }

/* inbox */
.inbox { flex: 1; display: flex; gap: 8px; padding: 8px; min-width: 0; background: #d5d5d6; }
.listpane { width: 270px; flex: none; background: var(--panel); overflow-y: auto; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.listhead { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; font-weight: 500; border-bottom: 1px solid var(--line); }
.searchbox { width: calc(100% - 24px); margin: 10px 12px; padding: 7px 9px; border: 1px solid #ccc; border-radius: 4px; }
.row { display: flex; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: #f6f6f6; } .row.on { background: #e5e5e5; } .row.await { border-left: 4px solid var(--blue); padding-left: 10px; }
.pair { display: flex; flex: none; } .pair .avatar + .avatar { margin-left: -10px; }
.rowtxt { min-width: 0; flex: 1; }
.rowtop { display: flex; justify-content: space-between; gap: 6px; }
.names { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.when { color: var(--muted); font-size: 12px; flex: none; }
.last { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.meta .chip.agentchip { margin-left: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #c9c9c9; border: 2px solid #fff; flex: none; }
.avatar.sm { width: 32px; height: 32px; } .avatar.noimg { visibility: visible; background: #c9c9c9; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.empty.big { flex: 1; align-self: center; font-size: 16px; }

.chatarea { flex: 1; display: flex; min-width: 0; background: var(--panel); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.profile { width: 215px; flex: none; overflow-y: auto; padding-bottom: 20px; }
.profile .ptag { padding: 6px 14px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.photo { background: #ddd; height: 190px; overflow: hidden; }
.photo .avatar.big { width: 100%; height: 100%; border-radius: 0; border: 0; object-fit: cover; }
.pname { padding: 8px 12px; font-weight: 500; font-size: 14px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #bbb; margin-left: 8px; } .dot.on { background: var(--ok); }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin: 0 14px; }
.tabs a { flex: 1; text-align: center; padding: 12px 0; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--blue); border-color: var(--blue); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 10px; padding: 10px 12px; }
.grid b { display: block; font-size: 13px; } .grid span { color: var(--muted); font-size: 13px; }
.desc { padding: 0 14px; } .desc p { color: var(--muted); font-size: 13px; margin: 4px 0; }
.memo { display: block; width: calc(100% - 28px); margin: 14px; min-height: 160px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; resize: vertical; }
.profile > button { margin: 0 14px; }

.center { flex: 1; display: flex; flex-direction: column; min-width: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.centerhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.centerhead h2 { margin: 0; font-size: 17px; font-weight: 500; }
.menu { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; } .menu select { padding: 7px; border-radius: 4px; }
.thread { flex: 1; overflow-y: auto; padding: 8px 14px; }
.daypill { text-align: center; margin: 8px 0; } .daypill span { background: var(--blue); color: #fff; font-weight: 500; padding: 3px 12px; font-size: 12px; border-radius: 16px; }
.msg { display: flex; gap: 8px; margin: 8px 0; align-items: flex-start; }
.msg.in { flex-direction: row; justify-content: flex-end; }
.msgcol { max-width: 80%; } .msg.in .msgcol { text-align: right; }
.bubble { display: inline-block; text-align: left; padding: 6px 14px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.msg.out .bubble { background: var(--out); } .msg.in .bubble { background: var(--in); }
.stamp { font-size: 12px; color: #444; margin: 2px 8px; }
.readonly { background: #fff6e0; padding: 6px 14px; font-size: 12px; }
.composerbar { display: flex; gap: 10px; align-items: flex-end; padding: 8px 14px 10px; border-top: 1px solid var(--line); }
.composerbar textarea { flex: 1; border: 0; border-bottom: 1px solid #888; padding: 6px 2px; resize: none; font-size: 14px; outline: none; }
.composerbar textarea:disabled { background: transparent; }

/* monitoring */
.monitor { flex: 1; overflow: auto; padding: 18px 24px; background: var(--panel); }
.monitor h3 { margin: 22px 0 8px; font-weight: 500; }
.cards { display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; }
.card { background: #f4f4f4; border-radius: 6px; padding: 12px 18px; min-width: 130px; } .card .cv { font-size: 24px; font-weight: 500; }
.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px; border-bottom: 2px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.inactive { opacity: .55; } .num { width: 56px; padding: 4px; }

@media (max-width: 1100px) { .listpane { width: 220px; } }
@media (max-width: 760px) { .inbox { flex-direction: column; padding: 4px; } .listpane { width: 100%; max-height: 35vh; } }

.iconbtn { background: transparent; box-shadow: none; font-size: 18px; padding: 2px 8px; } .iconbtn:hover { background: rgba(255,255,255,.2); }
.center { min-width: 280px; }
.iconbtn.dark { color: var(--txt); } .iconbtn.dark:hover { background: #eee; }
.listpane.collapsed { width: 34px; display: flex; flex-direction: column; align-items: center; padding-top: 4px; overflow: hidden; }
.vlabel { writing-mode: vertical-rl; margin-top: 12px; color: var(--muted); }
.autobox { background: #f4f4f4; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }
.autobox .switch { display: flex; align-items: center; gap: 6px; cursor: pointer; } .autobox input { width: 16px; height: 16px; }
.newagent { margin: 10px 0; background: #f4f4f4; border-radius: 6px; padding: 8px 12px; } .newagent summary { cursor: pointer; font-weight: 500; }
.newagent form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.newagent input, .newagent select { padding: 6px; border: 1px solid #ccc; border-radius: 4px; }