:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --panel: #fff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #b42318;
  --success: #047857;
  --gold: #f5b84b;
  --shadow: 0 14px 38px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

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

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
}

.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: #111827;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.brand p,
.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
}

.app-header .brand p {
  font-size: 13px;
}

.top-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.nav-item {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #344054;
  text-align: center;
  padding: 10px 12px;
  cursor: pointer;
}

.nav-item.active {
  border-color: #bdd0ff;
  background: #eff6ff;
  color: var(--primary);
}

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

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 28px;
}

.topbar,
.panel-head,
.toolbar,
.top-actions,
.inline-actions,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar,
.panel-head {
  justify-content: space-between;
}

.topbar h2,
.panel-head h3,
.toolbox-card h3 {
  margin: 4px 0 0;
}

.panel-subtle-size {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
  white-space: nowrap;
}

.panel-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
}

.space-panel,
.content-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.space-panel {
  padding: 16px;
}

.content-panel {
  padding: 18px;
}

.space-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.space-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
}

.space-item strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.space-size {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.space-item.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.breadcrumb {
  margin-bottom: 12px;
  color: #344054;
  font-weight: 700;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.selection-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  border: 1px solid #bdd0ff;
  border-radius: 8px;
  background: #eff6ff;
  margin-bottom: 10px;
  padding: 8px 10px;
}

.selection-toolbar span {
  color: #344054;
  font-weight: 700;
  margin-right: 4px;
}

.search {
  max-width: 240px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button,
.file-button,
.link-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

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

.primary:hover {
  background: var(--primary-dark);
}

.secondary,
.file-button,
.ghost {
  border-color: var(--line);
  background: #fff;
  color: #27364a;
}

.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.danger {
  border-color: #f3b4ad;
  color: var(--danger);
}

.small,
.icon-button {
  min-height: 32px;
  padding: 6px 10px;
}

.full-button {
  width: 100%;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

.select-col {
  width: 44px;
  text-align: center;
}

.actions-col {
  width: 70px;
  text-align: right;
}

.row-check {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  vertical-align: middle;
  accent-color: var(--primary);
}

th {
  background: #f8fafc;
  color: #344054;
}

.name-cell {
  min-width: 320px;
  white-space: normal;
}

.name-button,
.link {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  text-align: left;
}

.sort-button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.sort-button.active,
.sort-button:hover {
  color: var(--primary);
}

.row-actions {
  text-align: right;
}

.row-action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.wps-edit-button {
  min-width: 52px;
  color: #b42318;
  border-color: #f0b4ae;
  background: #fff7f6;
}

.wps-sync-notice {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 48px));
  padding: 14px 18px;
  border: 1px solid #c7d2e0;
  border-radius: 8px;
  background: #ffffff;
  color: #243044;
  box-shadow: 0 14px 35px rgba(25, 38, 58, 0.2);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.wps-sync-notice.show {
  opacity: 1;
  transform: translateY(0);
}

.wps-sync-notice.success {
  border-color: #8ac7a9;
  background: #f0fbf5;
  color: #17633f;
}

.wps-sync-notice.error {
  border-color: #e6aaa5;
  background: #fff5f4;
  color: #9b2921;
}

.more-button {
  display: inline-grid;
  width: 30px;
  height: 30px;
  min-height: 30px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #98a2b3;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.more-button:hover {
  border-color: var(--line);
  background: #f8fafc;
  color: #475467;
}

.more-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.action-menu {
  position: fixed;
  z-index: 30;
  display: grid;
  gap: 2px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 6px;
}

.action-menu button,
.action-menu a,
.action-menu span {
  display: block;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #27364a;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  padding: 8px 10px;
}

.action-menu button:hover,
.action-menu a:hover {
  background: #f2f4f7;
}

.name-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(560px, 48vw);
}

.file-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-icon {
  position: relative;
  flex: 0 0 auto;
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 5px;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
}

.folder-icon {
  height: 24px;
  border-radius: 4px;
  background: #f5b84b;
  box-shadow: inset 0 -2px 0 rgba(146, 64, 14, 0.12);
}

.folder-icon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -4px;
  width: 13px;
  height: 7px;
  border-radius: 4px 4px 0 0;
  background: #ffd66b;
}

.file-icon:not(.folder-icon)::before {
  content: attr(data-label);
  position: relative;
  z-index: 1;
}

.file-icon:not(.folder-icon)::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-top: 7px solid rgba(255, 255, 255, 0.75);
  border-left: 7px solid rgba(0, 0, 0, 0.16);
}

.file-icon-excel {
  background: #178a52;
}

.file-icon-word {
  background: #2563eb;
}

.file-icon-ppt {
  background: #d9480f;
}

.file-icon-pdf {
  background: #d92d20;
}

.file-icon-image {
  background: #7c3aed;
}

.file-icon-text {
  background: #475467;
}

.file-icon-zip {
  background: #805c28;
}

.file-icon-file {
  background: #667085;
}

button:disabled,
.link:disabled {
  color: #98a2b3;
  cursor: not-allowed;
}

.status {
  display: inline-block;
  margin-left: 8px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
}

.status.ok {
  background: #e8f7ef;
  color: var(--success);
}

.status.bad {
  background: #fff0ed;
  color: var(--danger);
}

.status.running {
  background: #eff6ff;
  color: var(--primary);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.card-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.card,
.toolbox-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.card span {
  color: var(--muted);
  font-size: 13px;
}

.trash-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.trash-select-all {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  font-weight: 700;
  padding: 9px 12px;
}

.trash-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.sub-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin: -18px -18px 16px;
  padding: 12px 18px 0;
}

.sub-tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: #475467;
  padding: 8px 14px;
}

.sub-tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--primary);
}

.admin-sub-panel {
  display: grid;
  gap: 12px;
}

.inset-head {
  margin-bottom: 4px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.user-row span,
.disabled-row {
  color: var(--muted);
}

.user-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.user-actions select {
  width: 130px;
}

.permission-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.permission-browser,
.permission-editor {
  display: grid;
  align-content: start;
  gap: 10px;
}

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

.permission-table th,
.permission-table td {
  text-align: center;
}

.permission-table th:first-child,
.permission-table td:first-child,
.permission-table th:last-child,
.permission-table td:last-child {
  text-align: left;
}

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

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h3 {
  margin: 0;
}

.move-dialog-form {
  display: grid;
  gap: 12px;
}

.move-current {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  font-weight: 700;
  padding: 10px 12px;
}

.move-list {
  display: grid;
  gap: 6px;
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.move-folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  padding: 8px;
  text-align: left;
}

.move-folder-item:hover {
  border-color: #c7d7fe;
  background: #f8fbff;
}

@media (max-width: 980px) {
  .app,
  .panel-grid,
  .admin-layout,
  .permission-layout,
  .user-row,
  .trash-row {
    grid-template-columns: 1fr;
  }

  .user-actions {
    justify-content: flex-start;
  }

  .app-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .top-tabs,
  .app-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .toolbar,
  .top-actions,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    max-width: none;
  }
}
