:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --ink-2: #5b6472;
  --ink-3: #8b95a5;
  --line: #e5e8ee;
  --line-2: #eef1f5;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --brand-soft: #eef3fe;
  --ok: #0f9d58;
  --ok-soft: #e8f7ee;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px -8px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }

.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.ta-r { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline { display: inline; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 58px; padding: 0 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 15px; }
.logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(160deg, #3b82f6, #1d4ed8);
  color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; flex: none;
}
.logo.lg { width: 46px; height: 46px; border-radius: 13px; font-size: 22px; }
.nav { display: flex; gap: 4px; margin-left: 6px; }
.nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--ink-2);
  font-weight: 500; font-size: 13.5px;
}
.nav a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.whoami { font-size: 13px; color: var(--ink-2); max-width: 160px; overflow: hidden;
          text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 22px 70px; }
.wrap.narrow { max-width: 430px; padding-top: 8vh; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin-bottom: 18px; flex-wrap: wrap;
}
.head-actions { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card.tight { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}

/* ---------- 表单 ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.field input, .field select, .search, .link, .editbox input {
  width: 100%; padding: 9px 11px; font: inherit;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .search:focus, .link:focus, .editbox input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
.field.sm { gap: 4px; }
.field.sm.grow { flex: 1 1 200px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--brand); width: 15px; height: 15px; flex: none; }
.check em { font-style: normal; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 550;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #fafbfc; border-color: #d7dce5; text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-danger { color: var(--danger); border-color: #f3c8c4; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #e9b2ad; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 提示 ---------- */
.alert { padding: 10px 13px; border-radius: 9px; font-size: 13.5px; margin-bottom: 14px; }
.alert-err { background: var(--danger-soft); color: #8a2b21; border: 1px solid #f3c8c4; }
.alert-ok { background: var(--ok-soft); color: #0b6b3d; border: 1px solid #bde5cd; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 550; line-height: 1.7; white-space: nowrap;
}
.tag-green { background: var(--ok-soft); color: #0b6b3d; }
.tag-red { background: var(--danger-soft); color: #8a2b21; }
.tag-grey { background: var(--line-2); color: var(--ink-2); }

/* ---------- 登录 ---------- */
.auth-card { padding: 30px 28px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .logo { margin-bottom: 14px; }
.auth-head h1 { font-size: 19px; }
.auth-head p { margin: 6px 0 0; font-size: 13px; }
.auth-foot { display: flex; justify-content: space-between; margin-top: 18px; font-size: 13px; }
.err-code { font-size: 44px; font-weight: 750; color: var(--brand); letter-spacing: -.02em; }

/* ---------- 上传 ---------- */
.dropzone {
  border: 1.5px dashed #cdd5e0; border-radius: var(--radius);
  padding: 34px 20px; text-align: center; cursor: pointer;
  background: #fbfcfe; transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dz-icon { width: 34px; height: 34px; color: var(--brand); margin-bottom: 6px; }
.dz-title { margin: 4px 0; font-size: 14.5px; }
.linklike {
  background: none; border: 0; padding: 0; font: inherit;
  color: var(--brand-ink); font-weight: 600; cursor: pointer; text-decoration: underline;
}
.options { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.opt-grid { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

.qlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.qrow { display: grid; grid-template-columns: minmax(0,1fr) 180px 88px; gap: 12px; align-items: center; }
.qmeta { min-width: 0; display: flex; flex-direction: column; }
.qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand);
         border-radius: 99px; transition: width .2s; }
.qrow.ok .bar i { background: var(--ok); }
.qrow.bad .bar i { background: var(--danger); }
.qstat { text-align: right; }
.qrow.bad .qstat { color: var(--danger); }

.results { display: flex; flex-direction: column; gap: 12px; }
.result { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.r-top { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.r-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 12px; color: var(--ink-2); background: var(--line-2);
         padding: 1px 8px; border-radius: 20px; flex: none; }
.linkrow { display: flex; gap: 8px; align-items: center; }
.linkrow .link { flex: 1; font-size: 12.5px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.qrbox { display: flex; align-items: center; gap: 16px; margin-top: 12px;
         padding-top: 12px; border-top: 1px dashed var(--line); }
.qr { width: 132px; height: 132px; background: #fff; border: 1px solid var(--line);
      border-radius: 9px; padding: 6px; flex: none; }

/* ---------- 文件列表 ---------- */
.search { width: 230px; }
.table-head, .row, .utable-head, .urow {
  display: grid; align-items: center; gap: 12px; padding: 0 16px;
}
.table-head {
  height: 40px; font-size: 12px; font-weight: 600; color: var(--ink-3);
  background: #fafbfc; border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0,1fr) 84px 168px 74px 122px 292px;
}
.table-head > span:last-child { text-align: right; }
.rows { display: flex; flex-direction: column; }
.row {
  grid-template-columns: minmax(0,1fr) 84px 168px 74px 122px 292px;
  padding-top: 11px; padding-bottom: 11px;
  border-bottom: 1px solid var(--line-2);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #fbfcfe; }
.row.dead { opacity: .62; }
.c-file { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ficon {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  display: grid; place-items: center; background: var(--line-2); color: var(--ink-2);
}
.ficon svg { width: 16px; height: 16px; }
.k-text { background: #eef3fe; color: #2563eb; }
.k-image { background: #eaf7f0; color: #0f9d58; }
.k-pdf { background: #fdecea; color: #d92d20; }
.k-audio { background: #f4eefe; color: #7c3aed; }
.k-video { background: #fef4e7; color: #b45309; }
.fmeta { min-width: 0; display: flex; flex-direction: column; }
.fname { font-size: 13.5px; font-weight: 550; overflow: hidden;
         text-overflow: ellipsis; white-space: nowrap; }
.fsub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-state { display: flex; gap: 5px; flex-wrap: wrap; }
.c-act { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.row .qrbox { grid-column: 1 / -1; }
.editbox { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.editbox .field.sm { max-width: 380px; }
.edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { text-align: center; padding: 54px 20px; color: var(--ink-2); }
.empty p { margin: 0 0 14px; }

/* ---------- 预览 ---------- */
.code-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.code {
  margin: 0; padding: 15px; background: #fbfcfe; border: 1px solid var(--line);
  border-radius: 10px; overflow: auto; max-height: 72vh;
  font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
}
.media { text-align: center; }
.media img { max-width: 100%; max-height: 76vh; border-radius: 8px; }
.media iframe { width: 100%; height: 76vh; border: 0; border-radius: 8px; background: #fff; }

/* ---------- 管理 ---------- */
.utable-head, .urow { grid-template-columns: minmax(0,1fr) 56px 84px 62px 62px 218px; }
.utable-head {
  height: 36px; font-size: 12px; font-weight: 600; color: var(--ink-3);
  border-bottom: 1px solid var(--line); padding: 0; margin-bottom: 6px;
}
.urow { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.utable-head { padding: 0; }
.urow:last-child { border-bottom: 0; }
.u-name { display: flex; flex-direction: column; min-width: 0; }
.u-act { display: flex; gap: 6px; justify-content: flex-end; }

.logs { max-height: 340px; overflow: auto; display: flex; flex-direction: column; }
.logline {
  display: grid; grid-template-columns: 122px 108px 96px minmax(0,1fr) 116px;
  gap: 10px; align-items: center; padding: 6px 0;
  border-bottom: 1px solid var(--line-2);
}
.logline:last-child { border-bottom: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(14px);
  background: #16181d; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 10px 30px -8px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 100; pointer-events: none;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1080px) {
  .table-head { display: none; }
  .row { grid-template-columns: 1fr; gap: 8px; }
  .c-act { justify-content: flex-start; }
}
