@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --bg: #080b12;
  --bg-surface: #0d1220;
  --bg-card: #111827;
  --bg-alt: #161f33;
  --bg-hover: #1a2540;
  --border: #1e2d4a;
  --border-lt: #243355;

  --blue: #3b82f6;
  --blue-dk: #2563eb;
  --blue-glow: rgba(59, 130, 246, .14);
  --green: #10b981;
  --green-dk: #059669;
  --yellow: #f59e0b;
  --red: #ef4444;
  --red-dk: #dc2626;
  --purple: #8b5cf6;

  --text: #e8edf5;
  --text-2: #7c8ba4;
  --text-3: #4a596d;

  --sidebar-w: 252px;
  --rad: 10px;
  --rad-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
  --trans: all .18s ease;
}

/* ── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

html {
  font-size: 15px;
  scroll-behavior: smooth
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6
}

a {
  color: var(--blue);
  text-decoration: none;
  transition: var(--trans)
}

a:hover {
  color: var(--blue-dk)
}

/* ── App Layout ────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border)
}

.sb-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0
}

.sb-logo-text {
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.25
}

.sb-logo-sub {
  font-size: .63rem;
  color: var(--text-2);
  font-weight: 400
}

.sb-nav {
  flex: 1;
  padding: 12px 0
}

.nav-section {
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
  padding: 10px 18px 5px
}

.nav-a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-2);
  font-size: .845rem;
  font-weight: 500;
  transition: var(--trans);
  position: relative;
  cursor: pointer;
  text-decoration: none
}

.nav-a:hover {
  color: var(--text);
  background: var(--bg-hover)
}

.nav-a.active {
  color: var(--blue);
  background: var(--blue-glow)
}

.nav-a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--blue);
  border-radius: 0 2px 2px 0
}

.nav-a svg,
.nav-a i {
  font-size: 15px;
  opacity: .7;
  flex-shrink: 0;
  width: 16px;
  text-align: center
}

.nav-a.active svg,
.nav-a.active i,
.nav-a:hover svg,
.nav-a:hover i {
  opacity: 1
}

.sb-user {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px
}

.sb-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0
}

.sb-info {
  flex: 1;
  min-width: 0
}

.sb-name {
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.sb-role {
  font-size: .62rem;
  color: var(--text-3);
  text-transform: capitalize
}

/* ── Main ────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50
}

.topbar-title {
  font-size: .95rem;
  font-weight: 600
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px
}

.content {
  padding: 26px 28px;
  flex: 1
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: 20px;
  box-shadow: var(--shadow-sm)
}

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px
}

.card-title {
  font-size: .9rem;
  font-weight: 600
}

/* ── Stat Grid ───────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
  margin-bottom: 22px
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--trans)
}

.stat:hover {
  border-color: var(--border-lt);
  transform: translateY(-1px);
  box-shadow: var(--shadow)
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0
}

.si-blue {
  background: rgba(59, 130, 246, .12);
  color: var(--blue)
}

.si-green {
  background: rgba(16, 185, 129, .12);
  color: var(--green)
}

.si-yellow {
  background: rgba(245, 158, 11, .12);
  color: var(--yellow)
}

.si-red {
  background: rgba(239, 68, 68, .12);
  color: var(--red)
}

.si-purple {
  background: rgba(139, 92, 246, .12);
  color: var(--purple)
}

.stat-val {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2
}

.stat-lbl {
  font-size: .72rem;
  color: var(--text-2);
  margin-top: 2px
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  font-size: .84rem;
  font-weight: 500;
  border-radius: var(--rad-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--trans);
  font-family: inherit;
  line-height: 1;
  text-decoration: none
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue)
}

.btn-primary:hover {
  background: var(--blue-dk);
  border-color: var(--blue-dk);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, .35)
}

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green)
}

.btn-success:hover {
  background: var(--green-dk);
  color: #fff
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border)
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-lt)
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red)
}

.btn-danger:hover {
  background: var(--red-dk);
  color: #fff
}

.btn-sm {
  padding: 5px 10px;
  font-size: .78rem
}

.btn-icon {
  padding: 6px;
  width: 30px;
  height: 30px;
  justify-content: center
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 100px;
  font-size: .68rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap
}

.badge-success {
  background: rgba(16, 185, 129, .15);
  color: var(--green)
}

.badge-primary {
  background: rgba(59, 130, 246, .15);
  color: var(--blue)
}

.badge-warning {
  background: rgba(245, 158, 11, .15);
  color: var(--yellow)
}

.badge-danger {
  background: rgba(239, 68, 68, .15);
  color: var(--red)
}

.badge-muted {
  background: rgba(124, 139, 164, .15);
  color: var(--text-2)
}

.badge-purple {
  background: rgba(139, 92, 246, .15);
  color: var(--purple)
}

/* ── Tables ──────────────────────────────────────────────── */
.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--rad);
  border: 1px solid var(--border)
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem
}

thead th {
  padding: 11px 15px;
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s
}

tbody tr:last-child {
  border-bottom: none
}

tbody tr:hover {
  background: var(--bg-hover)
}

tbody td {
  padding: 11px 15px;
  vertical-align: middle
}

.td-2 {
  color: var(--text-2);
  font-size: .8rem
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px
}

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-sm);
  color: var(--text);
  font-size: .86rem;
  font-family: inherit;
  transition: var(--trans);
  outline: none
}

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12)
}

.form-control::placeholder {
  color: var(--text-3)
}

textarea.form-control {
  resize: vertical;
  min-height: 80px
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237c8ba4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  appearance: none
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

/* ── Search ──────────────────────────────────────────────── */
.search-wrap {
  position: relative
}

.search-wrap input {
  padding-left: 33px
}

.search-wrap .si {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 13px;
  pointer-events: none
}

/* ── Page Header ─────────────────────────────────────────── */
.page-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 14px;
  flex-wrap: wrap
}

.page-hd h1 {
  font-size: 1.3rem;
  font-weight: 700
}

.page-hd p {
  font-size: .8rem;
  color: var(--text-2);
  margin-top: 2px
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 1px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px
}

.tab-btn {
  padding: 9px 16px;
  font-size: .845rem;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--trans);
  margin-bottom: -1px;
  font-family: inherit
}

.tab-btn:hover {
  color: var(--text)
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue)
}

.tab-panel {
  display: none
}

.tab-panel.active {
  display: block
}

/* ── Kanban ──────────────────────────────────────────────── */
.kanban {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px
}

.kanban-col {
  min-width: 265px;
  max-width: 295px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  display: flex;
  flex-direction: column
}

.kanban-col-hd {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border)
}

.kanban-col-name {
  font-size: .82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px
}

.kanban-stage-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0
}

.kanban-count {
  font-size: .7rem;
  color: var(--text-2);
  background: var(--bg-hover);
  padding: 2px 7px;
  border-radius: 100px
}

.kanban-cards {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px
}

.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: grab;
  transition: var(--trans)
}

.deal-card:hover {
  border-color: var(--border-lt);
  box-shadow: var(--shadow-sm)
}

.deal-card.dragging {
  opacity: .5;
  cursor: grabbing
}

.deal-card-title {
  font-size: .84rem;
  font-weight: 600;
  margin-bottom: 5px
}

.deal-card-client {
  font-size: .75rem;
  color: var(--text-2)
}

.deal-card-value {
  font-size: .8rem;
  color: var(--green);
  font-weight: 600;
  margin-top: 6px
}

.deal-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px
}

.deal-age {
  font-size: .65rem;
  color: var(--text-3)
}

/* ── Flash messages ──────────────────────────────────────── */
.flash {
  padding: 11px 16px;
  border-radius: var(--rad-sm);
  font-size: .84rem;
  font-weight: 500;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 9px
}

.flash-success {
  background: rgba(16, 185, 129, .12);
  border: 1px solid rgba(16, 185, 129, .3);
  color: var(--green)
}

.flash-error {
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .3);
  color: var(--red)
}

/* ── Login Page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow)
}

.login-logo {
  text-align: center;
  margin-bottom: 28px
}

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px
}

.login-logo h1 {
  font-size: 1.2rem;
  font-weight: 700
}

.login-logo p {
  font-size: .8rem;
  color: var(--text-2);
  margin-top: 3px
}

.login-btn {
  width: 100%;
  justify-content: center;
  padding: 11px;
  font-size: .9rem
}

/* ── Call pop-up ─────────────────────────────────────────── */
.call-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--blue);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 280px;
  box-shadow: var(--shadow);
  z-index: 9999;
  display: none;
  animation: slide-in .25s ease
}

.call-popup.visible {
  display: flex;
  align-items: flex-start;
  gap: 12px
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(12px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.call-popup-icon {
  width: 38px;
  height: 38px;
  background: rgba(59, 130, 246, .15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  font-size: 16px;
  flex-shrink: 0;
  animation: ring .8s infinite
}

@keyframes ring {

  0%,
  100% {
    transform: rotate(0)
  }

  25% {
    transform: rotate(-12deg)
  }

  75% {
    transform: rotate(12deg)
  }
}

.call-popup-info {
  flex: 1
}

.call-popup-name {
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 2px
}

.call-popup-phone {
  font-size: .78rem;
  color: var(--text-2)
}

.call-popup-type {
  font-size: .65rem;
  background: var(--blue-glow);
  color: var(--blue);
  padding: 2px 7px;
  border-radius: 100px;
  display: inline-block;
  margin-top: 5px
}

/* ── Misc ────────────────────────────────────────────────── */
.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-2)
}

.empty-state i {
  font-size: 2.2rem;
  margin-bottom: 10px;
  color: var(--text-3)
}

.empty-state p {
  font-size: .85rem
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px
}

.mt-4 {
  margin-top: 16px
}

.mb-4 {
  margin-bottom: 16px
}

.gap-2 {
  gap: 8px
}

.flex {
  display: flex
}

.items-center {
  align-items: center
}

.justify-between {
  justify-content: space-between
}

.flex-wrap {
  flex-wrap: wrap
}

.text-2 {
  color: var(--text-2)
}

.text-sm {
  font-size: .8rem
}

.fw-6 {
  font-weight: 600
}

.w-full {
  width: 100%
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px
}

.modal-overlay.open {
  display: flex
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow)
}

.modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border)
}

.modal-hd h3 {
  font-size: .95rem;
  font-weight: 600
}

.modal-body {
  padding: 20px
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px
}

/* ── Responsive ──────────────────────────────────────────── */
@media(max-width:768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease
  }

  .sidebar.open {
    transform: translateX(0)
  }

  .main {
    margin-left: 0
  }

  .form-row {
    grid-template-columns: 1fr
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr
  }

  .stats {
    grid-template-columns: 1fr 1fr
  }
}