@import url('https://fonts.googleapis.com/css2?family=Libre+Franklin:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --navy:      #2A3176;
  --navy-l:    #3a44a0;
  --navy-d:    #1e2454;
  --navy-bg:   #eef0fa;
  --gold:      #E8A020;
  --gold-bg:   #fef3e0;

  --bg:        #f4f5fb;
  --white:     #ffffff;
  --text:      #1a1a2e;
  --text-mid:  #4a5568;
  --text-low:  #718096;
  --border:    #e2e8f0;
  --border-hi: #2A3176;

  --r:         6px;
  --r-lg:      10px;
  --sh:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --sh-md:     0 4px 8px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.05);
  --sh-lg:     0 12px 24px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);

  --sidebar-w: 230px;
  --topbar-h:  56px;
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Libre Franklin', system-ui, 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, input, select, textarea { font-family: inherit; }

/* ── LAYOUT ──────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

.sb-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sb-logo-main {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: .03em;
  color: #fff;
}
.sb-logo-sub {
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  margin-top: 4px;
}

.sb-nav {
  flex: 1;
  padding: 14px 0;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 6px 18px 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.72);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.11); color: #fff; border-left-color: var(--gold); }
.nav-item.nav-disabled { opacity: .4; cursor: default; pointer-events: none; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

.sb-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  color: rgba(255,255,255,.3);
}

/* ── MAIN AREA ───────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── TOPBAR ──────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── CONTENT ─────────────────────────────────────────── */
.content { padding: 24px; flex: 1; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .12s;
  white-space: nowrap;
}
.btn-primary   { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-l); }
.btn-secondary { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost     { background: transparent; color: var(--text-mid); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger    { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #d18e18; }

/* ── FORMS ───────────────────────────────────────────── */
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-g { margin-bottom: 14px; }
.form-g:last-child { margin-bottom: 0; }

label.lbl {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-mid);
  margin-bottom: 5px;
}

.inp {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--text);
  background: var(--white);
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
}
.inp:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(42,49,118,.09);
}
textarea.inp { resize: vertical; min-height: 72px; }
select.inp { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.inp-group { display: flex; gap: 6px; }
.inp-group .inp { flex: 1; }

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
}
.card-hd {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title { font-size: 14.5px; font-weight: 600; flex: 1; }
.card-body  { padding: 18px; }

/* ── KPI GRID ────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh);
}
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-low);
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.kpi-sub {
  font-size: 11.5px;
  color: var(--text-low);
  margin-top: 4px;
}
.kpi-accent { border-top: 3px solid var(--gold); }

/* ── TABLE ───────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-low);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.tbl tbody tr:hover td { background: #fafbff; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-link { color: var(--navy); font-weight: 600; cursor: pointer; }
.tbl-link:hover { text-decoration: underline; }

/* ── BADGES ──────────────────────────────────────────── */
.badge-stage {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.chip {
  display: inline-block;
  padding: 2px 7px;
  background: var(--navy-bg);
  color: var(--navy);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── AVATAR ──────────────────────────────────────────── */
.av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,20,50,.45);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .18s ease;
}
.modal-lg  { max-width: 860px; }
.modal-xl  { max-width: 1060px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.97) translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.modal-hd {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-hd-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 22px; }
.modal-ft {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-low);
  transition: background .12s;
}
.btn-close:hover { background: var(--bg); color: var(--text); }

/* ── PIPELINE KANBAN ─────────────────────────────────── */
.pipeline-wrap {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 12px;
}
.pipeline-wrap::-webkit-scrollbar { height: 6px; }
.pipeline-wrap::-webkit-scrollbar-track { background: transparent; }
.pipeline-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.pipe-col {
  flex-shrink: 0;
  width: 230px;
  display: flex;
  flex-direction: column;
}
.pipe-col-hd {
  padding: 8px 11px;
  border-radius: var(--r) var(--r) 0 0;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pipe-col-count {
  background: rgba(255,255,255,.22);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
}
.pipe-col-body {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r) var(--r);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 180px;
}

.opp-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 12px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .1s;
  box-shadow: var(--sh);
}
.opp-card:hover {
  border-color: var(--navy);
  box-shadow: var(--sh-md);
  transform: translateY(-1px);
}
.opp-card-name    { font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.opp-card-company { font-size: 11.5px; color: var(--text-mid); margin-bottom: 7px; }
.opp-card-meta    { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--text-low); }

/* ── TABS ────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
  margin-bottom: 18px;
}
.tab {
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-mid);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); font-weight: 600; border-bottom-color: var(--navy); }

/* ── DETAIL PANEL (slide from right) ─────────────────── */
.detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,20,50,.3);
  z-index: 500;
}
.detail-overlay.open { display: block; }
.detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 580px;
  background: var(--white);
  box-shadow: var(--sh-lg);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .22s ease;
  z-index: 501;
}
.detail-panel.open { transform: translateX(0); }
.detail-hd {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 10;
}
.detail-hd-text { flex: 1; }
.detail-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.detail-body  { padding: 18px 20px; }

/* ── TIMELINE ────────────────────────────────────────── */
.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 5px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.tl-item { position: relative; padding-bottom: 14px; padding-left: 14px; }
.tl-item::before {
  content: '';
  position: absolute;
  left: -13px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--navy);
}
.tl-date { font-size: 11px; color: var(--text-low); margin-bottom: 1px; }
.tl-text { font-size: 13px; }

/* ── ACTIVITY LIST ───────────────────────────────────── */
.act-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.act-item:last-child { border-bottom: none; }
.act-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--navy-bg);
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.act-subject { font-weight: 600; font-size: 13px; }
.act-meta    { font-size: 11.5px; color: var(--text-low); margin-top: 2px; }
.act-body    { font-size: 12.5px; color: var(--text-mid); margin-top: 5px; }

/* ── TASK ITEM ───────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 17px; height: 17px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
  transition: all .12s;
}
.task-check.done { background: var(--navy); border-color: var(--navy); }
.task-title { font-size: 13px; font-weight: 500; }
.task-title.done { text-decoration: line-through; color: var(--text-low); }
.task-meta  { font-size: 11px; color: var(--text-low); margin-top: 1px; }
.task-overdue { color: #dc2626 !important; }

/* ── SEARCH ──────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-low); font-size: 14px; pointer-events: none; }
.search-inp { padding-left: 32px !important; }

/* ── VIEWS TOGGLE ────────────────────────────────────── */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.view-btn {
  padding: 6px 12px;
  font-size: 13px;
  background: var(--white);
  border: none;
  cursor: pointer;
  color: var(--text-mid);
  transition: background .12s;
}
.view-btn.active { background: var(--navy); color: #fff; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-low);
}
.empty-icon { font-size: 40px; opacity: .3; margin-bottom: 10px; }
.empty p { font-size: 14px; color: var(--text-mid); }

/* ── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 11px 18px;
  border-radius: var(--r);
  font-size: 13.5px;
  font-weight: 500;
  color: #fff;
  background: var(--navy);
  box-shadow: var(--sh-lg);
  z-index: 9999;
  animation: toastIn .25s ease;
}
.toast-out { animation: toastOut .35s ease forwards; }
.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-warn    { background: #b45309; }

@keyframes toastIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
@keyframes toastOut { to   { opacity:0; transform:translateY(10px); } }

/* ── UTILS ───────────────────────────────────────────── */
.flex   { display: flex; }
.flex-1 { flex: 1; }
.col    { flex-direction: column; }
.ai-c   { align-items: center; }
.jc-b   { justify-content: space-between; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-20  { margin-top: 20px; }
.mb-4   { margin-bottom: 4px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.w-full { width: 100%; }
.fw-6   { font-weight: 600; }
.fw-7   { font-weight: 700; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.c-low    { color: var(--text-low); }
.c-mid    { color: var(--text-mid); }
.c-navy   { color: var(--navy); }
.c-danger { color: var(--danger); }
.money    { font-variant-numeric: tabular-nums; font-weight: 600; }
.nowrap   { white-space: nowrap; }
.flex-wrap { flex-wrap: wrap; }

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: #92400e;
}

hr.div { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── SECTION HEADER ──────────────────────────────────── */
.sec-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sec-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-low);
}

/* ── STAGE PROGRESS BAR ──────────────────────────────── */
.stage-bar {
  display: flex;
  gap: 3px;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  margin: 10px 0;
}
.stage-seg { flex: 1; background: var(--border); }
.stage-seg.filled { background: var(--navy); }
.stage-seg.current { background: var(--gold); }

/* ── MONEY HIGHLIGHT ─────────────────────────────────── */
.money-big {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

/* scrollbar global */
::-webkit-scrollbar       { width: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
