/* ==========================================================================
   红书助手 · 设计基座
   统一色板 / 排版 / 布局 / 组件，供各功能模块复用
   ========================================================================== */

/* ---------------------------------------------------------------- 变量 */
:root {
  /* 品牌 */
  --brand: #ff2e4d;
  --brand-600: #e81f3f;
  --brand-700: #c91533;
  --brand-soft: #fff1f3;
  --brand-line: #ffd6dd;

  /* 中性色 */
  --ink: #1f2023;
  --ink-2: #33353a;
  --sub: #6b6e76;
  --muted: #9a9da4;
  --faint: #c4c6cc;
  --bg: #f5f5f6;
  --bg-2: #efeff1;
  --panel: #ffffff;
  --line: #e7e8eb;
  --line-2: #d8dade;

  /* 语义色 */
  --ok: #2f7d5b;
  --ok-soft: #eaf5ef;
  --ok-line: #c9e6d6;
  --warn: #b8720f;
  --warn-soft: #fdf4e4;
  --warn-line: #f2ddb4;
  --bad: #c0392b;
  --bad-soft: #fbedeb;
  --bad-line: #f3d2cd;
  --info: #2d6bff;
  --info-soft: #eef3ff;
  --info-line: #d3e0ff;

  /* 圆角 */
  --r-xs: 6px;
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --r-xl: 22px;

  /* 阴影 */
  --sh-s: 0 1px 2px rgba(16, 17, 20, 0.05);
  --sh-m: 0 6px 24px rgba(16, 17, 20, 0.07);
  --sh-l: 0 18px 48px rgba(16, 17, 20, 0.14);

  /* 布局 */
  --sidebar-w: 240px;
  --max: 1200px;

  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC",
    "Source Han Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img {
  display: block;
  max-width: 100%;
}

/* hidden 属性优先于组件自身的 display 设置 */
[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: rgba(255, 46, 77, 0.18);
}

/* 滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: #d3d5da transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: #d3d5da;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #b9bcc2;
}

/* ---------------------------------------------------------------- 布局 */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(150deg, #ff4d68, var(--brand) 55%, #d91636);
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
  box-shadow: 0 6px 14px rgba(255, 46, 77, 0.28);
}

.brand-mark {
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

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

.brand-name {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.4;
}

.nav-group-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  padding: 6px 10px;
  font-weight: 600;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1 1 auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-s);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
  white-space: nowrap;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--sub);
  transition: color 0.15s;
}

.nav-item:hover {
  background: #f6f6f8;
}

button.nav-item {
  width: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.65;
  text-align: left;
}

button.nav-item:hover {
  background: #f6f6f8;
}

.nav-action {
  color: var(--sub);
}

.nav-item.is-active {
  background: var(--brand-soft);
  color: var(--brand-700);
  font-weight: 600;
}

.nav-item.is-active svg {
  color: var(--brand);
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0 6px;
  line-height: 16px;
}

.nav-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 10px;
}

.side-foot {
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.privacy-chip {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--sub);
  background: #fafafb;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 8px 9px;
}

.privacy-chip svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--ok);
}

.side-admin {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--sub);
  padding: 6px 8px;
  border-radius: var(--r-s);
}

.side-admin:hover {
  background: #f6f6f8;
  color: var(--ink);
}

.side-admin svg {
  width: 14px;
  height: 14px;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.view {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 26px 30px 40px;
}

.site-foot {
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding: 18px 30px 30px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.site-foot b {
  color: var(--sub);
  font-weight: 600;
}

/* ---------------------------------------------------------------- 页头 */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head-main {
  min-width: 0;
  flex: 1 1 320px;
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 6px;
  white-space: nowrap;
}

.page-eyebrow svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.page-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--sub);
  max-width: 720px;
  line-height: 1.7;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
}

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 20px;
  min-width: 0;
}

.card-flat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 16px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 16px;
  height: 16px;
  color: var(--brand);
}

.card-sub {
  font-size: 12px;
  color: var(--sub);
}

.card-head .spacer {
  flex: 1 1 auto;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--sub);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label .spacer {
  flex: 1 1 auto;
}

/* 通用分栏 */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.split-wide {
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
}

.split-wide-r {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
}

.sticky-col {
  position: sticky;
  top: 20px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-s {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.row-tight {
  display: flex;
  align-items: center;
  gap: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--r-s);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.4;
  min-height: 36px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s,
    transform 0.05s;
  white-space: nowrap;
  user-select: none;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.btn:hover {
  border-color: #c2c5ca;
  background: #fafafb;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 46, 77, 0.22);
}

.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  box-shadow: 0 6px 16px rgba(255, 46, 77, 0.28);
}

.btn-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.btn-dark:hover {
  background: #000;
  border-color: #000;
}

.btn-soft {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-700);
}

.btn-soft:hover {
  background: #ffe4e9;
  border-color: #ffc2cd;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--sub);
}

.btn-ghost:hover {
  background: #f2f2f4;
  color: var(--ink);
  border-color: transparent;
}

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: var(--r-xs);
}

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

.btn-xs {
  min-height: 26px;
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-lg {
  min-height: 44px;
  padding: 11px 22px;
  font-size: 14px;
  border-radius: 10px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: var(--r-xs);
}

.btn-icon svg {
  width: 15px;
  height: 15px;
}

.btn.is-busy {
  pointer-events: none;
  opacity: 0.7;
}

.btn .spin {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.btn.is-busy .spin {
  display: inline-block;
}

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

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------- 表单 */
.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.field-label .req {
  color: var(--brand);
  font-size: 11px;
}

.field-label .hint,
.field-label .counter {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.counter.is-over {
  color: var(--bad);
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: #fff;
  padding: 9px 11px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 38px;
}

.input::placeholder,
.textarea::placeholder {
  color: #a9acb3;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: #c2c5ca;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(31, 32, 35, 0.08);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
  background: #f6f6f8;
  color: var(--muted);
  cursor: not-allowed;
}

.textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.7;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6e76' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.input-sm {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
  border-radius: var(--r-xs);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.field-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.55;
}

.field-hint.is-warn {
  color: var(--warn);
}

.field-hint.is-error {
  color: var(--bad);
}

/* 输入前缀单位 */
.input-unit {
  position: relative;
}

.input-unit .unit {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}

.input-unit .input {
  padding-right: 34px;
}

/* 滑块 */
input[type="range"].range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}

input[type="range"].range::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--line-2);
  border-radius: 99px;
}

input[type="range"].range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
}

input[type="range"].range::-moz-range-track {
  height: 4px;
  background: var(--line-2);
  border-radius: 99px;
}

input[type="range"].range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.range-row .range {
  flex: 1 1 auto;
}

.range-row .range-val {
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  min-height: 30px;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch .track {
  width: 36px;
  height: 21px;
  border-radius: 99px;
  background: var(--line-2);
  position: relative;
  transition: background 0.16s;
  flex: 0 0 auto;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
  transition: transform 0.16s;
}

.switch input:checked + .track {
  background: var(--brand);
}

.switch input:checked + .track::after {
  transform: translateX(15px);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 复选 / 单选 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  min-height: 30px;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  margin: 0;
  cursor: pointer;
}

/* 选项按钮组（横排单选） */
.choice-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.choice {
  border: 1px solid var(--line-2);
  background: #fff;
  border-radius: 99px;
  padding: 5px 13px;
  font-size: 12.5px;
  color: var(--sub);
  transition: all 0.14s;
  min-height: 30px;
}

.choice:hover {
  border-color: #c2c5ca;
  color: var(--ink);
}

.choice.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 550;
}

.choice.is-on-brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ---------------------------------------------------------------- 标签页 */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #ededef;
  border-radius: 10px;
  margin-bottom: 18px;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--sub);
  font-size: 13px;
  font-weight: 550;
  padding: 6px 15px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  min-height: 32px;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(16, 17, 20, 0.1);
}

.tab .tab-count {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

/* 下划线式 tabs */
.tabs-line {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tabs-line .tab {
  border-radius: 0;
  background: none;
  box-shadow: none;
  padding: 8px 0 10px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs-line .tab.is-active {
  border-bottom-color: var(--brand);
  background: none;
  box-shadow: none;
  color: var(--brand-700);
}

/* ---------------------------------------------------------------- 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  line-height: 1.5;
  padding: 2px 8px;
  border-radius: 99px;
  background: #f2f2f4;
  color: var(--sub);
  border: 1px solid transparent;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

.tag-brand {
  background: var(--brand-soft);
  color: var(--brand-700);
  border-color: var(--brand-line);
}

.tag-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}

.tag-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
}

.tag-bad {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: var(--bad-line);
}

.tag-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: var(--info-line);
}

.tag-dark {
  background: var(--ink);
  color: #fff;
}

.tag-btn {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--sub);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  transition: all 0.14s;
}

.tag-btn:hover {
  border-color: #c2c5ca;
  color: var(--ink);
}

.tag-btn.is-on {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-700);
  font-weight: 550;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: currentColor;
}

/* ---------------------------------------------------------------- 指标 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 15px 16px;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.kpi-label {
  font-size: 12px;
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.kpi-label svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
}

.kpi-value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.kpi-value small {
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
  margin-left: 3px;
  letter-spacing: 0;
}

.kpi-foot {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-accent {
  background: linear-gradient(140deg, #fff 0%, #fff6f7 100%);
  border-color: var(--brand-line);
}

.kpi-accent .kpi-value {
  color: var(--brand-700);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.delta.up {
  color: var(--ok);
}

.delta.down {
  color: var(--bad);
}

.delta.flat {
  color: var(--muted);
}

/* ---------------------------------------------------------------- 表格 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--panel);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 560px;
}

table.table th,
table.table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

table.table th {
  background: #fafafb;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--sub);
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
  z-index: 1;
}

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

table.table tbody tr:hover {
  background: #fbfbfc;
}

table.table td.num {
  font-variant-numeric: tabular-nums;
}

table.table td.wrap {
  white-space: normal;
  min-width: 220px;
}

/* 进度条 */
.bar-track {
  height: 6px;
  border-radius: 99px;
  background: #f0f0f2;
  overflow: hidden;
  min-width: 60px;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--brand);
  transition: width 0.4s ease;
}

.bar-fill.ok {
  background: var(--ok);
}

.bar-fill.info {
  background: var(--info);
}

/* ---------------------------------------------------------------- 空态 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 44px 20px;
  text-align: center;
  color: var(--sub);
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: #f3f3f5;
  display: grid;
  place-items: center;
  color: var(--muted);
  margin-bottom: 2px;
}

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

.empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.empty-desc {
  font-size: 12.5px;
  max-width: 380px;
  line-height: 1.7;
}

/* 骨架 */
.skeleton {
  background: linear-gradient(90deg, #f1f1f3 25%, #e9e9ec 37%, #f1f1f3 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 6px;
  min-height: 12px;
}

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

/* ---------------------------------------------------------------- 提示 */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1f2023;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--sh-l);
  max-width: 440px;
  animation: toast-in 0.2s ease;
}

.toast svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.toast.ok {
  background: #1d4a37;
}

.toast.err {
  background: #8e2b20;
}

.toast.warn {
  background: #7a4b09;
}

.toast.is-out {
  animation: toast-out 0.18s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(18, 19, 22, 0.42);
  backdrop-filter: blur(2px);
  z-index: 150;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 24px;
  overflow-y: auto;
  animation: fade-in 0.16s ease;
}

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

.modal {
  background: #fff;
  border-radius: var(--r-l);
  box-shadow: var(--sh-l);
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  animation: modal-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal.is-wide {
  max-width: 720px;
}

.modal.is-narrow {
  max-width: 400px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.modal-title {
  font-size: 15px;
  font-weight: 650;
  flex: 1 1 auto;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  border: 0;
  background: transparent;
  color: var(--sub);
  display: grid;
  place-items: center;
}

.modal-close:hover {
  background: #f2f2f4;
  color: var(--ink);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.modal-foot .spacer {
  flex: 1 1 auto;
}

/* 确认框内容 */
.confirm-message {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.7;
}

.confirm-warn {
  margin-top: 10px;
  background: var(--bad-soft);
  border: 1px solid var(--bad-line);
  color: var(--bad);
  border-radius: var(--r-s);
  padding: 9px 12px;
  font-size: 12.5px;
}

/* 侧滑抽屉 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(18, 19, 22, 0.38);
  z-index: 150;
  display: flex;
  justify-content: flex-end;
  animation: fade-in 0.16s ease;
}

.drawer {
  width: min(460px, 100%);
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-l);
  animation: drawer-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes drawer-in {
  from {
    transform: translateX(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- 工具类 */
.mono {
  font-family: var(--mono);
  font-size: 12px;
}

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

.sub {
  color: var(--sub);
}

.bad {
  color: var(--bad);
}

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

.warn {
  color: var(--warn);
}

.brand {
  color: var(--brand);
}

.fs-12 {
  font-size: 12px;
}

.fs-13 {
  font-size: 13px;
}

.fw-600 {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

.scroll-y {
  overflow-y: auto;
}

/* 页面切换动画 */
.view > .page {
  animation: page-in 0.18s ease;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------------- 路由加载 */
.route-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50vh;
  color: var(--sub);
  font-size: 13px;
}

.route-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------------------------------------------------------------- 长文 */
.prose {
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-2);
}

.prose p {
  margin: 0 0 12px;
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose b {
  color: var(--ink);
  font-weight: 650;
}

.prose ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

.prose li {
  margin-bottom: 5px;
}

/* ---------------------------------------------------------------- 图表 */
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  font-size: 12.5px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--sub);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-item i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.donut-svg {
  display: block;
  width: 100%;
  max-width: 220px;
  height: auto;
  margin: 0 auto;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--sub);
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}

.donut-legend-item i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: 0 0 auto;
}

.donut-legend-item b {
  margin-left: auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1020px) {
  .split,
  .split-wide,
  .split-wide-r {
    grid-template-columns: minmax(0, 1fr);
  }

  .sticky-col {
    position: static;
  }

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

@media (max-width: 900px) {
  :root {
    --sidebar-w: 0px;
  }

  .sidebar {
    inset: auto 0 0 0;
    width: 100%;
    height: 62px;
    padding: 0 6px calc(0px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--line);
    flex-direction: row;
    align-items: stretch;
    z-index: 60;
    overflow-x: auto;
  }

  .brand,
  .nav-group-label,
  .side-foot,
  .nav-divider {
    display: none;
  }

  .side-nav {
    flex-direction: row;
    align-items: center;
    gap: 1px;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    overflow-x: auto;
  }

  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px 5px;
    font-size: 10px;
    min-width: 44px;
    justify-content: center;
    text-align: center;
    border-radius: var(--r-xs);
  }

  .nav-item svg {
    width: 19px;
    height: 19px;
  }

  .nav-item .nav-badge {
    display: none;
  }

  .main {
    margin-left: 0;
    padding-bottom: 66px;
  }

  .view {
    padding: 18px 16px 30px;
  }

  .site-foot {
    padding: 14px 16px 22px;
  }

  .page-title {
    font-size: 21px;
  }

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

  .field-row,
  .field-row-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .grid-2,
  .grid-3,
  .grid-4,
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .card {
    padding: 16px;
    border-radius: var(--r-m);
  }

  .modal-mask {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-height: 92vh;
    border-radius: var(--r-l) var(--r-l) 0 0;
  }
}

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