/* ═══════════════════════════════════════════
   设计系统 — 琥珀暖色系
   与本地版视觉语言保持一致
   ═══════════════════════════════════════════ */

:root {
  --amber-50:  #FFFBF3;
  --amber-100: #FDF3E0;
  --amber-200: #F9E4BE;
  --amber-300: #F3CE8E;
  --amber-400: #E8B063;
  --amber-500: #D8923B;
  --amber-600: #B87328;
  --amber-700: #8F5619;
  --amber-800: #6B3F12;

  --ink-900: #1F1B16;
  --ink-800: #33302A;
  --ink-700: #4A453D;
  --ink-600: #6B655B;
  --ink-500: #8C857A;
  --ink-400: #ABA49A;
  --ink-300: #CFC9BF;
  --ink-200: #E5E1D9;
  --ink-100: #F2EFE9;

  --red-500: #C0392B;
  --red-100: #FBE9E7;
  --green-600: #2E7D5B;
  --green-100: #E4F3EC;
  --blue-600: #2563A8;
  --blue-100: #E6F0FA;

  --bg: #FBF9F5;
  --surface: #FFFFFF;
  --surface-2: #F7F4EE;
  --border: #E8E2D6;
  --border-strong: #D6CEBD;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(31, 27, 22, .05);
  --shadow: 0 2px 8px rgba(31, 27, 22, .07);
  --shadow-lg: 0 8px 28px rgba(31, 27, 22, .11);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

[data-theme="dark"] {
  --amber-50:  #241C10;
  --amber-100: #2E2415;
  --amber-200: #3E301A;
  --amber-300: #5C4622;
  --amber-400: #8A6733;
  --amber-500: #C9944A;
  --amber-600: #DBA95E;
  --amber-700: #E8BE7E;
  --amber-800: #F2D3A0;

  --ink-900: #F5F2EC;
  --ink-800: #E3DFD6;
  --ink-700: #C9C3B7;
  --ink-600: #A69F92;
  --ink-500: #857E72;
  --ink-400: #63605A;
  --ink-300: #45423C;
  --ink-200: #33312C;
  --ink-100: #25241F;

  --bg: #16150F;
  --surface: #1D1B15;
  --surface-2: #24221B;
  --border: #322F27;
  --border-strong: #454136;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 8px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink-800);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--amber-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── 滚动条 ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-300);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

/* ═══ 布局 ═══ */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-900);
  letter-spacing: -.2px;
}

.sidebar-brand .ver {
  font-size: 11px;
  color: var(--ink-500);
  font-family: var(--mono);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--ink-700);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .13s, color .13s;
  user-select: none;
  margin-bottom: 2px;
}

.nav-item:hover { background: var(--surface-2); color: var(--ink-900); }

.nav-item.active {
  background: var(--amber-100);
  color: var(--amber-700);
  font-weight: 500;
}

.nav-item .ico {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: .85;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-500);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-900);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.content {
  padding: 22px;
  flex: 1;
}

/* ═══ 卡片 ═══ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-title .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--amber-500);
  flex-shrink: 0;
}

.card-desc {
  font-size: 12.5px;
  color: var(--ink-500);
  margin-bottom: 12px;
  line-height: 1.6;
}

/* ═══ 网格 ═══ */

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

/* ═══ 面板内滚动 ═══ */

/*
 * 让长内容在卡片**内部**滚动，而不是把整个页面撑长。
 *
 * 高度 = 视口 - 顶栏(56) - 内容区上下内边距(22 × 2)，正好铺满一屏，
 * 页面本身不产生滚动条（margin-bottom 必须归零，否则会多出 16px 的
 * 整页滚动）。
 *
 * 用法：卡片加 .scroll-panel，里面需要滚动的那个子元素加 .scroll-body。
 * 注意 .scroll-body 的 min-height:0 不能省 —— flex 子项默认 min-height:auto，
 * 会被内容撑开，overflow 永远不会触发（这正是改动前"整页滚动"的原因）。
 */
.scroll-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  /* 只在视口极矮（< 380px）时兜底；设太大会让矮窗口平白多出一截整页滚动 */
  min-height: 280px;
  margin-bottom: 0;
}

.scroll-panel > .scroll-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* 滚到底后不把滚动传递给页面，避免"滚着滚着整页又动了" */
  overscroll-behavior: contain;
}

/* ═══ 统计块 ═══ */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  color: var(--ink-500);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-value {
  font-size: 23px;
  font-weight: 600;
  color: var(--ink-900);
  font-family: var(--mono);
  letter-spacing: -.5px;
  line-height: 1.2;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--ink-500);
  margin-top: 3px;
}

/* ═══ 按钮 ═══ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-800);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .14s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--ink-400);
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--amber-500);
  border-color: var(--amber-500);
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  background: var(--amber-600);
  border-color: var(--amber-600);
}

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: var(--red-500); border-color: #E7C4BE; }
.btn-danger:hover:not(:disabled) { background: var(--red-100); }
.btn-block { width: 100%; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-600);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink-900); }

/* ═══ 表单 ═══ */

.field { margin-bottom: 13px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-700);
  margin-bottom: 5px;
  font-weight: 500;
}

.field .hint {
  font-size: 11.5px;
  color: var(--ink-500);
  margin-top: 4px;
  line-height: 1.55;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-900);
  font-size: 13px;
  font-family: inherit;
  transition: border-color .14s, box-shadow .14s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--amber-400);
  box-shadow: 0 0 0 3px var(--amber-100);
}

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

input::placeholder, textarea::placeholder { color: var(--ink-400); }

input:disabled, textarea:disabled {
  background: var(--surface-2);
  color: var(--ink-500);
}

/* ═══ 表格 ═══ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 13px;
  background: var(--surface-2);
  color: var(--ink-600);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-800);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--amber-50); }

td .actions { display: flex; gap: 6px; }

/* ═══ 徽标 ═══ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-amber { background: var(--amber-100); color: var(--amber-700); }
.badge-green { background: var(--green-100); color: var(--green-600); }
.badge-red { background: var(--red-100); color: var(--red-500); }
.badge-blue { background: var(--blue-100); color: var(--blue-600); }
.badge-gray { background: var(--ink-100); color: var(--ink-600); }

/* ═══ 进度条 ═══ */

.progress {
  height: 6px;
  background: var(--ink-100);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-400), var(--amber-500));
  border-radius: 3px;
  transition: width .35s ease;
}

.progress-bar.warn { background: linear-gradient(90deg, #E8A33D, #D97706); }
.progress-bar.danger { background: linear-gradient(90deg, #DC6B5C, var(--red-500)); }

/* ═══ 提示 ═══ */

.toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 360px;
  animation: slideIn .22s ease;
  pointer-events: auto;
  border-left: 3px solid var(--amber-500);
}

.toast.ok { border-left-color: var(--green-600); }
.toast.err { border-left-color: var(--red-500); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ═══ 空状态 ═══ */

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-500);
}

.empty .ico {
  font-size: 34px;
  opacity: .3;
  margin-bottom: 10px;
}

.empty h3 {
  font-size: 14px;
  color: var(--ink-600);
  margin-bottom: 5px;
  font-weight: 500;
}

.empty p { font-size: 12.5px; }

/* ═══ 加载 ═══ */

.spinner {
  width: 15px; height: 15px;
  border: 2px solid var(--ink-200);
  border-top-color: var(--amber-500);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ 工具类 ═══ */

.row { display: flex; align-items: center; gap: 9px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mb-2 { margin-bottom: 12px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.muted { color: var(--ink-500); }
.mono { font-family: var(--mono); }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hidden { display: none !important; }
