/* ==========================================================================
   CFR2 配套主页 · 样式
   令牌与组件从主程序的 public/css/app.css 复制而来，保持同一套视觉语言。
   改主题色时两处要一起改，或者直接改这里的 --accent。
   ========================================================================== */

/* ---------------------------------------------------------------- 令牌 */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #e8e8ed;
  --topbar-bg: rgba(251, 251, 253, 0.72);

  --border: #d2d2d7;
  --border-2: #e8e8ed;

  --text: #1d1d1f;
  --text-dim: #6e6e73;
  --text-mute: #86868b;

  --accent: #1586ca;
  --accent-hover: #1276b3;
  --accent-active: #10679d;
  --accent-soft: rgba(21, 134, 202, 0.09);
  --accent-soft-strong: rgba(21, 134, 202, 0.16);
  --accent-ring: rgba(21, 134, 202, 0.28);
  --accent-contrast: #ffffff;

  --ok: #1d8a4e;
  --warn: #a86500;
  --err: #d70015;
  --info: #0b63a8;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 980px;

  --shadow-pop: 0 4px 24px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --content-max: 1100px;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1d1d1f;
  --surface-2: #1d1d1f;
  --surface-3: #2d2d2f;
  --topbar-bg: rgba(0, 0, 0, 0.72);

  --border: #38383a;
  --border-2: #2d2d2f;

  --text: #f5f5f7;
  --text-dim: #a1a1a6;
  --text-mute: #86868b;

  --ok: #30d158;
  --warn: #ffd60a;
  --err: #ff453a;
  --info: #64d2ff;

  --shadow-pop: 0 4px 24px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------- 基础 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

p {
  margin: 0;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}

input {
  font: inherit;
  letter-spacing: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

::selection {
  background: var(--accent-soft-strong);
}

.mono {
  font-family: var(--mono);
  font-size: 0.88em;
  letter-spacing: 0;
}

.mute {
  color: var(--text-mute);
}

.muted {
  color: var(--text-dim);
}

.nowrap {
  white-space: nowrap;
}

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

.tnum {
  font-variant-numeric: tabular-nums;
}

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

/* ---------------------------------------------------------------- 布局 */

.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.home-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 28px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-2);
}

.home-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--accent-contrast);
  background: var(--accent);
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-mute);
}

.home-top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 56px 28px 80px;
  flex: 1;
  animation: rise 0.5s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.home-hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: -0.03em;
}

.home-hero p {
  margin-top: 10px;
  font-size: 16px;
  color: var(--text-dim);
}

/* 文件统计那行要比描述小一号、淡一档，避免两条文字抢注意力 */
.home-hero .home-stats {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--text-mute);
}

.home-hero .search-box {
  margin-top: 26px;
  max-width: 420px;
}

.home-foot {
  padding: 0 28px 48px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-mute);
}

.home-foot .mono {
  word-break: break-all;
}

/* ---------------------------------------------------------------- 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:hover {
  background: var(--surface-3);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  height: 30px;
  padding: 0 13px;
  font-size: 13.5px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
}

/* ---------------------------------------------------------------- 表单 */

.search-box {
  position: relative;
  width: 100%;
}

.search-box > span {
  position: absolute;
  top: 50%;
  left: 13px;
  transform: translateY(-50%);
  color: var(--text-mute);
  pointer-events: none;
  display: flex;
}

.search-box svg {
  width: 15px;
  height: 15px;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 14px 9px 36px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.input::placeholder {
  color: var(--text-mute);
}

.input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

/* ---------------------------------------------------------------- 表格 */

.table-wrap {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  overflow: hidden;
}

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

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-2);
  color: var(--text-mute);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-2);
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.16s var(--ease);
}

.table tbody tr:hover {
  background: var(--bg);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

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

.cell-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cell-name .icon {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-dim);
}

:root[data-theme="dark"] .cell-name .icon {
  background: var(--surface-3);
}

.cell-name .icon svg {
  width: 16px;
  height: 16px;
}

.cell-name .text {
  min-width: 0;
}

.cell-name .name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-name .sub {
  font-size: 12px;
  color: var(--text-mute);
}

.cell-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ---------------------------------------------------------------- 提示 */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  margin-top: 24px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: 14px;
}

:root[data-theme="dark"] .alert {
  background: var(--surface-3);
}

.alert svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}

.alert-body {
  min-width: 0;
  flex: 1;
}

.alert-body strong {
  display: block;
  margin-bottom: 3px;
  font-weight: 500;
}

.alert-text {
  color: var(--text-dim);
}

.alert-warn {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  color: var(--warn);
}

.alert-error {
  background: color-mix(in srgb, var(--err) 8%, transparent);
  color: var(--err);
}

.alert-info {
  background: var(--accent-soft);
  color: var(--accent);
}

.alert-ok {
  background: color-mix(in srgb, var(--ok) 9%, transparent);
  color: var(--ok);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 24px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--text-mute);
}

:root[data-theme="dark"] .empty-icon {
  background: var(--surface-3);
}

.empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty h3 {
  font-size: 17px;
}

.empty p {
  max-width: 420px;
  color: var(--text-dim);
  font-size: 14px;
}

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
}

@keyframes skeleton {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

.spinner {
  width: 15px;
  height: 15px;
  flex: none;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner.lg {
  width: 26px;
  height: 26px;
  border-width: 2.5px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------------- 通知 */

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 14px;
  animation: toast-in 0.32s var(--ease) both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}

.toast-body {
  min-width: 0;
  flex: 1;
}

.toast-title {
  margin-bottom: 2px;
  font-weight: 500;
}

.toast-msg {
  color: var(--text-dim);
  font-size: 13.5px;
  word-break: break-all;
}

.toast-ok svg {
  color: var(--ok);
}
.toast-error svg {
  color: var(--err);
}
.toast-info svg {
  color: var(--accent);
}

.toast-close {
  padding: 0;
  border: none;
  background: none;
  color: var(--text-mute);
  line-height: 1;
  display: flex;
}

.toast-close svg {
  width: 13px;
  height: 13px;
}

/* ---------------------------------------------------------------- 主题切换 */

.theme-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
}

:root[data-theme="dark"] .theme-toggle {
  background: var(--surface-3);
}

.theme-toggle button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: none;
  border-radius: var(--r-pill);
  background: none;
  color: var(--text-mute);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.theme-toggle button svg {
  width: 14px;
  height: 14px;
}

.theme-toggle button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 700px) {
  .home-top {
    padding: 0 18px;
  }

  .home-main {
    padding: 36px 18px 60px;
  }

  .table th,
  .table td {
    padding: 11px 13px;
  }

  .table .col-size,
  .table .col-date {
    display: none;
  }

  .toast-stack {
    right: 16px;
    bottom: 16px;
    left: 16px;
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
