/* ============================================================
   Meta CRM — Modern SaaS theme
   ============================================================ */
:root {
  --accent: #0d6efd;
  --accent-dark: #0b5ed7;
  --accent-soft: #e7f1ff;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e9ebf2;
  --border-strong: #dfe2ec;
  --text: #0f172a;
  --muted: #6b7280;
  --muted-2: #94a3b8;
  --green: #16a34a;  --green-soft: #dcfce7;
  --red: #dc2626;    --red-soft: #fee2e2;
  --amber: #d97706;  --amber-soft: #fef3c7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 4px 16px rgba(16,24,40,.07);
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  margin: 0;
}
a { color: var(--accent-dark); }

/* ---------- layout shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column; z-index: 50;
  transition: transform .2s ease;
}
.app-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.content { padding: 1.5rem; flex: 1; }

/* ---------- brand ---------- */
.sidebar .brand {
  display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem;
  color: var(--text); padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.sidebar .brand .brand-logo {
  width: 34px; height: 34px; flex-shrink: 0;
}

/* ---------- nav ---------- */
.sidebar-nav { padding: .6rem .6rem; overflow-y: auto; flex: 1; }
.nav-label {
  font-size: .67rem; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted-2); padding: .8rem .65rem .3rem; font-weight: 700;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem; color: var(--muted); text-decoration: none;
  padding: .55rem .65rem; border-radius: 9px; font-size: .9rem; font-weight: 500;
  margin-bottom: 1px; position: relative;
}
.sidebar-nav a i { font-size: 1.1rem; }
.sidebar-nav a:hover { background: #f3f4f8; color: var(--text); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.sidebar-nav a.active::before {
  content: ''; position: absolute; left: -.6rem; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px; background: var(--accent);
}
.sidebar-nav .badge-soft {
  margin-left: auto; background: var(--accent-soft); color: var(--accent-dark);
  font-size: .68rem; padding: .1rem .4rem; border-radius: 6px; font-weight: 700;
}

/* ---------- sidebar footer ---------- */
.sidebar-foot { border-top: 1px solid var(--border); padding: .6rem; }
.sidebar-foot .u { display: flex; align-items: center; gap: .55rem; padding: .4rem .5rem; border-radius: 9px; text-decoration: none; color: var(--text); }
.sidebar-foot .u:hover { background: #f3f4f8; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; flex-shrink: 0;
}

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h); background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
}
.topbar .search { flex: 1; max-width: 440px; position: relative; }
.topbar .search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.topbar .search input {
  width: 100%; border: 1px solid var(--border-strong); background: #f8fafc; border-radius: 10px;
  padding: .5rem .8rem .5rem 2.2rem; font-size: .88rem; outline: none;
}
.topbar .search input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.topbar .spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: #f3f4f8; color: var(--text); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }
.menu-toggle { display: none; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); background: var(--surface); }
.card .card-body { padding: 1.1rem 1.25rem; }
.card-title { font-size: .95rem; font-weight: 600; color: var(--text); margin-bottom: .9rem; }

/* ---------- KPI cards ---------- */
.metric-card { border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.metric-card .label { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; }
.metric-card .value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.kpi { display: flex; align-items: flex-start; gap: .9rem; }
.kpi .ic { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.kpi .label { color: var(--muted); font-size: .76rem; font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.trend { display: inline-flex; align-items: center; gap: .15rem; font-size: .74rem; font-weight: 600; padding: .1rem .4rem; border-radius: 6px; }
.trend.up { color: var(--green); background: var(--green-soft); }
.trend.down { color: var(--red); background: var(--red-soft); }
.trend.flat { color: var(--muted); background: #f1f5f9; }
.ic.indigo { background: var(--accent-soft); color: var(--accent-dark); }
.ic.green { background: var(--green-soft); color: var(--green); }
.ic.amber { background: var(--amber-soft); color: var(--amber); }
.ic.blue { background: #e0f2fe; color: #0284c7; }
.ic.pink { background: #fce7f3; color: #db2777; }
.ic.violet { background: #f3e8ff; color: #9333ea; }
.ic.red { background: var(--red-soft); color: var(--red); }

/* ---------- buttons ---------- */
.btn { border-radius: 9px; font-weight: 500; }
.btn-sm { border-radius: 8px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline-primary { color: var(--accent-dark); border-color: var(--border-strong); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- tables ---------- */
.table { --bs-table-hover-bg: #f7f8fc; }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted);
  font-weight: 600; border-bottom: 1px solid var(--border); background: #fbfbfd;
}
.table td, .table th { border-color: var(--border); }
.table-sm td, .table-sm th { padding: .5rem .6rem; vertical-align: middle; }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 20px; font-size: .74rem; font-weight: 600; }

/* ---------- forms ---------- */
.form-control, .form-select { border-radius: 9px; border-color: var(--border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-control-sm, .form-select-sm { border-radius: 8px; }
.form-label.small { color: var(--muted); font-weight: 500; }

/* ---------- page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: .85rem; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty i { font-size: 2.2rem; color: var(--muted-2); display: block; margin-bottom: .5rem; }

/* ---------- pipeline (backward-compat) ---------- */
.stage-col { background: #eef1f6; border-radius: 12px; padding: .6rem; min-height: 200px; }
.stage-col h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: #475569; }
.lead-card { background: #fff; border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }

/* ---------- dropdown polish ---------- */
.dropdown-menu { border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: .35rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .7rem; font-size: .88rem; }
.dropdown-item:active { background: var(--accent); }

/* ---------- dashboard: funnel ---------- */
.funnel-row { display: flex; align-items: center; gap: .75rem; padding: .4rem 0; }
.funnel-meta { width: 150px; flex-shrink: 0; display: flex; align-items: center; gap: .45rem; font-size: .86rem; }
.funnel-meta .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.funnel-meta .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-track { flex: 1; height: 12px; background: #f1f3f9; border-radius: 8px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: 8px; transition: width .5s ease; min-width: 2px; }
.funnel-num { width: 78px; flex-shrink: 0; text-align: right; font-size: .85rem; }

/* ---------- dashboard: recent leads ---------- */
.recent-lead { display: flex; align-items: center; gap: .7rem; padding: .55rem .35rem; border-radius: 10px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); }
.recent-lead:last-child { border-bottom: 0; }
.recent-lead:hover { background: #f7f8fc; }
.recent-lead .rl-body { flex: 1; min-width: 0; }
.recent-lead .rl-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-lead .rl-sub { margin-top: .15rem; }
.recent-lead .rl-meta { text-align: right; flex-shrink: 0; }

/* ---------- dashboard: tasks ---------- */
.task-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .35rem; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: 0; }
.task-row.overdue { background: var(--red-soft); border-radius: 9px; padding-left: .55rem; padding-right: .55rem; }
.task-row .prio { width: 8px; height: 32px; border-radius: 4px; flex-shrink: 0; }
.task-row .prio-high { background: var(--red); }
.task-row .prio-medium { background: var(--amber); }
.task-row .prio-low { background: #0ea5e9; }
.task-row .t-title { font-weight: 500; font-size: .88rem; }
.task-row .t-lead { font-size: .78rem; color: var(--accent-dark); text-decoration: none; }

/* ---------- dashboard: mini stat (ad metrics) ---------- */
.mini-stat { display: flex; align-items: center; gap: .6rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fcfcfe; height: 100%; }
.mini-stat .ms-ic { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; flex-shrink: 0; }
.mini-stat .ms-ic.indigo { background: var(--accent-soft); color: var(--accent-dark); }
.mini-stat .ms-ic.green { background: var(--green-soft); color: var(--green); }
.mini-stat .ms-ic.amber { background: var(--amber-soft); color: var(--amber); }
.mini-stat .ms-ic.blue { background: #e0f2fe; color: #0284c7; }
.mini-stat .ms-ic.pink { background: #fce7f3; color: #db2777; }
.mini-stat .ms-ic.violet { background: #f3e8ff; color: #9333ea; }
.mini-stat .ms-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .3px; }
.mini-stat .ms-value { font-size: 1.05rem; font-weight: 700; line-height: 1.2; }

/* ---------- responsive ---------- */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .topbar .search { max-width: none; }
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 45; }
.sidebar-backdrop.show { display: block; }
