:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e2e6ec;
  --text: #1f2733;
  --muted: #7a8699;
  --brand: #1585c7;
  --brand-dark: #106aa0;
  --brand-soft: rgba(21, 133, 199, 0.14);
  --ok: #1a9c5b;
  --warn: #c47b12;
  --err: #d23c3c;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
/* Ensure the `hidden` attribute always wins, even over class rules that set
   a `display` value (e.g. .empty { display: grid }). */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: #eef2f9; color: var(--muted); font-size: 12px; white-space: nowrap;
}
button { font: inherit; cursor: pointer; }
.linkbtn { background: none; border: none; color: var(--brand); padding: 0; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 16px; }
.icon-btn:hover { color: var(--brand); }

/* ---------- brand logo (circular crop hides the image's gray corners) ---- */
.brand-logo {
  flex: none; display: block; width: 34px; height: 34px; border-radius: 50%;
  overflow: hidden; background: #fff;
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(20, 30, 50, .12);
}
.brand-logo img { width: 118%; height: 118%; margin: -9%; object-fit: cover; display: block; }
.brand-logo.lg { width: 76px; height: 76px; box-shadow: 0 0 0 1px var(--border), 0 6px 18px rgba(20, 30, 50, .14); }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(1100px 500px at 50% -10%, #e7f2fa 0%, rgba(231,242,250,0) 60%),
    linear-gradient(160deg, #eef3f8, #f5f7fb);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(20, 30, 50, .10); padding: 34px 32px 28px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-brand h1 { font-size: 21px; margin: 16px 0 0; letter-spacing: -.2px; }
.login-brand p { margin: 6px 0 0; }
#login-form { margin-top: 26px; display: flex; flex-direction: column; }
#login-form label { font-weight: 600; margin: 14px 0 6px; }
#login-form input {
  padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; outline: none; transition: border-color .12s, box-shadow .12s;
}
#login-form input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.advanced { margin-top: 14px; }
.advanced summary { cursor: pointer; color: var(--muted); }
#submit {
  margin-top: 22px; padding: 12px; border: none; border-radius: 9px;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
  transition: background .12s;
}
#submit:hover { background: var(--brand-dark); }
#submit:disabled { opacity: .6; cursor: default; }
.error { color: var(--err); margin: 12px 0 0; }
.footnote { margin-top: 22px; line-height: 1.5; text-align: center; font-size: 12px; }

/* ---------- app shell ---------- */
.topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: -.1px; }
.brand-sub { font-size: 11px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.who { font-size: 13px; white-space: nowrap; }
.ghost { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; color: var(--text); }
.ghost:hover { border-color: var(--brand); color: var(--brand); }

.layout { display: flex; height: calc(100% - 56px); }
.sidebar {
  width: 300px; flex: none; background: var(--panel);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px; font-weight: 700;
}
.search {
  margin: 0 16px 10px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none;
}
.bucket-list { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; flex: 1; min-height: 0; }
.bucket-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.bucket-item:hover { background: #f2f5fb; }
.bucket-item.active { background: #e7efff; }
.bucket-item .b-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loading, .pad { padding: 12px; }

.list-hint {
  margin: 0 16px 8px; padding: 8px 10px; font-size: 12px; line-height: 1.4;
  color: var(--warn); background: #fff7e9; border: 1px solid #f2dcae; border-radius: 8px;
}
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }
.empty { display: grid; place-items: center; min-height: 160px; padding: 40px 0; color: var(--muted); }
.crumbs { display: flex; align-items: center; gap: 12px; }
.crumbs h2 { margin: 0; font-size: 20px; }

.pathbar { margin: 16px 0 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  flex: none; width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--text); font-size: 15px; line-height: 1;
}
.nav-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.nav-btn:disabled { opacity: .4; cursor: default; }
.breadcrumb { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin-left: 4px; }
.crumb {
  background: none; border: none; padding: 3px 6px; border-radius: 6px;
  color: var(--brand); font-size: 14px; max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.crumb:hover { background: #eef2f9; }
.crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.crumb.current:hover { background: none; }
.crumb-sep { color: var(--muted); }

.dropzone {
  margin-top: 8px; border: 2px dashed #c7d0dd; border-radius: 12px;
  background: #fbfcfe; padding: 34px; text-align: center; transition: .15s;
}
.dropzone.drag { border-color: var(--brand); background: #eef4ff; }
.dropzone p { margin: 4px 0; }
.dz-icon { font-size: 30px; color: var(--brand); }

.queue { list-style: none; margin: 14px 0 0; padding: 0; }
.q-item {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
  background: var(--panel);
}
.q-item .q-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item.pending .q-status { color: var(--brand); }
.q-item.done .q-status { color: var(--ok); }
.q-item.partial .q-status { color: var(--warn); }
.q-item.failed .q-status { color: var(--err); }
.q-item { transition: opacity .4s ease, transform .4s ease; }
.q-item.fade-out { opacity: 0; transform: translateY(-4px); }

.listing { margin-top: 26px; }
.listing-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.select-all { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.select-all input { width: 15px; height: 15px; cursor: pointer; }
.listing-actions { display: flex; align-items: center; gap: 10px; }
.danger.small { padding: 5px 12px; font-size: 13px; font-weight: 600; border: none; border-radius: 7px; }
.object-list { list-style: none; margin: 0; padding: 0; }
.object-list .obj {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 4px; border-bottom: 1px solid #f0f2f6;
}
.object-list .o-check, .object-list .o-check-spacer { flex: none; width: 15px; height: 15px; cursor: pointer; }
.object-list .o-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.object-list .o-size { flex: none; }
.object-list .o-del {
  flex: none; background: none; border: none; padding: 2px 6px; border-radius: 6px;
  font-size: 14px; line-height: 1; opacity: .55; transition: .12s;
}
.object-list .obj:hover .o-del { opacity: 1; }
.object-list .o-del:hover { background: #fdeaea; }
.object-list .o-del:disabled { opacity: .4; cursor: default; }
.object-list .folder { font-weight: 600; cursor: pointer; }
.object-list .folder:hover { background: #f2f5fb; }
.object-list .folder .o-open { flex: none; color: var(--brand); font-size: 12px; opacity: 0; }
.object-list .folder:hover .o-open { opacity: 1; }
.error { color: var(--err); }

/* ---------- confirm modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 30, 50, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: 100%; max-width: 400px; background: var(--panel); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(20, 30, 50, .25); padding: 22px 24px;
}
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0; color: var(--muted); line-height: 1.5; white-space: pre-line; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-actions button { padding: 8px 16px; border-radius: 8px; font-weight: 600; }
.danger { background: var(--err); color: #fff; border: none; }
.danger:hover { background: #b93030; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  max-width: 90vw; background: #222b3a; color: #fff; padding: 11px 18px; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(20, 30, 50, .3); z-index: 60; font-size: 14px;
}
.toast-ok { background: var(--ok); }
.toast-err { background: var(--err); }
