:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #dce1e6;
  --text: #1b2026;
  --muted: #5d6772;
  --accent: #1f6feb;
  --accent-weak: #e7f0ff;
  --danger: #b8342a;
  --danger-weak: #fbecea;
  --ok: #137333;
  --warn: #9a6700;
  --shadow: 0 6px 24px rgba(20, 28, 38, .08);
  --radius: 6px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #101317;
  --surface: #181c22;
  --surface-2: #222831;
  --border: #303844;
  --text: #e5eaf0;
  --muted: #98a3b0;
  --accent: #6aa5ff;
  --accent-weak: #1b2d47;
  --danger: #ff7267;
  --danger-weak: #3a2222;
  --ok: #63c47f;
  --warn: #e2b341;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
svg { flex: none; }
.boot { padding: 32px; color: var(--muted); }

/* 布局 */
.app-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; padding: 0 8px; }
.brand-mark { width: 28px; height: 28px; border-radius: 5px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius);
  border: 0; background: transparent; color: var(--muted); text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.usage-label { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.usage-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.usage-fill { height: 100%; background: var(--accent); }
.link-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.dot.relay { background: var(--warn); }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .search { flex: 1; max-width: 320px; min-width: 0; }
.topbar-spacer { flex: 1; }
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; flex-wrap: wrap; }
.crumb { border: 0; background: none; color: var(--muted); padding: 3px 5px; border-radius: 4px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:hover { color: var(--accent); background: var(--surface-2); }
.crumb.current { color: var(--text); font-weight: 600; }
.sep { color: var(--muted); }
.page { padding: 20px 22px 28px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 19px; margin: 0; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 控件 */
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 7px 11px; min-height: 34px; white-space: nowrap;
}
.btn:hover, .icon-btn:hover { background: var(--surface-2); }
.btn:disabled, .icon-btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.icon-btn { padding: 7px; width: 34px; }
.input, .select {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius); padding: 7px 10px; min-height: 34px;
}
.input:focus, .select:focus, .btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field-label { font-weight: 600; font-size: 13px; }
.field-hint { color: var(--muted); font-size: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }

/* 文件列表 */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; min-width: 0; }
.table th { color: var(--muted); font-size: 12px; font-weight: 600; background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.col-name { width: 42%; }
.col-size { width: 13%; }
.col-date { width: 20%; }
.col-shared { width: 10%; }
.col-actions { width: 15%; text-align: right; }
.cell-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.cell-name .name { overflow-wrap: anywhere; }
.name-btn { border: 0; background: none; padding: 0; text-align: left; color: inherit; min-width: 0; overflow-wrap: anywhere; }
.name-btn:hover { color: var(--accent); text-decoration: underline; }
.file-icon { color: var(--muted); }
.file-icon.folder { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--accent-weak); color: var(--accent); }
.row-actions { display: inline-flex; gap: 2px; justify-content: flex-end; }
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px;
}
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: 4px; text-align: left; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 6px; }
.drop-active { outline: 2px dashed var(--accent); outline-offset: -4px; }

.topbar-search { width: min(320px, 42vw); }
.page-note { margin: -4px 0 14px; color: var(--muted); font-size: 13px; max-width: 960px; }
.col-owner { width: 14%; }
.col-role { width: 12%; }
.col-status { width: 10%; }
.col-usage { width: 20%; }
.col-user-actions { width: 21%; text-align: right; }
.account-summary { padding: 6px 10px; font-size: 12px; }
.status-ok { color: var(--ok); }
.status-off { color: var(--danger); }
.audit-section { margin-top: 24px; }
.audit-section h2 { font-size: 16px; margin: 0 0 6px; }
.audit-panel { max-height: 420px; overflow: auto; }
.audit-target { overflow-wrap: anywhere; }

/* 上传任务面板 */
.upload-fab { position: fixed; right: 18px; bottom: 18px; z-index: 38; box-shadow: var(--shadow); }
.menu-toggle { display: none; }
.upload-panel {
  position: fixed; right: 18px; bottom: 18px; width: 370px; max-width: calc(100vw - 28px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 40; overflow: hidden;
}
.upload-head { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-bottom: 1px solid var(--border); font-weight: 600; }
.upload-head .count { color: var(--muted); font-weight: 400; }
.upload-list { max-height: 300px; overflow-y: auto; }
.upload-item { padding: 10px 11px; border-bottom: 1px solid var(--border); }
.upload-item:last-child { border-bottom: 0; }
.upload-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.upload-name { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.upload-directory { color: var(--muted); font-size: 12px; margin: 2px 0 0 22px; overflow-wrap: anywhere; }
.upload-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.progress { height: 5px; border-radius: 99px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); }
.progress.error > i { background: var(--danger); }
.upload-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px; }
.upload-actions .btn { padding: 3px 8px; min-height: 26px; font-size: 12px; }

/* 分享与测速 */
.share-url { display: flex; gap: 6px; align-items: center; min-width: 0; }
.share-url code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 6px; }
.card p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.result { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 14px; font-variant-numeric: tabular-nums; }
.result .big { font-size: 24px; font-weight: 650; }
.result small { display: block; color: var(--muted); }
.public-wrap { max-width: 460px; margin: 7vh auto; padding: 0 16px; }
.public-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }

/* 弹窗与提示 */
.modal { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: min(460px, calc(100vw - 28px)); padding: 0; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(8, 12, 18, .52); }
.dialog-form { margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 16px; }
.dialog-body { padding: 16px; }
.dialog-body p { margin: 0 0 12px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.dialog-error { color: var(--danger); font-size: 13px; }
.toast-host { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--radius); padding: 9px 13px; max-width: min(92vw, 520px); }
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-success { border-color: var(--ok); color: var(--ok); }
.sheet-backdrop { display: none; }
.account-menu { position: absolute; right: 16px; top: 52px; z-index: 35; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: var(--radius); padding: 4px; }
.account-menu button { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 10px; width: 100%; border-radius: 4px; }
.account-menu button:hover { background: var(--surface-2); }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.login-card .btn-primary { width: 100%; padding: 10px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sheet-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(8, 12, 18, .45); z-index: 25; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar .search { max-width: none; order: 3; flex-basis: 100%; }
  .crumbs { flex: 1; }
  .crumb { max-width: 112px; }
  .page { padding: 14px 12px 24px; }
  .col-size, .col-date, .col-shared, .col-meta, .col-owner, .col-role, .col-status, .col-usage { display: none; }
  .topbar-search { order: 3; flex-basis: 100%; width: 100%; }
  .user-table .col-name { width: 48%; }
  .user-table .col-user-actions { width: 52%; }
  .row-actions { flex-wrap: wrap; }
  .row-actions .btn { padding: 6px; font-size: 12px; }
  .audit-panel .table { min-width: 560px; }
  .share-url { width: 100%; }
  .share-url code { max-width: 100%; }
  .col-name { width: 68%; }
  .col-actions { width: 32%; }
  .table th, .table td { padding: 8px; }
  .upload-panel { right: 8px; left: 8px; bottom: 8px; width: auto; max-width: none; }
  .upload-list { max-height: 34vh; }
  .dialog-actions .btn { flex: 1; }
}
