:root {
  --sany-red: #e60012;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe4f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --blue: #0b63ce;
  --blue-2: #eaf3ff;
  --green: #14a46c;
  --orange: #f59e0b;
  --purple: #7c3aed;
  --danger: #dc2626;
  --shadow: 0 10px 24px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(480px, 1.15fr) minmax(400px, .85fr);
  background: #f6f8fb;
}

.login-hero {
  color: var(--ink);
  padding: 56px 70px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #fff;
  border-right: 1px solid var(--line);
  position: relative;
}

.login-hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 100%;
  background: var(--sany-red);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  object-fit: contain;
  background: #fff;
}

.login-logo {
  width: 116px;
  height: 116px;
}

.side-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--sany-red);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.login-hero h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.18;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 680px;
  color: #475569;
  font-size: 16px;
  line-height: 1.8;
  margin-top: 22px;
}

.hero-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero-flow span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #334155;
  background: #f8fafc;
}

.login-card {
  align-self: center;
  justify-self: center;
  width: min(480px, calc(100% - 48px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

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

.field label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  background: #fff;
}

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

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: #9eb8d9; }
.btn.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn.red {
  background: var(--sany-red);
  color: #fff;
  border-color: var(--sany-red);
}
.btn.ghost {
  background: transparent;
}
.btn.small {
  padding: 5px 9px;
  font-size: 12px;
}

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

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.side-brand {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.side-brand .text {
  line-height: 1.18;
  font-weight: 800;
}

.side-brand .sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

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

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  color: #334155;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.nav button.active {
  background: #fff1f2;
  color: #b91c1c;
  font-weight: 800;
  border-left: 3px solid var(--sany-red);
}

.nav-count {
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
}

.topbar {
  height: 66px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title h1 {
  margin: 0;
  font-size: 20px;
}

.crumb {
  color: var(--muted);
  font-size: 12px;
}

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

.role-pill, .status-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.status-pill.ok {
  color: var(--green);
  background: #edfff7;
  border-color: #bbf7d0;
}

.content {
  padding: 18px 22px 30px;
}

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

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

.search {
  min-width: 260px;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  background: #fff;
}

.grid {
  display: grid;
  gap: 14px;
}
.grid.kpi { grid-template-columns: repeat(8, minmax(120px, 1fr)); }
.grid.two { grid-template-columns: 1.2fr .8fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}

.card.pad { padding: 16px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-title h2, .card-title h3 {
  margin: 0;
  font-size: 16px;
}
.subtle { color: var(--muted); font-size: 12px; }

.kpi-card {
  padding: 14px;
  min-height: 92px;
}
.kpi-label {
  color: var(--muted);
  font-size: 12px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 900;
  margin-top: 8px;
}
.kpi-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.alert-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.stage-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
  cursor: pointer;
}
.stage-box strong {
  display: block;
  font-size: 20px;
  margin: 8px 0 4px;
}
.stage-box.active {
  border-color: var(--blue);
  background: var(--blue-2);
}

.bar-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  font-size: 13px;
}
.bar {
  height: 10px;
  border-radius: 99px;
  background: #e2e8f0;
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #22c55e);
}

.list {
  display: grid;
  gap: 8px;
}
.list-item {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.list-item .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.tagline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.badge.blue { background: var(--blue-2); color: var(--blue); border-color: #bfdbfe; }
.badge.green { background: #ecfdf5; color: var(--green); border-color: #bbf7d0; }
.badge.orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.badge.purple { background: #f5f3ff; color: var(--purple); border-color: #ddd6fe; }
.badge.red { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.badge.gray { background: #f8fafc; color: #475569; }

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: #475569;
}
.tabs button.active {
  color: var(--blue);
  border-color: var(--blue);
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 920px;
  background: #fff;
}
th, td {
  border-bottom: 1px solid #edf2f7;
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
  font-size: 13px;
}
th {
  background: #f8fbff;
  color: #334155;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.lane {
  background: #eef3f8;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 420px;
  padding: 10px;
}
.lane h3 {
  margin: 0 0 10px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}
.task-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 9px;
  padding: 11px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.task-card.warn {
  border-left-color: var(--danger);
  background: #fff8f8;
}
.task-title {
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 7px;
}
.task-meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.map-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}
.map-canvas {
  position: relative;
  min-height: 560px;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(23,105,224,.10), rgba(20,164,108,.08)),
    radial-gradient(circle at 34% 36%, rgba(23,105,224,.18), transparent 22%),
    radial-gradient(circle at 62% 60%, rgba(230,0,18,.12), transparent 24%),
    #fff;
}
.map-canvas::before {
  content: "";
  position: absolute;
  inset: 52px 70px;
  border: 1px dashed rgba(23, 105, 224, .32);
  border-radius: 46% 54% 52% 48%;
  transform: rotate(-6deg);
}
.map-title {
  position: absolute;
  left: 18px;
  top: 16px;
  z-index: 1;
}
.marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 5px 14px rgba(15,23,42,.28);
  cursor: pointer;
}
.marker::after {
  content: attr(data-label);
  position: absolute;
  left: 16px;
  top: -7px;
  min-width: 82px;
  font-size: 12px;
  color: #334155;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 5px;
  display: none;
}
.marker:hover::after { display: block; }
.marker.stage-0 { background: #94a3b8; }
.marker.stage-1 { background: #1769e0; }
.marker.stage-2 { background: #f59e0b; }
.marker.stage-3 { background: #7c3aed; }
.marker.stage-4 { background: #14a46c; }
.marker.stage-5 { background: #dc2626; }

.detail-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  min-height: 180px;
}
.detail-panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}
.kv {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px 10px;
  font-size: 13px;
  margin: 12px 0;
}
.kv span:nth-child(odd) { color: var(--muted); }

.profile-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
}
.customer-list {
  max-height: calc(100vh - 174px);
  overflow: auto;
}
.customer-card {
  padding: 12px;
  border-bottom: 1px solid #edf2f7;
  cursor: pointer;
}
.customer-card.active {
  background: var(--blue-2);
}
.customer-name {
  font-weight: 900;
  margin-bottom: 6px;
}
.section-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.timeline {
  border-left: 2px solid #d8e7fb;
  padding-left: 14px;
  display: grid;
  gap: 12px;
}
.timeline-item {
  position: relative;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .18);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}
.drawer {
  width: min(560px, 100%);
  background: #fff;
  min-height: 100vh;
  padding: 18px;
  box-shadow: -18px 0 40px rgba(15,23,42,.18);
  overflow: auto;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.drawer-head h2 {
  margin: 0;
  font-size: 20px;
}

.ai-box {
  background: #f8fbff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px;
}
.ai-box strong { color: var(--blue); }

.permission-table {
  min-width: 760px;
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.switch input { width: 16px; height: 16px; }

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

@media (max-width: 1200px) {
  .grid.kpi { grid-template-columns: repeat(4, 1fr); }
  .grid.two, .split, .map-page, .profile-grid { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { padding: 32px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; min-height: auto; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .topbar { position: relative; height: auto; padding: 14px; align-items: flex-start; gap: 12px; flex-direction: column; }
  .top-actions { flex-wrap: wrap; }
  .content { padding: 14px; }
  .grid.kpi, .grid.three, .grid.four, .section-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
}
