:root {
  --app-surface: rgba(255, 255, 255, 0.9);
  --app-border: rgba(15, 23, 42, 0.08);
  --app-shadow: 0 1rem 2.5rem rgba(15, 23, 42, 0.08);
}

html,
body {
  min-height: 100%;
}

body.app-body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: #f4f7f8;
  color: #1f2937;
  position: relative;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 15%, rgba(25, 135, 84, 0.16) 0, transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(13, 110, 253, 0.14) 0, transparent 26%),
    radial-gradient(circle at 50% 100%, rgba(255, 193, 7, 0.12) 0, transparent 28%),
    linear-gradient(180deg, #f8fbfd 0%, #f1f4f7 100%);
}

.card {
  background: var(--app-surface);
  border-color: var(--app-border) !important;
  box-shadow: var(--app-shadow);
  backdrop-filter: blur(12px);
}

.auth-page main {
  min-height: 100vh;
}

.admin-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.admin-shell.collapsed {
  grid-template-columns: 96px minmax(0, 1fr);
}

.sidebar-card {
  position: sticky;
  top: 1rem;
}

.brand-stack {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, #198754, #6fbd40);
  box-shadow: 0 1rem 2rem rgba(25, 135, 84, 0.25);
}

.brand-copy {
  min-width: 0;
}

.min-w-0 {
  min-width: 0;
}

.site-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-nav {
  display: grid;
  gap: 0.6rem;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(25, 135, 84, 0.12);
  border-radius: 1rem;
  color: #1f2937;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.96);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.side-link:hover {
  color: #198754;
  border-color: rgba(25, 135, 84, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 0.75rem 1.5rem rgba(25, 135, 84, 0.12);
}

.side-link.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, rgba(25, 135, 84, 0.95), rgba(111, 189, 64, 0.92));
  box-shadow: 0 1rem 2rem rgba(25, 135, 84, 0.22);
}

.side-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.45;
  flex: 0 0 auto;
}

.side-link.active .side-dot {
  background: #fff;
  opacity: 1;
}

.side-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-shell.collapsed .brand-copy,
.admin-shell.collapsed .sidebar-meta,
.admin-shell.collapsed .side-text {
  display: none;
}

.admin-shell.collapsed .brand-stack {
  justify-content: center;
}

.admin-shell.collapsed .side-link {
  justify-content: center;
  padding-inline: 0.75rem;
}

.admin-shell.collapsed #toggleSidebar {
  font-size: 0;
}

.admin-shell.collapsed #toggleSidebar::after {
  content: "≡";
  font-size: 1rem;
}

.admin-main {
  display: grid;
  gap: 1.5rem;
  min-width: 0;
}

.page-hero h1 {
  letter-spacing: -0.02em;
}

.files-storage-picker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.files-storage-picker .form-select {
  min-width: 220px;
}

.table-responsive {
  border-radius: 1rem;
}

.table > :not(caption) > * > * {
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

.table-sort-btn {
  min-width: 8rem;
}

.file-manager-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.fm-panel {
  border: 1px solid var(--app-border);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.78);
  padding: 1rem;
}

.fm-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.fm-panel-kicker {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.fm-main-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.fm-toolbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fm-search-wrap {
  min-width: 260px;
  flex: 1 1 260px;
}

.fm-search-wrap .form-control,
.fm-sort-wrap .form-select {
  border-radius: 999px;
}

.fm-sort-wrap {
  min-width: 190px;
}

.fm-breadcrumb-wrap {
  min-width: 0;
}

.fm-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.fm-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.fm-action-bar .btn-group {
  row-gap: 0.5rem;
}

.fm-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.fm-stat-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
  padding: 0.9rem 1rem;
}

.fm-stat-label {
  color: #64748b;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.fm-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.fm-tree {
  display: grid;
  gap: 0.45rem;
  max-height: 42rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.fm-tree-node {
  display: grid;
  gap: 0.35rem;
}

.fm-tree-children {
  display: grid;
  gap: 0.35rem;
  margin-left: 0.9rem;
  padding-left: 0.9rem;
  border-left: 1px solid rgba(15, 23, 42, 0.08);
}

.fm-tree-button {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  color: #1f2937;
  background: rgba(248, 250, 252, 0.95);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

.fm-tree-button:hover {
  color: #198754;
  border-color: rgba(25, 135, 84, 0.25);
  transform: translateY(-1px);
  box-shadow: 0 0.75rem 1.4rem rgba(15, 23, 42, 0.08);
}

.fm-tree-button.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, rgba(25, 135, 84, 0.98), rgba(111, 189, 64, 0.92));
  box-shadow: 0 1rem 1.8rem rgba(25, 135, 84, 0.2);
}

.fm-tree-button.is-ancestor {
  border-color: rgba(25, 135, 84, 0.16);
  background: rgba(25, 135, 84, 0.05);
}

.fm-tree-button.is-drag-over,
.fm-crumb-btn.is-drag-over,
#fmRootButton.is-drag-over {
  color: #fff !important;
  border-color: transparent !important;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.95), rgba(32, 201, 151, 0.9)) !important;
  box-shadow: 0 1rem 1.8rem rgba(13, 110, 253, 0.18);
}

.fm-tree-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.55;
  flex: 0 0 auto;
}

.fm-tree-button.is-active .fm-tree-dot {
  opacity: 1;
}

.fm-tree-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fm-empty-block,
.fm-detail-empty {
  border: 1px dashed rgba(15, 23, 42, 0.16);
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.75);
  color: #64748b;
  padding: 1rem;
}

.fm-table .fm-check-col {
  width: 3rem;
}

.fm-row.is-selected > * {
  background: rgba(25, 135, 84, 0.08);
}

.fm-row.is-dragging {
  opacity: 0.58;
}

.fm-row.is-drag-over > * {
  background: rgba(13, 110, 253, 0.08);
}

.fm-table tbody.is-drag-over td {
  background: rgba(13, 110, 253, 0.06);
}

.fm-name-button,
.fm-name-stack {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.fm-name-stack .text-truncate {
  max-width: 100%;
}

.fm-icon-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.15rem;
  height: 2rem;
  padding: 0 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}

.fm-icon-folder {
  color: #157347;
  background: rgba(25, 135, 84, 0.12);
}

.fm-icon-file {
  color: #0d6efd;
  background: rgba(13, 110, 253, 0.12);
}

.fm-soft-badge {
  color: #157347 !important;
  background: rgba(25, 135, 84, 0.12) !important;
  border: 1px solid rgba(25, 135, 84, 0.16);
}

.fm-detail-stack {
  display: grid;
  gap: 0.75rem;
}

.fm-detail-line {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.94);
  padding: 0.85rem 1rem;
}

.fm-detail-callout {
  border-radius: 1rem;
  padding: 0.95rem 1rem;
  color: #fff;
  background: linear-gradient(135deg, #198754, #5ba84a);
}

.fm-tip-list {
  display: grid;
  gap: 0.75rem;
}

.fm-tip-item {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.94);
  padding: 0.85rem 1rem;
}

.fm-preview-body {
  min-height: 18rem;
  display: grid;
  place-items: center;
}

.fm-preview-text {
  width: 100%;
  min-height: 22rem;
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  background: rgba(248, 250, 252, 0.94);
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.fm-preview-frame {
  width: 100%;
  min-height: 72vh;
  border: 0;
  border-radius: 1rem;
  background: #f8fafc;
}

.fm-log-success {
  color: #157347;
  border-color: rgba(25, 135, 84, 0.22);
  background: rgba(25, 135, 84, 0.08);
}

.fm-log-danger {
  color: #b02a37;
  border-color: rgba(220, 53, 69, 0.22);
  background: rgba(220, 53, 69, 0.08);
}

.share-link-input {
  min-width: 260px;
}

.status-log,
.log {
  white-space: pre-wrap;
  background: rgba(248, 249, 250, 0.92);
  border: 1px solid var(--app-border);
  border-radius: 1rem;
  padding: 1rem;
  min-height: 3.25rem;
}

.log:empty {
  display: none;
}

.task-progress-text,
.task-speed-text,
.task-status-text {
  white-space: nowrap;
}

.share-shell {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  gap: 1.25rem;
}

.share-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.share-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.custom-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.file-icon-col {
  width: 64px;
  text-align: center;
}

.file-icon {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.85rem;
  background: rgba(25, 135, 84, 0.08);
}

.file-icon img,
.file-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

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

.zip-fab {
  align-self: flex-start;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .admin-shell,
  .admin-shell.collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar-card {
    position: static;
  }

  .admin-shell.mobile-collapsed .side-nav,
  .admin-shell.mobile-collapsed .sidebar-meta {
    display: none;
  }

  .admin-shell.collapsed .brand-copy,
  .admin-shell.collapsed .side-text {
    display: block;
  }

  .admin-shell.collapsed .side-link {
    justify-content: flex-start;
    padding-inline: 1rem;
  }

  .admin-shell.collapsed #toggleSidebar {
    font-size: 0.875rem;
  }

  .admin-shell.collapsed #toggleSidebar::after {
    content: "";
  }

  .file-manager-shell {
    grid-template-columns: 1fr;
  }

  .fm-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 576px) {
  .share-head {
    flex-direction: column;
  }

  .share-head-actions {
    width: 100%;
    justify-content: space-between;
  }

  .custom-buttons {
    width: 100%;
  }

  .custom-buttons .btn {
    flex: 1 1 140px;
  }

  .files-storage-picker {
    flex-direction: column;
    align-items: stretch;
  }

  .fm-main-toolbar,
  .fm-action-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .fm-toolbar-actions,
  .fm-action-bar .d-flex,
  .fm-action-bar .btn-group {
    width: 100%;
  }

  .fm-action-bar .btn,
  .fm-action-bar .btn-group > .btn {
    flex: 1 1 auto;
  }

  .fm-stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .fm-name-button,
  .fm-name-stack {
    align-items: flex-start;
  }
}
