/* Agency CRM – theme layer on top of Bootstrap 5.3 */
:root {
  --crm-sidebar-w: 256px;
  --crm-sidebar-bg: #111827;
  --crm-sidebar-fg: #cbd5e1;
  --crm-sidebar-muted: #64748b;
  --crm-sidebar-active: #4f46e5;
  --crm-accent: #4f46e5;
  --crm-accent-soft: #eef2ff;
  --crm-bg: #f4f6fb;
  --crm-border: #e5e7eb;
  --bs-primary: #4f46e5;
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4338ca;
  --bs-link-color-rgb: 67, 56, 202;
  --bs-link-hover-color: #3730a3;
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .9rem;
}
body { background: var(--crm-bg); }
.btn-primary { --bs-btn-bg: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; --bs-btn-disabled-bg: #818cf8; --bs-btn-disabled-border-color: #818cf8; }
.btn-outline-primary { --bs-btn-color: #4f46e5; --bs-btn-border-color: #4f46e5; --bs-btn-hover-bg: #4f46e5; --bs-btn-hover-border-color: #4f46e5; --bs-btn-active-bg: #4338ca; }
.text-bg-primary, .bg-primary { background-color: #4f46e5 !important; }
.text-primary { color: #4f46e5 !important; }
.form-control:focus, .form-select:focus { border-color: #a5b4fc; box-shadow: 0 0 0 .2rem rgba(79,70,229,.15); }

/* Layout */
.crm-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--crm-sidebar-w); background: var(--crm-sidebar-bg); color: var(--crm-sidebar-fg); overflow-y: auto; z-index: 1040; transition: transform .2s ease; }
.crm-sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06); }
.crm-sidebar .brand .logo { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg,#6366f1,#22d3ee); display: grid; place-items: center; color: #fff; }
.crm-sidebar .nav-group-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--crm-sidebar-muted); padding: 1rem 1.25rem .35rem; display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.crm-sidebar .nav-group-title .bi { transition: transform .2s; }
.crm-sidebar .nav-group-title.collapsed .bi { transform: rotate(-90deg); }
.crm-sidebar .nav-link { color: var(--crm-sidebar-fg); padding: .48rem 1.25rem; display: flex; align-items: center; gap: .7rem; border-left: 3px solid transparent; font-size: .87rem; }
.crm-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.04); }
.crm-sidebar .nav-link.active { color: #fff; background: rgba(99,102,241,.16); border-left-color: #818cf8; }
.crm-sidebar .nav-link .bi { font-size: 1rem; width: 1.1rem; text-align: center; opacity: .9; }
.crm-sidebar .nav-link .badge { margin-left: auto; }
.crm-main { margin-left: var(--crm-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.crm-topbar { position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--crm-border); height: 60px; display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; }
.crm-topbar .search { max-width: 420px; flex: 1; }
.crm-content { padding: 1.5rem; flex: 1; }
.crm-backdrop { display: none; }
@media (max-width: 991.98px) {
  .crm-sidebar { transform: translateX(-100%); }
  body.sidebar-open .crm-sidebar { transform: translateX(0); }
  body.sidebar-open .crm-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
  .crm-main { margin-left: 0; }
  .crm-content { padding: 1rem; }
}

/* Cards & tables */
.card { border: 1px solid var(--crm-border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--crm-border); font-weight: 600; padding: .85rem 1.1rem; border-top-left-radius: .75rem !important; border-top-right-radius: .75rem !important; }
.table { --bs-table-striped-bg: #fafbff; margin-bottom: 0; }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: #64748b; font-weight: 600; background: #f8fafc; border-bottom: 1px solid var(--crm-border); white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #f5f7ff; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; color: #0f172a; }
.page-header .subtitle { color: #64748b; margin-top: .2rem; }
.breadcrumb { font-size: .8rem; margin-bottom: .25rem; }

/* KPI tiles */
.kpi { display: block; text-decoration: none; color: inherit; height: 100%; }
.kpi .card-body { display: flex; gap: .9rem; align-items: center; padding: 1rem 1.1rem; }
.kpi .icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0; }
.kpi .value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; color: #0f172a; }
.kpi .label { color: #64748b; font-size: .78rem; }
.kpi:hover .card { border-color: #c7d2fe; box-shadow: 0 4px 14px rgba(79,70,229,.08); }
.tone-primary .icon { background: #eef2ff; color: #4f46e5; } .tone-success .icon { background: #ecfdf5; color: #059669; }
.tone-warning .icon { background: #fffbeb; color: #d97706; } .tone-danger .icon { background: #fef2f2; color: #dc2626; }
.tone-info .icon { background: #ecfeff; color: #0891b2; } .tone-secondary .icon { background: #f1f5f9; color: #475569; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; font-weight: 700; margin: 1.5rem 0 .75rem; }

/* Badges */
.badge { font-weight: 600; letter-spacing: .01em; }
.badge.text-bg-light { border: 1px solid var(--crm-border); }

/* Kanban */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 280px; background: #eef1f7; border-radius: .75rem; padding: .6rem; min-height: 200px; }
.kanban-col.drag-over { outline: 2px dashed #818cf8; background: #e0e7ff; }
.kanban-col h6 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; padding: .3rem .4rem .6rem; margin: 0; }
.kanban-card { background: #fff; border: 1px solid var(--crm-border); border-radius: .6rem; padding: .7rem .75rem; margin-bottom: .55rem; cursor: grab; font-size: .84rem; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .5; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--crm-border); border-left: 1px solid var(--crm-border); }
.cal .dow { background: #f8fafc; font-size: .72rem; text-transform: uppercase; color: #64748b; font-weight: 700; padding: .45rem; border-right: 1px solid var(--crm-border); border-bottom: 1px solid var(--crm-border); }
.cal .day { min-height: 110px; padding: .35rem; border-right: 1px solid var(--crm-border); border-bottom: 1px solid var(--crm-border); background: #fff; overflow: hidden; }
.cal .day.out { background: #fafafa; color: #94a3b8; }
.cal .day.today { background: #f5f7ff; }
.cal .day .num { font-size: .75rem; font-weight: 700; margin-bottom: .2rem; }
.cal .ev { display: block; font-size: .72rem; padding: .1rem .35rem; border-radius: .3rem; margin-bottom: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
@media (max-width: 767.98px) { .cal .day { min-height: 70px; } .cal .ev { font-size: .62rem; } }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline:before { content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px; width: 2px; background: var(--crm-border); }
.timeline li { position: relative; padding-left: 44px; margin-bottom: 1rem; }
.timeline .dot { position: absolute; left: 4px; top: 0; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid #c7d2fe; display: grid; place-items: center; font-size: .7rem; color: #4f46e5; }

/* Misc */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #64748b; }
.empty-state .bi { font-size: 2.4rem; color: #c7d2fe; display: block; margin-bottom: .5rem; }
dl.meta dt { font-weight: 500; color: #64748b; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
dl.meta dd { margin-bottom: .8rem; color: #0f172a; }
.nav-tabs .nav-link { color: #475569; font-weight: 500; }
.nav-tabs .nav-link.active { color: #4f46e5; font-weight: 600; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.toast-container { z-index: 1090; }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }
.filters .form-control, .filters .form-select { min-width: 140px; }
.item-row { border: 1px solid var(--crm-border); border-radius: .75rem; padding: 1rem; margin-bottom: 1rem; background: #fcfcff; position: relative; }
.pre-line { white-space: pre-line; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #e0e7ff 0, transparent 40%), radial-gradient(circle at 80% 80%, #cffafe 0, transparent 40%), var(--crm-bg); }
.notif-menu { width: 340px; max-height: 420px; overflow-y: auto; }
@media print { .crm-sidebar, .crm-topbar, .no-print { display: none !important; } .crm-main { margin: 0; } }
.row-cols-xxl-7 > * { } @media (min-width: 1400px) { .row-cols-xxl-7 > * { flex: 0 0 auto; width: 14.2857%; } }
.kpi .value { font-size: clamp(1.05rem, 1.25vw, 1.35rem); overflow-wrap: anywhere; }
a { text-decoration: none; } a:hover { text-decoration: underline; } .btn:hover, .nav-link:hover, .list-group-item-action:hover, .kpi:hover, .dropdown-item:hover { text-decoration: none; }
