/* ==========================================================================
   合同与证照管理 · 设计系统
   ========================================================================== */

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

:root {
  /* 品牌 */
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef1ff;
  --brand-ring: rgba(79, 70, 229, .18);

  /* 中性色 */
  --bg: #f2f3f7;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f8f9fc;
  --text: #14161c;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --line: #e6e8ef;
  --line-2: #eef0f6;
  --shadow-sm: 0 1px 2px rgba(16, 20, 40, .05), 0 1px 1px rgba(16, 20, 40, .03);
  --shadow-md: 0 4px 16px rgba(16, 20, 40, .07), 0 1px 3px rgba(16, 20, 40, .04);
  --shadow-lg: 0 18px 48px rgba(16, 20, 40, .16);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 22px;

  /* 风险色阶（与后端 RISK_LEVELS 一致） */
  --risk-expired: #8f1d1d;
  --risk-expired-bg: #fdecec;
  --risk-d30: #e2453c;
  --risk-d30-bg: #fdeceb;
  --risk-d60: #e8752a;
  --risk-d60-bg: #fdf0e7;
  --risk-d90: #d9a406;
  --risk-d90-bg: #fdf7e3;
  --risk-d120: #22a05a;
  --risk-d120-bg: #e8f7ef;
  --risk-safe: #9aa1a9;
  --risk-safe-bg: #f1f3f5;

  /* 合同类别 */
  --cat-eng: #2563eb;
  --cat-eng-bg: #e9f0fe;
  --cat-goods: #7c3aed;
  --cat-goods-bg: #f2ebfe;
  --cat-service: #0d9488;
  --cat-service-bg: #e3f6f3;

  --ok: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;

  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

html[data-theme="dark"] {
  --brand: #8b87f8;
  --brand-2: #a78bfa;
  --brand-soft: #23253a;
  --brand-ring: rgba(139, 135, 248, .25);

  --bg: #0b0d13;
  --bg-elev: #14161f;
  --card: #161922;
  --card-2: #1c202b;
  --text: #f1f3f8;
  --text-2: #b7bece;
  --muted: #8a93a6;
  --line: #262a37;
  --line-2: #1f232f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);

  --risk-expired: #a83232;
  --risk-expired-bg: #2c1618;
  --risk-d30: #e2453c;
  --risk-d30-bg: #2e1717;
  --risk-d60: #e8752a;
  --risk-d60-bg: #2c1c12;
  --risk-d90: #d9a406;
  --risk-d90-bg: #2a2411;
  --risk-d120: #22a05a;
  --risk-d120-bg: #12281c;
  --risk-safe: #7b8492;
  --risk-safe-bg: #1d2029;

  --cat-eng: #60a5fa;
  --cat-eng-bg: #16243c;
  --cat-goods: #a78bfa;
  --cat-goods-bg: #241c3c;
  --cat-service: #2dd4bf;
  --cat-service-bg: #10302d;

  --ok: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ---------------- 启动动画 ---------------- */
.boot {
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; background: var(--bg); color: var(--muted); font-size: 13px;
  transition: opacity .35s ease;
}
.boot.hide { opacity: 0; pointer-events: none; }
.boot-logo {
  width: 66px; height: 66px; border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  box-shadow: 0 16px 40px var(--brand-ring);
  animation: bootPulse 1.6s ease-in-out infinite;
}
.boot-logo span {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bootPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---------------- 登录 ---------------- */
.login-wrap {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow: auto;
}
.login-bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1000px 520px at 12% -12%, rgba(79, 70, 229, .22), transparent 62%),
    radial-gradient(760px 460px at 92% 8%, rgba(124, 58, 237, .18), transparent 60%),
    radial-gradient(700px 500px at 50% 108%, rgba(13, 148, 136, .14), transparent 62%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 392px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 24px 24px;
  box-shadow: var(--shadow-lg);
  animation: rise .5s cubic-bezier(.16, 1, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-mark {
  width: 58px; height: 58px; margin: 0 auto 14px;
  border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 28px var(--brand-ring);
  color: #fff;
}
.login-mark svg { width: 28px; height: 28px; }
.login-brand h1 { font-size: 20px; margin: 0 0 6px; letter-spacing: -.2px; }
.login-brand p { margin: 0; font-size: 13px; color: var(--muted); }
.login-error { min-height: 18px; margin: 10px 0 4px; font-size: 13px; color: var(--danger); }
.login-foot { text-align: center; margin: 16px 0 0; font-size: 12px; color: var(--muted); }

/* ---------------- 表单控件 ---------------- */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px; letter-spacing: .2px;
}
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 12px 14px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b93a1' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px;
  padding-right: 38px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring);
  background: var(--card);
}
.field .hint { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.switch {
  position: relative; width: 48px; height: 28px; flex: none;
  background: var(--line); border-radius: 999px; cursor: pointer;
  transition: background .22s ease; border: none; padding: 0;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .22s cubic-bezier(.16, 1, .3, 1);
}
.switch[aria-checked="true"] { background: var(--brand); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card);
  font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: transform .16s cubic-bezier(.16, 1, .3, 1), box-shadow .18s ease, background .18s ease, opacity .18s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 8px 22px var(--brand-ring);
}
.btn-ghost { background: var(--card-2); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }
.btn svg { width: 17px; height: 17px; }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: transparent; border: none; border-radius: 11px;
  color: var(--text-2); cursor: pointer; position: relative;
  transition: background .16s ease, transform .16s ease;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn:hover { background: var(--card-2); }
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--risk-d30); border: 2px solid var(--bg-elev);
}

/* ---------------- 应用外壳 ---------------- */
.app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 6px;
  height: 52px; padding: 0 10px;
  padding-top: var(--safe-t);
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line-2);
}
.topbar-title {
  flex: 1; margin: 0; text-align: center;
  font-size: 16.5px; font-weight: 650; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .icon-btn[hidden] + .topbar-title { text-align: center; }

.main {
  flex: 1;
  width: 100%; max-width: 620px; margin: 0 auto;
  padding: 12px 14px calc(var(--tabbar-h) + var(--safe-b) + 76px);
}

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line-2);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10.5px; color: var(--muted); position: relative;
  transition: color .18s ease;
}
.tab svg { width: 22px; height: 22px; transition: transform .22s cubic-bezier(.16, 1, .3, 1); }
.tab.active { color: var(--brand); font-weight: 600; }
.tab.active svg { transform: translateY(-1px) scale(1.06); }
.tab:active svg { transform: scale(.9); }
.tab-badge {
  position: absolute; top: 7px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--risk-d30); color: #fff;
  font-size: 10px; font-style: normal; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--bg-elev);
}

.fab {
  position: fixed; z-index: 46;
  right: max(16px, calc(50% - 310px + 16px));
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  width: 54px; height: 54px; border-radius: 18px; border: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 14px 32px var(--brand-ring), 0 4px 10px rgba(0, 0, 0, .12);
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}
.fab:active { transform: scale(.9) rotate(90deg); }
.fab svg { width: 26px; height: 26px; }

/* ---------------- 分段控件 / 筛选 ---------------- */
.segment {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 3px; padding: 3px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 13px; margin-bottom: 12px;
}
.segment button {
  border: none; background: transparent; color: var(--text-2);
  padding: 9px 6px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .2s cubic-bezier(.16, 1, .3, 1);
}
.segment button.active {
  background: var(--card); color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.searchbar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
}
.searchbar .input { padding-left: 38px; }
.search-wrap { position: relative; flex: 1; }
.search-wrap svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 13px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: all .18s ease; white-space: nowrap;
}
.chip.active { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 6px 16px var(--brand-ring); }
.chip:active { transform: scale(.95); }
.chip .n { opacity: .7; margin-left: 4px; font-weight: 500; }

/* ---------------- 卡片（参考图主视觉） ---------------- */
.cards { display: flex; flex-direction: column; gap: 11px; }

.card-item {
  position: relative;
  display: block; width: 100%; text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 15px;
  padding: 13px 14px 12px 16px;
  cursor: pointer; overflow: hidden;
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), box-shadow .2s ease, border-color .2s ease;
  animation: cardIn .34s cubic-bezier(.16, 1, .3, 1) backwards;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } }
.card-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent, var(--line));
}
.card-item:active { transform: scale(.985); }
@media (hover: hover) {
  .card-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
}

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-name {
  flex: 1; margin: 0; font-size: 15.5px; font-weight: 650; line-height: 1.42;
  letter-spacing: -.1px; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-arrow { flex: none; color: var(--muted); margin-top: 2px; }
.card-arrow svg { width: 17px; height: 17px; }

.card-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin-top: 9px; font-size: 12.8px; color: var(--text-2);
}
.card-meta .due { font-weight: 700; }
.card-meta .sep { color: var(--line); }
.card-meta .tag {
  padding: 1px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}

.badge {
  flex: none; padding: 3px 9px; border-radius: 7px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  background: var(--risk-d30); color: #fff;
}
.badge.soft { background: var(--brand-soft); color: var(--brand); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.gray { background: var(--risk-safe-bg); color: var(--risk-safe); }

/* 类别着色 */
.cat-工程类 { color: var(--cat-eng); background: var(--cat-eng-bg); }
.cat-货物类 { color: var(--cat-goods); background: var(--cat-goods-bg); }
.cat-服务类 { color: var(--cat-service); background: var(--cat-service-bg); }

/* 进度条 */
.card-bar { height: 3px; border-radius: 2px; background: var(--line-2); margin-top: 11px; overflow: hidden; }
.card-bar > i { display: block; height: 100%; border-radius: 2px; background: var(--accent, var(--brand)); transition: width .5s cubic-bezier(.16, 1, .3, 1); }

/* ---------------- 区块标题 ---------------- */
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 2px 11px; font-size: 16px; font-weight: 700; letter-spacing: -.2px;
}
.section-title .more { font-size: 13px; font-weight: 600; color: var(--brand); }
.section-title small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 8px; }

/* ---------------- 风险概览磁贴 ---------------- */
.risk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.risk-tile {
  position: relative; border: none; border-radius: 14px;
  padding: 11px 11px 10px; text-align: left; cursor: pointer;
  color: #fff; overflow: hidden;
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), box-shadow .2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
}
.risk-tile::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, .16), transparent 55%);
  pointer-events: none;
}
.risk-tile:active { transform: scale(.955); }
.risk-tile.active { outline: 3px solid color-mix(in srgb, var(--brand) 70%, transparent); outline-offset: 2px; }
.risk-tile .t-head { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; opacity: .95; }
.risk-tile .t-head svg { width: 13px; height: 13px; }
.risk-tile .t-num { font-size: 27px; font-weight: 800; line-height: 1.18; letter-spacing: -1px; margin-top: 3px; }
.risk-tile[data-zero="1"] { opacity: .58; }
.hint-line { margin: 10px 2px 0; font-size: 12px; color: var(--muted); }

/* ---------------- 统计条 ---------------- */
.stat-card {
  display: flex; align-items: center; gap: 13px;
  margin-top: 12px; padding: 15px 16px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 15px; box-shadow: var(--shadow-sm);
}
.stat-card .s-ico {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.stat-card .s-ico svg { width: 21px; height: 21px; }
.stat-card .s-label { flex: 1; font-size: 15px; font-weight: 650; }
.stat-card .s-sub { font-size: 12px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.stat-card .s-num { font-size: 27px; font-weight: 800; letter-spacing: -1px; }

/* ---------------- 通用面板 ---------------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-sm); margin-bottom: 12px;
}
.panel-title { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.panel-sub { margin: -6px 0 12px; font-size: 12.5px; color: var(--muted); }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 9px 12px; font-size: 14px; align-items: start; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-word; font-weight: 550; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------- 列表行 ---------------- */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 2px; border-bottom: 1px solid var(--line-2);
  cursor: pointer; transition: background .16s ease;
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--card-2); }
.row .r-ico {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--brand-soft); color: var(--brand);
}
.row .r-main { flex: 1; min-width: 0; }
.row .r-title { font-size: 14.5px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-sub { font-size: 12.3px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r-right { flex: none; text-align: right; }

/* ---------------- 提醒项 ---------------- */
.rem-item {
  display: flex; gap: 12px; padding: 13px 14px;
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--accent, var(--line));
  border-radius: 13px; margin-bottom: 9px; cursor: pointer;
  transition: transform .18s cubic-bezier(.16,1,.3,1), box-shadow .18s;
}
.rem-item:active { transform: scale(.985); }
.rem-item.unread { box-shadow: var(--shadow-sm); }
.rem-ico {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center; color: #fff; background: var(--accent);
}
.rem-ico svg { width: 18px; height: 18px; }
.rem-body { flex: 1; min-width: 0; }
.rem-title { font-size: 14.3px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem-text { font-size: 12.8px; color: var(--text-2); margin-top: 3px; }
.rem-time { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------------- 空态 / 骨架屏 ---------------- */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty svg { width: 62px; height: 62px; opacity: .32; margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; font-size: 15.5px; color: var(--text-2); font-weight: 650; }
.empty p { margin: 0; font-size: 13px; }

.skel { border-radius: 14px; background: linear-gradient(90deg, var(--card-2) 25%, var(--line-2) 37%, var(--card-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skel-card { height: 84px; margin-bottom: 11px; }

/* ---------------- 底部弹出层 ---------------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 10, 18, .42);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 620px;
  max-height: 88vh; overflow: auto;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(22px + var(--safe-b));
  box-shadow: var(--shadow-lg);
  animation: sheetUp .34s cubic-bezier(.16, 1, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 4px; border-bottom: 1px solid var(--line-2);
  cursor: pointer; font-size: 15px;
}
.menu-item:last-child { border-bottom: none; }
.menu-item svg { width: 20px; height: 20px; color: var(--brand); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { color: var(--danger); }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 60px); z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  max-width: 420px; padding: 11px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--text) 92%, transparent);
  color: var(--bg-elev); font-size: 13.8px; font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: toastIn .28s cubic-bezier(.16, 1, .3, 1);
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: #16a34a; color: #fff; }
.toast.err { background: #dc2626; color: #fff; }
.toast.hide { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------------- 上传区 ---------------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: 15px;
  padding: 26px 18px; text-align: center; cursor: pointer;
  background: var(--card-2); transition: all .2s ease;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone svg { width: 40px; height: 40px; color: var(--brand); opacity: .8; margin-bottom: 10px; }
.dropzone .dz-title { font-size: 14.5px; font-weight: 650; }
.dropzone .dz-sub { font-size: 12.3px; color: var(--muted); margin-top: 5px; }

.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.file-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 11px; font-size: 13.5px;
}
.file-item .f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .f-size { color: var(--muted); font-size: 12px; }

.att-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 11px;
}
.att-item .a-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.att-item .a-ico svg { width: 18px; height: 18px; }
.att-item .a-name { flex: 1; min-width: 0; font-size: 13.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 导入结果 ---------------- */
.result-box { border-radius: 13px; padding: 14px; font-size: 13.8px; margin-top: 12px; }
.result-box.ok { background: var(--risk-d120-bg); color: var(--risk-d120); border: 1px solid color-mix(in srgb, var(--risk-d120) 28%, transparent); }
.result-box.err { background: var(--risk-d30-bg); color: var(--risk-d30); border: 1px solid color-mix(in srgb, var(--risk-d30) 28%, transparent); }
.err-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.err-table th, .err-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line-2); }
.err-table th { font-weight: 700; color: var(--muted); font-size: 12px; }

/* ---------------- 主题切换 ---------------- */
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-switch button {
  padding: 12px 8px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--card-2); cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: all .2s ease;
}
.theme-switch button svg { width: 19px; height: 19px; }
.theme-switch button.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------------- 徽章组 ---------------- */
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 3px 9px; border-radius: 999px; font-size: 11.8px; font-weight: 620; background: var(--card-2); color: var(--text-2); border: 1px solid var(--line); }

@media (max-width: 360px) {
  .risk-tile .t-num { font-size: 23px; }
  .risk-tile .t-head { font-size: 10.5px; }
  .card-name { font-size: 14.6px; }
}@media (min-width: 621px) {
  .tabbar { max-width: 620px; margin: 0 auto; border-radius: 18px 18px 0 0; border-left: 1px solid var(--line-2); border-right: 1px solid var(--line-2); }
  .topbar { max-width: 620px; margin: 0 auto; }
}
@media print { .tabbar, .fab, .topbar { display: none; } }

/* ---------------- 详情页小指标 ---------------- */
.mini-stat {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 12px;
}
.mini-stat .ms-label { font-size: 11.8px; color: var(--muted); font-weight: 600; letter-spacing: .2px; }
.mini-stat .ms-value { font-size: 16.5px; font-weight: 750; margin-top: 4px; letter-spacing: -.3px; }
.mini-stat .ms-sub { font-size: 11.8px; color: var(--muted); margin-top: 3px; }

/* ---------------- 提示抖动 ---------------- */
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ---------------- 表单页 ---------------- */
.form-cat {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px;
}
.form-cat button {
  padding: 13px 6px; border-radius: 13px; cursor: pointer;
  border: 1.6px solid var(--line); background: var(--card-2);
  font-size: 13.5px; font-weight: 650; color: var(--text-2);
  transition: all .2s cubic-bezier(.16, 1, .3, 1);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.form-cat button i { width: 9px; height: 9px; border-radius: 3px; display: block; }
.form-cat button:active { transform: scale(.95); }
.form-cat button.active { color: #fff; border-color: transparent; box-shadow: 0 8px 20px rgba(0, 0, 0, .16); }

.sticky-submit {
  position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px);
  margin-top: 18px; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  padding: 10px 0; border-radius: 14px;
}

/* ---------------- 导入页 ---------------- */
.tpl-card {
  display: flex; align-items: center; gap: 13px;
  padding: 15px; border: 1px solid var(--line); border-radius: 15px;
  background: var(--card); margin-bottom: 11px;
}
.tpl-card .t-ico {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.tpl-card .t-ico svg { width: 22px; height: 22px; }
.tpl-card .t-body { flex: 1; min-width: 0; }
.tpl-card .t-title { font-size: 15px; font-weight: 680; }
.tpl-card .t-sub { font-size: 12.3px; color: var(--muted); margin-top: 3px; }

.steps { counter-reset: s; }
.steps li { position: relative; padding-left: 30px; margin-bottom: 9px; font-size: 13.5px; color: var(--text-2); list-style: none; }
.steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 1px;
  width: 20px; height: 20px; border-radius: 7px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}

.user-avatar {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-weight: 750; font-size: 15px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
}
.me-head {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 18px; border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 14px 34px var(--brand-ring);
  margin-bottom: 14px;
}
.me-head .avatar {
  width: 54px; height: 54px; border-radius: 17px; flex: none;
  background: rgba(255, 255, 255, .2);
  border: 1.5px solid rgba(255, 255, 255, .35);
  display: grid; place-items: center; font-size: 21px; font-weight: 750;
  backdrop-filter: blur(6px);
}
.me-head h2 { margin: 0; font-size: 18px; letter-spacing: -.2px; }
.me-head p { margin: 4px 0 0; font-size: 12.5px; opacity: .88; }
