/* ==========================================================================
   到期倒计时看板 — 样式表
   ========================================================================== */

:root {
  --bg: #0f1119;
  --bg-glow-1: rgba(56, 122, 255, 0.16);
  --bg-glow-2: rgba(139, 92, 246, 0.13);
  --bg-glow-3: rgba(16, 185, 129, 0.08);

  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.055);
  --surface-solid: #171a23;
  --surface-hover: rgba(255, 255, 255, 0.07);
  --card-hover: rgba(255, 255, 255, 0.07);
  --track: rgba(255, 255, 255, 0.1);

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #eef1f8;
  --text-dim: #9aa3b8;
  --text-faint: #656d80;

  --accent: #5b8cff;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(91, 140, 255, 0.14);

  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --expired: #a1a1aa;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.85);
  --shadow-lg: 0 32px 64px -20px rgba(0, 0, 0, 0.9);

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-full: 999px;

  --scrim: rgba(4, 5, 10, 0.62);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-theme='light'] {
  --bg: #f2f5fb;
  --bg-glow-1: rgba(79, 140, 255, 0.16);
  --bg-glow-2: rgba(168, 85, 247, 0.11);
  --bg-glow-3: rgba(16, 185, 129, 0.09);

  --surface: #ffffff;
  --surface-2: #f5f7fc;
  --surface-solid: #ffffff;
  --surface-hover: #f2f5fb;
  --card-hover: #ffffff;
  --track: rgba(15, 23, 42, 0.1);

  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.17);

  --text: #0e1424;
  --text-dim: #57617a;
  --text-faint: #8992a6;

  --accent: #2f6bff;
  --accent-2: #7c3aed;
  --accent-soft: rgba(47, 107, 255, 0.09);

  --ok: #059669;
  --warn: #c2740a;
  --danger: #dc2626;
  --expired: #7b8698;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 14px 30px -16px rgba(15, 23, 42, 0.22), 0 2px 6px -3px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 34px 60px -26px rgba(15, 23, 42, 0.3);

  --scrim: rgba(15, 23, 42, 0.32);
}

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

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(58rem 34rem at 12% -8%, var(--bg-glow-1), transparent 62%),
    radial-gradient(48rem 30rem at 92% 4%, var(--bg-glow-2), transparent 60%),
    radial-gradient(46rem 32rem at 50% 108%, var(--bg-glow-3), transparent 62%);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}

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

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.icon {
  width: 1em;
  height: 1em;
  display: block;
  flex: none;
}

[data-ico] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.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;
}

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

.app {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 24px 96px;
}

/* --------------------------------------------------------------- 顶栏 --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px -8px var(--accent);
}

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease),
    transform 0.16s var(--ease), color 0.16s var(--ease);
}

.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn:active {
  transform: scale(0.975);
}

.btn .icon {
  font-size: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -10px var(--accent);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  filter: brightness(1.09);
}

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

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

.btn-danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.32);
  background: rgba(248, 113, 113, 0.1);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.19);
}

.btn-sm {
  height: 31px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: 9px;
}

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

.btn-icon .icon {
  font-size: 17px;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

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

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

.stat {
  position: relative;
  padding: 16px 17px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.stat::after {
  content: '';
  position: absolute;
  right: -28px;
  top: -28px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--stat-color, var(--accent));
  opacity: 0.1;
  filter: blur(6px);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.stat-label .icon {
  font-size: 14px;
  color: var(--stat-color, var(--accent));
}

.stat-value {
  font-size: 27px;
  font-weight: 660;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 3px;
}

.stat-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ----------------------------------------------------------- 筛选区 --- */

.panel {
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--r);
  padding: 13px;
  margin-bottom: 18px;
}

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

.search {
  position: relative;
  flex: 1 1 210px;
  min-width: 170px;
}

.search .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 34px 0 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: border-color 0.16s var(--ease);
}

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

.search input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: none;
  place-items: center;
  color: var(--text-faint);
  font-size: 15px;
}

.search-clear:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.search.has-value .search-clear {
  display: grid;
}

.select {
  height: 38px;
  padding: 0 30px 0 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3b8' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
  font-size: 13.5px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

[data-theme='light'] .select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.select:focus {
  outline: none;
  border-color: var(--accent);
}

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.seg button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: var(--text-faint);
  font-size: 16px;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}

.seg button:hover {
  color: var(--text);
}

.seg button.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.16s var(--ease);
}

.chip .icon {
  font-size: 14px;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip.on {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

.chip-count {
  font-size: 11px;
  padding: 0 5px;
  min-width: 17px;
  text-align: center;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-faint);
}

.chip.on .chip-count {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
}

/* ------------------------------------------------------------- 卡片区 --- */

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

.grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 11px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 17px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease), background 0.2s var(--ease);
  animation: cardIn 0.36s var(--ease) both;
}

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

.card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--cat-color, var(--accent));
  opacity: 0.85;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  background: var(--card-hover);
}

.card.is-expired {
  opacity: 0.72;
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.cat-ico {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 19px;
  color: var(--cat-color, var(--accent));
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--cat-color, var(--accent)) 26%, transparent);
}

.card-title {
  min-width: 0;
  flex: 1;
}

.card-title h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pin-mark {
  color: var(--warn);
  font-size: 14px;
  flex: none;
  margin-top: 2px;
}

.card-body {
  display: flex;
  align-items: center;
  gap: 14px;
}

.count-block {
  min-width: 0;
}

.count-num {
  font-size: 40px;
  font-weight: 680;
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--st-color, var(--text));
}

.count-num.small {
  font-size: 24px;
}

.count-unit {
  font-size: 13px;
  font-weight: 550;
  color: var(--text-faint);
  margin-left: 4px;
}

.count-cap {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-dim);
}

.ring {
  margin-left: auto;
  flex: none;
  position: relative;
  width: 62px;
  height: 62px;
}

.ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 5.5;
  stroke-linecap: round;
}

.ring .track {
  stroke: var(--track);
}

.ring .bar {
  stroke: var(--st-color, var(--accent));
  transition: stroke-dashoffset 0.6s var(--ease);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 620;
  color: var(--st-color, var(--text-dim));
}

.progress-line {
  height: 5px;
  border-radius: var(--r-full);
  background: var(--track);
  overflow: hidden;
}

.progress-line > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--st-color, var(--accent));
  transition: width 0.6s var(--ease);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 580;
  color: var(--st-color, var(--text-dim));
  background: color-mix(in srgb, var(--st-color, var(--text-dim)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--st-color, var(--text-dim)) 25%, transparent);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-faint);
  padding-top: 11px;
  border-top: 1px solid var(--border);
}

.dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  margin: 0 3px;
}

.card-notes {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 分类专属配置：编辑抽屉里的输入网格 + 卡片上的摘要行 */
#f-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.label-optional {
  font-weight: 400;
  color: var(--text-faint);
}

.card-specs {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  word-break: break-word;
}

.card-specs .icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

@media (max-width: 640px) {
  #f-specs {
    grid-template-columns: 1fr;
  }
}

.tag-soft {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-dim);
}

.tag-soft .icon {
  font-size: 12px;
}

.card-actions {
  position: absolute;
  top: 11px;
  right: 11px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.19s var(--ease), transform 0.19s var(--ease);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  box-shadow: var(--shadow);
}

.card:hover .card-actions,
.card:focus-within .card-actions {
  opacity: 1;
  transform: none;
}

.card-actions .btn-icon {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-dim);
}

.card-actions .btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.card-actions .btn-icon.del:hover {
  background: rgba(248, 113, 113, 0.16);
  color: var(--danger);
}

/* ------------------------------------------------------------- 列表视图 --- */

.list-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.list-row {
  display: grid;
  grid-template-columns: 30px minmax(160px, 1.5fr) 130px minmax(120px, 1fr) 110px 74px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s var(--ease);
}

.list-row:last-child {
  border-bottom: none;
}

.list-row.head {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
}

.list-row:not(.head):hover {
  background: var(--surface-2);
}

.list-row.is-expired {
  opacity: 0.66;
}

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

.list-name .cat-ico {
  width: 29px;
  height: 29px;
  border-radius: 9px;
  font-size: 15px;
}

.list-name b {
  font-weight: 590;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-name small {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
}

.list-days {
  font-weight: 640;
  font-size: 15px;
}

.list-days small {
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-left: 3px;
}

.list-actions {
  display: flex;
  gap: 3px;
  justify-content: flex-end;
}

.list-actions .btn-icon {
  width: 28px;
  height: 28px;
  font-size: 14px;
  color: var(--text-faint);
}

.list-actions .btn-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.list-actions .btn-icon.del:hover {
  color: var(--danger);
}

.cell-muted {
  font-size: 13px;
  color: var(--text-dim);
}

/* ------------------------------------------------------------- 时间轴 --- */

.timeline {
  position: relative;
  padding-left: 30px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--border-strong), transparent);
}

.tl-item {
  position: relative;
  margin-bottom: 13px;
}

.tl-item::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 22px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--st-color, var(--accent));
  border: 2.5px solid var(--bg);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--st-color, var(--accent)) 30%, transparent);
}

.tl-month {
  font-size: 12px;
  font-weight: 640;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 4px 0 9px;
}

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

.empty {
  text-align: center;
  padding: 74px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
}

.empty-ico {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 30px;
  color: var(--accent);
  background: var(--accent-soft);
}

.empty h2 {
  margin: 0 0 7px;
  font-size: 18px;
  font-weight: 640;
}

.empty p {
  margin: 0 auto 22px;
  max-width: 400px;
  color: var(--text-dim);
  font-size: 13.5px;
}

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease);
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.overlay.center {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.right {
  justify-content: flex-end;
}

.sheet {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transition: transform 0.28s var(--ease);
}

.overlay.center .sheet {
  width: 100%;
  max-width: 430px;
  border-radius: var(--r-lg);
  transform: scale(0.95) translateY(10px);
}

.overlay.center.open .sheet {
  transform: none;
}

.overlay.right .sheet {
  width: 100%;
  max-width: 520px;
  height: 100%;
  border-radius: 0;
  border-width: 0 0 0 1px;
  transform: translateX(100%);
}

.overlay.right.open .sheet {
  transform: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sheet-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 640;
}

.sheet-head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}

.sheet-head .btn-icon {
  margin-left: auto;
}

.sheet-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  flex: none;
  background: var(--surface-2);
}

.sheet-foot .spacer {
  margin-left: auto;
}

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

.field {
  margin-bottom: 17px;
}

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

.label {
  display: block;
  font-size: 12.5px;
  font-weight: 580;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.label .req {
  color: var(--danger);
  margin-left: 2px;
}

.hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

.input,
.textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.textarea {
  min-height: 74px;
  resize: vertical;
  line-height: 1.55;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

input[type='date'].input {
  cursor: pointer;
}

input[type='date'].input::-webkit-calendar-picker-indicator {
  filter: invert(0.62);
  cursor: pointer;
}

[data-theme='light'] input[type='date'].input::-webkit-calendar-picker-indicator {
  filter: none;
}

.row {
  display: flex;
  gap: 10px;
}

.row > * {
  flex: 1;
  min-width: 0;
}

.row.tight {
  gap: 8px;
}

.f-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.f-cat {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-faint);
  transition: all 0.16s var(--ease);
}

.f-cat .icon {
  font-size: 18px;
  color: var(--cat-color, var(--text-dim));
}

.f-cat:hover {
  border-color: var(--border-strong);
}

.f-cat.on {
  border-color: color-mix(in srgb, var(--cat-color, var(--accent)) 55%, transparent);
  background: color-mix(in srgb, var(--cat-color, var(--accent)) 13%, transparent);
  color: var(--cat-color, var(--accent));
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 15px;
}

.tabs button {
  flex: 1;
  height: 32px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  transition: all 0.16s var(--ease);
}

.tabs button:hover {
  color: var(--text);
}

.tabs button.on {
  background: var(--accent-soft);
  color: var(--accent);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.switch-row:last-of-type {
  border-bottom: none;
}

.switch-row .sr-text {
  flex: 1;
  min-width: 0;
}

.switch-row .sr-text b {
  display: block;
  font-size: 13.5px;
  font-weight: 560;
}

.switch-row .sr-text span {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 1px;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--border-strong);
  transition: background 0.2s var(--ease);
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease);
}

.switch.on {
  background: var(--accent);
}

.switch.on::after {
  transform: translateX(18px);
}

.section-title {
  font-size: 11.5px;
  font-weight: 660;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 24px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* --------------------------------------------------------------- 确认框 --- */

.confirm-ico {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 23px;
  color: var(--danger);
  background: rgba(248, 113, 113, 0.13);
  margin-bottom: 15px;
}

.confirm h3 {
  margin: 0 0 7px;
  font-size: 17px;
  font-weight: 640;
}

.confirm p {
  margin: 0;
  color: var(--text-dim);
  font-size: 13.5px;
  word-break: break-word;
}

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

.toasts {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: min(92vw, 460px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toastIn 0.3s var(--ease) both;
}

.toast.out {
  animation: toastOut 0.25s var(--ease) both;
}

.toast .icon {
  font-size: 16px;
  flex: none;
}

.toast.ok .icon {
  color: var(--ok);
}
.toast.err .icon {
  color: var(--danger);
}
.toast.info .icon {
  color: var(--accent);
}
.toast.warn .icon {
  color: var(--warn);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(9px) scale(0.97);
  }
}

/* ----------------------------------------------------------- 同步指示 --- */

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-dim);
}

.sync-pill .icon {
  font-size: 14px;
}

.sync-pill.on .icon {
  color: var(--ok);
}

.sync-pill.busy .icon {
  color: var(--accent);
  animation: spin 1s linear infinite;
}

.sync-pill.err .icon {
  color: var(--danger);
}

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

/* --------------------------------------------------------------- 杂项 --- */

.key-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-box .input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}

.key-box code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
  flex: none;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 11px;
  text-align: center;
  color: var(--text-dim);
}

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

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .list-row {
    grid-template-columns: 30px minmax(120px, 1.6fr) 108px 74px;
  }
  .list-row .col-hide {
    display: none;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 20px 14px 90px;
  }
  .brand-text p {
    display: none;
  }
  .topbar-actions .btn-label {
    display: none;
  }
  .topbar-actions .btn {
    width: 38px;
    padding: 0;
  }
  .grid,
  .grid.compact {
    grid-template-columns: 1fr;
  }
  .f-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .stat-value {
    font-size: 23px;
  }
  .toasts {
    bottom: 16px;
  }
}

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