/* ==========================================================================
   PulseCRM — Design Tokens & Base Styles
   ========================================================================== */

:root {
  /* Color */
  --ink:        #13182B;   /* sidebar / darkest surface */
  --ink-soft:   #1D2440;   /* sidebar hover */
  --indigo:     #4F46E5;   /* primary signal */
  --indigo-deep:#4338CA;
  --indigo-50:  #EEF0FF;
  --canvas:     #F6F7FB;   /* app background */
  --surface:    #FFFFFF;   /* cards */
  --border:     #E4E7F0;
  --text:       #1A1F36;
  --text-muted: #64748B;
  --text-faint: #94A0B8;
  --positive:   #16A34A;
  --positive-50:#EAFBF1;
  --danger:     #DC2626;
  --danger-50:  #FDECEC;
  --warning:    #D97706;
  --warning-50: #FEF6E9;
  --info:       #0891B2;

  /* Type */
  --font-display: 'Lexend', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Radius / shadow */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(19, 24, 43, 0.06);
  --shadow-md: 0 4px 16px rgba(19, 24, 43, 0.08);
  --shadow-lg: 0 12px 32px rgba(19, 24, 43, 0.14);

  --sidebar-width: 248px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  color: var(--text);
}

a { color: var(--indigo); text-decoration: none; }
a:hover { color: var(--indigo-deep); }

:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

/* ==========================================================================
   App Shell
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--ink);
  color: #C9CDE0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1030;
  transition: transform .2s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo), #7C73FF);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-brand .name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem .75rem;
}

.sidebar-nav .nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #5C6385;
  font-weight: 600;
  padding: 1rem .6rem .35rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: #C9CDE0;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s ease, color .12s ease;
}

.sidebar-nav .nav-link svg, .sidebar-nav .nav-link i {
  width: 18px; flex-shrink: 0;
  opacity: .85;
}

.sidebar-nav .nav-link:hover {
  background: var(--ink-soft);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--indigo);
  color: #fff;
}

.sidebar-nav .nav-link.active svg, .sidebar-nav .nav-link.active i { opacity: 1; }

.sidebar-foot {
  padding: .85rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

/* ---- Main column ---- */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-content {
  padding: 1.75rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}

.page-eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: .15rem;
}

/* ==========================================================================
   Components
   ========================================================================== */

.card-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.btn-primary {
  background: var(--indigo);
  border-color: var(--indigo);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--indigo-deep);
  border-color: var(--indigo-deep);
}
.btn-outline-primary {
  color: var(--indigo);
  border-color: var(--indigo);
}
.btn-outline-primary:hover {
  background: var(--indigo);
  border-color: var(--indigo);
}

.btn-light-soft {
  background: var(--indigo-50);
  color: var(--indigo-deep);
  border: 1px solid transparent;
}
.btn-light-soft:hover { background: #E1DFFF; color: var(--indigo-deep); }

.table-crm {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table-crm thead th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: .65rem .9rem;
  background: var(--canvas);
  white-space: nowrap;
}
.table-crm thead th:first-child { border-top-left-radius: var(--radius-md); }
.table-crm thead th:last-child { border-top-right-radius: var(--radius-md); }
.table-crm tbody td {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13.5px;
}
.table-crm tbody tr {
  background: var(--surface);
  transition: background .1s ease;
}
.table-crm tbody tr:hover { background: var(--indigo-50); cursor: pointer; }
.table-crm tbody tr:last-child td { border-bottom: none; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

.badge {
  font-weight: 600;
  font-size: 11.5px;
  padding: .32em .65em;
  border-radius: 100px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: .35rem;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}
.stat-card .stat-delta { font-size: 12px; font-weight: 600; }
.stat-delta.up { color: var(--positive); }
.stat-delta.down { color: var(--danger); }

.form-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: .3rem;
}
.form-control, .form-select {
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  border-color: var(--border);
  padding: .5rem .7rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-50);
}

.modal-content {
  border-radius: var(--radius-lg);
  border: none;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.4rem;
}
.modal-header .modal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
}
.modal-body { padding: 1.4rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 1rem 1.4rem; }

.nav-tabs-crm {
  border-bottom: 1px solid var(--border);
  gap: .25rem;
}
.nav-tabs-crm .nav-link {
  border: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  padding: .65rem .9rem;
  border-radius: 0;
  border-bottom: 2px solid transparent;
}
.nav-tabs-crm .nav-link.active {
  color: var(--indigo);
  border-bottom: 2px solid var(--indigo);
  background: transparent;
}

.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--indigo-50);
  color: var(--indigo);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  font-size: 22px;
}

/* ==========================================================================
   Deal Board (Kanban / Swimlanes) — signature element
   ========================================================================== */

.board-wrap {
  overflow-x: auto;
  padding-bottom: 1rem;
}

.board {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-height: 60vh;
}

.board-col {
  flex: 0 0 290px;
  width: 290px;
  background: #EEF0F7;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.board-col-head {
  padding: .85rem .9rem .6rem;
  position: sticky;
  top: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.board-col-head .stage-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.board-col-head .stage-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
}

.board-col-head .stage-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.board-col-body {
  flex: 1;
  overflow-y: auto;
  padding: .25rem .6rem .6rem;
  min-height: 80px;
}

.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--indigo);
  border-radius: var(--radius-md);
  padding: .75rem .85rem;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: box-shadow .12s ease, transform .12s ease;
}
.deal-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.deal-card:active { cursor: grabbing; }

.deal-card .deal-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: .3rem;
  display: block;
}
.deal-card .deal-org {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.deal-card .deal-amount {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
}
.deal-card .deal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .55rem;
}

.deal-card.sortable-ghost {
  opacity: 0.4;
}
.deal-card.sortable-drag {
  box-shadow: var(--shadow-lg);
}

.board-col.drag-over { background: #E3E6FF; }

.board-col-foot {
  padding: .5rem .9rem .8rem;
}

/* ==========================================================================
   Utility
   ========================================================================== */

.text-indigo { color: var(--indigo); }
.bg-canvas { background: var(--canvas); }
.cursor-pointer { cursor: pointer; }
.fw-display { font-family: var(--font-display); }

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .75rem .9rem;
  margin-bottom: 1.1rem;
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrap input {
  padding-left: 2.1rem;
}
.search-input-wrap .icon {
  position: absolute;
  left: .7rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 14px;
}

.detail-sidebar .info-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.detail-sidebar .info-row:last-child { border-bottom: none; }
.detail-sidebar .info-label { color: var(--text-muted); }
.detail-sidebar .info-value { font-weight: 500; text-align: right; }

@media (max-width: 991px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
}
