/* ==========================================================================
   藏书阁 · 图书管理系统
   纸感暖色 + 墨绿，衬线标题
   ========================================================================== */

:root {
  --bg: #f2eee4;
  --bg-deep: #e9e3d5;
  --card: #fffdf8;
  --card-soft: #faf6ec;
  --ink: #23261f;
  --ink-2: #565b4e;
  --ink-3: #8b8f80;
  --line: #e3dbcb;
  --line-soft: #ece7da;

  --brand: #1f4d43;
  --brand-deep: #163831;
  --brand-2: #2e6b5d;
  --brand-soft: #e2ebe6;

  --accent: #b5643b;
  --accent-soft: #f6e8de;

  --danger: #b23a2c;
  --danger-soft: #f9e5e0;
  --warn: #b07c27;
  --warn-soft: #f8eed8;
  --ok: #3d7a55;
  --ok-soft: #e4efe6;
  --blue: #37618c;
  --blue-soft: #e4ebf3;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(35, 38, 31, .05);
  --shadow: 0 1px 2px rgba(35, 38, 31, .04), 0 10px 28px -14px rgba(35, 38, 31, .18);

  --serif: 'Songti SC', 'STSong', 'Noto Serif SC', 'Source Han Serif SC', 'SimSun', Georgia, serif;
  --sans: -apple-system, 'PingFang SC', 'Microsoft YaHei UI', 'Microsoft YaHei', 'Noto Sans SC', 'Segoe UI', sans-serif;
  --mono: 'Cascadia Mono', 'Consolas', 'SF Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }

svg { display: block; }

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

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 228px;
  flex: 0 0 228px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 16px 18px;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, .045), transparent 46%),
    linear-gradient(168deg, #1b2b26 0%, #14211d 62%, #101b18 100%);
  color: #cfd9d3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 8px 24px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05));
  border: 1px solid rgba(255, 255, 255, .12);
  color: #e8dfc9;
}

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

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .14em;
  color: #f2eee4;
  font-weight: 600;
}
.brand-text span {
  font-size: 10.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #7d8d85;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #a9b8b1;
  font-size: 14px;
  letter-spacing: .04em;
  text-align: left;
  transition: background .16s ease, color .16s ease;
}

.nav-item:hover { background: rgba(255, 255, 255, .06); color: #eef2ee; }

.nav-item.is-active {
  background: rgba(181, 100, 59, .17);
  color: #f6ede2;
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -13px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-icon { width: 19px; height: 19px; flex: 0 0 19px; opacity: .95; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 10px 2px;
  font-size: 11.5px;
  color: #6f8078;
  letter-spacing: .04em;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #6fbf8b;
  box-shadow: 0 0 0 3px rgba(111, 191, 139, .16);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 34px 40px 64px;
}

.view-root { max-width: 1180px; margin: 0 auto; }

/* ---------- 页头 ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.page-head h1 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.3;
}

.page-head .sub {
  margin-top: 5px;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: .03em;
}

.page-head .head-actions { display: flex; gap: 9px; flex-wrap: wrap; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13.5px;
  letter-spacing: .02em;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}

.btn:hover { background: #fbf7ee; border-color: var(--line-2, #d6ccb8); color: var(--ink); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #f6f1e6;
}
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }

.btn.danger { color: var(--danger); border-color: #e6c8c1; background: #fff9f7; }
.btn.danger:hover { background: var(--danger-soft); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(35, 38, 31, .05); }

.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }

.btn .plus { font-size: 16px; line-height: 1; margin-top: -1px; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: var(--ink-3);
  transition: background .14s ease, color .14s ease;
}
.icon-btn:hover { background: rgba(35, 38, 31, .06); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

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

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 13px 18px;
  margin-bottom: 22px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  border: 1px solid #ecc8c0;
  color: #7e2b20;
  font-size: 13.5px;
}

.alert .alert-main { display: flex; align-items: center; gap: 10px; }
.alert strong { font-weight: 600; }

.alert svg { width: 18px; height: 18px; flex: 0 0 18px; }

/* ---------- 统计卡 ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  padding: 18px 20px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--tone, var(--brand)), transparent 70%);
  opacity: .7;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.stat-label { font-size: 12.5px; color: var(--ink-3); letter-spacing: .06em; }

.stat-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--tone-soft, var(--brand-soft));
  color: var(--tone, var(--brand));
}
.stat-icon svg { width: 16px; height: 16px; }

.stat-value {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: .01em;
}

.stat-value small {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-3);
  margin-left: 5px;
  letter-spacing: .04em;
}

.stat-foot { margin-top: 7px; font-size: 12px; color: var(--ink-3); }

/* ---------- 卡片与网格 ---------- */

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .08em;
}

.card-sub { font-size: 12px; color: var(--ink-3); letter-spacing: .03em; }

/* ---------- 图表 ---------- */

.chart-wrap { position: relative; }

.chart-wrap svg { width: 100%; height: auto; overflow: visible; }

.axis-label {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--ink-3);
  letter-spacing: .02em;
}

.grid-line { stroke: var(--line-soft); stroke-width: 1; }

.trend-line { fill: none; stroke: var(--brand-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.trend-area { fill: url(#trendFill); }

.trend-dot { fill: var(--card); stroke: var(--brand-2); stroke-width: 1.6; }

.donut-center text { font-family: var(--serif); }

.donut-center .num { font-size: 22px; font-weight: 600; fill: var(--ink); }
.donut-center .unit { font-size: 10px; fill: var(--ink-3); letter-spacing: .12em; }

.legend { display: flex; flex-direction: column; gap: 7px; min-width: 0; }

.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); }

.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }

.legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.legend-count { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

.donut-flex { display: flex; align-items: center; gap: 22px; }

.donut-flex .donut { flex: 0 0 168px; width: 168px; }

/* 横向条形 */

.bar-list { display: flex; flex-direction: column; gap: 13px; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }

.bar-name {
  font-size: 13px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-count { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); }

.bar-track {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--brand-2), #5f9a86);
  transition: width .5s cubic-bezier(.2, .8, .3, 1);
}

/* ---------- 最近借阅列表 ---------- */

.mini-list { display: flex; flex-direction: column; }

.mini-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
}
.mini-row:last-child { border-bottom: none; padding-bottom: 2px; }

.mini-book { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-reader { color: var(--ink-3); font-size: 12.5px; flex: 0 0 auto; }
.mini-date { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); flex: 0 0 auto; }

/* ---------- 工具栏 ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.search {
  position: relative;
  flex: 1 1 260px;
  max-width: 380px;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-3);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  outline: none;
  font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.search input::placeholder { color: var(--ink-3); }

.search input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(46, 107, 93, .12);
}

.select {
  height: 36px;
  padding: 0 30px 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b8f80' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none;
  font-size: 13px;
  color: var(--ink-2);
  outline: none;
  cursor: pointer;
}

.select:focus { border-color: var(--brand-2); }

.toolbar-spacer { flex: 1; }

.result-count { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

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

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 12px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--ink-3);
  background: var(--card-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13.5px;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fdfaf2; }

tbody tr.is-overdue { background: rgba(178, 58, 44, .035); }
tbody tr.is-overdue:hover { background: rgba(178, 58, 44, .06); }

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

.book-cover {
  width: 34px;
  height: 46px;
  flex: 0 0 34px;
  border-radius: 4px 7px 7px 4px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 15px;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
  box-shadow: inset 2px 0 0 rgba(255, 255, 255, .18), 0 2px 6px -2px rgba(0, 0, 0, .25);
  overflow: hidden;
  user-select: none;
}

.book-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.book-author { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }

.isbn { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.stock { display: flex; align-items: center; gap: 9px; white-space: nowrap; }

.stock-num { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.stock-num.is-empty { color: var(--danger); }

.stock-bar { width: 52px; height: 4px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.stock-bar i { display: block; height: 100%; border-radius: 2px; background: var(--brand-2); }
.stock-bar i.low { background: var(--warn); }
.stock-bar i.zero { background: var(--danger); }

.location { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

.row-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }

/* ---------- 徽章 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 20px;
  font-size: 11.5px;
  letter-spacing: .03em;
  white-space: nowrap;
}

.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: #efeadf; color: var(--ink-3); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.badge.tag { background: var(--brand-soft); color: var(--brand); }
.badge.tag::before { display: none; }

/* ---------- 读者卡片 ---------- */

.reader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.reader-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 19px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease;
}

.reader-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.reader-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.avatar {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 18px;
  color: #fff8ec;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16);
}

.reader-name { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: .04em; }
.reader-card-no { font-family: var(--mono); font-size: 11px; color: var(--ink-3); letter-spacing: .04em; }

.reader-meta { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 14px; }

.reader-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px dashed var(--line-soft);
}

.reader-foot .count { font-size: 12.5px; color: var(--ink-2); }
.reader-foot .count strong { font-family: var(--mono); font-size: 13px; }

/* ---------- 空状态 ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 62px 20px;
  text-align: center;
  color: var(--ink-3);
}

.empty svg { width: 44px; height: 44px; opacity: .5; }
.empty-title { font-family: var(--serif); font-size: 16px; color: var(--ink-2); letter-spacing: .05em; }
.empty-sub { font-size: 12.5px; }

/* ---------- 数据页 ---------- */

.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

.data-card { display: flex; flex-direction: column; gap: 10px; }

.data-card p { font-size: 13px; color: var(--ink-2); line-height: 1.75; }

.data-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 4px; }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 26px 18px;
  border: 1.5px dashed var(--line-2, #d5cab5);
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
  text-align: center;
}

.drop-zone:hover, .drop-zone.is-drag {
  border-color: var(--brand-2);
  background: var(--brand-soft);
  color: var(--brand);
}

.drop-zone svg { width: 26px; height: 26px; opacity: .8; }

.drop-zone input[type="file"] { display: none; }

.import-label { font-size: 12px; color: var(--ink-3); letter-spacing: .04em; }

textarea {
  width: 100%;
  min-height: 148px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(46, 107, 93, .1); }

.import-result {
  margin-top: 10px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.7;
  background: var(--card-soft);
  border: 1px solid var(--line);
}

.import-result.is-error { background: var(--danger-soft); border-color: #ecc8c0; color: #7e2b20; }

.import-result.is-ok { background: var(--ok-soft); border-color: #c8dfcd; color: #2f5c42; }

.import-result ul { margin: 6px 0 0; padding-left: 18px; }
.import-result li { margin: 2px 0; }

.hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--card-soft);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
}

/* ---------- Tab ---------- */

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 31px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-3);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

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

.tab.is-active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(35, 38, 31, .08);
}

.tab .tab-count {
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(35, 38, 31, .07);
  color: var(--ink-3);
  line-height: 17px;
}

.tab.is-active .tab-count { background: var(--brand-soft); color: var(--brand); }

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 30, 27, .45);
  backdrop-filter: blur(3px);
  animation: fadeIn .16s ease;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -30px rgba(20, 30, 26, .5);
  animation: popIn .18s cubic-bezier(.2, .9, .3, 1.05);
}

.modal.wide { max-width: 620px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}

.modal-title { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .06em; }

.modal-close {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--ink-3);
}
.modal-close:hover { background: rgba(35, 38, 31, .06); color: var(--ink); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 18px 22px 4px; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 18px 22px 20px;
}

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

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

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }

.field label { font-size: 12px; color: var(--ink-2); letter-spacing: .05em; }
.field label .req { color: var(--accent); margin-left: 2px; }

.field input,
.field select {
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  outline: none;
  font-size: 13.5px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field textarea { min-height: 76px; }

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(46, 107, 93, .11);
}

.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  background: var(--card-soft);
  color: var(--ink-3);
  cursor: not-allowed;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.field .help { font-size: 11.5px; color: var(--ink-3); }

.form-error {
  display: none;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--danger-soft);
  border: 1px solid #ecc8c0;
  color: #7e2b20;
  font-size: 12.5px;
}

.form-error.show { display: block; }

/* ---------- Toast ---------- */

#toast-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 200px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 11px;
  background: #1d2b26;
  color: #eef2ee;
  font-size: 13px;
  box-shadow: 0 16px 40px -16px rgba(15, 25, 21, .6);
  animation: toastIn .22s cubic-bezier(.2, .9, .3, 1.1);
}

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

.toast .toast-dot { width: 7px; height: 7px; border-radius: 50%; background: #6fbf8b; flex: 0 0 7px; }
.toast.is-error .toast-dot { background: #e2725f; }

/* ---------- 动画 ---------- */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

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

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

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
  .data-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .app { flex-direction: column; }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    overflow-x: auto;
  }

  .brand { padding: 0 8px 0 0; flex: 0 0 auto; }
  .brand-text span { display: none; }

  .nav { flex-direction: row; gap: 2px; }

  .nav-item { padding: 8px 11px; white-space: nowrap; font-size: 13px; }
  .nav-item.is-active::before { display: none; }

  .sidebar-foot { display: none; }

  .main { padding: 22px 16px 48px; }

  .page-head h1 { font-size: 23px; }

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

  .donut-flex { flex-direction: column; align-items: flex-start; gap: 14px; }
  .donut-flex .donut { align-self: center; }

  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .modal-mask { padding: 12px; align-items: flex-end; }
  .modal { max-height: 90vh; }
}
