/* ==========================================================================
   yin0328.cn 文件管理器 —— 仿 Windows 资源管理器
   ========================================================================== */

:root {
  --accent: #0a5cd8;
  --accent-hover: #0b4fb8;
  --accent-soft: #e8f0fd;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-side: #f3f4f6;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --text: #1b1f24;
  --text-dim: #6a7280;
  --danger: #c42b1c;
  --danger-soft: #fdeceb;
  --radius: 6px;
  --toolbar-h: 46px;
  --status-h: 26px;
}

* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input { font-family: inherit; font-size: inherit; }

[hidden] { display: none !important; }

/* ==================== 登录页 ==================== */

.login-wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 400px at 15% 0%, #e8f0fd, transparent 60%),
    radial-gradient(700px 350px at 90% 100%, #eef0f5, transparent 60%),
    var(--bg-soft);
  overflow: auto;
}

.login-card {
  width: 100%;
  max-width: 350px;
  margin: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 34px 30px 26px;
  box-shadow: 0 2px 6px rgba(16,24,40,.05), 0 18px 44px rgba(16,24,40,.10);
}

.login-logo { font-size: 40px; line-height: 1; text-align: center; }
.login-card h1 {
  margin: 12px 0 2px;
  font-size: 19px;
  font-weight: 650;
  text-align: center;
}
.login-sub {
  margin: 0 0 26px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
}
.field input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,92,216,.14);
}

.login-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  border: 1px solid #f3c9c5;
  color: var(--danger);
  font-size: 13px;
}

.login-hint {
  margin: 16px 0 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  font-weight: 550;
  cursor: pointer;
  transition: background .13s, border-color .13s, color .13s;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a8231a; border-color: #a8231a; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ==================== 主界面骨架 ==================== */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---- 工具条 ---- */
.toolbar {
  flex: none;
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}

.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-right { margin-left: auto; gap: 6px; }

.tb-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background .12s, border-color .12s;
}
.tb-btn:hover { background: #e9ebef; border-color: var(--line); }
.tb-btn:active { background: #dfe2e8; }
.tb-btn:disabled { opacity: .35; cursor: default; background: transparent; border-color: transparent; }
.tb-btn-sm { min-width: 24px; height: 24px; font-size: 12px; }

/* 面包屑 */
.breadcrumb {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 1px;
  height: 30px;
  padding: 0 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
}
.breadcrumb::-webkit-scrollbar { height: 4px; }
.breadcrumb::-webkit-scrollbar-thumb { background: #c8ccd4; border-radius: 2px; }

.crumb {
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.crumb:hover { background: var(--accent-soft); color: var(--accent); }
.crumb.current { font-weight: 600; }
.crumb-sep { color: #aeb4bf; flex: none; padding: 0 1px; }

/* 搜索框 */
.tb-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 190px;
  flex: none;
}
.tb-search input {
  width: 100%;
  height: 30px;
  padding: 0 26px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
}
.tb-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,92,216,.13); }
.tb-search .tb-btn { position: absolute; right: 3px; }

/* 用户标识 */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  font-weight: 550;
  max-width: 170px;
  overflow: hidden;
  white-space: nowrap;
}
.badge {
  padding: 1px 6px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  flex: none;
}

/* ---- 主体 ---- */
.body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---- 侧边栏 ---- */
.sidebar {
  flex: none;
  width: 232px;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding-bottom: 16px;
}
.sidebar::-webkit-scrollbar { width: 9px; }
.sidebar::-webkit-scrollbar-thumb { background: #c9cdd5; border-radius: 5px; border: 2px solid var(--bg-side); }

.side-head {
  padding: 12px 14px 5px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.tree { list-style: none; margin: 0; padding: 0 6px; }
.tree ul { list-style: none; margin: 0; padding-left: 15px; }

.tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
}
.tree-node:hover { background: #e6e9ee; }
.tree-node.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.tw {
  width: 14px;
  flex: none;
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  transition: transform .13s;
}
.tw.open { transform: rotate(90deg); }
.tree-icon { flex: none; }
.tree-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.disk {
  margin: 0 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.75;
}
.disk-bar {
  height: 7px;
  margin-top: 7px;
  background: #e6e9ee;
  border-radius: 4px;
  overflow: hidden;
}
.disk-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.disk-fill.warn { background: #d97706; }
.disk-fill.crit { background: var(--danger); }

/* ---- 内容区 ---- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.quickbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-soft);
  border-bottom: 1px solid #d3e0f7;
  font-size: 12.5px;
}
#quickCount { margin-right: 8px; font-weight: 600; color: var(--accent); }
.qb-btn {
  height: 26px;
  padding: 0 11px;
  border: 1px solid #c4d6f2;
  border-radius: 13px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-weight: 550;
}
.qb-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.qb-btn.danger { color: var(--danger); border-color: #f0c8c4; }
.qb-btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ---- 详细信息表格 ---- */
.table-wrap {
  flex: 1 1 auto;
  overflow: auto;
  position: relative;
}
.table-wrap::-webkit-scrollbar { width: 11px; height: 11px; }
.table-wrap::-webkit-scrollbar-thumb { background: #c9cdd5; border-radius: 6px; border: 3px solid #fff; }

table.files {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
table.files thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 32px;
  padding: 0 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.files thead th.sortable { cursor: pointer; user-select: none; }
table.files thead th.sortable:hover { background: #e9ebef; color: var(--text); }
table.files thead th.sorted::after {
  content: "▲";
  margin-left: 5px;
  font-size: 9px;
  color: var(--accent);
}
table.files thead th.sorted.desc::after { content: "▼"; }

.col-check { width: 36px; }
.col-name  { width: auto; }
.col-mtime { width: 150px; }
.col-type  { width: 92px; }
.col-size  { width: 88px; text-align: right !important; }
.col-perm  { width: 104px; }
.col-owner { width: 108px; }

tbody tr {
  height: 30px;
  cursor: default;
}
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #eef2f8; }
tbody tr.selected { background: var(--accent-soft) !important; }
tbody tr.selected td { color: var(--accent); }

tbody td {
  padding: 0 10px;
  border-bottom: 1px solid #f0f2f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
tbody td.col-size { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); }
tbody td.col-mtime { color: var(--text-dim); }
tbody td.col-owner { color: var(--text-dim); }

.cell-name {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row-icon { flex: none; font-size: 15px; line-height: 1; }
.row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.is-dir .row-name { font-weight: 550; }

.perm-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eef0f4;
  color: #3b4252;
}
.perm-code.ro { background: #fdf3e3; color: #9a6212; }
.perm-code.rw { background: #e7f5ea; color: #1f7a37; }
.perm-code.full { background: #e8f0fd; color: var(--accent); }

.checkbox { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }

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

/* ---- 图标视图 ---- */
.grid-view {
  flex: 1 1 auto;
  overflow: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
  align-content: start;
}
.grid-item {
  padding: 12px 6px;
  border-radius: var(--radius);
  text-align: center;
  cursor: default;
  border: 1px solid transparent;
}
.grid-item:hover { background: #eef2f8; }
.grid-item.selected { background: var(--accent-soft); border-color: #c4d6f2; }
.grid-icon { font-size: 30px; line-height: 1; margin-bottom: 8px; }
.grid-name {
  font-size: 12.5px;
  line-height: 1.35;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- 状态栏 ---- */
.statusbar {
  flex: none;
  height: var(--status-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-dim);
}

/* ==================== 右键菜单 ==================== */

.ctx-menu {
  position: fixed;
  z-index: 1000;
  min-width: 186px;
  padding: 5px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 4px 10px rgba(16,24,40,.10), 0 14px 34px rgba(16,24,40,.16);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.ctx-item:hover { background: var(--accent-soft); color: var(--accent); }
.ctx-item.disabled { opacity: .4; cursor: default; }
.ctx-item.disabled:hover { background: transparent; color: var(--text); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.ctx-sep { height: 1px; margin: 5px 8px; background: var(--line); }
.ctx-icon { width: 15px; text-align: center; flex: none; }
.ctx-key { margin-left: auto; color: var(--text-dim); font-size: 11.5px; }

/* ==================== 对话框 ==================== */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(16,24,40,.34);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  width: 100%;
  max-width: 470px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 20px 54px rgba(16,24,40,.28);
  overflow: hidden;
}
.modal.wide { max-width: 720px; }
.modal-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.modal-x {
  width: 27px; height: 27px;
  border: 0; background: transparent; border-radius: 5px;
  cursor: pointer; color: var(--text-dim); font-size: 13px;
}
.modal-x:hover { background: var(--bg-soft); color: var(--text); }
.modal-body { flex: 1 1 auto; overflow: auto; padding: 18px; }
.modal-foot {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

/* 表单行 */
.form-row { margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-row > label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 550;
}
.form-row input[type=text],
.form-row input[type=password],
.form-row input[type=number],
.form-row select,
.form-row textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: #fff;
}
.form-row textarea {
  height: auto;
  min-height: 260px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,92,216,.13);
}
.form-hint { margin: 5px 0 0; font-size: 12px; color: var(--text-dim); }

/* 属性面板 */
.prop-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.prop-icon { font-size: 34px; line-height: 1; }
.prop-name { font-weight: 650; font-size: 14.5px; word-break: break-all; }
.prop-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }

.kv { width: 100%; border-collapse: collapse; }
.kv th {
  width: 112px;
  padding: 6px 0;
  text-align: left;
  vertical-align: top;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 12.5px;
}
.kv td { padding: 6px 0; word-break: break-all; }

/* rwx 权限编辑器 */
.perm-editor { display: flex; flex-direction: column; gap: 9px; }
.perm-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 10px;
}
.perm-who { font-size: 12.5px; color: var(--text-dim); font-weight: 550; }
.perm-bits { display: flex; gap: 16px; }
.perm-bit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12.5px;
}
.perm-bit input { accent-color: var(--accent); width: 14px; height: 14px; }

.perm-readout {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.perm-octal {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 16px;
  font-weight: 650;
  color: var(--accent);
}
.perm-sym {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: .06em;
}

.share-box {
  margin-top: 4px;
  padding: 11px 13px;
  border: 1px solid #d3e0f7;
  border-radius: var(--radius);
  background: #f4f8fe;
}
.share-box .perm-bit { margin-right: 18px; }

/* 用户管理表 */
table.utable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.utable th {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
}
table.utable td { padding: 7px 8px; border-bottom: 1px solid #f0f2f5; }
table.utable tr:hover td { background: var(--bg-soft); }
.mini-btn {
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}
.mini-btn:hover { background: var(--bg-soft); }
.mini-btn.danger { color: var(--danger); border-color: #f0c8c4; }
.mini-btn.danger:hover { background: var(--danger-soft); }

/* 搜索结果提示 */
.search-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: #fff8e6;
  border-bottom: 1px solid #f0dfb0;
  font-size: 12.5px;
  color: #8a6212;
}

/* ==================== 上传进度条 ==================== */

.upload-tray {
  position: fixed;
  right: 18px;
  bottom: 42px;
  z-index: 1200;
  width: 290px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: 0 6px 16px rgba(16,24,40,.12), 0 18px 40px rgba(16,24,40,.18);
  overflow: hidden;
}
.ut-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 12.5px;
}
.ut-head button {
  border: 0; background: transparent; cursor: pointer; color: var(--text-dim);
}
.ut-bar { height: 5px; background: #e6e9ee; }
.ut-fill { height: 100%; width: 0; background: var(--accent); transition: width .18s; }
.ut-detail { padding: 9px 12px; font-size: 12px; color: var(--text-dim); }

/* ==================== 响应式 ==================== */

@media (max-width: 900px) {
  .sidebar { width: 180px; }
  .tb-search { width: 130px; }
  .col-owner { display: none; }
  table.files thead th.col-owner { display: none; }
}

@media (max-width: 720px) {
  .sidebar { display: none; }
  .tb-search { display: none; }
  .col-mtime, .col-type { display: none; }
  table.files thead th.col-mtime,
  table.files thead th.col-type { display: none; }
  .user-chip { max-width: 92px; }
  .toolbar { gap: 6px; padding: 0 6px; }
  .grid-view { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
}
