/* =============================================================
   管理后台
   ============================================================= */
:root {
  --blue: #0096d6;
  --blue-dark: #00739f;
  --blue-soft: #e9f7fe;
  --ink: #0f1720;
  --ink-2: #2b3a48;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5eaf0;
  --line-soft: #eef2f7;
  --bg: #f5f7fa;
  --card: #ffffff;
  --ok: #0f9d58;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 37, 60, .06), 0 4px 14px rgba(15, 37, 60, .05);
  --shadow-md: 0 16px 40px rgba(15, 37, 60, .12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system, sans-serif;
  font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* --------------------------------------------------------- 登录 */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(800px 420px at 18% 10%, #dff1fb 0%, transparent 62%),
    radial-gradient(700px 380px at 86% 88%, #e6f0fa 0%, transparent 60%),
    #f4f7fb;
}
.login-card {
  width: min(420px, 100%); background: #fff; border-radius: 20px; padding: 40px 34px 34px;
  box-shadow: 0 30px 70px rgba(13, 42, 68, .12); border: 1px solid rgba(255, 255, 255, .8);
}
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(140deg, #00b4f0, #0087c9 60%, #005e91);
  color: #fff; display: grid; place-items: center;
  font-family: Georgia, serif; font-style: italic; font-weight: 700; font-size: 21px;
  box-shadow: 0 8px 18px rgba(0, 130, 190, .26);
}
.brand-text strong { display: block; font-size: 15px; letter-spacing: .04em; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--muted-2); }
.login-card h1 { font-size: 22px; letter-spacing: -.01em; margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-foot { margin-top: 20px; font-size: 12px; color: var(--muted-2); text-align: center; }

/* --------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 244px; flex-shrink: 0; background: #0e1a26; color: #c7d5e2;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-head { padding: 22px 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sidebar-head .brand { display: flex; align-items: center; gap: 11px; }
.sidebar-head .brand-text strong { color: #fff; font-size: 14px; }
.sidebar-head .brand-text em { font-size: 11px; color: #7f93a6; }
.side-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.side-nav .group-label {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: #64798c; padding: 14px 12px 6px;
}
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  font-size: 13.5px; color: #c7d5e2; transition: background .18s, color .18s; margin-bottom: 2px;
}
.side-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: #0d7fb4; color: #fff; box-shadow: 0 6px 16px rgba(13, 127, 180, .28); }
.side-link .badge {
  margin-left: auto; background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}
.sidebar-foot { padding: 14px 12px 18px; border-top: 1px solid rgba(255, 255, 255, .08); display: grid; gap: 6px; }
.sidebar-foot a, .sidebar-foot button {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px;
  font-size: 12.5px; color: #9db0c2; text-align: left; transition: background .18s, color .18s;
}
.sidebar-foot a:hover, .sidebar-foot button:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  padding: 0 28px; height: 68px; display: flex; align-items: center; gap: 16px;
}
.topbar h1 { font-size: 18px; letter-spacing: -.01em; }
.topbar .crumb { font-size: 12px; color: var(--muted-2); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 26px 28px 90px; max-width: 1320px; width: 100%; }

/* --------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 18px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  transition: background .18s, border-color .18s, transform .18s, box-shadow .18s; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: linear-gradient(135deg, #00a6ea, #0090cf); color: #fff; box-shadow: 0 8px 18px rgba(0, 150, 214, .24); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(0, 150, 214, .32); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; box-shadow: none; transform: none; cursor: not-allowed; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--blue); color: var(--blue-dark); }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 7px; }
.btn-xs { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 6px; }
.btn-block { width: 100%; }

/* --------------------------------------------------------- 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft); background: #fcfdfe;
}
.card-head h2 { font-size: 14.5px; }
.card-head .hint { font-size: 12px; color: var(--muted-2); }
.card-head .head-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* --------------------------------------------------------- 概览 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -34px; bottom: -34px; width: 110px; height: 110px;
  border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(0, 150, 214, .12), transparent 70%);
}
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted-2); margin-left: 4px; }
.stat .delta { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }
.stat.accent { background: linear-gradient(135deg, #0a7fb5, #00a6ea); border-color: transparent; color: #fff; }
.stat.accent .label, .stat.accent .delta { color: rgba(255, 255, 255, .82); }
.stat.accent::after { background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .28), transparent 68%); }

.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
.quick-links { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-link {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  display: flex; align-items: center; gap: 10px; transition: border-color .18s, background .18s;
}
.quick-link:hover { border-color: var(--blue); background: var(--blue-soft); }
.quick-link .ql-ico {
  width: 34px; height: 34px; border-radius: 9px; background: var(--blue-soft); color: var(--blue-dark);
  display: grid; place-items: center; flex-shrink: 0;
}
.quick-link .ql-ico svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.quick-link strong { display: block; font-size: 13px; }
.quick-link span { font-size: 11.5px; color: var(--muted-2); }

/* --------------------------------------------------------- 表单 */
.field { margin-bottom: 14px; }
.field > label, .field-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px;
}
.field .req { color: var(--danger); margin-left: 2px; }
.field input, .field select, .field textarea, .input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; outline: none; font-size: 13.5px;
  transition: border-color .18s, box-shadow .18s;
}
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 150, 214, .12);
}
.field .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 5px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }
.row-inline { display: flex; align-items: center; gap: 10px; }
.row-inline .field { flex: 1; margin-bottom: 0; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 40px; height: 22px; border-radius: 999px; background: #cfd9e3; position: relative;
  transition: background .2s; flex-shrink: 0;
}
.switch .track::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* --------------------------------------------------- 可编辑条目 */
.item-card { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; background: #fff; }
.item-card.is-off { opacity: .62; background: #fafbfc; }
.item-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft); background: #fbfcfe;
  border-radius: 12px 12px 0 0;
}
.item-head .idx {
  font-size: 11px; font-weight: 700; color: var(--blue-dark); background: var(--blue-soft);
  border-radius: 6px; padding: 3px 8px; flex-shrink: 0;
}
.item-head .title-input {
  flex: 1; border: 0; background: transparent; font-size: 14px; font-weight: 600; padding: 4px 6px;
  border-radius: 6px; outline: none;
}
.item-head .title-input:focus { background: #fff; box-shadow: 0 0 0 1px var(--blue) inset; }
.item-tools { display: flex; align-items: center; gap: 4px; }
.icon-mini {
  width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent; transition: background .16s, color .16s, border-color .16s;
}
.icon-mini svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-mini:hover { background: var(--blue-soft); color: var(--blue-dark); }
.icon-mini.danger:hover { background: #fef2f2; color: var(--danger); }
.item-body { padding: 16px; }

details.block { border-top: 1px dashed var(--line); }
details.block > summary {
  cursor: pointer; list-style: none; padding: 11px 16px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); display: flex; align-items: center; gap: 8px;
}
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::after { content: "展开"; margin-left: auto; font-weight: 400; color: var(--muted-2); }
details.block[open] > summary::after { content: "收起"; }
details.block .block-body { padding: 4px 16px 16px; }

.sub-card { border: 1px solid var(--line-soft); background: #fbfcfe; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.sub-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sub-card-head .tag { font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .08em; white-space: nowrap; flex-shrink: 0; }
.sub-card-head .spacer { flex: 1; }
.link-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.link-row input { height: 34px; font-size: 13px; }
.link-row .li-label { flex: 1.2; }
.link-row .li-href { flex: 1.6; }

/* 图片字段 */
.img-field { display: flex; gap: 12px; align-items: flex-start; }
.img-field .thumb {
  width: 124px; height: 84px; border-radius: 9px; border: 1px solid var(--line);
  background: #f4f7fa center/cover no-repeat; flex-shrink: 0; position: relative; overflow: hidden;
}
.img-field .thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-field.is-logo .thumb { background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 12px 12px; }
.img-field.is-logo .thumb img { object-fit: contain; }
.img-field .img-tools { flex: 1; min-width: 0; }
.img-field .img-tools input { font-size: 12px; color: var(--muted); }
.img-field .img-actions { display: flex; gap: 6px; margin-top: 6px; }

/* --------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 11.5px; letter-spacing: .06em; color: var(--muted);
  font-weight: 600; padding: 11px 14px; background: #fafbfd; border-bottom: 1px solid var(--line);
  white-space: nowrap; text-transform: uppercase;
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fbfdff; }
table.data .cell-name { font-weight: 600; }
table.data .cell-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 1px; }
table.data .mono { font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.badge.new { background: #e8f6fd; color: #0369a1; }
.badge.following { background: #fef3c7; color: #b45309; }
.badge.won { background: #e7f7ee; color: #0f7a43; }
.badge.lost { background: #f1f5f9; color: #64748b; }
.status-select {
  height: 30px; border-radius: 7px; border: 1px solid var(--line); font-size: 12px; padding: 0 8px; background: #fff;
}
.lead-msg { max-width: 320px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters .search {
  height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; width: 240px;
  outline: none; font-size: 13px;
}
.filters .search:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 150, 214, .12); }
.tabs { display: inline-flex; background: #f1f5f9; border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button {
  height: 30px; padding: 0 13px; border-radius: 7px; font-size: 12.5px; color: var(--muted); font-weight: 500;
}
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 37, 60, .1); font-weight: 600; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted-2); font-size: 13px; }
.empty strong { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: 6px; }

/* 保存条 */
.save-bar {
  position: fixed; left: 244px; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding: 12px 28px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 -8px 24px rgba(15, 37, 60, .05);
  transform: translateY(100%); transition: transform .28s cubic-bezier(.22, .61, .36, 1);
}
.save-bar.show { transform: none; }
.save-bar .dirty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.save-bar .dirty-text { font-size: 12.5px; color: var(--ink-2); }
.save-bar .spacer { flex: 1; }

/* 提示 */
.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%) translateY(-10px);
  background: #0f1720; color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 13px;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfdae4; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b3c3d1; background-clip: content-box; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .25s; z-index: 100; }
  .sidebar.open { transform: none; }
  .save-bar { left: 0; }
  .content { padding: 20px 16px 90px; }
  .topbar { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .quick-links { grid-template-columns: 1fr; }
  .menu-btn { display: grid !important; }
}
.menu-btn { display: none; width: 38px; height: 38px; border-radius: 8px; place-items: center; border: 1px solid var(--line); background: #fff; }
.menu-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
