:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #fafbfc;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #16181d;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2f6bf0;
  --accent-soft: #eaf1fe;
  --danger: #d64545;
  --danger-soft: #fdecec;
  --ok: #0f8f5f;
  --ok-soft: #e7f6ef;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --radius: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
}

/* hidden 属性必须压过 .login-layer / .app-shell 上的 display 声明，
   否则登录层永远不会消失，表现为「输入密码后没反应」。 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
}

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

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* ---------- 登录 ---------- */

.login-layer {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 50;
}

.login-card {
  width: 340px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

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

.login-card p {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
}

.login-error {
  min-height: 18px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 12px;
}

/* ---------- 布局 ---------- */

.app-shell {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--text);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.brand strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.brand small {
  color: var(--text-faint);
  font-size: 11px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 10px 0;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 11px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.topbar .eyebrow {
  margin: 0 0 2px;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view {
  padding: 22px 26px 60px;
}

/* ---------- 通用组件 ---------- */

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

.card + .card {
  margin-top: 16px;
}

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

.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.card-head p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-muted);
}

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

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

.btn-primary:hover:not(:disabled) {
  background: #2559d0;
}

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

.btn-danger:hover:not(:disabled) {
  background: #bf3a3a;
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-off {
  background: #f0f1f3;
  color: var(--text-muted);
}

.pill-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

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

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

.stat span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  font-weight: 600;
}

.notice {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 14px;
}

.notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.notice-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

/* ---------- 字体表 ---------- */

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

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

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: var(--surface-muted);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.order-badge {
  display: inline-block;
  min-width: 44px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  text-align: center;
}

.tag {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

/* ---------- 上传区 ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone strong {
  font-size: 13px;
  font-weight: 500;
}

.dropzone span {
  color: var(--text-muted);
  font-size: 12px;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  color: var(--text-muted);
  font-size: 12px;
}

.field input,
.field select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  outline: none;
  font-size: 13px;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.field small {
  color: var(--text-faint);
  font-size: 11px;
}

.progress {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 10px;
}

.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s ease;
}

/* ---------- 资源网格 ---------- */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
}

.tab.is-active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  cursor: pointer;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile .tile-meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 8px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0));
  color: #fff;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.tile .tile-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.15);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: transparent;
}

.tile.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tile.is-selected .tile-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tile .tile-badge {
  position: absolute;
  top: 8px;
  right: 8px;
}

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

.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- 详情抽屉 ---------- */

.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 22, 0.32);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  z-index: 41;
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
}

.drawer-body img {
  width: 100%;
  border-radius: var(--radius);
  background: var(--surface-muted);
  margin-bottom: 14px;
}

.kv {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 6px 10px;
  font-size: 12px;
  margin-bottom: 16px;
}

.kv dt {
  color: var(--text-muted);
}

.kv dd {
  margin: 0;
  word-break: break-all;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.drawer-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(22, 24, 29, 0.92);
  color: #fff;
  font-size: 13px;
  z-index: 60;
  max-width: 80vw;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }
  .brand {
    padding: 0 12px 0 4px;
  }
  .sidebar-footer {
    display: none;
  }
  .upload-panel {
    grid-template-columns: 1fr;
  }
  .view {
    padding: 16px;
  }
}
