:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --panel: #ffffff;
  --panel2: #f9fafb;
  --blue: #1664ff;
  --blue2: #4281ff;
  --blue3: #0055ff;
  --btnWhiteBg: #f6f8fa;
  --btnWhiteBorder: #dde2e9;
  --btnWhiteText: #41464f;
  --blueSoftBg: rgba(22, 100, 255, .10);
  --topbarH: 54px;
  --subbarH: 48px;
  --headerH: calc(var(--topbarH) + var(--subbarH));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbarH);
  z-index: 2000;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}
.brand .logo {
  display: block;
  width: auto;
  height: 28px;
  border-radius: 0;
  object-fit: contain;
}
.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.subbar {
  position: fixed;
  top: var(--topbarH);
  left: 0;
  right: 0;
  height: var(--subbarH);
  z-index: 1999;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}
.subbar .actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.subtabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn.active {
  border-color: rgba(22, 100, 255, .35);
  background: rgba(22, 100, 255, .06);
  color: var(--blue3);
}
.subbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.subbar-slot:empty { display: none; }
.header-bucket {
  display: flex;
  gap: 10px;
  align-items: center;
}
.hb-name { font-weight: 700; }

.layout {
  min-height: calc(100vh - var(--headerH));
}
.sidebar {
  padding: 16px;
  background: var(--panel2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.layout > .sidebar,
.dashboard-layout .sidebar {
  position: fixed;
  top: var(--headerH);
  left: 0;
  width: 260px;
  height: calc(100vh - var(--headerH));
}
.main {
  padding: 16px;
}
.layout > .main {
  margin-left: 260px;
}

body > .topbar + .main {
  margin-top: var(--topbarH);
}
body > .topbar + .subbar + .main,
body > .topbar + .subbar + .layout {
  margin-top: var(--headerH);
}

.op-link {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
}
.op-link:hover { text-decoration: underline; color: var(--blue3); }
.op-link:active { color: var(--blue3); opacity: .9; }

.card {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
}
.card .hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card .bd { padding: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  height: 32px;
  padding: 0 16px;
  border-radius: 4px;
  font-size: 13px;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-white {
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08);
  background-color: var(--btnWhiteBg);
  border: 1px solid var(--btnWhiteBorder);
  color: var(--btnWhiteText);
}
.btn-white:hover { border-color: var(--blue2); text-decoration: none; }
.btn-white:active { background-color: rgb(241 243 245); border-color: var(--blue3); box-shadow: none; }

.btn-blue {
  box-shadow: 0 1px 1px rgba(0, 0, 0, .15);
  background-color: var(--blue);
  border: 1px solid var(--blue3);
  color: #fff;
}
.btn-blue:hover { background-color: var(--blue2); text-decoration: none; }
.btn-blue:active { background-color: var(--blue3); border-color: #0044cc; box-shadow: none; }

.input, .select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 10px;
  background: #fff;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.bucket-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; overflow: hidden; flex: 1; padding-bottom: 10px; }
.menu-list { display: flex; flex-direction: column; gap: 15px; margin-top: 12px; }
.bucket-item {
  padding: 8px 10px;
  border-radius: 4px;
  background: transparent;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.bucket-item:hover { background: rgba(0, 0, 0, .03); text-decoration: none; }
.bucket-item.active {
  background: var(--blueSoftBg);
  color: var(--blue3);
}
.bucket-item.active .tag {
  border-color: rgba(22, 100, 255, .25);
  color: var(--blue3);
  background: rgba(22, 100, 255, .08);
}

.grid {
  width: 100%;
  border-collapse: collapse;
}
.grid th, .grid td {
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  text-align: left;
  font-size: 13px;
}
.grid th { color: var(--muted); font-weight: 600; }
.tag {
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
}
.crumbs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.crumbs a { color: #1f2937; }

.notice {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
}

.dashboard-layout .main { padding: 0; }
.dashboard-layout .sidebar { padding: 14px; }
.dashboard-layout { grid-template-columns: 1fr; }
.dashboard-layout .main { margin-left: 260px; }
.dashboard-layout .card {
  height: 100%;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
}
.dashboard-layout .card .bd { padding: 0; }
.file-table-wrap {
  height: calc(100vh - var(--headerH) - 54px);
  overflow: auto;
}
.file-name-btn {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.file-name-btn:hover { text-decoration: underline; }

.ui-toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.ui-toast {
  pointer-events: none;
  max-width: min(560px, calc(100vw - 28px));
  background: rgba(17, 24, 39, .92);
  color: #fff;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .18s ease, transform .18s ease;
}
.ui-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.ui-toast.error { background: rgba(153, 27, 27, .92); }
.ui-toast.success { background: rgba(6, 95, 70, .92); }

.ui-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .42);
  z-index: 9998;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
.ui-backdrop.show { opacity: 1; pointer-events: auto; }

.ui-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.98);
  width: min(520px, calc(100vw - 28px));
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 10000;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  overflow: hidden;
  pointer-events: none;
}
.ui-modal.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}
.ui-modal .hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ui-modal .bd { padding: 14px; }
.ui-modal .ft {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.ui-x {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.ui-x:hover { border-color: var(--blue2); }
.ui-x:active { background: rgb(241 243 245); border-color: var(--blue3); }

.ui-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(650px, 92vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--border);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform .18s ease;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.ui-drawer.open { transform: translateX(0); pointer-events: auto; }
.ui-drawer .hd {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ui-drawer .title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-drawer .bd {
  padding: 14px;
  overflow: auto;
  flex: 1;
}
.preview {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel2);
  height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview img, .preview video, .preview audio, .preview iframe {
  width: 100%;
  display: block;
}
.preview img, .preview video {
  height: 100%;
  max-height: 540px;
  object-fit: contain;
}
.preview iframe {
  height: 100%;
  border: 0;
}
.preview pre {
  width: 100%;
  height: 100%;
  overflow: auto;
}
.kv {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 10px;
  font-size: 13px;
}
.kv .k { color: var(--muted); }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  word-break: break-all;
}
