:root {
  color-scheme: dark;
  color: #e2e8f0;
  background: #0f172a;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #020617 0%, #111827 100%);
}

body {
  color: #cbd5e1;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input {
  font: inherit;
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
}

.login-card {
  width: min(480px, 100%);
  padding: 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-badge {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, #3366ff, #22c55e);
  color: #fff;
  font-weight: 800;
}

.brand-text strong {
  display: block;
  color: #f8fafc;
  font-size: 20px;
}

.brand-text span {
  display: block;
  color: #94a3b8;
  font-size: 13px;
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(28px, 3vw, 38px);
  color: #f8fafc;
  line-height: 1.05;
}

.login-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: #cbd5e1;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.8);
  color: #f8fafc;
}

input:focus {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #14b8a6);
  color: #fff;
  font-weight: 700;
}

.btn-ghost {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.page {
  width: min(1260px, 100%);
  max-width: 1260px;
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar strong {
  font-size: 22px;
  color: #f8fafc;
}

.topbar span {
  display: block;
  color: #94a3b8;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  padding: 10px 14px;
  color: #e2e8f0;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 3vw, 44px);
}

.page-header p {
  margin: 0;
  color: #94a3b8;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 22px;
  padding: 22px;
}

.stat-label {
  display: block;
  margin-bottom: 10px;
  color: #94a3b8;
  font-size: 13px;
}

.stat-value {
  font-size: 28px;
  color: #f8fafc;
}

.timeline-grid {
  display: grid;
  gap: 12px;
}

.timeline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.08);
}

.timeline-date {
  color: #94a3b8;
}

.timeline-value {
  color: #f8fafc;
  font-weight: 700;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: #94a3b8;
}

.loader-screen {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: 60vh;
  text-align: center;
}

.spinner {
  width: 56px;
  height: 56px;
  border: 6px solid rgba(148, 163, 184, 0.18);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-box {
  width: min(580px, 100%);
  margin: 0 auto;
  padding: 28px;
  text-align: center;
}

.error-box h2 {
  margin-top: 0;
  color: #f8fafc;
}

.error-box p {
  color: #cbd5e1;
  margin-bottom: 18px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.16);
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.hide, .toast.toast-hide {
  opacity: 0;
  transform: translateY(10px);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.35);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.35);
}

.app-shell {
  width: 100%;
}

.layout {
  display: flex;
  gap: 20px;
}

.sidebar {
  min-width: 220px;
  max-width: 220px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: calc(100vh - 88px);
  position: sticky;
  top: 24px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(148, 163, 184, 0.04);
  color: #cbd5e1;
  border: none;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(59, 130, 246, 0.16);
  color: #fff;
}

.content {
  flex: 1;
  min-width: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.input-search {
  flex: 1;
}

.input-small {
  width: 140px;
}

.kanban-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.kanban-column {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 220px;
}

.kanban-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.kanban-count {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}

.lead-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-name {
  margin: 0;
  font-size: 14px;
  color: #f8fafc;
}

.lead-meta {
  color: #94a3b8;
  font-size: 13px;
}

.lead-footer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge-blue {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.badge-accent {
  background: rgba(16, 185, 129, 0.16);
  color: #86efac;
}

.badge-green {
  background: rgba(16, 185, 129, 0.18);
  color: #86efac;
}

.badge-muted {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
}

.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-list {
  display: grid;
  gap: 10px;
}

.conversation-item {
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.08);
  color: #cbd5e1;
  cursor: pointer;
}

.conversation-item.active,
.conversation-item:hover {
  background: rgba(59, 130, 246, 0.16);
  color: #f8fafc;
}

.conversation-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.conversation-meta {
  font-size: 13px;
  color: #94a3b8;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-header h2 {
  margin: 0;
}

.message-list {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 420px;
  overflow-y: auto;
}

.message-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.08);
}

.message-bubble.own {
  margin-left: auto;
  background: rgba(59, 130, 246, 0.15);
}

.message-bubble.other {
  margin-right: auto;
}

.message-bubble p {
  margin: 0 0 6px;
}

.message-bubble small {
  color: #94a3b8;
  font-size: 12px;
}

.chat-input-bar {
  display: flex;
  gap: 12px;
}

.chat-input-bar .input {
  flex: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-body {
  display: grid;
  gap: 10px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.table-wrapper {
  overflow-x: auto;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 20px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  color: #e2e8f0;
}

.table th {
  text-align: left;
  font-size: 13px;
  color: #94a3b8;
}

.table tbody tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 20px;
  z-index: 999;
}

.modal {
  width: min(600px, 100%);
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 24px;
  padding: 24px;
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-sm {
  padding: 8px 12px;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.btn-secondary {
  background: rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
}

.btn-logout {
  width: auto;
  padding: 10px 14px;
}

.progress-bar {
  height: 10px;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #60a5fa;
  border-radius: 999px;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(148, 163, 184, 0.18);
  border-top-color: #60a5fa;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
