/* ===== 导航门户 · 全站样式 ===== */
:root {
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-dim: #6b7280;
  --text-faint: #9ca3af;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 2px 8px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== 登录页 ===== */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #eef2f7 0%, #e2e8f0 100%);
  padding: 20px;
}
.login-wrap { width: 100%; max-width: 380px; }
.login-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--accent); color: #fff;
  font-size: 24px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.login-brand h1 { font-size: 21px; margin: 0 0 6px; font-weight: 600; }
.login-brand p { font-size: 13px; color: var(--text-dim); margin: 0; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-msg { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 6px; }
.login-foot { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 18px; }

/* ===== 按钮 ===== */
.btn-primary, .btn-ghost, .btn-danger, .btn-sm {
  border: none; border-radius: 8px; cursor: pointer;
  transition: background .15s, opacity .15s;
  font-size: 14px;
}
.btn-primary { background: var(--accent); color: #fff; padding: 10px 18px; font-weight: 500; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); padding: 9px 16px; }
.btn-ghost:hover { background: #f9fafb; }
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; padding: 6px 12px; font-size: 13px; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { background: #f3f4f6; color: var(--text); padding: 6px 12px; font-size: 13px; border: 1px solid var(--border); }
.btn-sm:hover { background: #e5e7eb; }

/* ===== 门户主框架 ===== */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 15px;
}
.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 20px; background: #f3f4f6;
  font-size: 13px; cursor: pointer; position: relative;
}
.user-chip:hover { background: #e5e7eb; }
.user-menu {
  position: absolute; right: 0; top: 42px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  min-width: 160px; padding: 6px; display: none; z-index: 100;
}
.user-menu.open { display: block; }
.user-menu button {
  display: block; width: 100%; text-align: left; padding: 9px 12px;
  background: none; border: none; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text);
}
.user-menu button:hover { background: #f3f4f6; }
.user-menu .sep { height: 1px; background: var(--border); margin: 4px 0; }

.main { display: flex; flex: 1; min-height: 0; }

/* 侧边栏布局 */
.sidebar {
  width: 236px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 10px; overflow-y: auto; flex-shrink: 0;
}
.side-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-faint); padding: 6px 12px; font-weight: 600;
}
.side-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text); font-size: 14px; margin-bottom: 2px;
  transition: background .12s;
}
.side-item:hover { background: #f3f4f6; }
.side-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.side-item .ico { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.side-item .cnt {
  margin-left: auto; font-size: 11px; color: var(--text-faint);
  background: #f3f4f6; padding: 1px 7px; border-radius: 10px;
}
.side-item.active .cnt { background: #dbeafe; color: var(--accent); }

.content { flex: 1; padding: 24px 28px; overflow-y: auto; min-width: 0; }

/* 内容区标题 */
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 20px; margin: 0 0 5px; font-weight: 600; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* 文档列表（侧边栏模式下） */
.doc-list { display: grid; gap: 10px; }
.doc-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.doc-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.doc-item:active { transform: scale(.995); }
.doc-icon {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.doc-icon.t-link { background: #dbeafe; }
.doc-icon.t-html { background: #dcfce7; }
.doc-icon.t-excel { background: #fef3c7; }
.doc-body { flex: 1; min-width: 0; }
.doc-body h4 { margin: 0 0 2px; font-size: 14px; font-weight: 500; }
.doc-body p { margin: 0; font-size: 12px; color: var(--text-faint); }
.doc-tag {
  font-size: 11px; padding: 3px 9px; border-radius: 6px; flex-shrink: 0;
  background: #f3f4f6; color: var(--text-dim);
}

/* 网格布局 */
.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.grid-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s;
  display: flex; flex-direction: column; gap: 10px;
}
.grid-card:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-2px); }
.grid-card .gc-ico { font-size: 24px; }
.grid-card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.grid-card p { margin: 0; font-size: 12.5px; color: var(--text-dim); flex: 1; }
.grid-card .gc-meta { font-size: 11.5px; color: var(--text-faint); }

/* Tab 布局 */
.tabs-bar {
  display: flex; gap: 4px; background: var(--surface); padding: 8px 20px 0;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab-item {
  padding: 9px 16px; cursor: pointer; font-size: 14px; color: var(--text-dim);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color .12s, border-color .12s;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }

/* 空状态 */
.empty {
  text-align: center; padding: 70px 20px; color: var(--text-faint);
}
.empty .e-ico { font-size: 44px; margin-bottom: 14px; opacity: .5; }
.empty h3 { margin: 0 0 6px; font-size: 15px; color: var(--text-dim); font-weight: 500; }
.empty p { margin: 0; font-size: 13px; }

/* ===== 文档查看器 ===== */
.viewer-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; z-index: 200; padding: 24px;
}
.viewer-overlay.open { display: flex; align-items: center; justify-content: center; }
.viewer {
  background: var(--surface); border-radius: 14px; width: 100%; height: 100%;
  max-width: 1400px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.viewer-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.viewer-actions { display: flex; gap: 8px; align-items: center; }
.viewer-body { flex: 1; overflow: auto; background: #fff; min-height: 0; }
.viewer-body iframe { width: 100%; height: 100%; border: none; display: block; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 15px; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }

/* ===== Excel 表格 ===== */
.xlsx-wrap { padding: 0; }
.xlsx-sheets {
  display: flex; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: #fafbfc; overflow-x: auto; position: sticky; top: 0; z-index: 5;
}
.xlsx-sheet-tab {
  padding: 6px 14px; border-radius: 7px; cursor: pointer; font-size: 13px;
  background: #fff; border: 1px solid var(--border); white-space: nowrap; color: var(--text-dim);
}
.xlsx-sheet-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.xlsx-scroll { overflow: auto; max-height: calc(100vh - 220px); }
table.xlsx {
  border-collapse: collapse; font-size: 13px; white-space: nowrap;
  min-width: 100%;
}
table.xlsx th, table.xlsx td {
  border: 1px solid #e8eaed; padding: 7px 11px; text-align: left;
}
table.xlsx th {
  background: #f8fafc; font-weight: 600; position: sticky; top: 0; z-index: 3;
  color: var(--text);
}
table.xlsx tbody tr:nth-child(even) { background: #fcfcfd; }
table.xlsx tbody tr:hover { background: var(--accent-soft); }
table.xlsx td.rowno, table.xlsx th.rowno {
  background: #f8fafc; color: var(--text-faint); text-align: right;
  position: sticky; left: 0; z-index: 2; font-size: 12px; min-width: 44px;
}
table.xlsx th.rowno { z-index: 4; }
.xlsx-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #fafbfc; border-bottom: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim); gap: 12px; flex-wrap: wrap;
}
.xlsx-toolbar .sp { display: flex; gap: 8px; align-items: center; }
.xlsx-pager { display: flex; gap: 6px; align-items: center; }
.xlsx-pager button {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 12.5px; color: var(--text);
}
.xlsx-pager button:disabled { opacity: .45; cursor: not-allowed; }
.xlsx-pager button:not(:disabled):hover { background: #f3f4f6; }

/* ===== 管理后台 ===== */
.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }
.admin-nav {
  width: 210px; background: #1e293b; color: #cbd5e1; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 0;
}
.admin-brand {
  padding: 18px 20px; font-weight: 600; font-size: 15px; color: #fff;
  border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 9px;
}
.admin-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: #38bdf8; }
.admin-nav-items { flex: 1; padding: 12px 10px; }
.admin-nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px;
  border-radius: 8px; cursor: pointer; font-size: 13.5px; margin-bottom: 3px;
  transition: background .12s, color .12s;
}
.admin-nav-item:hover { background: #334155; color: #fff; }
.admin-nav-item.active { background: var(--accent); color: #fff; }
.admin-nav-foot { padding: 12px 10px; border-top: 1px solid #334155; }
.admin-nav-foot .admin-nav-item { font-size: 13px; }
.admin-main { flex: 1; padding: 26px 30px; overflow-y: auto; min-width: 0; }

.admin-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.admin-head h2 { margin: 0; font-size: 19px; font-weight: 600; }
.admin-head p { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 18px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-body { padding: 18px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 11px 14px; background: #f8fafc;
  font-weight: 600; color: var(--text-dim); font-size: 12.5px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfc; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 6px;
  background: #f3f4f6; color: var(--text-dim);
}
.badge.admin { background: #ede9fe; color: #6d28d9; }
.badge.user { background: #e0f2fe; color: #0369a1; }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }
.badge.t-link { background: #dbeafe; color: #1e40af; }
.badge.t-html { background: #dcfce7; color: #166534; }
.badge.t-excel { background: #fef3c7; color: #92400e; }

.sort-handle { cursor: grab; color: var(--text-faint); font-size: 15px; user-select: none; }
.sort-handle:active { cursor: grabbing; }
tr.dragging { opacity: .4; }
tr.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid { display: grid; gap: 14px; }

/* 模态框 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 300;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 620px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600;
  font-size: 15px; display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

/* Toast */
.toast-box { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; padding: 11px 18px; border-radius: 9px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); animation: slideIn .2s ease;
  max-width: 340px;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* 上传区 */
.upload-box {
  border: 2px dashed var(--border); border-radius: 10px; padding: 22px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  background: #fafbfc;
}
.upload-box:hover, .upload-box.drag { border-color: var(--accent); background: var(--accent-soft); }
.upload-box .u-ico { font-size: 28px; margin-bottom: 8px; opacity: .6; }
.upload-box .u-txt { font-size: 13.5px; color: var(--text-dim); }
.upload-box .u-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.file-chosen { margin-top: 10px; font-size: 13px; color: var(--ok); font-weight: 500; }

.type-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.type-opt {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 13px 10px;
  text-align: center; cursor: pointer; transition: all .15s;
}
.type-opt:hover { border-color: #cbd5e1; background: #fafbfc; }
.type-opt.active { border-color: var(--accent); background: var(--accent-soft); }
.type-opt .t-ico { font-size: 20px; margin-bottom: 5px; }
.type-opt .t-name { font-size: 13px; font-weight: 500; }
.type-opt .t-desc { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 11px; background: #cbd5e1;
  position: relative; transition: background .18s;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }

@media (max-width: 820px) {
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .main { flex-direction: column; }
  .admin-nav { width: 60px; }
  .admin-nav .label, .admin-brand .txt { display: none; }
  .content { padding: 18px 16px; }
  .admin-main { padding: 18px 16px; }
  .type-choice { grid-template-columns: 1fr; }
}
