/**
 * WisDesk / 越渠通 — B2B ERP 浅色设计系统
 * 参考 akta.pro：锐利圆角、紧凑层级、高对比中性色 + 单一强调色（浅色系）
 */
:root {
  --wd-bg: #f3f4f6;
  --wd-bg-elevated: #ffffff;
  --wd-bg-muted: #eef0f3;
  --wd-bg-subtle: #e8ebf0;
  --wd-border: #e1e4ea;
  --wd-border-strong: #c5cbd6;
  --wd-text: #0c1222;
  --wd-text-secondary: #4a5568;
  --wd-text-muted: #7a8494;
  --wd-text-faint: #9aa3b2;
  --wd-accent: #0b6e56;
  --wd-accent-hover: #085544;
  --wd-accent-muted: #e4f3ee;
  --wd-accent-border: #9fd4c2;
  --wd-danger: #c0392b;
  --wd-danger-hover: #a93226;
  --wd-warning-bg: #fff8eb;
  --wd-warning-border: #f0d9a8;
  --wd-warning-text: #8a6419;
  --wd-radius-xs: 2px;
  --wd-radius-sm: 3px;
  --wd-radius: 4px;
  --wd-radius-md: 6px;
  --wd-shadow-sm: 0 1px 2px rgba(12, 18, 34, 0.04);
  --wd-shadow: 0 8px 28px rgba(12, 18, 34, 0.08);
  --wd-font: "IBM Plex Sans", "Source Han Sans SC", "Noto Sans SC", system-ui, sans-serif;
  --wd-font-mono: "IBM Plex Mono", "Menlo", "Consolas", monospace;
  --wd-sidebar-w: 11.5rem;
}

* { font-family: var(--wd-font); }
[x-cloak] { display: none !important; }

/* ── Buttons ── */
.btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--wd-radius-sm);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 550;
  letter-spacing: 0.01em;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  line-height: 1.35;
}
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--wd-radius-sm); }
/* 列表顶栏：输入/下拉与 btn-sm 同高（约 30px） */
.ctrl-sm {
  box-sizing: border-box !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  padding-left: 10px !important;
  padding-right: 10px !important;
  font-size: 12px !important;
  line-height: 28px !important;
  width: auto;
  vertical-align: middle;
}
input.ctrl-sm.input,
select.ctrl-sm.input {
  display: inline-block;
  width: auto !important;
  max-width: 100%;
}
.btn.btn-sm.ctrl-sm {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  line-height: 1 !important;
  gap: 4px;
}
.btn.btn-sm.ctrl-sm.ctrl-sm-icon {
  width: 30px !important;
  min-width: 30px !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.btn-primary { background: var(--wd-accent); color: #fff; border-color: var(--wd-accent); }
.btn-primary:hover { background: var(--wd-accent-hover); border-color: var(--wd-accent-hover); }
.btn-success { background: var(--wd-accent); color: #fff; border-color: var(--wd-accent); }
.btn-success:hover { background: var(--wd-accent-hover); border-color: var(--wd-accent-hover); }
.btn-danger { background: var(--wd-danger); color: #fff; border-color: var(--wd-danger); }
.btn-danger:hover { background: var(--wd-danger-hover); }
.btn-outline {
  background: var(--wd-bg-elevated);
  border-color: var(--wd-border-strong);
  color: var(--wd-text);
}
.btn-outline:hover { background: var(--wd-bg-muted); border-color: var(--wd-border-strong); }
.btn-ghost { background: transparent; color: var(--wd-text-secondary); }
.btn-ghost:hover { background: var(--wd-bg-muted); color: var(--wd-text); }
.btn-icon {
  padding: 6px;
  border-radius: var(--wd-radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--wd-text-secondary);
}
.btn-icon:hover { background: var(--wd-bg-muted); color: var(--wd-text); }
.btn-icon:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: auto; }

/* ── Cards ── */
.card {
  background: var(--wd-bg-elevated);
  border-radius: var(--wd-radius);
  border: 1px solid var(--wd-border);
  padding: 18px 20px;
  box-shadow: var(--wd-shadow-sm);
}
.card-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--wd-text);
  letter-spacing: -0.01em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--wd-radius-xs);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-blue { background: var(--wd-accent-muted); color: var(--wd-accent-hover); }
.badge-green { background: #d8f0e4; color: #146b48; }
.badge-yellow { background: #fff1d6; color: #8a6419; }
.badge-red { background: #fde8e6; color: #9b2c20; }
.badge-gray { background: var(--wd-bg-subtle); color: var(--wd-text-secondary); }
.badge-purple { background: #ece8f5; color: #4d3d78; }
.badge-brown { background: #efe8e0; color: #5c4a3a; }
.badge-orange { background: #fde8d0; color: #8a5a2b; }
.badge-dark { background: #d8dce3; color: #3d4654; }

/* ── Inputs ── */
.input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--wd-border-strong);
  border-radius: var(--wd-radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  background: var(--wd-bg-elevated);
  color: var(--wd-text);
}
.input:focus {
  border-color: var(--wd-accent);
  box-shadow: 0 0 0 2px rgba(11, 110, 86, 0.14);
}
.input::placeholder { color: var(--wd-text-faint); }
textarea.input { min-height: 80px; resize: vertical; }
select.input { cursor: pointer; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 10px;
  font-weight: 600;
  color: var(--wd-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--wd-border);
  background: var(--wd-bg-muted);
}
.table td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--wd-text);
  border-bottom: 1px solid var(--wd-border);
}
.table tbody tr:hover td { background: #f8f9fb; }
.table .font-mono, .font-mono { font-family: var(--wd-font-mono); }

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 34, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-content {
  background: var(--wd-bg-elevated);
  border-radius: var(--wd-radius-md);
  border: 1px solid var(--wd-border);
  padding: 24px;
  width: 92%;
  max-width: 560px;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: var(--wd-shadow);
}

/* ── Tabs ── */
.tab-btn {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--wd-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--wd-text); }
.tab-btn.active {
  color: var(--wd-accent);
  border-bottom-color: var(--wd-accent);
  font-weight: 600;
}

/* ── Sidebar ── */
#sidebar-container {
  width: var(--wd-sidebar-w) !important;
  flex: 0 0 var(--wd-sidebar-w) !important;
  max-width: var(--wd-sidebar-w);
}
.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--wd-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 12px 5px;
  user-select: none;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 0;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--wd-text-secondary);
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  margin: 0;
  border-left: 2px solid transparent;
}
.sidebar-item i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-item:hover {
  background: var(--wd-bg-muted);
  color: var(--wd-text);
}
.sidebar-item.active {
  background: var(--wd-accent-muted);
  color: var(--wd-accent-hover);
  font-weight: 600;
  border-left-color: var(--wd-accent);
  padding-left: 10px;
}

/* ── Prose / Markdown ── */
.prose h1, .prose h2, .prose h3, .prose strong { color: var(--wd-text); }
.prose h1 { font-size: 1.5em; font-weight: 700; margin: 1em 0 0.5em; }
.prose h2 { font-size: 1.25em; font-weight: 700; margin: 0.8em 0 0.4em; }
.prose h3 { font-size: 1.1em; font-weight: 600; margin: 0.6em 0 0.3em; }
.prose h4 { font-size: 1em; font-weight: 600; margin: 0.5em 0 0.2em; color: var(--wd-text-secondary); }
.prose p { margin: 0.4em 0; line-height: 1.7; }
.prose ul, .prose ol { margin: 0.4em 0 0.4em 1.5em; }
.prose li { margin: 0.15em 0; line-height: 1.6; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose blockquote {
  border-left: 2px solid var(--wd-border-strong);
  padding: 0.4em 0.8em;
  margin: 0.5em 0;
  background: var(--wd-bg-muted);
  color: var(--wd-text-secondary);
}
.prose code {
  background: var(--wd-bg-muted);
  padding: 1px 5px;
  border-radius: var(--wd-radius-xs);
  font-size: 0.9em;
  font-family: var(--wd-font-mono);
  color: var(--wd-text-secondary);
}
.prose hr { border: none; border-top: 1px solid var(--wd-border); margin: 1em 0; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 13px;
  border: 1px solid var(--wd-border);
  border-radius: var(--wd-radius);
  overflow: hidden;
}
.prose table thead { background: var(--wd-bg-muted); }
.prose table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  color: var(--wd-text-secondary);
  border-bottom: 1px solid var(--wd-border);
}
.prose table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--wd-border);
  color: var(--wd-text);
}
.prose table tbody tr:last-child td { border-bottom: none; }
.prose table tbody tr:hover { background: #f8f9fb; }

.md-body {
  font-size: 14px;
  line-height: 1.75;
  color: var(--wd-text);
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 1.3em 0 0.55em;
  color: var(--wd-accent-hover);
  border-bottom: 1px solid var(--wd-border);
  padding-bottom: 0.3em;
}
.md-body h2 {
  font-size: 1.25em;
  font-weight: 700;
  margin: 1.1em 0 0.45em;
  color: var(--wd-accent);
  border-bottom: 1px solid var(--wd-bg-muted);
  padding-bottom: 0.2em;
}
.md-body h3 { font-size: 1.1em; font-weight: 600; margin: 1em 0 0.35em; color: var(--wd-accent); }
.md-body h4 { font-size: 1em; font-weight: 600; margin: 0.8em 0 0.3em; }
.md-body p { margin: 0.55em 0; }
.md-body ul { margin: 0.5em 0; padding-left: 1.8em; list-style-type: disc; }
.md-body ol { margin: 0.5em 0; padding-left: 1.8em; list-style-type: decimal; }
.md-body li { margin: 0.2em 0; line-height: 1.65; }
.md-body strong { font-weight: 700; color: var(--wd-text); }
.md-body hr { border: none; border-top: 1px solid var(--wd-border); margin: 1.2em 0; }
.md-body blockquote {
  border-left: 2px solid var(--wd-border-strong);
  padding: 0.55em 1em;
  margin: 0.8em 0;
  background: var(--wd-bg-muted);
  color: var(--wd-text-secondary);
  border-radius: 0 var(--wd-radius-sm) var(--wd-radius-sm) 0;
}
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
  border: 1px solid var(--wd-border-strong);
}
.md-body thead { background: var(--wd-bg-muted); }
.md-body th {
  font-weight: 700;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--wd-border-strong);
  white-space: nowrap;
}
.md-body td { padding: 8px 12px; border: 1px solid var(--wd-border); vertical-align: top; }
.md-body tbody tr:nth-child(even) { background: #f8f9fb; }
.md-body tbody tr:hover { background: var(--wd-bg-muted); }
.md-body code {
  background: var(--wd-bg-muted);
  padding: 2px 6px;
  border-radius: var(--wd-radius-xs);
  font-size: 0.88em;
  font-family: var(--wd-font-mono);
}
.md-body pre {
  background: var(--wd-bg-muted);
  padding: 14px 16px;
  border-radius: var(--wd-radius);
  overflow-x: auto;
  margin: 0.8em 0;
  border: 1px solid var(--wd-border);
}
.md-body pre code { background: none; padding: 0; }
.md-body a { color: var(--wd-accent); text-decoration: underline; }
.md-body a:hover { color: var(--wd-accent-hover); }
.md-body img { max-width: 100%; border-radius: var(--wd-radius-sm); margin: 0.8em 0; }

/* ── Stat / Kanban ── */
.stat-card {
  background: var(--wd-bg-elevated);
  border-radius: var(--wd-radius);
  border: 1px solid var(--wd-border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--wd-shadow-sm);
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--wd-text);
}
.stat-card .stat-label {
  font-size: 11px;
  color: var(--wd-text-muted);
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kanban-col {
  min-width: 270px;
  background: var(--wd-bg-muted);
  border-radius: var(--wd-radius);
  padding: 12px;
  border: 1px solid var(--wd-border);
}
.kanban-card {
  background: var(--wd-bg-elevated);
  border: 1px solid var(--wd-border);
  border-radius: var(--wd-radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.kanban-card:hover {
  box-shadow: var(--wd-shadow-sm);
  border-color: var(--wd-border-strong);
}

.project-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--wd-radius-sm);
  cursor: pointer;
  border: 1px solid var(--wd-border-strong);
  background: var(--wd-bg-muted);
  transition: all 0.12s;
  text-align: left;
}
.project-switcher-btn:hover { background: var(--wd-bg-subtle); }
.project-switcher-dropdown {
  position: fixed;
  width: 280px;
  background: var(--wd-bg-elevated);
  border: 1px solid var(--wd-border);
  border-radius: var(--wd-radius);
  box-shadow: var(--wd-shadow);
  z-index: 9999;
  max-height: 360px;
  overflow-y: auto;
}
.project-switcher-dropdown .team-header {
  padding: 8px 14px;
  font-size: 10px;
  font-weight: 600;
  color: var(--wd-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--wd-bg-muted);
}
.project-switcher-dropdown .project-option {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--wd-text-secondary);
}
.project-switcher-dropdown .project-option:hover { background: var(--wd-bg-muted); }
.project-switcher-dropdown .project-option.selected {
  background: var(--wd-accent-muted);
  color: var(--wd-accent-hover);
  font-weight: 600;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--wd-border-strong); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--wd-text-faint); }

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--wd-border);
  border-top-color: var(--wd-accent);
  border-radius: 50%;
  animation: wd-spin 0.75s linear infinite;
}
@keyframes wd-spin { to { transform: rotate(360deg); } }

.dropzone {
  border: 1px dashed var(--wd-border-strong);
  border-radius: var(--wd-radius);
  padding: 28px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--wd-bg-muted);
}
.dropzone:hover { border-color: var(--wd-accent); background: var(--wd-accent-muted); }
.dropzone-active { border-color: var(--wd-accent); background: var(--wd-accent-muted); }

.line-clamp-1 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; }
.line-clamp-2 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.line-clamp-3 { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; }

.crm-map-picker {
  height: 220px;
  width: 100%;
  border-radius: var(--wd-radius-sm);
  border: 1px solid var(--wd-border);
  z-index: 0;
}
.crm-map-picker.crm-map-panel { height: calc(100vh - 240px); min-height: 360px; }
.crm-account-search-item {
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--wd-radius-sm);
}
.crm-account-search-item:hover { background: var(--wd-bg-muted); }

/* ── Login ── */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--wd-bg);
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 220px; }
}
.login-brand {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(11, 110, 86, 0.08) 0%, transparent 42%),
    linear-gradient(180deg, #f8f9fb 0%, #eef2f5 100%);
  border-right: 1px solid var(--wd-border);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(12, 18, 34, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 18, 34, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 85%);
  pointer-events: none;
}
.login-brand-inner { position: relative; z-index: 1; }
.login-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wd-accent);
  margin-bottom: 18px;
}
.login-brand-title {
  font-size: clamp(2.4rem, 4.5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--wd-text);
  margin: 0 0 14px;
}
.login-brand-desc {
  max-width: 28rem;
  font-size: 15px;
  line-height: 1.65;
  color: var(--wd-text-secondary);
}
.login-brand-meta {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  padding-top: 28px;
  border-top: 1px solid var(--wd-border);
}
.login-brand-meta div strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--wd-text);
}
.login-brand-meta div span {
  font-size: 11px;
  color: var(--wd-text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: var(--wd-bg-elevated);
}
.login-card {
  width: 100%;
  max-width: 300px;
}
.login-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--wd-text);
  margin: 0 0 6px;
}
.login-card .login-sub {
  font-size: 13px;
  color: var(--wd-text-muted);
  margin-bottom: 28px;
}
.login-card .input {
  width: 100%;
  padding: 9px 11px;
  font-size: 13px;
}
.login-card .btn-primary {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  letter-spacing: 0.02em;
  margin-top: 4px;
}
.login-hint {
  margin-top: 18px;
  font-size: 11px;
  color: var(--wd-text-faint);
  text-align: center;
}
