:root {
  color-scheme: light;
  --ink: #15261f;
  --muted: #68756f;
  --line: #dfe7e2;
  --panel: #ffffff;
  --canvas: #f4f7f5;
  --brand: #167352;
  --brand-dark: #0d5038;
  --brand-soft: #e4f2eb;
  --blue: #315f94;
  --amber: #ad6a12;
  --red: #b44545;
  --shadow: 0 16px 45px rgba(19, 44, 34, .08);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 46%) 1fr;
  background: #f8faf9;
}
.login-visual {
  position: relative;
  overflow: hidden;
  padding: 64px;
  color: white;
  background:
    radial-gradient(circle at 78% 20%, rgba(91, 186, 142, .34), transparent 28%),
    radial-gradient(circle at 20% 90%, rgba(78, 144, 117, .26), transparent 30%),
    linear-gradient(145deg, #0b3d2c 0%, #125c43 55%, #0a3326 100%);
}
.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}
.visual-content { position: relative; z-index: 1; max-width: 620px; }
.brand-lockup { display: flex; align-items: center; gap: 14px; font-weight: 700; letter-spacing: .02em; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 13px; background: rgba(255,255,255,.12); }
.visual-content h1 { margin: 110px 0 22px; font-family: Georgia, "Noto Serif SC", serif; font-size: clamp(42px, 5vw, 72px); line-height: 1.05; font-weight: 500; }
.visual-content p { max-width: 520px; color: rgba(255,255,255,.76); font-size: 18px; line-height: 1.8; }
.flow-line { margin-top: 54px; display: flex; gap: 10px; flex-wrap: wrap; }
.flow-line span { padding: 9px 14px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(255,255,255,.08); font-size: 13px; }
.login-panel { display: grid; place-items: center; padding: 48px; }
.login-card { width: min(420px, 100%); }
.eyebrow { color: var(--brand); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; }
.login-card h2 { margin: 12px 0 8px; font-size: 34px; }
.login-card > p { margin: 0 0 34px; color: var(--muted); }

.field { display: grid; gap: 8px; margin-bottom: 18px; }
.field label { color: #42504a; font-size: 13px; font-weight: 700; }
.input, .select, .textarea {
  width: 100%; border: 1px solid #ced9d3; border-radius: 11px; padding: 12px 14px; color: var(--ink); background: white; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,115,82,.1); }
.button { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 750; color: var(--ink); background: #e9eeeb; }
.button:hover { filter: brightness(.97); }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-dark); }
.button.outline { border: 1px solid var(--line); background: white; }
.button.danger { color: white; background: var(--red); }
.button.full { width: 100%; padding: 13px; }
.button.small { padding: 7px 10px; font-size: 12px; }
.button:disabled { opacity: .5; cursor: not-allowed; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; background: #102d23; color: #dbe9e2; overflow-y: auto; }
.sidebar .brand-lockup { padding: 4px 8px 24px; color: white; }
.sidebar .brand-mark { width: 36px; height: 36px; }
.nav-group { margin: 14px 0 6px; padding: 0 10px; color: #7ea393; font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin: 3px 0; border: 0; border-radius: 9px; color: #bcd0c7; background: transparent; text-align: left; font-size: 14px; }
.nav-item svg { width: 17px; height: 17px; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: #1f5b45; box-shadow: inset 3px 0 #71c59d; }
.main { min-width: 0; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); backdrop-filter: blur(12px); }
.crumb { color: var(--muted); font-size: 13px; }
.user-menu { display: flex; align-items: center; gap: 12px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--brand); font-size: 12px; font-weight: 800; }
.user-meta strong { display: block; font-size: 13px; }
.user-meta span { color: var(--muted); font-size: 11px; }
.content { padding: 30px; max-width: 1500px; margin: auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-family: Georgia, "Noto Serif SC", serif; font-size: 32px; font-weight: 500; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 6px 24px rgba(30, 56, 45, .035); }
.stat-card { padding: 20px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--brand); background: var(--brand-soft); }
.stat-icon svg { width: 17px; }
.stat-value { margin: 18px 0 4px; font-size: 29px; font-weight: 750; letter-spacing: -.03em; }
.stat-note { color: var(--muted); font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: 1.4fr .85fr; gap: 18px; margin-top: 18px; }
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head span { color: var(--muted); font-size: 12px; }
.progress-row { display: grid; grid-template-columns: 110px 1fr 42px; align-items: center; gap: 12px; margin: 16px 0; font-size: 13px; }
.progress { height: 8px; overflow: hidden; border-radius: 99px; background: #edf1ef; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.activity { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid #edf1ef; }
.activity:last-child { border-bottom: 0; }
.activity-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.activity p { margin: 0; font-size: 13px; }
.activity time { color: var(--muted); font-size: 11px; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search { max-width: 330px; position: relative; flex: 1; }
.search .input { padding-left: 38px; }
.search svg { position: absolute; left: 13px; top: 13px; width: 16px; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: white; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f8faf9; text-align: left; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.table td { padding: 14px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfcfb; }
.primary-cell { font-weight: 700; }
.secondary { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; color: #4e5c56; background: #edf1ef; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.active, .badge.approved, .badge.published, .badge.success, .badge.qualified, .badge.won { color: #167352; background: #e5f4ec; }
.badge.pending, .badge.pending_review, .badge.new, .badge.contacted { color: var(--amber); background: #fff2dc; }
.badge.failed, .badge.rejected, .badge.disabled, .badge.lost { color: var(--red); background: #fbe8e8; }
.badge.draft, .badge.viewer { color: var(--blue); background: #e9f0f8; }
.empty { padding: 55px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 7px; color: var(--ink); }

.lead-board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
.lead-column { min-height: 420px; padding: 12px; border-radius: 13px; background: #eaf0ed; }
.lead-column h3 { margin: 3px 3px 12px; font-size: 13px; }
.lead-card { margin-bottom: 10px; padding: 14px; border: 1px solid #dce5e0; border-radius: 11px; background: white; box-shadow: 0 5px 16px rgba(20,45,35,.04); }
.lead-card strong { font-size: 13px; }
.lead-card p { margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.score { float: right; color: var(--brand); font-weight: 800; }
.tag { display: inline-block; margin: 2px 4px 2px 0; padding: 3px 7px; border-radius: 5px; color: #436054; background: var(--brand-soft); font-size: 10px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(10, 30, 22, .45); backdrop-filter: blur(4px); }
.modal { width: min(680px, 100%); max-height: 90vh; overflow-y: auto; border-radius: 16px; background: white; box-shadow: var(--shadow); }
.modal.wide { width: min(900px, 100%); }
.modal-head, .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 22px; }
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.close { border: 0; background: transparent; font-size: 22px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.json-box { max-height: 340px; overflow: auto; padding: 14px; border-radius: 10px; color: #d6eee3; background: #12271f; font: 12px/1.65 Consolas, monospace; white-space: pre-wrap; }

#toast-root { position: fixed; z-index: 90; top: 20px; right: 20px; display: grid; gap: 10px; }
.toast { min-width: 280px; padding: 13px 16px; border-left: 4px solid var(--brand); border-radius: 9px; background: white; box-shadow: var(--shadow); font-size: 13px; animation: slide-in .2s ease; }
.toast.error { border-color: var(--red); }
.loading { min-height: 280px; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #d9e3de; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding: 18px 10px; }
  .sidebar .brand-lockup span, .nav-item span, .nav-group { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 20px 14px; }
  .topbar { padding: 0 16px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}
