/* ===== 苹果质感 · 克制风 ===== */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --text-sub: #6e6e73;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== 通用控件 ===== */
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
label { display: block; font-size: 13px; color: var(--text-sub); margin-bottom: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px; font-weight: 500;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, opacity .15s, border-color .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f5f5f7; }
.btn-danger { background: #fff; color: var(--red); border-color: var(--border); }
.btn-danger:hover { background: #fff5f5; border-color: var(--red); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 40px 32px;
}
.login-card h1 { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--text-sub); font-size: 13px; margin-bottom: 28px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 11px; }
.login-card .hint { font-size: 12px; color: var(--text-sub); margin-top: 6px; }
.err {
  background: #fff5f5; color: var(--red);
  border: 1px solid #ffd9d6; border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; margin-bottom: 16px;
  display: none;
}
.err.show { display: block; }

/* ===== 主框架 ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #fbfbfd; border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column; padding: 20px 12px;
  position: fixed; top: 0; bottom: 0; left: 0;
}
.sidebar .logo { font-size: 17px; font-weight: 600; padding: 8px 12px 20px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-sub); cursor: pointer; font-size: 14px;
  transition: background .12s, color .12s; margin-bottom: 2px;
}
.nav-item:hover { background: #f0f0f3; color: var(--text); }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item .ic { width: 18px; text-align: center; font-size: 15px; }
.sidebar .foot { margin-top: auto; }

.main { flex: 1; margin-left: 220px; padding: 32px 40px; max-width: 1600px; }
.page-title { font-size: 24px; font-weight: 600; margin-bottom: 24px; }
.page { display: none; }
.page.active { display: block; }

/* ===== 卡片 / 表格 ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; font-size: 14px; }
th { color: var(--text-sub); font-weight: 500; font-size: 13px; border-bottom: 1px solid var(--border-light); }
td { border-bottom: 1px solid var(--border-light); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-green { background: #e8f8ec; color: #1a8a3a; }
.badge-gray { background: #f0f0f3; color: #6e6e73; }

/* 操作/可点文字链接 */
.link { color: var(--blue); cursor: pointer; font-size: 13px; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }
.link + .link { margin-left: 14px; }

/* 统计小卡 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 14px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px;
}
.stat .n { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--text-sub); margin-top: 2px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 0 0 auto; }
.grow { flex: 1 1 auto !important; }
.muted { color: var(--text-sub); font-size: 13px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.32);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 420px; padding: 28px;
}
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: rgba(30,30,32,.92); color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 提取结果框 */
.result-box {
  background: #1d1d1f; color: #e8e8ed; border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-all;
  max-height: 320px; overflow-y: auto;
}

/* 分页 */
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 18px; }

/* 表单输入元素适度限宽：卡片填满整宽，但输入框不拉伸到傻 */
#page-import select,
#page-import textarea { max-width: 760px; }
#page-extract .row { max-width: 720px; }

/* 左右两栏：主体 + 右侧概览栏 */
.split { display: flex; gap: 20px; align-items: flex-start; }
.split-main { flex: 1; min-width: 0; }
.split-side { flex: 0 0 280px; }
.overview .item { display: flex; justify-content: space-between; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--border-light); }
.overview .item:last-child { border-bottom: none; }
.overview .item .k { color: var(--text-sub); font-size: 13px; }
.overview .item .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== 响应式：随窗口宽度自适应 ===== */
@media (max-width: 1180px) {
  .split { flex-direction: column; }
  .split-side { flex: none; width: 100%; order: -1; }      /* 窄屏概览移到顶部 */
  .overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .overview .item { flex-direction: column; align-items: flex-start; gap: 3px; border-bottom: none; padding: 4px 0; }
}
@media (max-width: 820px) {
  .sidebar { width: 64px; padding: 16px 8px; }             /* 窄屏侧边栏收成图标条 */
  .sidebar .logo { font-size: 0; padding: 8px 0 16px; }
  .nav-item { justify-content: center; font-size: 0; }      /* 隐藏文字 */
  .nav-item .ic { font-size: 15px; }                        /* 只留图标 */
  .main { margin-left: 64px; }
}
@media (max-width: 720px) {
  .main { padding: 20px 16px; }
  .overview { grid-template-columns: repeat(2, 1fr); }
  #page-import select, #page-import textarea, #page-extract .row { max-width: none; }
}
