:root {
  --ink: #202225;
  --muted: #6a6f78;
  --line: #dde2ea;
  --soft: #f5f7fb;
  --paper: #ffffff;
  --mint: #e4f5ee;
  --mint-ink: #166a4a;
  --blue: #e7efff;
  --blue-ink: #2f5ca8;
  --rose: #fde8eb;
  --rose-ink: #a33147;
  --amber: #fff3d7;
  --amber-ink: #8a5a00;
  --green: #22a36a;
  --orange: #f29b38;
  --red: #de4b5f;
  --brand: #245f73;
  --brand-2: #a85f46;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(245, 247, 251, 0.96)),
    linear-gradient(135deg, #d9ebf1, #f8dfca);
}

.login-panel {
  width: min(430px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 20px 45px rgba(18, 46, 57, 0.13);
}

.login-brand {
  color: var(--ink);
  padding: 0 0 20px;
}

.login-brand p {
  color: var(--muted);
}

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

.demo-accounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.demo-accounts button {
  border-radius: 7px;
  min-height: 34px;
  color: var(--brand);
  background: #eef5f6;
}

.error-text {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.sidebar {
  background: #122e39;
  color: white;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px 18px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 35% 30%, #ffe2a8 0 18%, transparent 19%),
    linear-gradient(135deg, #4aa483, #d58d63);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: #b9cbd2;
  font-size: 12px;
}

.role-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 0 18px;
}

.role-switcher button,
.nav button,
.segmented button {
  border-radius: 7px;
  min-height: 36px;
}

.role-switcher button {
  color: #e7f0f4;
  background: rgba(255, 255, 255, 0.09);
  font-size: 12px;
}

.role-switcher button.active {
  color: #102f3a;
  background: #f7d58b;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce9ee;
  padding: 10px 12px;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.13);
  color: white;
}

.privacy-note {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: 20px;
  padding-top: 14px;
  color: #b9cbd2;
  font-size: 12px;
  line-height: 1.55;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

.topbar h2 {
  margin: 0;
  font-size: 25px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  min-width: 190px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #eef2f5;
  color: var(--ink);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #d7e8df;
  display: grid;
  place-items: center;
  color: var(--mint-ink);
  font-weight: 800;
}

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

.grid.two {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
}

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

.panel,
.metric,
.lead-card,
.table-wrap,
.form-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel,
.form-panel {
  padding: 16px;
}

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

.panel h3,
.form-panel h3 {
  margin: 0;
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
}

.metric {
  padding: 15px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 25px;
}

.metric small {
  color: var(--green);
}

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

.user-create-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0 16px;
  background: #f9fafc;
}

.field {
  display: grid;
  gap: 6px;
}

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

label {
  font-size: 13px;
  color: #3f454d;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd6df;
  border-radius: 7px;
  background: white;
  padding: 10px 11px;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(36, 95, 115, 0.13);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  color: white;
  background: var(--brand);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}

.btn.secondary {
  color: var(--ink);
  background: #eef2f5;
}

.btn.warn {
  background: var(--brand-2);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid #edf0f4;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: #626a74;
  background: #f9fafc;
  font-size: 12px;
  font-weight: 750;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 750;
}

.status.pending {
  color: var(--amber-ink);
  background: var(--amber);
}

.status.following {
  color: var(--blue-ink);
  background: var(--blue);
}

.status.converted {
  color: var(--mint-ink);
  background: var(--mint);
}

.status.lost {
  color: var(--rose-ink);
  background: var(--rose);
}

.thumb {
  width: 58px;
  height: 42px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), transparent),
    linear-gradient(135deg, #d9ebf1, #f6d8c8);
}

.thumb.large {
  width: 100%;
  height: 150px;
}

.leader-row,
.feed-row,
.record-row,
.award-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #edf0f4;
}

.leader-row:last-child,
.feed-row:last-child,
.record-row:last-child,
.award-row:last-child {
  border-bottom: 0;
}

.rank-badge {
  width: 31px;
  height: 31px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #eef2f5;
  font-weight: 800;
}

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

.leader-main strong,
.record-row strong {
  display: block;
}

.bar {
  height: 8px;
  border-radius: 99px;
  background: #e8edf3;
  overflow: hidden;
  margin-top: 7px;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #45a47c, #f0b85b);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  background: #eef2f5;
  padding: 4px;
  border-radius: 8px;
}

.segmented button {
  background: transparent;
  color: #515861;
  padding: 0 10px;
}

.segmented button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 28, 35, 0.08);
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filters input,
.filters select {
  max-width: 190px;
}

.detail-drawer {
  position: fixed;
  inset: auto 0 0 auto;
  width: min(520px, 100vw);
  max-height: 88vh;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px 0 0 0;
  box-shadow: 0 -12px 40px rgba(23, 32, 41, 0.18);
  padding: 18px;
  overflow: auto;
  z-index: 10;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 23, 31, 0.25);
  z-index: 9;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #122e39;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  z-index: 20;
  box-shadow: 0 12px 28px rgba(15, 24, 31, 0.22);
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(26px, 1fr));
  align-items: end;
  gap: 8px;
  height: 170px;
  padding-top: 8px;
}

.chart div {
  min-height: 16px;
  border-radius: 7px 7px 0 0;
  background: #91b7c2;
  position: relative;
}

.chart div:nth-child(even) {
  background: #d6966f;
}

.chart span {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 11px;
}

.funnel {
  display: grid;
  gap: 9px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) 54px;
  gap: 8px;
  align-items: center;
}

.funnel-track {
  height: 18px;
  background: #e8edf3;
  border-radius: 999px;
  overflow: hidden;
}

.funnel-track i {
  display: block;
  height: 100%;
  background: #245f73;
}

.mobile-fab {
  display: none;
}

@media (max-width: 900px) {
  .shell {
    display: block;
    padding-bottom: 70px;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .brand {
    padding-bottom: 10px;
  }

  .nav {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav button {
    text-align: center;
    padding: 9px 6px;
  }

  .privacy-note {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

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

  .filters input,
  .filters select {
    max-width: none;
    flex: 1 1 150px;
  }

  .mobile-fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: inline-flex;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: var(--brand-2);
    color: white;
    font-size: 26px;
    box-shadow: 0 10px 22px rgba(30, 34, 38, 0.25);
    z-index: 8;
  }
}

@media (max-width: 520px) {
  .role-switcher {
    grid-template-columns: 1fr;
  }

  .topbar h2 {
    font-size: 21px;
  }

  .metric strong {
    font-size: 22px;
  }

  .leader-row,
  .feed-row,
  .record-row,
  .award-row {
    align-items: flex-start;
  }
}
