:root {
  --bg: #f5f8fc;
  --panel: #ffffff;
  --border: #e6ebf2;
  --text: #0f1b2d;
  --muted: #64748b;
  --primary: #1d5bf0;
  --primary-50: #eaf1ff;
  --green: #22b866;
  --green-50: #e6f8ee;
  --red: #ef4444;
  --red-50: #fdecec;
  --amber: #f59e0b;
  --amber-50: #fff5e0;
  --purple: #8b5cf6;
  --purple-50: #f2edff;
  --pink: #ec4899;
  --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 4px 16px rgba(15, 27, 45, .04);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand img { width: 42px; height: 42px; }
.brand-name { font-size: 22px; font-weight: 700; color: #0f2b6b; letter-spacing: -.3px; }
.brand-tag { font-size: 10.5px; color: var(--primary); }
.brand-lg img { width: 56px; height: 56px; }
.brand-lg .brand-name { font-size: 28px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: #33415c; font-weight: 500; }
.nav a:hover { background: #f2f5fa; }
.nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav .badge { margin-left: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #94a3b8; padding: 16px 12px 6px; }
.plan { margin-top: auto; border: 1px solid var(--border); border-radius: 12px; padding: 14px; font-size: 13px; }
.plan b { color: var(--primary); display: block; margin: 2px 0 12px; }
.progress { height: 8px; background: #e8edf5; border-radius: 10px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 14px 26px; background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.search { flex: 1; max-width: 440px; position: relative; }
.search input { width: 100%; padding: 10px 14px 10px 38px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafd; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; color: #94a3b8; }
.topbar .spacer { flex: 1; }
.status-select { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; font-weight: 600; cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.status-select:hover { background: #f2f5fa; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #94a3b8; }
.dot.available, .dot.online { background: var(--green); }
.dot.away { background: var(--amber); }
.dot.on-call { background: var(--red); }
.dot.connecting { background: #60a5fa; }
.userchip { display: flex; align-items: center; gap: 10px; cursor: pointer; position: relative; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.userchip small { display: block; color: var(--muted); font-size: 12px; }
.menu { position: absolute; right: 0; top: 46px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 180px; padding: 6px; display: none; z-index: 50; }
.menu.open { display: block; }
.menu button { width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: #f2f5fa; }

.content { padding: 24px 26px 110px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.footer { display: flex; justify-content: space-between; padding: 14px 26px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }

/* ---------- cards & grids ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.card-head h3 { font-size: 15.5px; font-weight: 600; }
.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-dash { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.mb { margin-bottom: 18px; }
.stat { display: flex; gap: 14px; align-items: flex-start; }
.stat .ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .label { color: #475569; font-size: 13px; }
.stat .val { font-size: 26px; font-weight: 700; margin: 2px 0 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--green); font-weight: 600; }
.down { color: var(--red); font-weight: 600; }
.bg-green { background: var(--green); } .bg-blue { background: var(--primary); } .bg-red { background: var(--red); } .bg-purple { background: var(--purple); } .bg-amber { background: var(--amber); } .bg-pink { background: var(--pink); }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-list { flex: 1; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.donut-list div { display: grid; grid-template-columns: 14px 1fr auto 52px; align-items: center; gap: 8px; }
.donut-list .num { font-weight: 600; text-align: right; }
.donut-list .pct { color: var(--muted); text-align: right; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: #475569; font-size: 12px; padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #fafbfd; }
td { padding: 10px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.who { display: flex; align-items: center; gap: 10px; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: #eef2f7; color: #475569; white-space: nowrap; }
.pill.New { background: var(--green-50); color: #15803d; }
.pill.Contacted { background: var(--amber-50); color: #b45309; }
.pill.Interested, .pill.completed, .pill.in-progress { background: var(--green-50); color: #15803d; }
.pill.Qualified, .pill.inbound { background: var(--primary-50); color: var(--primary); }
.pill.Converted { background: #dcfce7; color: #166534; }
.pill.Callback, .pill.ringing, .pill.pending { background: var(--purple-50); color: #6d28d9; }
.pill.Not-Interested, .pill.DNC, .pill.missed, .pill.failed, .pill.busy, .pill.no-answer { background: var(--red-50); color: #b91c1c; }
.pill.outbound { background: #e0f2fe; color: #0369a1; }
.pill.admin { background: #0f2b6b; color: #fff; }
.badge { background: var(--primary); color: #fff; border-radius: 20px; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; }

/* ---------- forms & buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover { background: #f5f7fb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #164bd0; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #1a9f57; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; }
.btn-block { width: 100%; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: #334155; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { padding: 9px 12px; border: 1px solid #d8dfea; border-radius: 9px; background: #fff; font-weight: 400; font-size: 14px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 91, 240, .12); }
textarea { min-height: 80px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 8px 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.code { font-family: ui-monospace, Consolas, monospace; background: #f1f5f9; padding: 2px 6px; border-radius: 5px; font-size: 12.5px; word-break: break-all; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--primary); margin: 6px 0 12px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 27, 45, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
#toasts { position: fixed; top: 76px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #0f1b2d; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; max-width: 360px; animation: pop .2s; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes pop { from { transform: translateY(-6px); opacity: 0; } }

/* ---------- live calls / activity ---------- */
.live-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f3f8; }
.live-item:last-child { border-bottom: 0; }
.live-item .ic { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.live-item .ic svg { width: 18px; }
.live-item b { font-weight: 600; }
.live-item small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; }

/* ---------- webphone ---------- */
.phone-fab { position: fixed; right: 24px; bottom: 24px; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--green); color: #fff; box-shadow: 0 8px 24px rgba(34, 184, 102, .4); cursor: pointer; z-index: 60; display: grid; place-items: center; }
.phone-fab svg { width: 26px; }
.phone-fab .fab-dot { position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; background: #94a3b8; }
.phone-fab .fab-dot.ok { background: #a3e635; }
.phone-fab.ringing { animation: ring 1s infinite; background: var(--primary); }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } }
.phone { position: fixed; right: 24px; bottom: 96px; width: 330px; background: #fff; border-radius: 18px; box-shadow: 0 18px 50px rgba(15, 27, 45, .22); border: 1px solid var(--border); z-index: 60; overflow: hidden; display: none; }
.phone.open { display: block; }
.phone-head { background: linear-gradient(135deg, #1d5bf0, #3b82f6); color: #fff; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; }
.phone-head b { font-size: 15px; }
.phone-head small { display: flex; align-items: center; gap: 6px; opacity: .9; font-size: 12px; margin-top: 3px; }
.phone-head .x { color: #fff; }
.phone-body { padding: 16px; }
.phone-body select { width: 100%; margin-bottom: 10px; }
.dial-input { width: 100%; font-size: 22px; text-align: center; font-weight: 600; letter-spacing: 1px; padding: 10px; border: 0; border-bottom: 2px solid var(--border); border-radius: 0; }
.dial-input:focus { box-shadow: none; border-color: var(--primary); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.keypad button { height: 50px; border-radius: 12px; border: 1px solid var(--border); background: #f8fafd; font-size: 19px; font-weight: 600; cursor: pointer; }
.keypad button small { display: block; font-size: 9px; color: var(--muted); letter-spacing: 1px; font-weight: 500; }
.keypad button:active { background: var(--primary-50); }
.call-btn { width: 64px; height: 64px; border-radius: 50%; border: 0; color: #fff; cursor: pointer; display: grid; place-items: center; margin: 0 auto; }
.call-btn svg { width: 26px; }
.call-row { display: flex; justify-content: center; gap: 24px; }
.incall { text-align: center; }
.incall .num { font-size: 21px; font-weight: 700; margin-top: 8px; }
.incall .meta { color: var(--muted); font-size: 13px; margin: 4px 0; }
.incall .timer { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; color: var(--primary); margin: 6px 0 14px; }
.ctrls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.ctrl { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 4px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafd; cursor: pointer; font-size: 11.5px; font-weight: 600; color: #334155; }
.ctrl svg { width: 20px; height: 20px; }
.ctrl.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.ctrl:disabled { opacity: .4; cursor: not-allowed; }
.panel-sub { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; text-align: left; }
.panel-sub .row { display: flex; gap: 8px; margin-top: 8px; }
.panel-sub .row input, .panel-sub .row select { flex: 1; }
.party { display: flex; justify-content: space-between; align-items: center; background: #f8fafd; border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-top: 8px; }
.phone-msg { background: var(--amber-50); color: #92400e; padding: 10px 12px; font-size: 12.5px; border-radius: 10px; margin-bottom: 12px; line-height: 1.45; }
.ringing-avatar { width: 72px; height: 72px; border-radius: 50%; margin: 6px auto 0; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; animation: pulse 1.4s infinite; }
.ringing-avatar svg { width: 32px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(29, 91, 240, .35); } 100% { box-shadow: 0 0 0 22px rgba(29, 91, 240, 0); } }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(circle at 20% 10%, #e3ecff, transparent 50%), var(--bg); padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 34px; width: 100%; max-width: 400px; }
.login-card h2 { font-size: 17px; margin: 6px 0 20px; color: #334155; font-weight: 600; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .g-dash { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; z-index: 80; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .menu-btn { display: inline-flex !important; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 16px 110px; }
  .topbar { padding: 10px 16px; }
  .userchip .uname, .search { display: none; }
  .phone { right: 8px; left: 8px; width: auto; bottom: 90px; }
}
.menu-btn { display: none !important; }
