* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #102a2a;
  --muted: #607272;
  --surface: #ffffff;
  --surface-soft: #f5faf9;
  --line: #dce7e5;
  --primary: #0f766e;
  --primary-dark: #0a5a54;
  --accent: #dff6f1;
  --accent-strong: #bfe8df;
  --danger: #b42318;
  --danger-soft: #fff2f0;
  --warning: #b54708;
  --warning-soft: #fff7e8;
  --shadow: 0 22px 60px rgba(31, 71, 69, 0.14);
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at top left, #dbf5ef 0, transparent 38%),
    linear-gradient(145deg, #f5faf9, #eef5f3);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.background-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
  z-index: -1;
}

.shape-one {
  width: 340px;
  height: 340px;
  right: -100px;
  top: -120px;
  background: rgba(15, 118, 110, 0.12);
}

.shape-two {
  width: 260px;
  height: 260px;
  left: -90px;
  bottom: -90px;
  background: rgba(245, 158, 11, 0.10);
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.login-layout {
  max-width: 1120px;
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.94);
}

.brand-panel {
  padding: clamp(46px, 7vw, 88px);
  color: white;
  background: linear-gradient(160deg, #0b5e58, #0f766e);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: white;
  color: var(--primary);
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.16);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  box-shadow: none;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 28px 0 10px;
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.18em;
  font-weight: 800;
  opacity: 0.78;
}

.eyebrow.dark {
  color: var(--primary);
  opacity: 1;
}

.brand-panel h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(2.25rem, 5vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.055em;
}

.brand-copy {
  max-width: 570px;
  margin: 24px 0 36px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.05rem;
  line-height: 1.7;
}

.feature-list {
  display: grid;
  gap: 14px;
}

.feature {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 15px 17px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.06);
}

.feature > span {
  color: #8ee5d7;
  font-size: 0.75rem;
  font-weight: 800;
  padding-top: 2px;
}

.feature strong {
  display: block;
  font-size: 0.94rem;
}

.feature p {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.86rem;
}

.login-card {
  align-self: center;
  padding: clamp(38px, 6vw, 76px);
}

.mobile-brand {
  display: none;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.login-card h2 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: -0.04em;
}

.subtext {
  margin: 12px 0 30px;
  color: var(--muted);
  line-height: 1.6;
}

form {
  display: grid;
  gap: 10px;
}

label {
  margin-top: 9px;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--ink);
  background: white;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea {
  padding-top: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.62);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.10);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 72px;
}

.text-button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.light-button,
.logout-button {
  min-height: 44px;
  padding: 0 17px;
  border-radius: 11px;
  border: 0;
  font-weight: 800;
}

.primary-button {
  margin-top: 12px;
  color: white;
  background: var(--primary);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.20);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.primary-button:disabled,
.secondary-button:disabled,
.light-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.full-width {
  width: 100%;
}

.secondary-button {
  color: var(--primary);
  background: var(--accent);
}

.light-button {
  color: var(--primary-dark);
  background: white;
}

.logout-button {
  width: 100%;
  color: #d4ece8;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.message {
  min-height: 22px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 0.87rem;
}

.message.success {
  color: var(--primary);
}

.security-note {
  margin: 22px 0 0;
  color: #849191;
  font-size: 0.78rem;
  text-align: center;
}

.crm {
  width: min(1460px, 100%);
  min-height: calc(100vh - 48px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 24px;
  box-shadow: var(--shadow);
  background: var(--surface-soft);
}

.sidebar {
  min-height: calc(100vh - 48px);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  color: white;
  background: #0b514d;
}

.sidebar-brand {
  padding: 4px 8px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand span,
.user-summary span {
  display: block;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.76rem;
}

.nav-list {
  display: grid;
  gap: 7px;
  margin-top: 24px;
}

.nav-item {
  min-height: 46px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.72);
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: rgba(255, 255, 255, 0.11);
}

.nav-icon {
  width: 25px;
  font-size: 1.1rem;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-summary {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary-dark);
  border-radius: 50%;
  background: #dff6f1;
  font-weight: 900;
}

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

.topbar {
  min-height: 82px;
  padding: 15px 28px;
  display: flex;
  align-items: center;
  gap: 17px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.connection-pill {
  margin-left: auto;
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
  border-radius: 999px;
  background: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  color: var(--ink);
  font-size: 1.3rem;
}

.mobile-only {
  display: none;
}

.global-message {
  margin: 18px 28px 0;
  padding: 13px 15px;
  color: var(--danger);
  border: 1px solid #ffd1cc;
  border-radius: 11px;
  background: var(--danger-soft);
  font-size: 0.88rem;
}

.global-message.success {
  color: var(--primary-dark);
  border-color: var(--accent-strong);
  background: var(--accent);
}

.page-section {
  padding: 28px;
}

.welcome-banner {
  padding: clamp(27px, 4vw, 42px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  color: white;
  border-radius: 20px;
  background: linear-gradient(135deg, #0f766e, #115e59);
}

.welcome-banner .eyebrow {
  margin-top: 0;
}

.welcome-banner h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.welcome-banner p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.76);
}

.stat-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-height: 155px;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.danger-card {
  border-color: #ffd5cf;
  background: #fffbfa;
}

.stat-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.stat-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent);
  color: var(--primary);
  font-weight: 900;
}

.danger-card .stat-icon {
  color: var(--danger);
  background: var(--danger-soft);
}

.stat-card strong {
  display: block;
  margin: 12px 0 10px;
  font-size: 2.35rem;
}

.stat-link {
  padding: 0;
  color: var(--primary);
  border: 0;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
}

.content-card {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

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

.section-heading.compact {
  padding: 0 0 14px;
  border: 0;
}

.section-heading .eyebrow {
  margin: 0 0 7px;
}

.section-heading h3 {
  margin: 0;
  font-size: 1.1rem;
}

.section-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

.data-table th,
.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid #edf2f1;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  background: #fbfdfc;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table td {
  font-size: 0.87rem;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  transition: background 0.16s ease;
}

.data-table tbody tr:hover {
  background: #f6fbfa;
}

.lead-primary {
  display: block;
  color: var(--ink);
  font-weight: 800;
}

.lead-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.77rem;
}

.status-badge {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  color: #24544f;
  background: #e7f5f2;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.overdue {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-badge.converted {
  color: #166534;
  background: #ecfdf3;
}

.view-button {
  min-height: 34px;
  padding: 0 11px;
  color: var(--primary);
  border: 1px solid var(--accent-strong);
  border-radius: 9px;
  background: #f3fbf9;
  font-size: 0.78rem;
  font-weight: 800;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px auto;
  gap: 12px;
  margin-bottom: 18px;
}

.search-box {
  position: relative;
}

.search-box span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box input {
  padding-left: 38px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(11, 39, 38, 0.38);
  backdrop-filter: blur(2px);
}

.lead-drawer {
  position: fixed;
  right: 0;
  top: 0;
  width: min(620px, 100%);
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  background: #f8fbfa;
  box-shadow: -22px 0 55px rgba(18, 54, 52, 0.22);
  transform: translateX(105%);
  transition: transform 0.24s ease;
}

.lead-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.drawer-header .eyebrow {
  margin: 0 0 7px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.45rem;
}

.drawer-loading {
  padding: 60px 24px;
  color: var(--muted);
  text-align: center;
}

.drawer-content {
  padding: 20px 22px 35px;
}

.contact-card,
.detail-grid,
.message-card,
.lead-form,
.history-section {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.contact-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.contact-card a,
.detail-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.message-card p {
  margin: 8px 0 0;
  color: #3f5655;
  line-height: 1.6;
  white-space: pre-wrap;
}

.lead-form {
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.timeline-item {
  position: relative;
  padding: 0 0 12px 22px;
  border-bottom: 1px solid #edf2f1;
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 5px var(--accent);
}

.timeline-item strong {
  display: block;
  font-size: 0.87rem;
}

.timeline-item p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.timeline-item time {
  color: #8a9998;
  font-size: 0.72rem;
}

@media (max-width: 1050px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crm {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .login-layout {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    display: none;
  }

  .mobile-brand {
    display: flex;
  }

  .login-card {
    min-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .crm {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    z-index: 120;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-only {
    display: grid;
  }

  .toolbar {
    grid-template-columns: 1fr 180px;
  }

  .toolbar .secondary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 0;
  }

  .login-layout,
  .crm {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .login-card {
    min-height: 100vh;
    padding: 32px 22px;
  }

  .topbar {
    padding: 13px 16px;
  }

  .connection-pill {
    display: none;
  }

  .page-section {
    padding: 17px;
  }

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

  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    min-height: 140px;
    padding: 16px;
  }

  .stat-card strong {
    font-size: 2rem;
  }

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

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar .secondary-button {
    grid-column: auto;
  }

  .contact-card,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
