/* ─── Reset & Base ─── */
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;font-family:'Pretendard',sans-serif;font-size:14px;color:#111827;background:#f1f5f9}
button{cursor:pointer;font-family:inherit}
input,select,textarea{font-family:inherit}

/* ─── Layout ─── */
.app{display:flex;height:100vh;overflow:hidden}

/* ─── Sidebar ─── */
.sidebar{
  width:220px;min-width:220px;background:#0f172a;
  display:flex;flex-direction:column;overflow-y:auto;
}
.sb-brand{
  display:flex;align-items:center;gap:10px;
  padding:20px 16px 18px;border-bottom:1px solid rgba(255,255,255,.07);
}
.sb-logo{
  width:34px;height:34px;border-radius:10px;
  background:linear-gradient(135deg,#6366f1,#8b5cf6);
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-weight:800;font-size:15px;flex-shrink:0;
}
.sb-brand span{color:#f8fafc;font-weight:700;font-size:15px;letter-spacing:-.3px}
.sb-brand small{display:block;color:#64748b;font-size:11px;margin-top:1px}
.sb-section{
  padding:20px 10px 4px;
  color:#475569;font-size:11px;font-weight:600;
  letter-spacing:.06em;text-transform:uppercase;
}
.sb-nav{display:flex;flex-direction:column;gap:2px;padding:0 8px}
.sb-item{
  display:flex;align-items:center;gap:10px;
  padding:10px 10px;border-radius:8px;
  color:#94a3b8;font-size:13.5px;font-weight:500;
  cursor:pointer;transition:background .15s,color .15s;
  border:none;background:none;width:100%;text-align:left;
}
.sb-item:hover{background:rgba(255,255,255,.05);color:#e2e8f0}
.sb-item.active{background:rgba(99,102,241,.18);color:#a5b4fc;font-weight:600}
.sb-item svg{width:16px;height:16px;flex-shrink:0;opacity:.7}
.sb-item.active svg{opacity:1}
.sb-bottom{margin-top:auto;padding:12px 8px;border-top:1px solid rgba(255,255,255,.07)}

/* ─── Main ─── */
.main{flex:1;display:flex;flex-direction:column;overflow:hidden}

/* ─── Topbar ─── */
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:0 28px;height:58px;min-height:58px;
  background:#fff;border-bottom:1px solid #e2e8f0;gap:16px;
}
.topbar-left{display:flex;align-items:center;gap:8px}
.page-title{font-size:16px;font-weight:700;color:#0f172a}
.page-sub{font-size:13px;color:#94a3b8;margin-left:4px}
.topbar-right{display:flex;align-items:center;gap:10px}
.tb-btn{
  display:flex;align-items:center;gap:6px;
  padding:7px 14px;border-radius:8px;border:1px solid #e2e8f0;
  background:#fff;font-size:13px;color:#374151;font-weight:500;transition:background .15s;
}
.tb-btn:hover{background:#f8fafc}
.tb-btn.primary{background:#6366f1;color:#fff;border-color:#6366f1}
.tb-btn.primary:hover{background:#4f46e5}
.tb-avatar{
  width:32px;height:32px;border-radius:999px;
  background:linear-gradient(135deg,#6366f1,#8b5cf6);
  display:flex;align-items:center;justify-content:center;
  color:#fff;font-size:13px;font-weight:700;
}

/* ─── Content ─── */
.content{flex:1;overflow-y:auto;padding:24px 28px}

/* ─── Page ─── */
.page{display:none}
.page.active{display:block}

/* ─── KPI Row ─── */
.kpi-row{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.kpi{background:#fff;border-radius:14px;padding:18px 20px;border:1px solid #e2e8f0;}
.kpi-label{font-size:12px;color:#94a3b8;font-weight:500;margin-bottom:6px}
.kpi-val{font-size:26px;font-weight:700;color:#0f172a;letter-spacing:-.04em;line-height:1}
.kpi-sub{font-size:12px;color:#94a3b8;margin-top:5px}
.kpi-val.green{color:#10b981}
.kpi-val.red{color:#ef4444}
.kpi-val.blue{color:#3b82f6}
.kpi-val.violet{color:#8b5cf6}

/* ─── Grid Rows ─── */
.row2{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}
.row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:16px;margin-bottom:16px}

/* ─── Card ─── */
.card{background:#fff;border-radius:14px;border:1px solid #e2e8f0;overflow:hidden;}
.card-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px 14px;border-bottom:1px solid #f1f5f9;
}
.card-title{font-size:14px;font-weight:700;color:#0f172a}
.card-action{
  font-size:12px;color:#6366f1;font-weight:600;
  padding:5px 10px;border-radius:6px;border:1px solid #e0e7ff;
  background:#f5f3ff;cursor:pointer;
}
.card-action:hover{background:#ede9fe}
.card-body{padding:16px 20px}

/* ─── Mini Bar Chart ─── */
.bar-chart{display:flex;align-items:flex-end;gap:6px;height:80px;padding:8px 0}
.bar-wrap{display:flex;flex-direction:column;align-items:center;gap:4px;flex:1}
.bar{width:100%;border-radius:4px 4px 0 0;background:#e0e7ff;transition:background .2s;min-height:4px}
.bar:hover{background:#6366f1}
.bar-label{font-size:10px;color:#94a3b8}

/* ─── Table ─── */
.tbl-wrap{overflow-x:auto}
table{width:100%;border-collapse:collapse}
thead th{
  padding:10px 14px;text-align:left;
  font-size:12px;font-weight:600;color:#64748b;
  background:#f8fafc;border-bottom:1px solid #e2e8f0;white-space:nowrap;
}
tbody tr{border-bottom:1px solid #f1f5f9;transition:background .1s}
tbody tr:last-child{border-bottom:none}
tbody tr:hover{background:#fafbfe}
tbody td{padding:11px 14px;font-size:13.5px;color:#374151;vertical-align:middle}
.td-muted{color:#94a3b8;font-size:12px}

/* ─── Badge ─── */
.badge{
  display:inline-flex;align-items:center;gap:4px;
  padding:3px 9px;border-radius:999px;font-size:12px;font-weight:600;
}
.badge.green{background:#d1fae5;color:#065f46}
.badge.red{background:#fee2e2;color:#991b1b}
.badge.blue{background:#dbeafe;color:#1e40af}
.badge.violet{background:#ede9fe;color:#5b21b6}
.badge.gray{background:#f1f5f9;color:#475569}
.badge.amber{background:#fef3c7;color:#92400e}
.badge.dot::before{content:'';width:6px;height:6px;border-radius:999px;background:currentColor}

/* ─── Progress ─── */
.prog-wrap{margin-bottom:14px}
.prog-wrap:last-child{margin-bottom:0}
.prog-head{display:flex;justify-content:space-between;margin-bottom:6px;font-size:13px}
.prog-head strong{font-weight:600}
.prog-head span{color:#94a3b8;font-size:12px}
.prog-track{height:8px;background:#f1f5f9;border-radius:999px;overflow:hidden}
.prog-fill{height:100%;border-radius:inherit;background:#6366f1}
.prog-fill.green{background:#10b981}
.prog-fill.amber{background:#f59e0b}

/* ─── Form ─── */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-group{display:flex;flex-direction:column;gap:6px}
.form-group.full{grid-column:span 2}
.form-label{font-size:12px;font-weight:600;color:#374151}
.form-control{
  padding:9px 12px;border-radius:8px;border:1px solid #e2e8f0;
  font-size:13.5px;outline:none;transition:border-color .15s;
  background:#fff;color:#111827;
}
.form-control:focus{border-color:#6366f1;box-shadow:0 0 0 3px rgba(99,102,241,.1)}
.form-control[disabled]{background:#f8fafc;color:#94a3b8}
select.form-control{
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 10px center;padding-right:28px;
}
textarea.form-control{resize:vertical;min-height:72px}
.form-actions{display:flex;gap:8px;margin-top:6px}
.btn{
  padding:9px 18px;border-radius:8px;border:none;
  font-size:13.5px;font-weight:600;transition:background .15s;
  display:inline-flex;align-items:center;gap:6px;cursor:pointer;
}
.btn-primary{background:#6366f1;color:#fff}
.btn-primary:hover{background:#4f46e5}
.btn-outline{background:#fff;color:#374151;border:1px solid #e2e8f0}
.btn-outline:hover{background:#f8fafc}
.btn-danger{background:#fee2e2;color:#991b1b;border:1px solid #fecaca}
.btn-danger:hover{background:#fecaca}
.btn-sm{padding:6px 12px;font-size:12px}
.btn-icon{padding:7px;border-radius:8px;background:#f8fafc;border:1px solid #e2e8f0;color:#64748b}
.btn-icon:hover{background:#f1f5f9}

/* ─── Tabs ─── */
.tabs{display:flex;gap:4px;padding:4px;background:#f1f5f9;border-radius:10px;width:fit-content;margin-bottom:20px}
.tab{padding:7px 16px;border-radius:7px;font-size:13px;font-weight:500;color:#64748b;cursor:pointer;transition:all .15s;border:none;background:none}
.tab.active{background:#fff;color:#0f172a;box-shadow:0 1px 3px rgba(0,0,0,.08);font-weight:600}

/* ─── Toggle Switch ─── */
.toggle-row{display:flex;align-items:center;justify-content:space-between;padding:12px 0;border-bottom:1px solid #f1f5f9}
.toggle-row:last-child{border-bottom:none}
.toggle-info strong{display:block;font-size:13.5px;font-weight:600;margin-bottom:2px}
.toggle-info span{font-size:12px;color:#94a3b8}
.toggle{position:relative;width:40px;height:22px;flex-shrink:0}
.toggle input{opacity:0;width:0;height:0}
.toggle-slider{
  position:absolute;inset:0;background:#e2e8f0;border-radius:999px;
  cursor:pointer;transition:background .2s;
}
.toggle-slider::before{
  content:'';position:absolute;width:16px;height:16px;border-radius:999px;
  background:#fff;bottom:3px;left:3px;transition:transform .2s;
  box-shadow:0 1px 3px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider{background:#6366f1}
.toggle input:checked + .toggle-slider::before{transform:translateX(18px)}

/* ─── Detail layout (Inbound/Outbound) ─── */
.detail-layout{display:grid;grid-template-columns:260px 1fr;gap:16px;height:calc(100vh - 200px)}
.detail-list{background:#fff;border-radius:14px;border:1px solid #e2e8f0;display:flex;flex-direction:column;overflow:hidden}
.detail-list-head{padding:14px 16px;border-bottom:1px solid #f1f5f9;display:flex;align-items:center;justify-content:space-between}
.detail-list-body{overflow-y:auto;flex:1}
.detail-item{padding:12px 16px;border-bottom:1px solid #f8fafc;cursor:pointer;transition:background .1s;}
.detail-item:last-child{border-bottom:none}
.detail-item:hover{background:#fafbfe}
.detail-item.active{background:#f5f3ff;border-left:3px solid #6366f1}
.detail-item.active .di-num{color:#6366f1}
.di-num{font-size:13.5px;font-weight:700;color:#0f172a;margin-bottom:2px}
.di-sub{font-size:12px;color:#94a3b8}
.detail-panel{background:#fff;border-radius:14px;border:1px solid #e2e8f0;overflow-y:auto;padding:24px}

/* ─── IVR builder ─── */
.ivr-branch{
  display:flex;align-items:center;gap:10px;
  padding:10px;background:#f8fafc;border-radius:8px;border:1px solid #e2e8f0;margin-bottom:8px;
}
.ivr-key{
  width:32px;height:32px;border-radius:8px;background:#6366f1;
  color:#fff;display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:14px;flex-shrink:0;
}
.ivr-key.two{background:#8b5cf6}
.ivr-key.three{background:#06b6d4}

/* ─── Memo thread ─── */
.memo-thread{display:flex;flex-direction:column;gap:0}
.memo-entry{display:flex;gap:12px;padding:12px 0;border-bottom:1px solid #f1f5f9}
.memo-entry:last-child{border-bottom:none}
.memo-dot{width:30px;height:30px;border-radius:999px;background:#ede9fe;color:#7c3aed;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;flex-shrink:0}
.memo-content{flex:1}
.memo-meta{font-size:12px;color:#94a3b8;margin-bottom:4px}
.memo-text{font-size:13.5px;color:#374151;line-height:1.6}

/* ─── Call log ─── */
.call-row{display:flex;align-items:center;gap:12px;padding:10px 0;border-bottom:1px solid #f1f5f9;font-size:13px}
.call-row:last-child{border-bottom:none}
.call-dir{width:24px;height:24px;border-radius:6px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:700;flex-shrink:0}
.call-dir.in{background:#dbeafe;color:#1d4ed8}
.call-dir.out{background:#dcfce7;color:#166534}
.call-info{flex:1}
.call-info strong{display:block;font-weight:600;color:#0f172a}
.call-info span{color:#94a3b8;font-size:12px}
.call-dur{color:#64748b;font-size:12px;margin-left:auto}

/* ─── Queue card ─── */
.queue-card{background:#fff;border-radius:12px;border:1px solid #e2e8f0;padding:16px 18px;display:flex;flex-direction:column;gap:10px;}
.qc-head{display:flex;align-items:center;justify-content:space-between}
.qc-name{font-size:13.5px;font-weight:700}
.qc-meta{font-size:12px;color:#94a3b8;margin-top:1px}
.qc-nums{display:flex;gap:16px}
.qc-num{text-align:center}
.qc-num strong{display:block;font-size:20px;font-weight:700;letter-spacing:-.03em}
.qc-num span{font-size:11px;color:#94a3b8}

/* ─── Filter row ─── */
.filter-row{display:flex;align-items:center;gap:10px;margin-bottom:18px;flex-wrap:wrap}
.filter-row .form-control{min-width:140px;flex:0 0 auto}

/* ─── Number pill ─── */
.num-pill{
  display:inline-block;padding:3px 8px;border-radius:6px;
  background:#f5f3ff;color:#6366f1;font-weight:700;font-size:12px;letter-spacing:-.01em;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar{width:5px;height:5px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#e2e8f0;border-radius:999px}
::-webkit-scrollbar-thumb:hover{background:#cbd5e1}

/* ─── Modal ─── */
.modal-backdrop{
  display:none;position:fixed;inset:0;background:rgba(15,23,42,.4);
  z-index:100;align-items:center;justify-content:center;
}
.modal-backdrop.open{display:flex}
.modal{
  background:#fff;border-radius:16px;width:540px;max-width:95vw;
  box-shadow:0 24px 48px rgba(15,23,42,.18);overflow:hidden;
}
.modal-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:18px 22px;border-bottom:1px solid #f1f5f9;
}
.modal-head h3{font-size:16px;font-weight:700}
.modal-close{background:none;border:none;font-size:20px;color:#94a3b8;cursor:pointer;line-height:1}
.modal-body{padding:22px}
.modal-foot{padding:16px 22px;border-top:1px solid #f1f5f9;display:flex;justify-content:flex-end;gap:8px}
