:root {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1d222c;
  --border: #262d39;
  --text: #e6e8ec;
  --muted: #8a93a4;
  --accent: #4f8cff;
  --accent-2: #6ea2ff;
  --ok: #3fb950;
  --err: #f85149;
}

body.admin-page,
body.login-page {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --panel-float: #ffffff;
  --border: #d8e1ee;
  --text: #172033;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --ok: #16a34a;
  --err: #dc2626;
  --line: #d8e1ee;
  --fg: #172033;
}

body.admin-page[data-theme="dark"],
body.login-page[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1d222c;
  --panel-float: rgba(17, 21, 28, 0.98);
  --border: #262d39;
  --text: #e6e8ec;
  --muted: #8a93a4;
  --accent: #4f8cff;
  --accent-2: #6ea2ff;
  --ok: #3fb950;
  --err: #f85149;
  --line: #262d39;
  --fg: #e6e8ec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 20% 0%, #1b2030 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.modal-open {
  overflow: hidden;
}

header {
  text-align: center;
  padding: 48px 16px 8px;
}

.home-header {
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.home-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.home-entry-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.home-entry {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  transition: 0.15s;
}

.home-entry:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

.home-entry.secondary {
  background: transparent;
}

header h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.subtitle {
  color: var(--muted);
  margin: 6px 0 0;
}

main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 24px auto;
  padding: 0 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.hidden { display: none !important; }

/* ------- upload page ------- */

.dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 16px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s;
}

.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.06);
}

.dz-icon {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 8px;
}

.dz-text { font-size: 15px; }

.dz-hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.progress {
  margin-top: 14px;
  height: 6px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s;
}

.field-stack {
  margin-top: 16px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: white;
  border: 0;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: 0.15s;
  text-align: center;
  text-decoration: none;
  margin-top: 16px;
}

.primary:hover { background: var(--accent-2); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.primary.as-link { display: block; }
.primary.big { font-size: 16px; padding: 14px; }

.result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

#resultList {
  display: grid;
  gap: 14px;
}

.upload-result-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.result-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}

.url-box {
  display: flex;
  gap: 8px;
}

.url-box input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--accent-2);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.copy {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
}

.copy:hover { border-color: var(--accent); }

.upload-result-item .primary.as-link {
  margin-top: 10px;
}

/* ------- file info page ------- */

.file-card { text-align: center; padding: 36px 24px; }

.file-icon {
  font-size: 56px;
  margin-bottom: 10px;
}

.file-name {
  margin: 4px 0 8px;
  font-size: 18px;
  word-break: break-all;
}

.file-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.file-meta .dot { margin: 0 6px; opacity: 0.6; }

.file-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.lock-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.file-password-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.back {
  display: inline-block;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.back:hover { color: var(--text); }

.msg {
  text-align: center;
  font-size: 13px;
  margin: 12px 0;
  min-height: 18px;
}

.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

/* ------- admin ------- */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 8px;
}

.admin-header h1 {
  font-size: 20px;
  margin: 0 16px 0 0;
}

.admin-home-link {
  color: var(--text);
  text-decoration: none;
}

.admin-home-link:hover {
  color: var(--accent-2);
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  flex-wrap: wrap;
}

.admin-nav .user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-2);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  margin-right: 4px;
}

.admin-nav .user::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.18);
}

.admin-nav a,
.admin-nav .link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  transition: 0.15s;
}

.admin-nav a:hover,
.admin-nav .link-btn:hover {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border);
}

.admin-nav a.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(79, 140, 255, 0.25);
}

.admin-nav a.active:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: white;
}

.admin-nav .link-btn.logout-btn:hover {
  color: var(--err);
  background: rgba(248, 81, 73, 0.08);
  border-color: rgba(248, 81, 73, 0.3);
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 0 8px;
  color: var(--muted);
  user-select: none;
}

.theme-switch-text {
  min-width: 2.5em;
  text-align: right;
  font-size: 12.5px;
}

.theme-switch-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 44px;
  height: 24px;
}

.theme-switch-track input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.theme-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.2), rgba(37, 99, 235, 0.08));
  transition: 0.2s;
}

.theme-switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  transition: 0.2s;
}

.theme-switch-track input:checked + .theme-switch-slider {
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.32), rgba(79, 140, 255, 0.16));
  border-color: rgba(79, 140, 255, 0.55);
}

.theme-switch-track input:checked + .theme-switch-slider::after {
  transform: translateX(20px);
  background: #dbeafe;
}

.theme-switch-track input:focus-visible + .theme-switch-slider {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.captcha-q {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 1px;
  user-select: none;
}

.meta-line {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-bar input[type="search"] {
  flex: 1;
  min-width: 180px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  transition: 0.15s;
}

.search-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.search-bar button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}

.search-bar button:hover { background: var(--accent-2); }

.search-bar select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.search-bar .clear-btn,
.search-bar a.clear-btn {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: 0.15s;
}

.search-bar .clear-btn:hover,
.search-bar a.clear-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: transparent;
}

.section-title {
  margin: 0 0 14px;
  font-size: 18px;
}

.user-console-main {
  width: 100%;
  max-width: 1160px;
  margin: 24px auto 0;
  padding: 0 16px;
}

.user-upload-panel {
  padding: 24px;
}

.user-open-upload-btn {
  width: auto;
  min-width: 150px;
  margin-top: 0;
}

.user-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.user-panel-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.user-upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 200px;
  padding: 28px 18px;
  border: 1px dashed rgba(110, 162, 255, 0.45);
  border-radius: 18px;
  background:
    radial-gradient(400px 140px at 50% 0%, rgba(79, 140, 255, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.user-dropzone:hover,
.user-dropzone.over {
  border-color: var(--accent);
  background:
    radial-gradient(420px 160px at 50% 0%, rgba(79, 140, 255, 0.18), transparent 72%),
    rgba(79, 140, 255, 0.05);
  transform: translateY(-1px);
}

.user-dropzone-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-2);
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid rgba(110, 162, 255, 0.35);
  font-size: 28px;
}

.user-dropzone-title {
  font-size: 17px;
  font-weight: 600;
}

.user-dropzone-hint {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  word-break: break-all;
}

.user-upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.user-field {
  margin: 0;
}

.user-upload-meta {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  padding: 14px 16px;
  display: flex;
  align-items: center;
}

.user-progress {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: 14px 16px;
}

.user-progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 10px;
}

.user-progress-bar {
  margin-top: 0;
}

.user-upload-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.user-submit-btn {
  width: auto;
  min-width: 160px;
  margin-top: 0;
}

.user-upload-result {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.update-share {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.upload-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(7, 10, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.upload-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  padding: 28px 24px 24px;
}

.admin-form-modal {
  width: min(560px, 100%);
}

.admin-modal-form {
  gap: 16px;
}

.admin-add-user-btn {
  width: auto;
  min-width: 112px;
  padding: 10px 16px;
  margin-top: 0;
  font-size: 13px;
}

.upload-modal-head {
  margin-bottom: 18px;
  padding-right: 36px;
}

.upload-modal-title {
  margin: 0;
  font-size: 22px;
}

.upload-modal-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.upload-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.upload-modal-close:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

.panel-gap {
  margin-top: 18px;
}

.inline-form,
.inline-upload-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input,
.inline-upload-form input[type="text"],
.inline-upload-form input[type="password"],
.inline-upload-form input[type="file"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}

.inline-form button,
.inline-upload-form button {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
}

.inline-form button:hover,
.inline-upload-form button:hover {
  background: var(--accent-2);
}

.table-wrap { overflow-x: auto; }

.files {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.files th, .files td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.files th {
  color: var(--muted);
  font-weight: 500;
  background: var(--panel-2);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.files td.num, .files th.num { text-align: right; white-space: nowrap; }

.files td {
  white-space: nowrap;
}

.files .ellipsis {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files .regions-cell {
  width: 6.5em;
  max-width: 6.5em;
}

.regions-preview {
  display: inline-block;
  max-width: 6.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.files a { color: var(--accent-2); text-decoration: none; }
.files a:hover { text-decoration: underline; }

.cell-tooltip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  cursor: default;
}

.ui-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2000;
  max-width: min(42ch, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-float);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-line;
  word-break: break-word;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  pointer-events: none;
}

.ui-tooltip.tooltip-grid {
  min-width: 220px;
  max-width: min(52ch, calc(100vw - 24px));
  padding: 10px 12px;
}

.ui-tooltip-row {
  display: grid;
  grid-template-columns: 5.5em minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.ui-tooltip-row + .ui-tooltip-row {
  margin-top: 6px;
}

.ui-tooltip-label {
  color: var(--muted);
  white-space: nowrap;
}

.ui-tooltip-value {
  color: var(--text);
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}

.files .md5 {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files .empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

button.danger {
  background: transparent;
  color: var(--err);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

button.danger:hover { border-color: var(--err); background: rgba(248, 81, 73, 0.08); }

.secondary-btn,
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.secondary-btn:hover,
.file-label:hover {
  border-color: var(--accent);
}

.action-secondary {
  white-space: nowrap;
}

.admin-user-btn {
  border-radius: 6px !important;
}

.danger-text {
  color: var(--err);
}

.danger-text:hover {
  color: #ff6a64;
  border-color: rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.08);
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-row-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  width: fit-content;
  min-width: 0;
  white-space: nowrap;
}

.inline-actions {
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(110, 162, 255, 0.4);
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.16), rgba(79, 140, 255, 0.06));
  color: #d9e7ff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: 0.15s;
}

.action-btn:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.24), rgba(79, 140, 255, 0.1));
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(79, 140, 255, 0.16);
}

.file-row-actions .secondary-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.file-row-actions button.danger {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.admin-edit-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.admin-edit-block {
  display: grid;
  gap: 10px;
}

.rule-mode-group {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.rule-mode-group label,
.region-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px 10px;
  max-height: 220px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.as-link.disabled {
  pointer-events: none;
  opacity: 0.7;
}

.update-picker {
  align-self: flex-start;
}

.row-update-state {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 10px 12px;
}

.row-update-name {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 8px;
  word-break: break-all;
}

.row-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.row-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s;
}

.row-update-text {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  gap: 14px;
  font-size: 13px;
  flex-wrap: wrap;
}

.pager .page-link {
  color: var(--accent-2);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.pager .page-link:hover { border-color: var(--accent); }
.pager .page-cur { color: var(--muted); }

.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.page-size-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.page-size-picker select {
  min-width: 58px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 24px 4px 8px;
  height: 30px;
  line-height: 30px;
  font: inherit;
}

/* ------- admin login page ------- */

body.login-page {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(37, 99, 235, 0.12) 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(59, 130, 246, 0.1) 0%, transparent 60%),
    var(--bg);
}

.login-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  gap: 16px;
  width: 100%;
  max-width: none;
  margin: 0;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px 28px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 24px 60px rgba(15, 23, 42, 0.12);
}

.login-brand {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--panel-2);
  padding: 6px;
}

.login-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.login-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* shared vertical form (login + admin password) */
.form-vert {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-vert .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.form-vert .field-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
}

.form-vert input[type="text"],
.form-vert input[type="password"] {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-vert input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.captcha-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) 1fr;
  gap: 10px;
  align-items: stretch;
}

.captcha-row .captcha-q {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.12), rgba(37, 99, 235, 0.04));
  border: 1px dashed rgba(37, 99, 235, 0.28);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  letter-spacing: 2px;
  color: var(--accent-2);
  user-select: none;
  padding: 0 14px;
  min-height: 42px;
}

.captcha-row .captcha-img {
  display: block;
  width: 130px;
  height: 46px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  user-select: none;
  transition: 0.15s;
}

.captcha-row .captcha-img:hover {
  border-color: var(--accent);
}

.captcha-row .captcha-img.loading {
  background: var(--panel-2)
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
  background-size: 200% 100%;
  animation: cap-shimmer 1s linear infinite;
}

@keyframes cap-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.captcha-row .captcha-input {
  width: 100%;
}

.login-submit {
  margin-top: 4px;
  font-size: 14px;
  letter-spacing: 4px;
  padding: 12px;
}

.login-footer {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.login-switch {
  margin: -2px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.login-switch a {
  color: var(--accent-2);
  text-decoration: none;
}

.login-switch a:hover {
  text-decoration: underline;
}

body.login-page[data-theme="dark"] {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(79, 140, 255, 0.18) 0%, transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(110, 162, 255, 0.14) 0%, transparent 60%),
    var(--bg);
}

body.login-page[data-theme="dark"] .login-card {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 24px 60px rgba(0, 0, 0, 0.4);
}

body.login-page[data-theme="dark"] .captcha-row .captcha-q {
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.16), rgba(79, 140, 255, 0.06));
  border: 1px dashed rgba(110, 162, 255, 0.45);
}

/* ------- admin password page ------- */

.admin-page {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(37, 99, 235, 0.08) 0%, transparent 60%),
    var(--bg);
}

.admin-main {
  width: 100%;
  max-width: 460px;
  margin: 24px auto 0;
  padding: 0 16px;
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 28px 24px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 16px 40px rgba(15, 23, 42, 0.08);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.card-head .card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.16), rgba(37, 99, 235, 0.05));
  border: 1px solid rgba(37, 99, 235, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.card-head .card-title {
  margin: 0;
  font-size: 16px;
}

.card-head .card-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.card-head .card-sub strong { color: var(--accent-2); font-weight: 500; }

body.admin-page[data-theme="dark"] {
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(79, 140, 255, 0.10) 0%, transparent 60%),
    var(--bg);
}

body.admin-page[data-theme="dark"] .admin-card {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 16px 40px rgba(0, 0, 0, 0.35);
}

body.admin-page[data-theme="dark"] .card-head .card-icon {
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.22), rgba(79, 140, 255, 0.06));
  border: 1px solid rgba(110, 162, 255, 0.35);
}

.settings-stack {
  display: grid;
  gap: 18px;
}

.settings-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.settings-download-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-download-row a {
  color: var(--accent-2);
  text-decoration: none;
}

.settings-download-row a:hover {
  text-decoration: underline;
}

.settings-label {
  color: var(--muted);
}

.totp-setup {
  display: grid;
  gap: 18px;
}

.totp-qr-wrap {
  display: flex;
  justify-content: center;
}

.totp-qr {
  width: 220px;
  height: 220px;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
}

.totp-secret-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.totp-secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  width: min(460px, 100%);
}

.totp-secret-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--fg);
  font-size: 15px;
  letter-spacing: 0.08em;
}

.totp-secret-box .secondary-btn {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
}

.totp-secret-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.16);
}

.totp-actions {
  display: flex;
  justify-content: flex-start;
}

.totp-actions .primary {
  height: 44px;
  padding: 0 18px;
  margin-top: 0;
  border-radius: 12px;
}

.password-tip {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.password-tip strong { color: var(--text); font-weight: 500; }

.password-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.password-actions .primary { flex: 1; margin-top: 0; }

.password-actions .secondary {
  flex: 0 0 auto;
  padding: 12px 18px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  text-align: center;
}

.password-actions .secondary:hover {
  border-color: var(--accent);
  color: var(--text);
}

@media (max-width: 720px) {
  .admin-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .admin-nav {
    flex-wrap: wrap;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .user-upload-grid {
    grid-template-columns: 1fr;
  }

  .user-upload-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .user-submit-btn,
  .secondary-btn {
    width: 100%;
  }

  .user-panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .list-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .page-size-picker {
    justify-content: flex-end;
  }

  .pager {
    justify-content: center;
  }

  .user-open-upload-btn {
    width: 100%;
  }

  .upload-modal {
    padding: 24px 16px 18px;
    border-radius: 18px;
  }

  .file-row-actions {
    flex-wrap: nowrap;
  }
}

/* ------- modal confirm dialog ------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-backdrop.show {
  display: flex;
  animation: modal-fade 0.15s ease;
}

@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 24px 20px;
  max-width: 380px;
  width: 100%;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modal-pop 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.modal-msg {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-line;
  word-break: break-word;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.modal-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  vertical-align: middle;
  width: auto;
  min-width: 108px;
  height: 40px;
  padding: 0 18px;
  margin: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: 0.15s;
  border: 1px solid transparent;
}

.modal-actions .modal-cancel,
.modal-actions .modal-confirm {
  display: inline-flex;
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}

.modal-cancel {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border) !important;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--muted);
}

.modal-cancel:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--accent);
}

.modal-confirm.primary {
  display: inline-flex;
  width: auto;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.modal-confirm.primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.modal-confirm.danger {
  background: var(--err);
  color: white;
  border-color: var(--err);
  box-shadow: 0 4px 14px rgba(248, 81, 73, 0.25);
}

.modal-confirm.danger:hover {
  background: #ff6a64;
  border-color: #ff6a64;
}

@media (max-width: 480px) {
  .modal-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-actions button {
    width: 100%;
    min-width: 0;
  }
}
