:root {
  --ink: #1c2230; --ink2: #5b6475; --line: #e3e0d8; --bg: #f6f4ef; --card: #fff;
  --side: #1f2a26; --side2: #9fb0a8; --accent: #1f7a5a; --accent-d: #17624a; --accent-l: #e3f1ea;
  --red: #c8402f; --amber: #b7791f; --blue: #2c5f9e;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; } h2 { font-size: 15px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c9c5ba; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-d); }
.btn.sm { padding: 4px 10px; font-size: 13px; } .wide { width: 100%; }
.link { background: none; border: 0; color: var(--ink2); text-decoration: underline; padding: 4px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; margin-top: 16px; }
.row.form { margin-top: 12px; } .row.form input { flex: 1 1 180px; }
.err { color: var(--red); min-height: 1em; } .hint, .empty { color: var(--ink2); } .empty { padding: 24px; text-align: center; }

.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr) 320px; height: 100vh; }
.side { background: var(--side); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; margin: 0 6px 22px; }
.logo { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 16px; border: 2px dotted rgba(255,255,255,.55); }
.nav { text-align: left; background: none; border: 0; color: var(--side2); padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.nav:hover { color: #fff; } .nav.cur { background: rgba(255,255,255,.1); color: #fff; }
.me { margin-top: auto; padding: 12px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid rgba(255,255,255,.12); }
.me span { color: var(--side2); font-size: 12px; } .me .link { color: var(--side2); text-align: left; font-size: 12px; }

main { overflow: auto; padding: 26px 30px; }
.banner { background: #fff6dd; border: 1px solid #ecd58f; color: #6b4e05; padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; }
.vh { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tw { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--ink2); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid #efede7; vertical-align: middle; } tr:last-child td { border-bottom: 0; }
td small { display: block; color: var(--ink2); } .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.act { text-align: right; white-space: nowrap; } .act > * { margin-left: 6px; vertical-align: middle; } .act audio { height: 30px; width: 220px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: #eee; white-space: nowrap; }
.tag.answered { background: var(--accent-l); color: var(--accent-d); } .tag.no_answer { background: #f3ecdb; color: #7a5a12; }
.tag.missed, .tag.failed { background: #f9e3df; color: #99301f; } .tag.ringing { background: #e2ebf7; color: var(--blue); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }
.panel .tw { border: 0; border-radius: 0; margin: 0 -18px; } .panel .vh { margin-bottom: 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi span { color: var(--ink2); font-size: 12px; display: block; } .kpi strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; position: relative; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; } .card p { color: var(--ink2); margin: 8px 0 12px; min-height: 1.3em; }
.bar { height: 6px; background: #ece9e1; border-radius: 3px; margin-top: 12px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); }
.agents { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.agent { border-left: 4px solid #cfcbc0; } .agent.available { border-left-color: var(--accent); } .agent.on_call { border-left-color: var(--red); }
.agent.wrapup { border-left-color: var(--amber); } .agent.pause { border-left-color: var(--blue); } .agent.offline { opacity: .6; }
.st { font-size: 12px; font-weight: 600; color: var(--ink2); } .st.available { color: var(--accent-d); } .st.on_call { color: var(--red); } .st.wrapup { color: var(--amber); } .st.pause { color: var(--blue); }
.since { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 8px; overflow-x: auto; }
.col { flex: 1 0 22px; max-width: 60px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; color: var(--ink2); }
.colbar { width: 100%; min-height: 2px; background: #d9d4c6; border-radius: 4px 4px 0 0; display: flex; align-items: flex-end; overflow: hidden; } .colbar i { width: 100%; background: var(--accent); }
.legend { display: flex; align-items: center; gap: 6px; color: var(--ink2); font-size: 12px; margin: 12px 0 0; } .legend i { width: 10px; height: 10px; border-radius: 2px; } .legend .l1 { background: var(--accent); } .legend .l2 { background: #d9d4c6; margin-left: 10px; }

#phone { background: var(--card); border-left: 1px solid var(--line); padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.ph-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink2); } .ph-head select { margin-left: auto; padding: 4px 6px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #bbb; flex: none; } .dot.ok { background: var(--accent); }
.ph-input { width: 100%; font-size: 22px; text-align: center; padding: 12px; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.keys button { height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 20px; font-weight: 500; } .keys button:hover { background: #ece9e1; }
.keys.small button { height: 38px; font-size: 16px; }
.from { display: block; font-size: 12px; color: var(--ink2); margin-bottom: 12px; } .from select { width: 100%; margin-top: 4px; color: var(--ink); font-size: 14px; }
.btn-call, .btn-hang { border: 0; border-radius: 12px; padding: 14px 18px; color: #fff; font-weight: 600; font-size: 15px; flex: 1; }
.btn-call { background: var(--accent); } .btn-call:hover { background: var(--accent-d); } .btn-hang { background: var(--red); } .btn-hang:hover { background: #a93424; }
.ph-call, .ph-wrap { text-align: center; display: flex; flex-direction: column; gap: 8px; padding-top: 20px; }
.ph-state { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); } .ph-call.active .ph-state { color: var(--accent-d); }
.ph-name { font-size: 20px; font-weight: 600; overflow-wrap: anywhere; } .ph-num { color: var(--ink2); }
.ph-timer { font-size: 38px; font-weight: 300; font-variant-numeric: tabular-nums; margin: 10px 0; } .ph-call.ringing .ph-timer { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.ph-ctrl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .ph-ctrl button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 6px; font-size: 13px; }
.ph-ctrl button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.ph-actions { display: flex; gap: 8px; margin-top: 8px; }
.ph-wrap label { text-align: left; font-size: 12px; color: var(--ink2); margin-top: 12px; }
.dispo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .dispo button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 11px 6px; font-weight: 500; }
.dispo button:hover { border-color: var(--accent); background: var(--accent-l); }
.dialer { background: var(--accent-l); border-radius: 12px; padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.dialer-t { font-weight: 600; } .dialer-next strong { display: block; font-size: 16px; }

dialog { border: 0; border-radius: 14px; padding: 24px; width: min(480px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); } dialog::backdrop { background: rgba(20,25,22,.45); }
dialog label, .auth label { display: block; font-size: 13px; color: var(--ink2); margin-top: 12px; }
dialog label > input, dialog label > select, dialog label > textarea, .auth input { display: block; width: 100%; margin-top: 4px; color: var(--ink); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth form { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 30px; width: min(400px, 100%); } .auth .brand { margin: 0 0 18px; } .auth .btn { margin-top: 8px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 99; } .toast.bad { background: var(--red); }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; height: auto; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; } .brand { margin: 0 10px 0 4px; } .me { margin: 0 0 0 auto; border: 0; padding: 4px; }
  #phone { order: -1; border-left: 0; border-bottom: 1px solid var(--line); } main { padding: 16px; overflow: visible; }
}

.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; margin-left: 8px; } .badge[hidden] { display: none; }
.chat { display: grid; grid-template-columns: 220px minmax(0, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 12px; height: calc(100vh - 170px); min-height: 360px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.chat-list button { display: flex; justify-content: space-between; align-items: center; text-align: left; background: none; border: 0; padding: 10px; border-radius: 8px; font-weight: 500; }
.chat-list button:hover { background: var(--bg); } .chat-list button.cur { background: var(--accent-l); color: var(--accent-d); }
.chat-main { display: flex; flex-direction: column; min-height: 0; } .chat-h { padding: 12px 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; align-self: flex-start; background: var(--bg); border-radius: 12px; padding: 8px 12px; } .msg.mine { align-self: flex-end; background: var(--accent-l); }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; } .msg b { font-size: 12px; color: var(--accent-d); } .msg time { font-size: 11px; color: var(--ink2); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); } .chat-form input { flex: 1; }
@media (max-width: 700px) { .chat { grid-template-columns: 1fr; height: auto; } .chat-list { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; overflow-x: auto; } }
