:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273549;
  --border: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.88rem; }
.full-width { width: 100%; }

/* BUTTONS & INPUTS */
.btn {
  padding: 10px 16px; border: none; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 0.9rem; transition: 0.2s; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 0.92rem; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.84rem; color: var(--muted); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-row > * { flex: 1; min-width: 170px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* LOGIN */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; width: 100%; max-width: 430px; box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}
.brand-header { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; margin-bottom: 22px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #3b82f6, #10b981);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem;
}
.brand-logo.small { width: 32px; height: 32px; font-size: 0.9rem; border-radius: 8px; }
.brand-logo-img { width: min(230px, 85%); height: 56px; object-fit: contain; flex: 0 0 auto; }
.brand-logo-img.small { width: 88px; height: 30px; }
.mode-badge {
  background: rgba(59,130,246,0.15); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3);
  padding: 6px 10px; border-radius: 8px; font-size: 0.82rem; margin-bottom: 16px; text-align: center;
}
.login-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.demo-creds { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--muted); }
.cred-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cred-chips span {
  background: var(--surface-2); padding: 5px 10px; border-radius: 6px; cursor: pointer;
  color: var(--text); border: 1px solid var(--border);
}
.cred-chips span:hover { border-color: var(--primary); }

/* TOPBAR & UNIVERSAL SEARCH */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; position: sticky; top: 0; z-index: 50;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.app-title { font-weight: 700; font-size: 1.05rem; }
.role-tag {
  background: rgba(16,185,129,0.15); color: #6ee7b7; font-size: 0.72rem;
  font-weight: 700; padding: 3px 8px; border-radius: 99px; text-transform: uppercase;
}
.master-search-wrap { flex: 1; max-width: 560px; min-width: 240px; position: relative; }
.search-dropdown {
  position: absolute; top: 108%; left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--primary); border-radius: 10px; max-height: 400px; overflow-y: auto;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6); z-index: 100;
}
.search-item {
  padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.search-item:hover { background: var(--surface-2); }
.search-type {
  font-size: 0.72rem; padding: 2px 7px; border-radius: 6px; font-weight: 700;
  background: rgba(59,130,246,0.2); color: #93c5fd;
}
.search-type.emp { background: rgba(245,158,11,0.2); color: #fcd34d; }

.status-pill {
  display: flex; align-items: center; gap: 6px; background: var(--bg);
  padding: 6px 10px; border-radius: 99px; font-size: 0.82rem; border: 1px solid var(--border);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.green { background: var(--success); }
.dot.amber { background: var(--warning); }
.user-chip { font-size: 0.88rem; font-weight: 600; }

/* WORKSPACE */
.workspace { max-width: 1380px; margin: 0 auto; padding: 20px; }
.subnav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab-btn {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  padding: 9px 15px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-grid.small-grid { grid-template-columns: repeat(3, 1fr); }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.kpi-card span { color: var(--muted); font-size: 0.84rem; }
.kpi-card strong { font-size: 1.6rem; }
.kpi-card.highlight strong { color: #60a5fa; }
.kpi-card.success strong { color: var(--success); }
.kpi-card.warning strong { color: var(--warning); }

.panel-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
@media (max-width: 960px) { .panel-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.badge { padding: 3px 8px; border-radius: 99px; font-size: 0.76rem; font-weight: 600; display: inline-block; }
.badge-green { background: rgba(16,185,129,0.18); color: #6ee7b7; }
.badge-blue { background: rgba(59,130,246,0.18); color: #93c5fd; }
.badge-amber { background: rgba(245,158,11,0.18); color: #fcd34d; }
.badge-red { background: rgba(239,68,68,0.18); color: #fca5a5; }

/* TELECALLER BUCKET */
.bucket-banner {
  background: linear-gradient(135deg, #1e293b, #172554); border: 1px solid #3b82f6;
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px;
}
.bucket-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bucket-meter { min-width: 180px; }
.progress-track { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 6px; }
#bucketProgressBar { height: 100%; width: 0%; background: var(--success); transition: width 0.3s; }

.lead-hero {
  background: var(--bg); padding: 14px; border-radius: 10px; border: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
}
.quick-dial { display: flex; gap: 8px; }
.timer-box { display: flex; align-items: center; gap: 10px; font-family: monospace; font-size: 1.1rem; }
.mini-history { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.history-row {
  background: var(--bg); padding: 9px 12px; border-radius: 8px; margin-top: 8px;
  border-left: 3px solid var(--primary); font-size: 0.85rem;
}
.followup-list, .uni-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.uni-row {
  display: flex; justify-content: space-between; padding: 10px; background: var(--bg);
  border-radius: 8px; border: 1px solid var(--border);
}

/* KANBAN */
.kanban-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.kanban-col { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.kanban-col h4 { margin-bottom: 10px; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 10px; }

/* MODALS & CAMERA */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 200;
}
.modal-content {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
}
.detail-modal-box { max-width: 760px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.close-btn { background: none; border: none; color: var(--muted); font-size: 1.6rem; cursor: pointer; }
.camera-box { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
#faceVideo { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.scan-ring {
  position: absolute; inset: 14%; border: 2px dashed #3b82f6; border-radius: 50%; pointer-events: none;
}
.face-status { text-align: center; margin-top: 12px; font-weight: 600; color: #93c5fd; }
.face-progress-bar { height: 6px; background: var(--bg); border-radius: 99px; margin-top: 8px; overflow: hidden; }
#faceProgressFill { height: 100%; width: 0%; background: var(--success); transition: 0.3s; }

.upload-log { margin-top: 10px; font-size: 0.86rem; color: #6ee7b7; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* TOAST */
.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--primary); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 300;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
