/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-cream);
  border-right: 1px solid var(--line-faint);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  padding: var(--space-5);
  border-bottom: 1px solid var(--line-faint);
}
.sidebar__brand-zh {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-deep);
  letter-spacing: 3px;
}
.sidebar__brand-en {
  font-family: var(--font-num);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 2px;
  margin-top: 2px;
}
.sidebar__brand-tag {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 8px;
  font-size: 11px;
  background: var(--brand-moss-pale);
  color: var(--brand-moss-deep);
  border-radius: var(--radius-pill);
  letter-spacing: 1px;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-4) 0;
  overflow-y: auto;
}
.sidebar__group {
  margin-bottom: var(--space-4);
}
.sidebar__group-title {
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--ink-mute);
  padding: 8px var(--space-5);
  letter-spacing: 4px;
}
.sidebar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 var(--space-5);
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
  position: relative;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}
.sidebar__item:hover { color: var(--ink-deep); background: rgba(92, 107, 58, 0.04); }
.sidebar__item.is-active {
  color: var(--brand-moss);
  background: var(--brand-moss-pale);
  border-left-color: var(--brand-moss);
  font-weight: 500;
}
.sidebar__item-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: inherit;
}
.sidebar__item-badge {
  margin-left: auto;
  background: var(--accent-tomato);
  color: white;
  font-size: 10px;
  height: 16px; min-width: 16px;
  padding: 0 5px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header {
  height: var(--header-h);
  background: var(--bg-cream);
  border-bottom: 1px solid var(--line-faint);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header__crumb {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.header__crumb-sep { color: var(--ink-mute); }
.header__crumb-cur { color: var(--ink-deep); font-weight: 500; }
.header__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.header__icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.2s ease;
}
.header__icon-btn:hover { background: var(--bg-linen); color: var(--ink-deep); }
.header__user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.2s ease;
}
.header__user:hover { background: var(--bg-linen); }
.header__user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-moss);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif);
  font-size: 14px;
}
.header__user-name { font-size: 13px; color: var(--ink-deep); }
.header__user-role { font-size: 11px; color: var(--ink-mute); }

.content {
  padding: var(--space-6);
  flex: 1;
}
.content__head {
  margin-bottom: var(--space-5);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}
.content__title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink-deep);
  letter-spacing: 1px;
}
.content__subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
}

/* ============ Card ============ */
.card {
  background: var(--bg-cream);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.card__title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-deep);
  display: flex; align-items: center; gap: 8px;
}
.card__title::before {
  content: ""; width: 3px; height: 14px;
  background: var(--brand-moss);
  border-radius: 2px;
}

/* ============ Button ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary { background: var(--brand-moss); color: var(--ink-inverse); border-color: var(--brand-moss); }
.btn-primary:hover { background: var(--brand-moss-deep); border-color: var(--brand-moss-deep); }
.btn-primary-outline { background: transparent; color: var(--brand-moss); border-color: var(--brand-moss); }
.btn-primary-outline:hover { background: var(--brand-moss); color: var(--ink-inverse); }
.btn-crit { background: var(--accent-tomato); color: white; border-color: var(--accent-tomato); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-faint); }
.btn-ghost:hover { background: var(--bg-linen); color: var(--ink-deep); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 24px; font-size: 14px; }
.btn-block { width: 100%; }

/* ============ Tag ============ */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
}
.tag-moss { background: var(--brand-moss-pale); color: var(--brand-moss-deep); }
.tag-clay { background: rgba(139, 111, 71, 0.12); color: var(--accent-clay); }
.tag-tomato { background: rgba(201, 71, 43, 0.1); color: var(--accent-tomato); }
.tag-amber { background: rgba(212, 148, 60, 0.14); color: var(--accent-amber); }
.tag-mute { background: var(--bg-linen); color: var(--ink-soft); }

/* ============ Form ============ */
.form-row { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink-deep);
  margin-bottom: 8px;
  font-weight: 500;
}
.form-label .req { color: var(--accent-tomato); margin-left: 2px; }
.input, .textarea, .select {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-paper);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--ink-deep);
  transition: border 0.2s ease, background 0.2s ease;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand-moss);
  background: var(--bg-cream);
}
.textarea { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.input-group { display: flex; gap: 12px; }
.input-group .input, .input-group .select { flex: 1; }

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background: var(--line-faint);
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch::after {
  content: ""; position: absolute;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.switch.is-on { background: var(--brand-moss); }
.switch.is-on::after { left: 20px; }

/* ============ Table ============ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mute);
  padding: 14px 16px;
  background: var(--bg-paper);
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--line-faint);
}
.data-table td {
  padding: 16px;
  font-size: 13px;
  color: var(--ink-deep);
  border-bottom: 1px solid var(--line-faint);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(92, 107, 58, 0.03); }
.data-table .col-thumb {
  width: 48px; height: 48px;
  border-radius: 8px;
  background: var(--bg-linen);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  color: var(--ink-mute);
  font-size: 12px;
}
.data-table .col-thumb img { width: 100%; height: 100%; object-fit: cover; }
.data-table .col-action { white-space: nowrap; }
.data-table .col-action .btn { margin-right: 4px; }

/* ============ KPI Card ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.kpi {
  background: var(--bg-cream);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute;
  right: -20px; top: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--brand-moss-pale);
  opacity: 0.4;
}
.kpi__label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
  letter-spacing: 0.5px;
}
.kpi__value {
  font-family: var(--font-num);
  font-size: 32px;
  font-weight: 500;
  color: var(--accent-clay);
  line-height: 1.2;
  font-feature-settings: "tnum";
}
.kpi__delta {
  font-size: 11px;
  color: var(--brand-moss);
  margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}
.kpi__delta.is-down { color: var(--accent-tomato); }
.kpi__delta.is-up { color: var(--brand-moss); font-weight: 500; }

/* ============ Filter Bar ============ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-cream);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.filter-bar .input, .filter-bar .select { height: 36px; }
.filter-bar .label { font-size: 12px; color: var(--ink-soft); margin-right: 6px; }

/* ============ Tabs (segmented) ============ */
.segmented {
  display: inline-flex;
  background: var(--bg-paper);
  border: 1px solid var(--line-faint);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}
.segmented__item {
  padding: 6px 18px;
  font-size: 13px;
  color: var(--ink-soft);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}
.segmented__item.is-active {
  background: var(--brand-moss);
  color: var(--ink-inverse);
  font-weight: 500;
}

/* ============ Pagination ============ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: var(--space-5);
}
.pagination__item {
  min-width: 32px; height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  border: 1px solid var(--line-faint);
  background: var(--bg-cream);
}
.pagination__item.is-active { background: var(--brand-moss); color: var(--ink-inverse); border-color: var(--brand-moss); }
.pagination__item:hover:not(.is-active) { background: var(--bg-paper); color: var(--ink-deep); }

/* ============ Modal ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(42, 37, 32, 0.4);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--bg-cream);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease;
}
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line-faint);
}
.modal__title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-deep);
}
.modal__close { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); cursor: pointer; }
.modal__close:hover { background: var(--bg-linen); color: var(--ink-deep); }
.modal__body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.modal__foot { padding: var(--space-4) var(--space-5); border-top: 1px solid var(--line-faint); display: flex; justify-content: flex-end; gap: 8px; }

/* ============ Empty / Loading ============ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px var(--space-5);
  color: var(--ink-mute);
}
.empty__icon { width: 80px; height: 80px; margin-bottom: var(--space-3); opacity: 0.5; }
.empty__text { font-family: var(--font-serif); font-size: 16px; color: var(--ink-soft); margin-bottom: 6px; }
.empty__hint { font-size: 12px; color: var(--ink-mute); margin-bottom: 16px; text-align: center; line-height: 1.6; }
.empty__cta {
  padding: 8px 20px;
  background: var(--brand-moss);
  color: var(--ink-inverse);
  border-radius: var(--radius-pill);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  border: none;
}
.empty__cta:hover { background: var(--brand-moss-deep); }

/* 表格内空行（用于"暂无数据"单行展示） */
.data-table tbody .table-empty {
  text-align: center;
  color: var(--ink-mute);
  font-size: 12px;
  letter-spacing: 1px;
  height: 120px;
  background: var(--bg-paper);
  font-style: italic;
}
.data-table tbody .table-empty:hover td { background: var(--bg-paper); }
.data-table tbody .table-empty td { padding: 40px 16px; }

/* 加载进度条（顶部 3px 苔藓绿） */
.page-loading {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-moss);
  z-index: 9999;
  animation: pageLoad 1.2s ease forwards;
}
@keyframes pageLoad {
  0% { width: 0; }
  60% { width: 70%; }
  100% { width: 100%; opacity: 0; }
}

/* ============ Toast ============ */
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink-deep);
  color: var(--ink-inverse);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  z-index: 999;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.25s ease;
}
