/* 晨灿资料站 - 深色工业风 · 彩色卡片 UI */
:root {
  --bg: #070b16; --bg2: #0a1122;
  --panel: #0f1830; --card: #111c38; --card2: #0d1730;
  --border: #1d2b52; --border2: #2c3f70;
  --text: #e8eeff; --muted: #8b9cc4; --dim: #5d6f99;
  --acc: #22d3ee; --acc2: #818cf8; --acc3: #f472b6;
  --ok: #34d399; --warn: #fbbf24; --danger: #f87171;
  --grad: linear-gradient(90deg, #22d3ee, #818cf8 55%, #f472b6);
  --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(600px 300px at 85% -5%, rgba(129,140,248,.13), transparent 60%),
    radial-gradient(500px 260px at -5% 30%, rgba(34,211,238,.08), transparent 60%),
    radial-gradient(400px 240px at 60% 105%, rgba(244,114,182,.07), transparent 60%);
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #223257; border-radius: 9px; }
::-webkit-scrollbar-track { background: transparent; }
a { color: var(--acc); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 62px;
  background: rgba(9,14,28,.82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; cursor: pointer; flex-shrink: 0; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  font-size: 19px; background: var(--grad); color: #071022; font-weight: 700;
  box-shadow: 0 4px 18px rgba(34,211,238,.35);
}
.grad-text {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--dim); margin-top: 1px; }
.search-wrap { flex: 1; max-width: 520px; position: relative; }
.search-wrap input {
  width: 100%; height: 38px; padding: 0 40px 0 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card2); color: var(--text);
  font-size: 13px; outline: none; transition: .2s;
}
.search-wrap input:focus { border-color: var(--acc2); box-shadow: 0 0 0 3px rgba(129,140,248,.15); }
.search-wrap::before {
  content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 13px; opacity: .55; z-index: 1;
}
.search-wrap kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--dim); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px;
}
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--card2);
  color: var(--text); font-size: 13px; cursor: pointer; transition: .18s; white-space: nowrap;
}
.btn:hover { border-color: var(--border2); background: #132041; }
.btn-primary {
  background: var(--grad); border: none; color: #071022; font-weight: 600;
  box-shadow: 0 4px 16px rgba(34,211,238,.28);
}
.btn-primary:hover { filter: brightness(1.12); background: var(--grad); }
.btn-danger { color: var(--danger); border-color: rgba(248,113,113,.35); }
.btn-danger:hover { background: rgba(248,113,113,.12); }
.btn-sm { height: 29px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--card2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 11px; outline: none; transition: .18s;
}
input:focus, select:focus, textarea:focus { border-color: var(--acc2); box-shadow: 0 0 0 3px rgba(129,140,248,.14); }
label.fld { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.fld-group { margin-bottom: 13px; }
.fld-group input, .fld-group select, .fld-group textarea { width: 100%; }
textarea { resize: vertical; min-height: 64px; }

/* ---------- 布局 ---------- */
.layout { display: flex; gap: 18px; padding: 18px 20px 40px; max-width: 1560px; margin: 0 auto; position: relative; z-index: 1; }
.sidebar { width: 225px; flex-shrink: 0; position: sticky; top: 80px; align-self: flex-start; max-height: calc(100vh - 100px); overflow: auto; }
.side-title { font-size: 11px; color: var(--dim); letter-spacing: 2px; margin: 4px 2px 9px; font-weight: 600; }
.side-title:not(:first-child) { margin-top: 22px; }
.cat-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 10px;
  color: var(--muted); cursor: pointer; font-size: 13px; transition: .15s; margin-bottom: 2px;
  border: 1px solid transparent;
}
.cat-item:hover { background: var(--panel); color: var(--text); }
.cat-item.active { background: linear-gradient(90deg, rgba(34,211,238,.13), rgba(129,140,248,.10)); color: var(--text); border-color: rgba(129,140,248,.35); }
.cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.cat-item .cnt { margin-left: auto; font-size: 11px; color: var(--dim); background: var(--card2); border-radius: 8px; padding: 1px 7px; }
.top-list { list-style: none; }
.top-list li { padding: 7px 4px; border-bottom: 1px dashed rgba(29,43,82,.6); font-size: 12px; }
.top-list a { color: var(--muted); display: flex; gap: 7px; }
.top-list a:hover { color: var(--acc); }
.top-list .dn { margin-left: auto; color: var(--dim); flex-shrink: 0; }
.main { flex: 1; min-width: 0; }

/* ---------- 统计条 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 16px; display: flex; align-items: center; gap: 12px;
}
.stat-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.stat-num { font-size: 18px; font-weight: 700; line-height: 1.15; }
.stat-lbl { font-size: 11px; color: var(--dim); }
.stats .stat-card:nth-child(1) .stat-ico { background: rgba(34,211,238,.14); }
.stats .stat-card:nth-child(2) .stat-ico { background: rgba(52,211,153,.14); }
.stats .stat-card:nth-child(3) .stat-ico { background: rgba(251,191,36,.14); }
.stats .stat-card:nth-child(4) .stat-ico { background: rgba(129,140,248,.14); }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cur-cat { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cur-cat .cat-dot { width: 11px; height: 11px; }
.cur-cat small { color: var(--dim); font-weight: 400; font-size: 12px; }
.toolbar select { height: 33px; font-size: 12px; }
.toolbar .spacer { flex: 1; }

/* ---------- 资料卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.fcard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px 12px; cursor: pointer; transition: .18s; position: relative; overflow: hidden;
}
.fcard::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--cat-color, var(--acc2)); opacity: .85; }
.fcard:hover { transform: translateY(-3px); border-color: var(--border2); box-shadow: 0 10px 30px rgba(0,0,0,.45), 0 0 0 1px rgba(129,140,248,.18); }
.fcard-top { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 10px; }
.fic {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0; background: var(--card2); border: 1px solid var(--border);
}
.fname { font-size: 13.5px; font-weight: 600; line-height: 1.4; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 37px; }
.fdesc { font-size: 11.5px; color: var(--muted); margin-top: 7px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fmeta { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11px; color: var(--dim); flex-wrap: wrap; }
.fchip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 11px; }
.ftags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.tagchip { font-size: 10.5px; color: var(--acc2); background: rgba(129,140,248,.12); border: 1px solid rgba(129,140,248,.25); padding: 1px 8px; border-radius: 20px; cursor: pointer; }
.tagchip:hover { background: rgba(129,140,248,.22); }
.badge-ext { position: absolute; top: 12px; right: 12px; font-size: 9.5px; letter-spacing: .5px; color: var(--dim);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; text-transform: uppercase; background: rgba(7,11,22,.6); }
.empty { text-align: center; padding: 70px 20px; color: var(--dim); }
.empty .big { font-size: 44px; margin-bottom: 12px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 22px; }
.pager .pg-info { font-size: 12px; color: var(--dim); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: flex-start; justify-content: center;
  background: rgba(4,7,15,.72); backdrop-filter: blur(6px); overflow: auto; padding: 6vh 16px 40px; }
.modal.show { display: flex; animation: fadeIn .18s; }
.modal-box {
  width: 520px; max-width: 100%; background: var(--panel); border: 1px solid var(--border2);
  border-radius: 18px; padding: 22px 24px; animation: slideUp .22s; box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
.modal-box.wide { width: min(980px, 96vw); }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.modal-title { font-size: 15.5px; font-weight: 700; flex: 1; word-break: break-all; }
.modal-x { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--border); background: var(--card2);
  color: var(--muted); cursor: pointer; font-size: 14px; flex-shrink: 0; }
.modal-x:hover { color: var(--danger); border-color: rgba(248,113,113,.4); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } }

/* ---------- 详情弹窗 ---------- */
.pv-area {
  background: #050912; border: 1px solid var(--border); border-radius: 12px;
  min-height: 300px; height: 56vh; position: relative; overflow: hidden; margin-bottom: 15px;
  display: flex; align-items: center; justify-content: center;
}
.pv-area img, .pv-area video { max-width: 100%; max-height: 100%; object-fit: contain; }
.pv-area iframe { width: 100%; height: 100%; border: none; }
.pv-area pre.text-pv {
  width: 100%; height: 100%; overflow: auto; margin: 0; padding: 14px 16px;
  font-size: 12px; line-height: 1.55; font-family: Consolas, "JetBrains Mono", monospace;
}
.pv-fallback { text-align: center; color: var(--dim); }
.pv-fallback .big { font-size: 52px; margin-bottom: 10px; }
.pv-loading { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; color: var(--dim); font-size: 12.5px; z-index: 5; background: rgba(5,9,18,.8); }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--acc); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pv-progress { width: 200px; height: 5px; background: var(--border); border-radius: 5px; overflow: hidden; }
.pv-progress i { display: block; height: 100%; width: 0%; background: var(--grad); transition: width .2s; border-radius: 5px; }
.pv3d-info, .gcode-info {
  position: absolute; left: 10px; bottom: 10px; z-index: 4; font-size: 11px; color: var(--muted);
  background: rgba(7,11,22,.78); border: 1px solid var(--border); border-radius: 9px; padding: 7px 11px; line-height: 1.7;
  backdrop-filter: blur(4px); max-width: 70%;
}
.gcode-info b { color: var(--acc); }
.pv-hint { position: absolute; right: 10px; top: 10px; z-index: 4; font-size: 10.5px; color: var(--dim);
  background: rgba(7,11,22,.7); border-radius: 8px; padding: 4px 9px; border: 1px solid var(--border); }
.detail-meta h3 { font-size: 15px; word-break: break-all; margin-bottom: 8px; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.meta-pill { font-size: 11.5px; color: var(--muted); background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 10px; }
.meta-pill b { color: var(--text); font-weight: 600; }
.detail-desc { font-size: 12.5px; color: var(--muted); line-height: 1.65; margin: 8px 0; white-space: pre-wrap; word-break: break-all; }
.detail-actions { display: flex; gap: 9px; margin-top: 14px; flex-wrap: wrap; }
.edit-form { border: 1px dashed var(--border2); border-radius: 12px; padding: 14px; margin-top: 12px; }
.edit-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 上传 ---------- */
.dropzone {
  border: 2px dashed var(--border2); border-radius: 14px; padding: 30px 16px; text-align: center;
  color: var(--dim); cursor: pointer; transition: .2s; margin-bottom: 15px; font-size: 13px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--acc); color: var(--acc); background: rgba(34,211,238,.05); }
.dropzone .big { font-size: 34px; margin-bottom: 8px; }
.upl-list { max-height: 180px; overflow: auto; margin-bottom: 14px; }
.upl-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.upl-row .n { flex: 1; word-break: break-all; }
.upl-row .s { color: var(--dim); flex-shrink: 0; font-size: 11px; }
.upl-bar { width: 90px; height: 5px; background: var(--border); border-radius: 5px; overflow: hidden; flex-shrink: 0; }
.upl-bar i { display: block; height: 100%; background: var(--grad); width: 0%; transition: width .2s; }
.upl-row.done .st { color: var(--ok); } .upl-row.err .st { color: var(--danger); }
.upl-row .st { width: 52px; text-align: right; color: var(--dim); flex-shrink: 0; font-size: 11.5px; }

/* ---------- 表格（管理页） ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab { padding: 8px 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--card2);
  color: var(--muted); cursor: pointer; font-size: 13.5px; }
.tab.active { background: linear-gradient(90deg, rgba(34,211,238,.15), rgba(129,140,248,.12)); color: var(--text); border-color: rgba(129,140,248,.4); font-weight: 600; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--dim); font-size: 11.5px; font-weight: 600; letter-spacing: 1px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid rgba(29,43,82,.55); }
.tbl tr:hover td { background: rgba(129,140,248,.045); }
.badge { display: inline-block; font-size: 11px; padding: 2px 10px; border-radius: 20px; }
.badge.admin { color: var(--acc3); background: rgba(244,114,182,.12); border: 1px solid rgba(244,114,182,.3); }
.badge.user { color: var(--acc); background: rgba(34,211,238,.1); border: 1px solid rgba(34,211,238,.28); }
.badge.on { color: var(--ok); background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.3); }
.badge.off { color: var(--danger); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { font-size: 14px; margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .fld-group { margin-bottom: 0; }
.cat-line { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.cat-line input[type="color"] { width: 38px; height: 32px; padding: 2px; cursor: pointer; }
.cat-line input[type="text"] { flex: 1; max-width: 240px; }
.cat-line .cnt { color: var(--dim); font-size: 12px; }

/* ---------- 登录页 ---------- */
.auth-bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.auth-bg i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; }
.auth-bg i:nth-child(1) { width: 480px; height: 480px; background: #1d4ed8; top: -140px; right: -80px; }
.auth-bg i:nth-child(2) { width: 420px; height: 420px; background: #0e7490; bottom: -120px; left: -100px; }
.auth-bg i:nth-child(3) { width: 300px; height: 300px; background: #a21caf; top: 45%; left: 55%; opacity: .22; }
.auth-wrap { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 400px; max-width: 100%; background: rgba(13,20,40,.88); backdrop-filter: blur(16px);
  border: 1px solid var(--border2); border-radius: 20px; padding: 34px 32px; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.auth-card .brand { margin-bottom: 6px; }
.auth-title { font-size: 20px; font-weight: 700; margin: 16px 0 4px; }
.auth-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 24px; }
.auth-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 10px; }
.auth-card .btn-primary { width: 100%; height: 42px; justify-content: center; font-size: 14.5px; margin-top: 4px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: 11.5px; color: var(--dim); }

/* ---------- 用户菜单 / 通知 ---------- */
.userchip { position: relative; }
.chip-btn { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card2); cursor: pointer; color: var(--text); font-size: 13px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #071022;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.umenu { position: absolute; right: 0; top: 44px; width: 180px; background: var(--panel); border: 1px solid var(--border2);
  border-radius: 12px; padding: 6px; display: none; box-shadow: 0 18px 50px rgba(0,0,0,.5); z-index: 60; }
.umenu.show { display: block; }
.umenu button, .umenu a { display: flex; width: 100%; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 8px;
  border: none; background: none; color: var(--muted); font-size: 13px; cursor: pointer; text-align: left; }
.umenu button:hover, .umenu a:hover { background: var(--card2); color: var(--text); }
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast { background: var(--panel); border: 1px solid var(--border2); border-left: 3px solid var(--acc);
  border-radius: 11px; padding: 11px 16px; font-size: 13px; min-width: 220px; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); animation: slideUp .25s; word-break: break-all; }
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .search-wrap { max-width: none; }
  .brand-sub { display: none; }
  .pv-area { height: 44vh; }
}
