/* 教程资料库 · 后台样式 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #171a20;
  --ink2: #5b6472;
  --ink3: #8d97a5;
  --line: #e3e8ef;
  --line2: #eef2f7;
  --brand: #1f4fd8;
  --brand-dark: #163aa5;
  --brand-soft: #ecf1ff;
  --ok: #0b8f5c;
  --ok-soft: #e8f8f1;
  --err: #b4443a;
  --err-soft: #fdeeee;
  --warn: #b8720a;
  --warn-soft: #fdf4e3;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ============================ 框架 ============================ */

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

.side {
  width: 208px;
  flex-shrink: 0;
  background: #101828;
  color: #c7d0dd;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  padding: 4px 8px 18px;
}

.logo .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(140deg, #2b5ce6, #163aa5);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.side nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side nav a {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #a9b4c4;
  transition: background .15s, color .15s;
}

.side nav a:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.side nav a.on {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}

.side-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}

.side-foot .who {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}

.side-foot .quit { color: #8d99aa; }
.side-foot .quit:hover { color: #ff9b8f; }

.main {
  flex: 1;
  min-width: 0;
  padding: 22px 28px 48px;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: 19px;
  font-weight: 600;
  margin: 0;
}

.ghost-link {
  font-size: 12.5px;
  color: var(--ink3);
}

.ghost-link:hover { color: var(--brand); }

/* ============================ 提示条 ============================ */

.flash {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  margin-bottom: 16px;
}

.flash.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #c9ecdc; }
.flash.err { background: var(--err-soft); color: var(--err); border: 1px solid #f3cfcf; }

/* ============================ 卡片 ============================ */

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

.card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink2);
  margin: 0 0 14px;
  letter-spacing: .3px;
}

/* 统计块 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat .k {
  font-size: 12px;
  color: var(--ink3);
  margin-bottom: 6px;
}

.stat .v {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
}

.stat .v small { font-size: 13px; font-weight: 400; color: var(--ink3); }

/* ============================ 表格 ============================ */

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

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

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line2);
  vertical-align: middle;
}

th {
  background: #fbfcfe;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink3);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }

td .t-title {
  font-weight: 500;
  color: var(--ink);
}

td .t-url {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink3);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.pill {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--line2);
  color: var(--ink2);
  white-space: nowrap;
}

.pill.lv-in { background: var(--ok-soft); color: var(--ok); }
.pill.lv-mid { background: var(--warn-soft); color: var(--warn); }
.pill.paid { background: var(--err-soft); color: var(--err); }

.actions { display: flex; gap: 6px; white-space: nowrap; }

.actions a, .actions button {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink2);
  cursor: pointer;
  font-family: inherit;
  transition: all .14s;
}

.actions a:hover { border-color: #b7c7f5; color: var(--brand); }
.actions .danger:hover { border-color: #f0c4c4; color: var(--err); background: var(--err-soft); }

/* ============================ 表单 ============================ */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 6px;
}

.field .hint {
  font-size: 11.5px;
  color: var(--ink3);
  margin-top: 5px;
  line-height: 1.6;
}

input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

input:focus, textarea:focus, select:focus {
  background: #fff;
  border-color: #b7c7f5;
  box-shadow: 0 0 0 3px rgba(31, 79, 216, .1);
}

textarea { resize: vertical; min-height: 84px; line-height: 1.65; }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: all .15s;
}

.btn:hover { border-color: #cfd6e2; color: var(--ink); background: #fbfcfe; }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn.small { height: 30px; padding: 0 12px; font-size: 12.5px; }

.form-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}

.form-foot .spacer { flex: 1; }

/* ============================ 登录页 ============================ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e9eeff, #f4f6f9 60%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: 0 20px 48px -24px rgba(16, 24, 40, .22);
}

.login-card .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-card .brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(140deg, #2b5ce6, #163aa5);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
}

.login-card h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 600;
}

.login-card .sub {
  font-size: 12.5px;
  color: var(--ink3);
  margin-top: 2px;
}

.login-card .btn { width: 100%; margin-top: 4px; }

.login-err {
  background: var(--err-soft);
  color: var(--err);
  border: 1px solid #f3cfcf;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 4px 0;
  font-size: 13px;
  color: var(--ink2);
  flex-wrap: wrap;
}

.pager a, .pager span.cur {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.pager span.cur {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.pager .info { margin-left: auto; color: var(--ink3); font-size: 12.5px; }

/* 工具条 */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar input[type=text] { max-width: 260px; }
.toolbar select { max-width: 160px; }
.toolbar .spacer { flex: 1; }

/* 空状态 */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink3);
  font-size: 13px;
}

/* 设置页的分组 */
.set-block + .set-block { margin-top: 8px; }
.set-block h2 { margin-bottom: 4px; }
.set-block .desc { font-size: 12.5px; color: var(--ink3); margin: 0 0 16px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    overflow-x: auto;
  }
  .logo { padding: 0 12px 0 0; font-size: 0; }
  .logo .mark { font-size: 14px; }
  .side nav { flex-direction: row; }
  .side-foot { margin: 0 0 0 auto; border: none; padding: 0; }
  .main { padding: 16px; }
  .row2, .row3 { grid-template-columns: 1fr; }
}

/* 链接输入 + 自动识别按钮 */
.url-row {
  display: flex;
  gap: 8px;
}

.url-row input {
  flex: 1;
}

.url-row .btn {
  white-space: nowrap;
  height: 38px;
  margin-top: 2px;
}
