:root {
  --bg: #f3f5fb;
  --panel: #ffffff;
  --panel-2: #fafbfe;
  --line: #e7eaf3;
  --line-strong: #d6dbe8;
  --text: #1b2233;
  --muted: #6b7488;
  --blue: #2563eb;
  --blue-strong: #1d4ed8;
  --blue-soft: #eaf1ff;
  --green: #15935a;
  --red: #d14343;
  --amber: #b07400;
  --radius: 8px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-md: 0 6px 18px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --ring: 0 0 0 3px rgba(37, 99, 235, .18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 100% -10%, #eaf1ff 0%, rgba(234, 241, 255, 0) 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.3; letter-spacing: 0; }

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

button {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: white;
  padding: 9px 14px;
  cursor: pointer;
  min-height: 38px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, box-shadow .15s ease, transform .05s ease, opacity .15s ease;
}

button:hover { background: var(--blue-strong); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

button.secondary {
  background: #eef1f8;
  color: var(--text);
  box-shadow: none;
}
button.secondary:hover { background: #e4e8f2; }

button.danger { background: var(--red); }
button.danger:hover { background: #b9322f; }

button.ghost {
  background: transparent;
  color: var(--blue);
  padding: 6px 10px;
  box-shadow: none;
  min-height: 0;
}
button.ghost:hover { background: var(--blue-soft); }

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
  padding: 9px 11px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}

input::placeholder, textarea::placeholder { color: #9aa3b5; }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

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

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 4px 6px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: "";
  width: 10px;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--blue), var(--blue-strong));
}

.user-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
  background: var(--panel-2);
}

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

.nav button {
  text-align: left;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  box-shadow: none;
  min-height: 40px;
  border-radius: var(--radius-sm);
}

.nav button:hover { background: var(--panel-2); color: var(--text); }

.nav button.active {
  background: var(--blue-soft);
  color: var(--blue-strong);
  box-shadow: inset 3px 0 0 var(--blue);
}

.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 12px;
}

.main {
  padding: 20px;
  max-width: 1180px;
  width: 100%;
}

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

.title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

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

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

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

.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }

.login {
  width: min(420px, calc(100vw - 32px));
  margin: 12vh auto;
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.login h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

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

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

.lead-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}

.lead-item:hover {
  border-color: #9bbcfb;
  box-shadow: var(--shadow-md);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.between {
  justify-content: space-between;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf1f7;
  color: var(--muted);
  font-size: 12px;
}

.badge.blue {
  background: #e8f1ff;
  color: #0b58c5;
}

.badge.amber {
  background: #fef3da;
  color: var(--amber);
}

.badge.green {
  background: #e8f7ef;
  color: var(--green);
}

.badge.red {
  background: #fdecec;
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.section {
  margin-bottom: 14px;
}

.stack {
  display: grid;
  gap: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th,
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.table th {
  color: var(--muted);
  background: var(--panel-2);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--panel-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  z-index: 1100;
}

.hidden {
  display: none;
}

.health-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.health-dot.red {
  background: var(--red);
}

.health-dot.yellow {
  background: var(--amber);
}

.lead-red {
  border-left: 4px solid var(--red);
}

.lead-yellow {
  border-left: 4px solid var(--amber);
}

.metric {
  text-align: center;
}

.metric-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--blue);
}

.assist-item {
  border-left: 3px solid var(--amber);
  padding: 6px 10px;
  cursor: pointer;
}

.assist-item:hover {
  background: #fffaf0;
}

.amber-banner {
  background: #fef3da;
  border-color: #f0d28a;
  color: var(--amber);
  margin-bottom: 12px;
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

/* 看板：桌面用表格，手机用卡片 */
.dash-cards {
  display: none;
  gap: 10px;
  grid-template-columns: 1fr;
}

.dash-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.dash-card-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 14px;
}

.check input {
  width: auto;
}

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

@media (max-width: 760px) {
  .app {
    display: block;
  }

  .dash-table {
    display: none;
  }

  .dash-cards {
    display: grid;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

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

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

  .main {
    padding: 12px;
    max-width: none;
  }

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

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

  .topbar > .row,
  .topbar select,
  .topbar button {
    width: 100%;
  }

  .row {
    align-items: stretch;
  }

  .row > button,
  .row > select,
  .row > input {
    flex: 1 1 140px;
  }

  .lead-item,
  .card {
    padding: 12px;
  }

  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .table th,
  .table td {
    min-width: 96px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  input[type="file"] {
    min-height: 44px;
    padding: 10px;
  }

  .toast {
    width: calc(100vw - 24px);
    bottom: 12px;
    text-align: center;
  }

  .modal-overlay {
    align-items: flex-start;
    overflow-y: auto;
    padding: 12px;
  }

  .modal-card {
    margin-top: 7vh;
    max-width: none;
    padding: 16px;
  }
}

/* 内联弹窗（promptForm）：替代原生 prompt/confirm */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(23, 32, 51, 0.25);
}
.modal-card h3 {
  margin: 0 0 12px;
}

/* 徽章内的「撤销」轻量按钮 */
.linklike {
  background: none;
  border: none;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 0 0 4px;
  font-size: inherit;
}
