/* ── Unik CRM+ admin panel ─────────────────────────────────────── */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-hover: #1e293b;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ring: rgba(79, 70, 229, 0.25);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(15,23,42,.06);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 70% -10%, #312e81 0%, #0f172a 55%);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.brand b { font-size: 17px; letter-spacing: -.2px; }

/* ── Layout ────────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand b { color: #fff; }
.sidebar .brand { padding: 0 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 9px; color: #cbd5e1; font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: -.2px; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.content { padding: 24px; }

/* ── Components ─────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px; }
.stat .n { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }

label { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--text); outline: none; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.field { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 9px;
  border: 1px solid transparent; background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--primary-600); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #f8fafc; }
.btn.ghost { background: transparent; color: var(--primary); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #f8fafc; }
tbody tr:hover { background: #f8fafc; cursor: pointer; }
.code { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.open { background: #eef2ff; color: #4338ca; }
.pill.won { background: #dcfce7; color: #166534; }
.pill.lost { background: #fee2e2; color: #991b1b; }
.pill.stage { background: #f1f5f9; color: #475569; }
.pill.hot { background: #fee2e2; color: #b91c1c; }
.pill.warm { background: #fef3c7; color: #92400e; }
.pill.cold { background: #e0f2fe; color: #075985; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 16px; color: var(--muted); }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 24px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.muted { color: var(--muted); }
.empty { text-align: center; padding: 48px; color: var(--muted); }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 100; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: #b91c1c; }
.hidden { display: none !important; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.detail-grid .k { color: var(--muted); font-size: 12px; }
.detail-grid .v { font-weight: 600; margin-bottom: 8px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 22px 0 10px; }

/* Filter tabs (used on Reminders) */
.tabs { display: inline-flex; gap: 4px; background: #f1f5f9; border-radius: 10px; padding: 4px; }
.tab { border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  padding: 6px 14px; border-radius: 8px; cursor: pointer; }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* Notification bell + dropdown */
.notif { position: relative; }
.bell-btn { position: relative; border: 0; background: transparent; cursor: pointer; font-size: 18px;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.bell-btn:hover { background: #f1f5f9; }
.bell-badge { position: absolute; top: 0; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  background: #ef4444; color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; }
.bell-panel { position: absolute; top: 44px; right: 0; width: 340px; max-height: 460px; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 40; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; }
.bell-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; }
.bell-item:hover { background: #f8fafc; }
.bell-item .bell-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; margin-top: 6px; flex: none; }
.bell-item.unread { background: #eef2ff; }
.bell-item.unread .bell-dot { background: var(--primary); }
.bell-title { font-weight: 600; font-size: 14px; }
.bell-time { font-size: 12px; margin-top: 2px; }

/* ── Chat ──────────────────────────────────────────────────────── */
.chat-wrap { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; height: calc(100vh - 130px); }
.chat-list { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.chat-list-head { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); }
.thread-list { overflow-y: auto; flex: 1; }
.thread-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 16px 4px; }
.thread-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer;
  border-left: 3px solid transparent; }
.thread-row:hover { background: #f8fafc; }
.thread-row.active { background: #eef2ff; border-left-color: var(--primary); }
.thread-ico { width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  background: #f1f5f9; border-radius: 8px; font-size: 15px; }
.thread-meta { min-width: 0; flex: 1; }
.thread-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-title .lock { font-size: 11px; }
.thread-preview { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge-dot { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; flex: none; }

.chat-main { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.msg-scroll { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px;
  background: #f8fafc; }
.msg { max-width: 68%; align-self: flex-start; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); }
.msg.mine { align-self: flex-end; background: var(--primary); color: #fff; border-color: var(--primary); }
.msg-sender { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; word-wrap: break-word; }
.msg-time { font-size: 10px; opacity: .6; text-align: right; margin-top: 2px; }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 120px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 14px; }
.composer textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.user-pick { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; cursor: pointer; }
.user-pick:hover { background: #f1f5f9; }
.nav-badge { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px;
  padding: 0 6px; margin-left: auto; }

/* ── AI settings + copilot ─────────────────────────────────────── */
.ai-prov { margin-bottom: 16px; }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; }
.ai-grid input, .ai-grid select { width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-family: inherit; font-size: 14px; }
.ai-grid input:focus, .ai-grid select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.ai-grid .k { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.ai-howto { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.ai-howto ol { margin: 8px 0 0; padding-left: 18px; }
.ai-howto li { margin-bottom: 6px; font-size: 13px; }
.ai-status { font-size: 13px; }
.ai-status.ok { color: #15803d; }
.ai-status.err { color: #b91c1c; }

.ai-chat { max-width: 820px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { background: #eef2ff; color: var(--primary-600); border: 1px solid #c7d2fe; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; }
.chip:hover { background: #e0e7ff; }
.ai-chat textarea { resize: none; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: 14px; }
.ai-chat textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.ai-answer { margin-top: 14px; }
.ai-q { font-weight: 700; margin-bottom: 8px; }
.ai-a { white-space: pre-wrap; line-height: 1.6; }

/* ── Chat oversight ────────────────────────────────────────────── */
.ov-cats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; font-size: 13px; }
.flag-card { margin-bottom: 12px; border-left: 4px solid var(--border); }
.flag-snippet { margin-top: 10px; font-style: italic; background: #f8fafc; border-radius: 8px; padding: 10px 12px; }
.sev-pill { color: #fff; text-transform: uppercase; font-size: 11px; }
.sev-high   { color: #b91c1c; }
.pill.sev-high   { background: #dc2626; }
.pill.sev-medium { background: #d97706; }
.pill.sev-low    { background: #64748b; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  font-size: 13px; color: var(--muted); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
