:root {
  color-scheme: light;
  --ink: #0e1c31;
  --ink-2: #46556b;
  --ink-3: #7b8899;
  --line: #dfe5ec;
  --line-strong: #cbd4df;
  --paper: #fff;
  --canvas: #f4f7fa;
  --navy: #123e70;
  --navy-dark: #0b2c52;
  --navy-soft: #eaf2fb;
  --teal: #0b796d;
  --teal-soft: #e9f7f3;
  --gold: #916d18;
  --gold-soft: #fff8e5;
  --red: #ad3028;
  --red-soft: #fff0ef;
  --shadow: 0 16px 45px rgba(19, 42, 70, .08);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); line-height: 1.6; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; left: 16px; top: -50px; z-index: 100;
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 7px;
}
.skip-link:focus { top: 12px; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: 64px;
  background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1240px; height: 100%; margin: 0 auto; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; background: linear-gradient(140deg, var(--navy), #2367a8);
  color: #fff; font-weight: 750; letter-spacing: -.04em;
}
.brand-title { display: block; font-size: 15px; font-weight: 700; line-height: 1.25; }
.brand-sub { display: block; color: var(--ink-3); font-size: 11px; letter-spacing: .08em; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.site-home-link { color: var(--navy); border-color: #c9d9e9; background: #f7fbff; }
.site-home-link:hover { color: var(--navy-dark); border-color: #9ebbd6; background: var(--navy-soft); }

.shell { max-width: 1240px; margin: 0 auto; padding: 30px 28px 64px; }
.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; margin-bottom: 22px; }
.eyebrow { color: var(--teal); font-size: 12px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1 { margin: 4px 0 2px; font-size: clamp(25px, 3vw, 34px); line-height: 1.25; letter-spacing: -.025em; }
.page-copy { margin: 0; color: var(--ink-2); font-size: 14px; }

.button {
  min-height: 40px; border: 1px solid transparent; border-radius: 8px; padding: 8px 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--navy); color: #fff; text-decoration: none; cursor: pointer;
  font-size: 14px; font-weight: 650; transition: .18s ease;
}
.button:hover { background: var(--navy-dark); }
.button:focus-visible, .tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(35, 103, 168, .2); outline-offset: 2px;
}
.button-secondary { background: var(--paper); color: var(--ink-2); border-color: var(--line); }
.button-secondary:hover { background: #f4f7fa; color: var(--ink); border-color: var(--line-strong); }
.button-danger { background: var(--paper); color: var(--red); border-color: #edcfcb; }
.button-danger:hover { background: var(--red-soft); }
.button-compact { min-height: 34px; padding: 5px 11px; font-size: 13px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 2px rgba(23, 42, 65, .02); }
.view-tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 10px; background: #eaf0f5; }
.view-tab, .status-tab {
  border: 0; cursor: pointer; color: var(--ink-2); background: transparent; font-weight: 650;
}
.view-tab { min-width: 88px; padding: 8px 13px; border-radius: 7px; }
.view-tab[aria-selected="true"] { background: var(--paper); color: var(--navy); box-shadow: 0 1px 4px rgba(20,45,76,.1); }

.toolbar { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 14px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.status-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.status-tab { padding: 7px 11px; border-radius: 7px; font-size: 13px; }
.status-tab:hover { background: var(--canvas); color: var(--ink); }
.status-tab[aria-selected="true"] { background: var(--navy-soft); color: var(--navy); }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.selection-count { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.batch-select { width: 132px; min-height: 38px; }

select, input, textarea {
  width: 100%; color: var(--ink); background: #fbfcfd; border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 10px 12px; outline: 0; transition: .18s ease;
}
select:focus, input:focus, textarea:focus { border-color: #4e82b7; background: #fff; }
textarea { min-height: 150px; resize: vertical; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 950px; }
th, td { padding: 14px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f7f9fb; color: var(--ink-2); font-size: 12px; letter-spacing: .025em; white-space: nowrap; }
td { font-size: 14px; }
tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: 0; }
.cell-check { width: 44px; text-align: center; }
.cell-check input { width: 16px; height: 16px; accent-color: var(--navy); }
.lead-name { font-weight: 700; }
.lead-contact, .muted { color: var(--ink-2); }
.lead-contact { margin-top: 2px; font-size: 13px; }
.need-summary { max-width: 330px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); }
.source-label { color: var(--ink-2); white-space: nowrap; }
.time-label { color: var(--ink-2); white-space: nowrap; font-size: 13px; font-variant-numeric: tabular-nums; }
.link { color: var(--navy); text-decoration: none; font-weight: 650; }
.link:hover { text-decoration: underline; }

.status { display: inline-flex; align-items: center; padding: 3px 9px; border: 1px solid; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-new { color: var(--navy); background: var(--navy-soft); border-color: #cfe0f2; }
.status-contacted { color: var(--gold); background: var(--gold-soft); border-color: #efdfb2; }
.status-qualified { color: var(--teal); background: var(--teal-soft); border-color: #c2e6dd; }
.status-closed { color: #5e456f; background: #f4edf8; border-color: #decce8; }
.status-archived { color: #5f6875; background: #f1f3f5; border-color: #d9dee4; }
.status-other { color: var(--red); background: var(--red-soft); border-color: #edcfcb; }

.pagination { min-height: 66px; padding: 13px 18px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border-top: 1px solid var(--line); }
.pagination-info { color: var(--ink-2); font-size: 13px; }
.pagination-buttons { display: flex; gap: 8px; }

.state-box { min-height: 250px; padding: 52px 20px; display: grid; place-items: center; text-align: center; color: var(--ink-2); }
.state-inner { max-width: 420px; }
.state-icon { width: 44px; height: 44px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--navy-soft); color: var(--navy); border-radius: 50%; font-weight: 800; }
.state-title { margin: 0 0 5px; color: var(--ink); font-size: 17px; }
.state-copy { margin: 0 0 16px; font-size: 14px; }

.notice { margin: 0 0 16px; padding: 11px 14px; border: 1px solid; border-radius: 8px; font-size: 14px; }
.notice-error { color: var(--red); background: var(--red-soft); border-color: #edcfcb; }
.notice-success { color: var(--teal); background: var(--teal-soft); border-color: #bfe2da; }
.notice-warning { color: #74580f; background: var(--gold-soft); border-color: #e9d99e; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 20px; }
.stat-label { margin: 0 0 5px; color: var(--ink-3); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.stat-value { margin: 0; font-size: 30px; line-height: 1.25; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-note { margin: 5px 0 0; color: var(--ink-3); font-size: 12px; }
.distribution-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 18px; }
.distribution-card { padding: 20px; }
.distribution-card h2 { margin: 0 0 16px; font-size: 17px; }
.distribution-list { display: grid; gap: 11px; }
.distribution-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: 11px; align-items: center; font-size: 13px; }
.bar { height: 7px; overflow: hidden; border-radius: 20px; background: #edf1f5; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1b5b97, #2c81b1); }
.distribution-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; align-items: start; }
.detail-card { overflow: hidden; }
.card-heading { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-heading h2 { margin: 0; font-size: 17px; }
.read-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.read-item { min-width: 0; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.read-item:nth-child(odd) { border-right: 1px solid var(--line); }
.read-item-wide { grid-column: 1 / -1; border-right: 0 !important; }
.read-label { margin: 0 0 4px; color: var(--ink-3); font-size: 12px; font-weight: 650; }
.read-value { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.edit-form { padding: 20px; }
.field { margin-bottom: 17px; }
.field label { display: block; margin-bottom: 6px; color: var(--ink-2); font-size: 13px; font-weight: 650; }
.field-meta { float: right; color: var(--ink-3); font-size: 11px; font-weight: 400; }
.form-actions { display: flex; gap: 9px; align-items: center; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, .85fr) minmax(420px, 1.15fr); background: var(--paper); }
.login-side { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 46px clamp(30px, 5vw, 72px); color: #fff; overflow: hidden; background: linear-gradient(145deg, #092847 0%, #123f70 55%, #0a746b 150%); }
.login-side::before { content: ''; position: absolute; inset: 0; opacity: .18; background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px); background-size: 52px 52px; mask-image: linear-gradient(to bottom, #000, transparent 80%); }
.login-side > * { position: relative; z-index: 1; }
.login-side .brand-sub { color: rgba(255,255,255,.58); }
.login-message { max-width: 520px; }
.login-message h1 { margin: 0 0 14px; font-size: clamp(32px, 5vw, 54px); line-height: 1.12; }
.login-message p { color: rgba(255,255,255,.72); font-size: 16px; }
.login-footnote { color: rgba(255,255,255,.55); font-size: 12px; }
.login-main { display: grid; place-items: center; padding: 36px; background: var(--canvas); }
.login-stack { width: min(100%, 400px); }
.login-home {
  width: fit-content; margin: 0 0 14px; display: inline-flex; align-items: center; gap: 7px;
  color: var(--navy); text-decoration: none; font-size: 14px; font-weight: 650;
}
.login-home:hover { color: var(--navy-dark); text-decoration: underline; text-underline-offset: 4px; }
.login-card { width: min(100%, 400px); padding: 34px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 5px; font-size: 25px; }
.login-card > p { margin: 0 0 24px; color: var(--ink-2); font-size: 14px; }
.login-card .button { width: 100%; margin-top: 4px; }

.busy-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .28; } }

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .distribution-grid, .detail-layout { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { min-height: 280px; padding: 32px; }
  .login-main { padding: 28px 20px; }
}

@media (max-width: 680px) {
  .topbar { height: 58px; }
  .topbar-inner { padding: 0 16px; }
  .brand-sub { display: none; }
  .site-home-label { display: none; }
  .site-home-link { min-width: 34px; padding-inline: 9px; }
  .shell { padding: 22px 14px 46px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { align-items: stretch; }
  .toolbar-actions { width: 100%; }
  .batch-select { flex: 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 25px; }
  .pagination { align-items: flex-start; flex-direction: column; }
  .read-grid { grid-template-columns: 1fr; }
  .read-item:nth-child(odd) { border-right: 0; }
  .read-item-wide { grid-column: auto; }
  .login-side { min-height: 230px; }
  .login-message h1 { font-size: 34px; }
  .login-message p { font-size: 14px; }
  .login-footnote { display: none; }
  .login-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
