:root {
  --bg: #f9fafb;
  --panel: #ffffff;
  --line: rgba(229, 231, 235, 0.82);
  --text: #111827;
  --muted: #6b7280;
  --soft: #9ca3af;
  --brand: #059669;
  --brand-2: #10b981;
  --brand-soft: #ecfdf5;
  --blue: #2563eb;
  --orange: #c2410c;
  --purple: #7e22ce;
  --red: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--panel);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea {
  font: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

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

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

.sidebar {
  width: 256px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  padding: 24px 24px 18px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0;
}

.side-nav {
  flex: 1;
  padding: 0 12px;
}

.nav-item {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  margin: 2px 0;
  color: #6b7280;
  background: transparent;
  cursor: pointer;
  transition: background 180ms cubic-bezier(0.4, 0, 0.2, 1), color 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  color: #9ca3af;
  stroke-width: 1.8;
}

.nav-item:hover {
  background: #f3f4f6;
  color: #374151;
}

.nav-item.active {
  background: #e9fbf3;
  color: #047857;
  font-weight: 600;
}

.nav-item.active svg {
  color: #059669;
}

.side-footer {
  padding: 16px;
  border-top: 1px solid var(--line);
}

.language {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: #4b5563;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  cursor: pointer;
}

.profile {
  margin-top: 14px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 8px;
  padding: 0 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #bbf7d0;
  color: #047857;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.profile-title {
  font-weight: 600;
}

.profile-sub {
  color: var(--soft);
  font-size: 12px;
  margin-top: 2px;
}

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

.page {
  min-height: 100vh;
  background: rgba(249, 250, 251, 0.72);
  padding: 32px 16px 96px;
}

.content {
  max-width: 976px;
  margin: 0 auto;
}

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

.page-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
  font-weight: 700;
}

.page-desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 24px;
}

.card-body {
  padding: 20px;
}

.section-title {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  min-height: 100px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid transparent;
}

.stat strong {
  display: block;
  font-size: 32px;
  line-height: 1;
  margin-bottom: 10px;
}

.stat span {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.stat.total { background: #eff8f2; border-color: #d8f3e4; color: #047857; }
.stat.todo { background: #eff6ff; border-color: #dbeafe; color: #1d4ed8; }
.stat.invite { background: #fff7ed; border-color: #ffedd5; color: #c2410c; }
.stat.visit { background: #fbe8df; border-color: #f9d8c9; color: #c43b3b; }
.stat.deal { background: #faf5ff; border-color: #f3e8ff; color: #7e22ce; }
.stat.invalid { background: #f1eeee; border-color: #e8e2e2; color: #111111; }

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

.card-head .section-title {
  margin: 0;
}

.link-more {
  border: 0;
  background: transparent;
  color: #059669;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.appointment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 16px;
  border-radius: 8px;
  background: rgba(249, 250, 251, 0.88);
}

.person-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.name {
  font-size: 16px;
  font-weight: 700;
}

.phone {
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.time-strong {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
}

.countdown {
  color: #c2410c;
  font-weight: 700;
  white-space: nowrap;
}

.quick-actions {
  display: flex;
  gap: 12px;
  margin: 22px 0;
}

.btn {
  height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #374151;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: transform 120ms ease, background 180ms ease, border-color 180ms ease;
}

.btn:active { transform: scale(0.98); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { color: white; background: linear-gradient(135deg, #059669, #10b981); border-color: #059669; }
.btn.primary:hover { background: linear-gradient(135deg, #047857, #059669); }
.btn.purple { color: white; background: linear-gradient(135deg, #7c3aed, #9333ea); border-color: #7c3aed; }
.btn.ghost { border-color: var(--line); background: #fff; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; }

.latest-list {
  display: grid;
  gap: 4px;
}

.lead-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 180ms ease;
}

.lead-row:hover {
  background: #f9fafb;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: #34d399;
}

.lead-main {
  min-width: 0;
}

.lead-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #9ca3af;
  font-size: 12px;
  margin-top: 7px;
}

.lead-source {
  color: #6b7280;
}

.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  border: 1px solid transparent;
}

.badge.grade { background: #f3f4f6; color: #111827; border-color: #e5e7eb; }
.badge.follow { background: #f9fafb; color: #4b5563; border-color: #e5e7eb; }
.badge.invite { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.badge.visit { background: #fff1e7; color: #c43b3b; border-color: #ffd2c0; }
.badge.deal { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.badge.invalid { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.badge.blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

.filter-card {
  padding: 18px 20px;
  margin-bottom: 16px;
}

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

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  max-width: 300px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  outline: 0;
}

.search:focus {
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.filter-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
}

.filter-label {
  width: 52px;
  color: #4b5563;
  line-height: 28px;
  font-weight: 600;
}

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

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: #4b5563;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.chip.active {
  background: #e9fbf3;
  border-color: #bbf7d0;
  color: #047857;
  font-weight: 700;
}

.lead-card {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.lead-card:first-child {
  border-top: 0;
}

.lead-card:hover {
  background: #fbfbfb;
}

.lead-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr 1fr;
  gap: 10px 16px;
  margin-top: 14px;
  color: #4b5563;
  font-size: 13px;
}

.label {
  display: block;
  color: #9ca3af;
  font-size: 12px;
  margin-bottom: 4px;
}

.empty {
  padding: 42px 24px;
  text-align: center;
  color: var(--muted);
}

.report-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  color: #4b5563;
}

.bar {
  height: 10px;
  border-radius: 99px;
  background: #edf0f3;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #10b981;
}

.account-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.account-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr 0.7fr 0.7fr;
  gap: 14px;
  align-items: center;
  min-height: 64px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.account-row:first-child {
  border-top: 0;
}

.account-row.account-head {
  min-height: 42px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 12px;
  font-weight: 700;
}

.account-row b {
  display: block;
}

.account-row small {
  display: block;
  margin-top: 4px;
  color: #9ca3af;
  font-size: 12px;
}

.org-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.org-tree {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  max-height: 620px;
  overflow: auto;
}

.org-search {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  margin-bottom: 10px;
  outline: 0;
}

.org-node {
  height: 42px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  display: grid;
  grid-template-columns: 18px 22px minmax(0, auto) auto;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 calc(10px + var(--level) * 24px);
  color: #5f6673;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.org-node:hover {
  background: #f3f4f6;
}

.org-node.active {
  color: #1f6feb;
  background: #eaf2ff;
}

.org-node.selected {
  background: #f2f4f8;
}

.org-caret {
  color: #9ca3af;
  font-size: 14px;
}

.org-icon {
  color: #6b7280;
  font-size: 14px;
}

.org-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.org-count {
  color: #9ca3af;
  font-weight: 600;
}

.org-main {
  min-width: 0;
}

.org-main-head {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 2px 16px;
}

.org-main-head h3 {
  margin: 0;
  font-size: 18px;
}

.org-main-head p {
  margin: 6px 0 0;
  color: #6b7280;
}

.org-preview-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #374151;
  font-weight: 600;
}

.field input, .field select, .field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  outline: 0;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field.full {
  grid-column: 1 / -1;
}

.field-hint {
  align-self: end;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.6;
  padding: 0 2px 2px;
}

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.22);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-mask.show {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  width: min(460px, 100vw);
  height: 100vh;
  background: white;
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.drawer.show {
  transform: translateX(0);
}

.drawer-head {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.drawer-body {
  padding: 20px;
  overflow: auto;
}

.info-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 18px 0;
}

.info-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

.timeline {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
}

.timeline-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #10b981;
  margin: 7px auto 0;
  box-shadow: 0 0 0 4px #d1fae5;
}

.timeline-box {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.timeline-box b {
  display: block;
  margin-bottom: 5px;
}

.timeline-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 40;
  transform: translate(-50%, -80px);
  min-width: 220px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #047857;
  padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  transition: transform 220ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
}

.mobile-nav {
  display: none;
}

.hide {
  display: none !important;
}

@media (max-width: 1023px) {
  .sidebar {
    display: none;
  }

  .page {
    padding: 18px 12px 92px;
  }

  .content {
    max-width: 100%;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    height: 70px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
  }

  .mobile-nav button {
    border: 0;
    background: transparent;
    color: #6b7280;
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 8px 0;
    font-size: 11px;
  }

  .mobile-nav button.active {
    color: #059669;
    font-weight: 700;
  }

  .mobile-nav svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 767px) {
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .appointment {
    align-items: flex-start;
    flex-direction: column;
  }

  .quick-actions, .toolbar, .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions {
    flex-direction: column;
  }

  .quick-actions .btn, .toolbar-actions .btn {
    flex: 1;
    width: 100%;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    max-width: none;
  }

  .lead-card {
    grid-template-columns: 1fr;
  }

  .lead-grid, .form-grid, .info-list, .report-grid, .account-row, .org-layout {
    grid-template-columns: 1fr;
  }

  .account-head {
    display: none;
  }

  .filter-line {
    display: block;
  }

  .filter-label {
    width: auto;
    margin-bottom: 8px;
  }

}
