/* 工业风 · 浅蓝 — 蓝图网格 / 钢青面板 / 工程仪表感 */
:root {
  --bg: #e8eef4;
  --bg-elevated: #f7fafc;
  --bg-soft: #dce6ef;
  --bg-steel: #d0dce8;
  --ink: #15202b;
  --ink-2: #3d5163;
  --ink-3: #6b8299;
  --line: #c3d0dc;
  --line-strong: #9eb0c2;
  --accent: #1a7f9e;
  --accent-deep: #0f5c75;
  --accent-soft: #c8e4ef;
  --accent-glow: rgba(26, 127, 158, 0.18);
  --panel: #f0f5f9;
  --grid-line: rgba(90, 120, 150, 0.12);
  --shadow: 0 8px 24px rgba(30, 55, 80, 0.08);
  --shadow-deep: 0 12px 32px rgba(20, 45, 70, 0.14);
  --radius: 4px;
  --sidebar-w: 256px;
  --preview-w: min(540px, 46vw);
  --mono: "Cascadia Code", "Consolas", "SF Mono", "Menlo", monospace;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-family: var(--sans);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.35), transparent 40%);
  background-size: 24px 24px, 24px 24px, 100% 100%;
}

button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

#app.preview-open {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--preview-w);
}

/* ——— 侧栏：仪表盘外壳 ——— */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px;
  background:
    linear-gradient(180deg, #eef3f8 0%, #e2eaf2 100%);
  border-right: 1px solid var(--line-strong);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.55);
  position: relative;
}

.sidebar::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: repeating-linear-gradient(
    180deg,
    var(--accent) 0 8px,
    transparent 8px 16px
  );
  opacity: 0.55;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  color: #eaf6fa;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  background:
    linear-gradient(145deg, #2a8fad 0%, #15627c 55%, #0d4a5f 100%);
  border: 1px solid #0d4a5f;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.25),
    0 4px 10px rgba(15, 90, 115, 0.28);
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 15px;
  text-transform: none;
}

.brand-sub {
  color: var(--ink-3);
  font-size: 11px;
  margin-top: 3px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

.source-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 2px;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.source-label,
.crumb-wrap::before {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.source-label::before { content: "// "; color: var(--accent); }

.source-select { width: 100%; }

.btn-sm {
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.crumb-wrap {
  max-height: 92px;
  overflow: auto;
  padding: 8px 2px 0;
  border-top: 1px dashed var(--line);
}

.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  font-size: 12px;
  font-family: var(--mono);
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

.crumb-item {
  border: 0;
  background: transparent;
  color: var(--accent-deep);
  padding: 4px 6px;
  border-radius: 2px;
  cursor: pointer;
}

.crumb-item:hover { background: var(--accent-soft); }
.crumb-item.active {
  color: var(--ink);
  font-weight: 700;
  cursor: default;
  background: rgba(26, 127, 158, 0.1);
}

.crumb-sep { color: var(--ink-3); user-select: none; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  border-radius: 3px;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  background: rgba(255,255,255,0.65);
  border-color: var(--line);
  color: var(--ink);
}

.nav-item.active {
  background: linear-gradient(90deg, var(--accent-soft), rgba(200, 228, 239, 0.35));
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 2px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  background: rgba(26, 127, 158, 0.1);
  color: var(--accent-deep);
  border: 1px solid rgba(26, 127, 158, 0.25);
  flex: 0 0 auto;
}

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--ink-3);
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 2px;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.source-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 2px;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--bg-steel);
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  letter-spacing: 0.02em;
}

.hint {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.55;
}

.admin-link {
  text-align: center;
  text-decoration: none;
  display: block;
}

/* ——— 控件 ——— */
.btn {
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #fbfcfe, #e9eff5);
  color: var(--ink);
  border-radius: 3px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 1px 0 rgba(255,255,255,0.4);
  transition: background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: linear-gradient(180deg, #fff, #eef4f8);
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 2px rgba(20, 40, 60, 0.12);
}

.btn-primary {
  background: linear-gradient(180deg, #2a96b8, #15627c);
  border-color: #0f5c75;
  color: #f0fafc;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 2px 8px rgba(21, 98, 124, 0.28);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #33a8cc, #1a6f8c);
  box-shadow: 0 4px 14px rgba(21, 98, 124, 0.35);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
  box-shadow: none;
}

.btn-ghost:hover { background: var(--bg-soft); box-shadow: none; }

/* ——— 主区 ——— */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: rgba(240, 245, 249, 0.35);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px 10px;
}

.search-wrap { position: relative; flex: 1; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  font-size: 16px;
  font-family: var(--mono);
}

#searchInput {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  border-radius: 3px;
  padding: 11px 14px 11px 38px;
  outline: none;
  font-family: var(--mono);
  font-size: 13px;
  box-shadow: inset 0 1px 2px rgba(30, 55, 80, 0.06);
}

#searchInput::placeholder {
  color: var(--ink-3);
  font-family: var(--sans);
}

#searchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.seg {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  overflow: hidden;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 10px 12px;
  cursor: pointer;
  font-family: var(--mono);
}

.seg-btn + .seg-btn { border-left: 1px solid var(--line); }

.seg-btn.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.select {
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  border-radius: 3px;
  padding: 10px 12px;
  color: var(--ink-2);
  outline: none;
  font-size: 13px;
}

.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.status-bar {
  padding: 0 22px 8px;
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0.01em;
}

.content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 22px 22px;
}

.file-grid { display: grid; gap: 12px; }

.file-grid.view-grid {
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}

.file-grid.view-list {
  grid-template-columns: 1fr;
  gap: 6px;
}

/* ——— 文件卡片 ——— */
.file-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
  position: relative;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,0.7);
}

.file-card::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 10px; height: 10px;
  background:
    linear-gradient(225deg, var(--bg-steel) 50%, transparent 50%);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  opacity: 0.7;
  pointer-events: none;
}

.file-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.file-card:hover::after { opacity: 0; }

.file-card.active {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 6px 16px var(--accent-glow);
}

.file-card.active::after { opacity: 0; }

.view-grid .file-thumb {
  height: 120px;
  background:
    linear-gradient(180deg, #f7fafc 0%, #e8eef4 100%);
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.view-grid .file-thumb::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 12px 12px;
  opacity: 0.7;
  pointer-events: none;
}

.view-grid .file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: relative;
  z-index: 1;
}

.view-grid .file-body {
  padding: 11px 12px 12px;
  background: linear-gradient(180deg, #fbfcfe, #f3f7fa);
}

.view-list .file-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
}

.view-list .file-card::after { display: none; }

.view-list .file-thumb {
  width: 40px;
  height: 40px;
  border-radius: 2px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.view-list .file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.view-list .file-body { min-width: 0; }
.view-list .file-meta { text-align: right; white-space: nowrap; }

.type-chip {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 2px;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
  border: 1px solid transparent;
}

.type-word { background: #dceaf8; color: #1a4f7a; border-color: #a8c4de; }
.type-excel { background: #d8efe6; color: #0d5c3e; border-color: #9ec9b5; }
.type-pdf { background: #f8e4df; color: #8b2e1f; border-color: #d9b0a6; }
.type-ppt { background: #f7e8d4; color: #8a4b12; border-color: #d4b48a; }
.type-image { background: #e4e0f5; color: #3f3480; border-color: #b8b0d9; }
.type-other { background: var(--bg-steel); color: var(--ink-2); border-color: var(--line-strong); }

.folder-badge {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 2px;
  font-size: 20px;
  background: #d9e8f2;
  color: #1a5f7a;
  border: 1px solid #9ebdd0;
  position: relative;
  z-index: 1;
}

.file-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-list .file-name { font-size: 14px; }

.file-path {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--mono);
  margin-top: 8px;
}

.view-list .file-meta { margin-top: 0; }

.empty {
  margin: 10vh auto 0;
  text-align: center;
  max-width: 380px;
  padding: 28px;
  background: var(--bg-elevated);
  border: 1px dashed var(--line-strong);
  border-radius: 3px;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.empty-desc { color: var(--ink-2); line-height: 1.6; font-size: 13px; }

/* ——— 预览面板 ——— */
.preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-elevated);
  border-left: 1px solid var(--line-strong);
  box-shadow: -8px 0 24px rgba(20, 45, 70, 0.08);
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #eef4f8, #e6edf3);
}

.preview-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  word-break: break-all;
  letter-spacing: 0.01em;
}

.preview-meta {
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--mono);
  line-height: 1.5;
}

.preview-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.preview-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 16px 16px;
}

.preview-body iframe,
.preview-body img,
.preview-body video {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #f7fafc;
  box-shadow: var(--shadow);
}

.preview-body img { max-width: 100%; height: auto; }
.preview-body iframe { min-height: 70vh; height: 70vh; }

.doc-html {
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.doc-html th,
.doc-html td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

.doc-html th {
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 12px;
}

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

.sheet-tab {
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  color: var(--ink-2);
  border-radius: 2px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
}

.sheet-tab.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: var(--accent);
  font-weight: 700;
}

.sheet-wrap {
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.sheet-wrap table {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 12px;
  font-family: var(--mono);
}

.sheet-wrap th,
.sheet-wrap td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 6px 8px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-wrap th {
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}

.ppt-slide {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.ppt-slide h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--accent-deep);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}

.ppt-slide ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.notice {
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #f7fafc, #e9f1f6);
  color: var(--ink-2);
  border-radius: 2px;
  padding: 14px;
  line-height: 1.65;
  font-size: 13px;
}

.notice strong {
  color: var(--accent-deep);
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  font-size: 13px;
  font-family: var(--mono);
  padding: 24px 8px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ——— 拖拽遮罩 ——— */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 40, 55, 0.35);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 50;
}

.drop-card {
  background: var(--bg-elevated);
  border: 2px dashed var(--accent);
  border-radius: 4px;
  padding: 36px 48px;
  box-shadow: var(--shadow-deep);
  text-align: center;
}

.drop-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-family: var(--mono);
  color: var(--accent-deep);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
}

.drop-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ——— 后端未启动 ——— */
.backend-down {
  margin: 8vh auto;
  max-width: 440px;
  text-align: center;
  padding: 24px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.backend-down h3 {
  margin: 0 0 8px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--accent-deep);
}

.backend-down p { color: var(--ink-2); line-height: 1.6; margin: 0 0 12px; font-size: 13px; }

.backend-down code {
  display: block;
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px;
  font-size: 12px;
  font-family: var(--mono);
  overflow: auto;
  color: var(--ink);
}

/* ——— 响应式 ——— */
@media (max-width: 1100px) {
  #app, #app.preview-open {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .preview {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(520px, 92vw);
    z-index: 40;
    box-shadow: -16px 0 36px rgba(20, 45, 70, 0.18);
  }
}

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }
  .nav { flex-direction: row; overflow: auto; }
  .nav-item { white-space: nowrap; }
  .topbar { flex-direction: column; align-items: stretch; }
}
