/* ============== 设计 token ============== */
:root {
  /* 配色 - 现代 indigo + emerald */
  --bg-1: #f5f7fb;
  --bg-2: #eef1f8;
  --card: #ffffff;
  --ink: #1a1f2e;
  --ink-2: #4a5168;
  --ink-soft: #8a91a4;
  --line: #e7eaf2;
  --line-2: #f0f2f8;

  --brand: #6366f1;        /* indigo-500 */
  --brand-2: #818cf8;      /* indigo-400 */
  --brand-3: #4f46e5;      /* indigo-600 */
  --brand-soft: #eef2ff;
  --brand-glow: rgba(99, 102, 241, 0.18);

  --new: #10b981;          /* emerald-500 */
  --new-soft: #d1fae5;
  --old: #f59e0b;          /* amber-500 */
  --old-soft: #fef3c7;
  --warn: #ef4444;         /* red-500 */
  --warn-soft: #fee2e2;

  --kpi-1: #6366f1;
  --kpi-2: #8b5cf6;
  --kpi-3: #10b981;
  --kpi-4: #f59e0b;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 36px rgba(15, 23, 42, 0.08);

  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1200px 600px at 0% 0%, #e0e7ff 0%, transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, #ede9fe 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

/* ============== 顶栏 ============== */
.topbar {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
  color: #fff;
  box-shadow: 0 4px 24px rgba(79, 70, 229, 0.20);
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(600px 200px at 90% 0%, rgba(255,255,255,0.18) 0%, transparent 60%),
    radial-gradient(400px 200px at 10% 100%, rgba(255,255,255,0.10) 0%, transparent 60%);
  pointer-events: none;
}
.topbar-inner {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 20px 28px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
}
.brand-text h1 {
  font-size: 20px; margin: 0; font-weight: 700; letter-spacing: 0.3px;
}
.brand-sub { font-size: 12.5px; opacity: 0.85; margin-top: 1px; display: inline-block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============== 按钮 ============== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none; transition: all .18s ease;
  font-family: inherit;
}
.btn:hover { border-color: #c4cee4; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary {
  background: #fff; color: var(--brand-3);
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10);
}
.btn-primary:hover { background: #f8f9ff; color: var(--brand-3); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.15); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.25); border-color: rgba(255, 255, 255, 0.4); color: #fff; }

/* ============== 布局 ============== */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 24px 64px; }
.app { display: flex; flex-direction: column; gap: 28px; }
.hidden { display: none !important; }

/* ============== 空状态 ============== */
.empty { padding: 80px 16px; text-align: center; }
.empty-card {
  display: inline-block; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 56px 64px; box-shadow: var(--shadow-lg);
  max-width: 480px;
}
.empty-emoji { color: var(--brand); margin-bottom: 16px; opacity: 0.85; }
.empty-card h3 { margin: 0 0 8px; font-size: 20px; font-weight: 700; color: var(--ink); }
.empty-card p { margin: 4px 0; color: var(--ink-2); font-size: 14.5px; }
.empty-card .empty-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 12px; }

/* ============== KPI 卡片 ============== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.kpi-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all .25s ease;
}
.kpi-card::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--c, var(--brand));
  border-radius: 4px 0 0 4px;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-1 { --c: var(--kpi-1); }
.kpi-2 { --c: var(--kpi-2); }
.kpi-3 { --c: var(--kpi-3); }
.kpi-4 { --c: var(--kpi-4); }

.kpi-label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.kpi-value {
  font-size: 32px; font-weight: 700; color: var(--ink);
  margin: 8px 0 4px; letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.kpi-foot { font-size: 12px; color: var(--ink-soft); }

/* ============== 板块 ============== */
.board { display: flex; flex-direction: column; gap: 14px; }
.board-head {
  display: flex; align-items: center; gap: 14px;
  padding: 0 4px;
}
.board-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 12px var(--brand-glow);
}
.board-icon-1 { background: linear-gradient(135deg, #6366f1, #818cf8); }
.board-icon-2 { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.board-text { flex: 1; min-width: 0; }
.board-title { font-size: 18px; font-weight: 700; margin: 0; color: var(--ink); letter-spacing: 0.2px; }
.board-sub { font-size: 13px; color: var(--ink-soft); margin: 2px 0 0; }
.board-sub strong { color: var(--brand); font-weight: 600; }

/* ============== 面板（白卡片） ============== */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* ============== CSS Grid 表格 ============== */
.grid-table {
  display: flex;
  flex-direction: column;
  min-width: 700px;
  padding: 10px 0;
}
.grid-row, .grid-header {
  display: grid;
  align-items: center;
  grid-template-columns: var(--cols);
}
.grid-row { transition: background .15s ease; }
.grid-header {
  position: sticky; top: 0; z-index: 1;
  background: linear-gradient(180deg, #f9fafd 0%, #f3f4f9 100%);
  border-bottom: 2px solid var(--line);
}
.grid-row {
  border-bottom: 1px solid var(--line-2);
  min-height: 64px;
  position: relative;
  background: var(--card);
}
.grid-row:nth-child(even) { background: #fafbfd; }
.grid-row:last-child { border-bottom: none; }

.grid-header .grid-cell {
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: 0.2px;
  padding: 20px 20px;
}
.grid-cell {
  padding: 20px 20px;
  min-height: 64px;
  display: flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: var(--ink);
}
.grid-cell:first-child {
  padding-left: 48px;
}
.grid-cell.num {
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink-2);
}
.grid-cell.drill {
  justify-content: flex-end;
  color: #c0c8da; font-weight: 700; font-size: 18px;
}

/* hover 状态 - 整行高亮 + 左侧品牌色条（即时响应，无过渡） */
.grid-row.clickable { cursor: pointer; }
.grid-row.clickable::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--brand);
  transform: scaleY(0); transform-origin: center;
  border-radius: 0 3px 3px 0;
}
.grid-row.clickable:hover { background: var(--brand-soft) !important; }
.grid-row.clickable:hover::before { transform: scaleY(1); }
.grid-row.clickable:hover .drill { color: var(--brand); }
.grid-row.clickable:hover .grid-cell { color: var(--ink); }

/* ============== 标签 ============== */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
}
.tag.new { background: var(--new-soft); color: var(--new); }
.tag.old { background: var(--old-soft); color: var(--old); }

/* ============== 输入框 & 下拉框 ============== */
.link-edit {
  padding: 8px 12px;
  border: 1.5px solid #d4dae8;
  border-radius: 8px;
  font-size: 13.5px;
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
  max-width: 110px;
  font-family: inherit;
}
.link-edit:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.link-status {
  width: 100px;
  padding: 7px 10px;
  border: 1.5px solid #d4dae8;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235d6679'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  padding-right: 26px;
  font-family: inherit;
}
.link-status option[value="new"] { color: var(--new); font-weight: 700; }
.link-status option[value="old"] { color: var(--old); font-weight: 700; }
.link-status:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

.muted { color: var(--ink-soft); }
.score-strong { font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--brand); }
.sort-ind { font-size: 10px; opacity: 0.65; margin-left: 3px; }

/* ============== Toast ============== */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #1e2330; color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 13.5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22); z-index: 300;
  opacity: 0; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============== 千川式抽屉 ============== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(16, 22, 42, 0.55);
  opacity: 0; pointer-events: none;
  transition: opacity .30s ease; z-index: 200;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(920px, 76vw);
  background: var(--card);
  transform: translateX(100%);
  transition: transform .34s cubic-bezier(.22,.61,.36,1);
  display: flex; flex-direction: column;
  box-shadow: -16px 0 48px rgba(16, 22, 42, 0.25);
  border-radius: 20px 0 0 20px;
  overflow: hidden;
}
.drawer-overlay.open .drawer { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f9fafd);
}
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  font-size: 20px; line-height: 1; color: var(--ink-2);
  cursor: pointer; transition: all .16s ease;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.drawer-titles { flex: 1; min-width: 0; }
.drawer-title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-crumb { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.drawer-crumb .crumb { color: var(--ink-soft); }
.drawer-crumb .crumb.cur { color: var(--brand); font-weight: 600; }
.drawer-crumb .sep { color: #c0c8da; }

.drawer-scroll { flex: 1; overflow: auto; padding: 4px 0 20px; }

@keyframes drawerInRight { from { transform: translateX(28px); } to { transform: none; } }
@keyframes drawerInLeft  { from { transform: translateX(-28px); } to { transform: none; } }

/* ============== 响应式 ============== */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .topbar-inner { padding: 16px 18px; }
  .brand-text h1 { font-size: 18px; }
  .brand-sub { font-size: 11.5px; }
  .actions .btn { padding: 8px 12px; font-size: 12.5px; }
  .container { padding: 20px 14px 48px; }
  .kpi-grid { gap: 12px; }
  .kpi-value { font-size: 26px; }
  .grid-table { min-width: 560px; }
  .grid-cell { padding: 14px 12px; min-height: 56px; font-size: 14px; }
  .grid-cell:first-child { padding-left: 28px; }
  .grid-header .grid-cell { padding: 14px 12px; font-size: 12.5px; }
  .drawer { width: 100%; border-radius: 0; }
  .link-status { width: 82px; font-size: 12px; padding-right: 22px; }
  .link-edit { max-width: 90px; }
}

/* ============== 飞书登录屏 ============== */
.login-screen {
  position: fixed; inset: 0; z-index: 400;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #818cf8 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-screen.hidden { display: none; }
.login-card {
  background: #fff; border-radius: 22px; padding: 48px 52px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.30);
  text-align: center; max-width: 380px; width: 100%;
}
.login-logo {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}
.login-title { margin: 0 0 8px; font-size: 21px; font-weight: 700; color: var(--ink); }
.login-sub { margin: 0 0 28px; font-size: 14px; color: var(--ink-soft); }
.btn-feishu {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  width: 100%; padding: 13px 20px; border: none; border-radius: 12px;
  background: #3370ff; color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .18s ease; font-family: inherit;
}
.btn-feishu:hover { background: #2860e0; transform: translateY(-1px); box-shadow: 0 8px 22px rgba(51, 112, 255, 0.35); }
