/* ============================================================
   控制台 — 设计令牌
   ============================================================ */
:root {
  --brand: #3f6ae6;
  --brand-tint: rgba(63, 106, 230, .09);
  --brand-line: rgba(63, 106, 230, .26);

  --bg: #f6f7f9;
  --bg-soft: #f9fafb;
  --panel: #ffffff;

  --ink: #14181f;
  --ink-mid: #5c6675;
  --ink-soft: #8b94a4;
  --ink-ghost: #b6bdca;

  --line: #e8eaf0;
  --line-strong: #d9dde6;
  --hover: rgba(20, 24, 31, .035);
  --sk: #e6e9f1;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-pop: 0 8px 24px -12px rgba(16, 24, 40, .25);

  --ease: cubic-bezier(.22, .9, .26, 1);
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 68px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --brand: #7b98f5;
  --brand-tint: rgba(123, 152, 245, .14);
  --brand-line: rgba(123, 152, 245, .3);

  --bg: #0b0e13;
  --bg-soft: #0f1319;
  --panel: #12161d;

  --ink: #e9edf5;
  --ink-mid: #a3acbc;
  --ink-soft: #737d8f;
  --ink-ghost: #4d5566;

  --line: #1f242e;
  --line-strong: #2a3140;
  --hover: rgba(255, 255, 255, .04);
  --sk: #242b37;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-pop: 0 12px 32px -14px rgba(0, 0, 0, .8);
}

/* ============================================================
   基础
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  height: 100svh;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

::selection { background: var(--brand-tint); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 7px;
}

/* ============================================================
   外壳
   ============================================================ */
.shell {
  display: flex;
  height: 100svh;
  overflow: hidden;
}

/* ============================================================
   侧栏
   ============================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  transition: width .28s var(--ease), transform .3s var(--ease);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 64px;
  flex-shrink: 0;
  padding: 0 10px 0 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.brand-name {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

/* logo 空位，和登录页保持一致 */
.brand-mark {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  border: 1px dashed var(--ink-ghost);
  background: var(--bg-soft);
  transition: border-color .25s ease;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 5px;
  height: 5px;
  margin: auto;
  border-radius: 50%;
  background: var(--ink-ghost);
  transition: background .25s ease, width .25s ease, height .25s ease;
}
.brand:hover .brand-mark { border-color: var(--brand-line); }
.brand:hover .brand-mark::after { background: var(--brand); width: 8px; height: 8px; }

.collapse-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .3s var(--ease);
}
.collapse-btn:hover { background: var(--hover); color: var(--ink); }

/* 只在移动端出现的关闭按钮 */
.close-drawer { display: none; }

/* 菜单 */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 12px;
  scrollbar-width: thin;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  flex-shrink: 0;
  padding: 0 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-mid);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .75;
  transition: opacity .16s ease;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item:active { transform: scale(.99); }
.nav-item.is-active {
  background: var(--brand-tint);
  color: var(--brand);
  font-weight: 600;
}
.nav-item.is-active svg { opacity: 1; }

/* 侧栏底部 */
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 4px;
}
.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a72ea, #2f5fd8);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
}
.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-plan { font-size: 11px; color: var(--ink-soft); }

.foot-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.logout {
  margin-left: auto;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--ink-soft);
  transition: background .16s ease, color .16s ease;
}
.logout:hover { background: var(--hover); color: var(--ink); }

/* 折叠态 */
.shell.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.shell.is-collapsed .brand-name,
.shell.is-collapsed .nav-text,
.shell.is-collapsed .user-meta,
.shell.is-collapsed .logout { display: none; }
.shell.is-collapsed .brand { display: none; }
.shell.is-collapsed .sidebar-head { justify-content: center; padding: 0; }
.shell.is-collapsed .collapse-btn { transform: rotate(180deg); }
.shell.is-collapsed .nav-item { justify-content: center; padding: 0; }
.shell.is-collapsed .user { justify-content: center; }
.shell.is-collapsed .foot-actions { justify-content: center; }

/* ============================================================
   主区
   ============================================================ */
.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 62px;
  flex-shrink: 0;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.icon-btn.menu-btn { display: none; }

.page-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.page-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
}
.page-desc {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-mid);
  cursor: pointer;
  transition: background .16s ease, color .16s ease;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn .i-moon { display: none; }
[data-theme="dark"] .icon-btn .i-sun { display: none; }
[data-theme="dark"] .icon-btn .i-moon { display: block; }

.avatar-sm { width: 30px; height: 30px; font-size: 12px; }

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  transition: border-color .18s ease, background .18s ease;
}
.search:focus-within { border-color: var(--brand-line); background: var(--panel); }
.search input {
  width: 116px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}
.search input::placeholder { color: var(--ink-ghost); }
.search kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  font-family: inherit;
  font-size: 10.5px;
  color: var(--ink-ghost);
  line-height: 1.4;
}
.search-sm { height: 30px; }
.search-sm input { width: 110px; font-size: 12.5px; }

/* 内容区 */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 40px;
  scroll-behavior: smooth;
}
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
  border: 2px solid var(--bg);
}

.view { display: flex; flex-direction: column; gap: 14px; animation: viewIn .35s var(--ease); }
.view.is-hidden { display: none; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 16px 18px;
  transition: border-color .2s ease, box-shadow .25s ease;
}
.stat:hover { border-color: var(--line-strong); box-shadow: var(--shadow-pop); }
.stat-label { font-size: 12.5px; color: var(--ink-soft); }
.stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
  color: var(--ink);
}
.stat-foot { font-size: 11.5px; color: var(--ink-ghost); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 14px;
  align-items: start;
}

.panel { overflow: hidden; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-mini {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink-mid);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.btn-mini:hover { background: var(--hover); color: var(--ink); border-color: var(--line-strong); }
.btn-mini-strong {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--panel);
}
.btn-mini-strong:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ============================================================
   表格
   ============================================================ */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-soft);
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-mid);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: var(--hover); }

.col-right { text-align: right; }
.col-hide { display: table-cell; }
.col-check { width: 40px; padding-right: 0 !important; }
.col-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--brand);
  cursor: pointer;
}

.tag {
  display: inline-block;
  padding: 2.5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-soft);
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}
.pager-btns { display: flex; gap: 6px; }
.pager-btns button {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink-mid);
  font-size: 12px;
  cursor: pointer;
}
.pager-btns button:disabled { color: var(--ink-ghost); cursor: not-allowed; }

/* ============================================================
   占位骨架
   ============================================================ */
.sk {
  display: inline-block;
  height: 9px;
  border-radius: 5px;
  background: var(--sk);
  vertical-align: middle;
}
.sk-xs { width: 32px; }
.sk-sm { width: 64px; }
.sk-md { width: 96px; }
.sk-lg { width: 132px; }
.sk-full { width: 100%; }
.sk-half { width: 62%; }

/* 侧栏卡片 */
.side-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 18px;
}
.side-note {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}
.sk-rows {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.btn-block {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--ink-mid);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.btn-block:hover { background: var(--brand-tint); border-color: var(--brand-line); color: var(--brand); }

/* 图表占位区 */
.chart-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 236px;
  margin: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink-ghost);
  text-align: center;
}
.chart-slot span {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}
.chart-slot small { font-size: 11.5px; color: var(--ink-ghost); }

/* ============================================================
   遮罩（移动端）
   ============================================================ */
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(12, 16, 22, .42);
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s ease;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search { display: none; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    width: 258px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-pop);
  }
  .shell.is-open .sidebar { transform: translateX(0); }
  .shell.is-collapsed .sidebar { width: 258px; }
  .shell.is-collapsed .brand { display: inline-flex; }
  .shell.is-collapsed .brand-name,
  .shell.is-collapsed .nav-text,
  .shell.is-collapsed .user-meta,
  .shell.is-collapsed .logout { display: inline-block; }
  .shell.is-collapsed .nav-item { justify-content: flex-start; padding: 0 10px; }
  .shell.is-collapsed .sidebar-head { justify-content: space-between; padding: 0 10px 0 16px; }
  .shell.is-collapsed .collapse-btn { transform: none; }

  .collapse-btn { display: none; }
  .icon-btn.menu-btn { display: grid; }

  .close-drawer {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
  }
  .close-drawer:hover { background: var(--hover); color: var(--ink); }

  .scrim { display: block; }
  .shell.is-open .scrim { opacity: 1; pointer-events: auto; }

  .topbar { height: 56px; padding: 0 14px; gap: 10px; }
  .content { padding: 16px 14px 32px; }
  .page-desc { display: none; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 22px; }
  .col-hide { display: none; }
  .view { gap: 10px; }
  .split { gap: 10px; }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
  .panel-head { padding: 12px 14px; }
  .panel-tools .search { display: none; }
}

@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}


/* ============================================================
   工具 / 笔记 / 收藏 / 设置
   ============================================================ */
.view-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.view-note{ font-size:12.5px; color:var(--ink-soft); }
.btn-mini[disabled]{ opacity:.5; cursor:not-allowed; }

/* ---------- 工具 ---------- */
.tool-grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:14px;
}
.tool-card{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-height:168px;
  padding:18px;
  border-radius:var(--radius);
  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  transition:border-color .3s var(--ease), transform .3s var(--ease);
}
.tool-card:hover{ transform:translateY(-2px); border-color:var(--line-strong); }
.tool-top{ display:flex; align-items:center; justify-content:space-between; }
.tool-tag{
  padding:2px 8px;
  border-radius:999px;
  border:1px solid var(--brand-line);
  background:var(--brand-tint);
  color:var(--brand);
  font-size:11px;
}
.tool-ver{ font-size:11px; color:var(--ink-ghost); }
.tool-card h3{ margin:4px 0 0; font-size:15px; font-weight:600; }
.tool-card p{ margin:0; color:var(--ink-mid); font-size:12.5px; line-height:1.6; }
.tool-state{ margin-top:auto; font-size:11.5px; color:var(--ink-soft); }

.tool-card.is-slot{
  grid-column:1 / -1;
  min-height:104px;
  display:grid;
  place-content:center;
  justify-items:center;
  gap:4px;
  border-style:dashed;
  background:transparent;
  box-shadow:none;
  text-align:center;
}
.slot-plus{ font-size:22px; line-height:1; color:var(--ink-ghost); }

/* ---------- 笔记 ---------- */
.note-list{ display:flex; flex-direction:column; gap:10px; }
.note-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:16px 18px;
  border-radius:var(--radius);
  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  transition:border-color .3s var(--ease);
}
.note-row:hover{ border-color:var(--line-strong); }
.note-meta{ font-size:11.5px; color:var(--ink-soft); }
.note-main h3{ margin:4px 0; font-size:15px; font-weight:600; }
.note-main p{ margin:0; color:var(--ink-mid); font-size:12.5px; }
.note-arrow{ color:var(--ink-ghost); }
.empty-note{ margin:0; padding:26px 0; text-align:center; color:var(--ink-soft); font-size:12.5px; }

/* ---------- 收藏 ---------- */
.link-list{ display:flex; flex-direction:column; gap:10px; }
.link-row{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 18px;
  border-radius:var(--radius);
  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:var(--shadow);
  color:inherit;
  text-decoration:none;
  transition:border-color .3s var(--ease);
}
.link-row:hover{ border-color:var(--line-strong); }
.link-dot{ width:8px; height:8px; border-radius:50%; background:var(--brand); opacity:.55; }
.link-main{ display:flex; flex-direction:column; gap:2px; }
.link-main b{ font-size:14px; font-weight:550; }
.link-main small{ font-size:11.5px; color:var(--ink-soft); }
.link-arrow{ margin-left:auto; color:var(--ink-ghost); }

/* ---------- 设置 ---------- */
.form-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:16px;
  padding:4px 18px 18px;
}
.field{ display:flex; flex-direction:column; gap:6px; font-size:12.5px; color:var(--ink-mid); }
.field input,
.field select,
.field textarea{
  width:100%;
  padding:9px 11px;
  border-radius:10px;
  border:1px solid var(--line-strong);
  background:var(--bg-soft);
  color:var(--ink);
  font:inherit;
  font-size:13px;
  outline:none;
}
.field input:focus,
.field select:focus,
.field textarea:focus{
  border-color:var(--brand);
  box-shadow:0 0 0 3px var(--brand-tint);
}
.field textarea{ resize:vertical; }
.form-foot{ display:flex; align-items:center; gap:12px; padding:0 18px 18px; }
.form-hint{ font-size:11.5px; color:var(--ink-soft); }

/* ---------- 响应式 ---------- */
@media (max-width:1000px){
  .tool-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
}
@media (max-width:640px){
  .tool-grid{ grid-template-columns:1fr; }
  .form-grid{ grid-template-columns:1fr; }
}

/* ---------- logo ---------- */
.brand-logo{ width:28px; height:28px; display:block; flex-shrink:0; }

/* 未确认登录前先藏起来，避免闪一下控制台 */
body.auth-pending{ visibility:hidden; }
