/* ============================================================
   XT 超级工具箱 — 设计令牌
   ============================================================ */
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-full: 999px;

  --sidebar-w: 210px;
  --topbar-h: 56px;
  --content-max: 2100px;
  --gap: 7px;

  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-line: rgba(99, 102, 241, 0.45);

  --danger: #f2545b;
  --warn: #f59e0b;
  --info: #38bdf8;
  --ok: #22c55e;

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

html[data-theme="dark"] {
  --bg: #0c0d12;
  --bg-2: #12141c;
  --surface: #161923;
  --surface-2: #1c2030;
  --surface-3: #232839;
  --sidebar-bg: #0a0b10;
  --border: #262b3b;
  --border-soft: #1e2230;
  --text: #e7e9f0;
  --text-2: #a3aac0;
  --text-3: #6b7391;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.36);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --scrim: rgba(4, 5, 9, 0.72);
}

html[data-theme="light"] {
  --bg: #f4f5f9;
  --bg-2: #eceef5;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f7;
  --sidebar-bg: #ffffff;
  --border: #e2e5ef;
  --border-soft: #edeff6;
  --text: #191c26;
  --text-2: #5b6379;
  --text-3: #8b93a8;
  --shadow: 0 1px 2px rgba(19, 24, 44, 0.06), 0 10px 28px rgba(19, 24, 44, 0.08);
  --shadow-sm: 0 1px 2px rgba(19, 24, 44, 0.07);
  --scrim: rgba(24, 28, 44, 0.42);
}

/* ============================================================
   基础
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); }

.ico { width: 15px; height: 15px; fill: currentColor; flex: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ============================================================
   布局骨架
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* ---------- 左侧菜单 ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-soft);
  min-height: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  height: var(--topbar-h);
  flex: none;
}
.brand-logo {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: #fff;
  background: linear-gradient(140deg, #6366f1, #8b5cf6 55%, #d946ef);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 12.5px; letter-spacing: 0.2px; }
.brand-text span { font-size: 10.5px; color: var(--text-3); }

.menu { flex: 1; overflow-y: auto; padding: 4px 9px 12px; }
.menu-group-title {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 11px 8px 4px;
}
.menu-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  margin-bottom: 1px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, color 0.14s;
}
.menu-item > span { flex: 1; min-width: 0; }
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.menu-item.active::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 50%;
  transform: translateY(-50%);
  width: 2.5px;
  height: 15px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.menu-item.active .ico { color: var(--accent); }

.menu-badge {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
}
.menu-badge.danger { background: rgba(242, 84, 91, 0.16); color: var(--danger); }

.sidebar-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-3);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 2.5px rgba(34, 197, 94, 0.16);
  flex: none;
}
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 2.5px rgba(242, 84, 91, 0.18); }
.status-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.status-text strong { font-size: 11px; color: var(--text-2); font-weight: 600; }
.status-text span { font-size: 9.5px; font-family: var(--mono); }

/* ---------- 顶栏 ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.page-head { flex: none; min-width: 0; }
.page-head h1 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; }
.page-head p { font-size: 10.5px; color: var(--text-3); white-space: nowrap; margin-top: 1px; }

.tabs {
  display: flex;
  align-items: center;
  gap: 1px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs:empty { visibility: hidden; }
.tab {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--r-full);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.14s, color 0.14s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.tab .count {
  font-size: 9.5px;
  font-weight: 700;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-3);
}
.tab.active .count { background: var(--accent-soft); color: var(--accent); }
.tab .count.danger { background: rgba(242, 84, 91, 0.16); color: var(--danger); }

.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.14s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-3); }
.icon-btn:active { transform: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s;
}
.btn:hover { border-color: var(--text-3); }
.btn .ico { width: 14px; height: 14px; }
.btn-primary {
  background: linear-gradient(140deg, #6366f1, #7c3aed);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: rgba(242, 84, 91, 0.12); border-color: transparent; }
.btn-danger-solid {
  background: linear-gradient(140deg, #e11d48, #dc2626);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}
.btn-danger-solid:hover { filter: brightness(1.08); border-color: transparent; }
.btn-sm { height: 23px; padding: 0 8px; font-size: 11px; border-radius: 5px; }
.btn-sm .ico { width: 12px; height: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.menu-wrap { position: relative; }
.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 60;
  animation: pop 0.13s var(--ease);
}
.dropdown button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown-sep { height: 1px; background: var(--border-soft); margin: 4px 6px; }
@keyframes pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- 内容区 ---------- */
.content { flex: 1; overflow-y: auto; padding: 12px 14px 28px; }
.content-inner { max-width: var(--content-max); margin: 0 auto; }

/* ============================================================
   通用组件
   ============================================================ */
.section { margin-bottom: 14px; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.section-head h2 {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-head .sub { font-size: 11px; color: var(--text-3); font-weight: 400; }
.section-head .spacer { flex: 1; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}
.field {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 27px;
  padding: 0 9px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.14s;
}
.field:focus-within { border-color: var(--accent); }
.field .ico { width: 13px; height: 13px; color: var(--text-3); }
.field input, .field select {
  border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 12px; min-width: 0; width: 100%;
}
.field input::placeholder { color: var(--text-3); }
.field.grow { flex: 1; min-width: 160px; max-width: 320px; }
.field select { cursor: pointer; }
.field select option { background: var(--surface); color: var(--text); }

select.plain {
  height: 27px;
  padding: 0 24px 0 9px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7391'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s;
}
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip .n { font-size: 9.5px; opacity: 0.7; font-weight: 700; }
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--border-soft); color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.pill-dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.u-expired { color: var(--danger); background: rgba(242, 84, 91, 0.13); }
.u-critical { color: #ff8a4c; background: rgba(255, 138, 76, 0.14); }
.u-warning { color: var(--warn); background: rgba(245, 158, 11, 0.14); }
.u-soon { color: var(--info); background: rgba(56, 189, 248, 0.13); }
.u-safe { color: var(--ok); background: rgba(34, 197, 94, 0.13); }
.u-done { color: var(--text-3); background: var(--surface-3); }
.pri-high, .pri-critical { color: var(--danger); background: rgba(242, 84, 91, 0.13); }
.pri-normal { color: var(--text-2); background: var(--surface-3); }
.pri-low { color: var(--text-3); background: var(--surface-3); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.empty .em-ico { font-size: 26px; display: block; margin-bottom: 8px; opacity: 0.6; }
.empty h3 { font-size: 13px; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
.empty p { font-size: 11.5px; max-width: 340px; margin: 0 auto 12px; }

.skeleton {
  border-radius: var(--r-md);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer {
  from { background-position: 100% 50%; }
  to { background-position: 0 50%; }
}

/* ============================================================
   看板
   ============================================================ */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(760px 220px at 6% -30%, rgba(99, 102, 241, 0.22), transparent 62%),
    radial-gradient(600px 200px at 96% -10%, rgba(217, 70, 239, 0.15), transparent 60%),
    var(--surface);
  padding: 13px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.hero-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-greet h2 { font-size: 16.5px; font-weight: 800; letter-spacing: -0.4px; margin-bottom: 2px; }
.hero-greet p { font-size: 11.5px; color: var(--text-2); }
.hero-greet p b { color: var(--text); font-weight: 700; }
.hero-clock { margin-left: auto; text-align: right; font-family: var(--mono); line-height: 1.3; }
.hero-clock .t { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.hero-clock .d { font-size: 10.5px; color: var(--text-3); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
  gap: var(--gap);
  margin-bottom: 12px;
}
.stat {
  position: relative;
  overflow: hidden;
  padding: 8px 10px 9px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s var(--ease), border-color 0.14s;
}
.stat:hover { transform: translateY(-1px); border-color: var(--accent-line); }
.stat .lab {
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat .val { font-size: 21px; font-weight: 800; letter-spacing: -0.8px; line-height: 1.05; }
.stat .val small { font-size: 10.5px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.stat .foot { font-size: 10px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2.5px;
  background: var(--c, var(--accent));
}
.stat.danger { --c: var(--danger); }
.stat.warn { --c: var(--warn); }
.stat.info { --c: var(--info); }
.stat.ok { --c: var(--ok); }
.stat.neutral { --c: var(--text-3); }
.stat.danger .val { color: var(--danger); }
.stat.warn .val { color: var(--warn); }

.dash-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
@media (max-width: 1120px) { .dash-cols { grid-template-columns: minmax(0, 1fr); } }

.alert-list { display: flex; flex-direction: column; gap: 4px; }
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  border-left: 2.5px solid var(--c, var(--accent));
  background: var(--surface);
  cursor: pointer;
  transition: background 0.14s, transform 0.14s var(--ease);
}
.alert:hover { background: var(--surface-2); transform: translateX(2px); }
.alert.expired { --c: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.alert.critical { --c: #ff8a4c; background: color-mix(in srgb, #ff8a4c 5%, var(--surface)); }
.alert.warning { --c: var(--warn); }
.alert.soon { --c: var(--info); }
.alert.safe { --c: var(--ok); }
.alert.done { --c: var(--text-3); opacity: 0.7; }
.alert .a-date {
  flex: none;
  width: 44px;
  text-align: center;
  padding: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  line-height: 1.05;
}
.alert .a-date .m { font-size: 8.5px; color: var(--text-3); font-weight: 700; }
.alert .a-date .d { font-size: 15px; font-weight: 800; letter-spacing: -0.5px; }
.alert .a-main { flex: 1; min-width: 0; }
.alert .a-title {
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 1px;
}
.alert .a-meta {
  font-size: 10.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
}
.alert .a-right { flex: none; display: flex; align-items: center; gap: 6px; }

.panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  font-weight: 700;
}
.panel-head .spacer { flex: 1; }
.panel-body { padding: 8px 12px 10px; }
.panel-body.flush { padding: 0; }

.mini-list { display: flex; flex-direction: column; }
.mini {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
  cursor: pointer;
}
.mini:last-child { border-bottom: 0; }
.mini:hover { background: var(--surface-2); }
.mini-ico {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--c, var(--accent));
  color: #fff;
}
.mini-main { flex: 1; min-width: 0; }
.mini-main .t { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-main .s { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-val { flex: none; font-size: 11px; color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }

.bar-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.bar-name { width: 76px; flex: none; font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-full); background: linear-gradient(90deg, var(--accent), #a855f7); }
.bar-num { width: 24px; flex: none; text-align: right; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

.timeline { display: flex; flex-direction: column; }
.tl {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border-soft);
}
.tl:last-child { border-bottom: 0; }
.tl-dot {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  background: var(--surface-3);
}
.tl-main { flex: 1; min-width: 0; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-main b { font-weight: 600; }
.tl-time { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); flex: none; }

/* ============================================================
   紧凑卡片网格 —— 核心密度
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: var(--gap);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px 7px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, transform 0.14s var(--ease);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2.5px;
  background: var(--c, var(--accent));
}
.card:hover { transform: translateY(-1px); border-color: var(--accent-line); background: var(--surface-2); }
.card.u-expired { --c: var(--danger); }
.card.u-critical { --c: #ff8a4c; }
.card.u-warning { --c: var(--warn); }
.card.u-soon { --c: var(--info); }
.card.u-safe { --c: var(--ok); }
.card.u-done { --c: var(--text-3); }

/* 行 1：图标 + 标题 + 倒计时 */
.c-r1 { display: flex; align-items: center; gap: 5px; min-width: 0; }
.c-ico {
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 11px;
  background: var(--surface-3);
}
.c-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card:hover .c-title { color: var(--accent); }
.c-days {
  flex: none;
  font-size: 10.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--c, var(--accent));
  padding: 0 5px;
  border-radius: var(--r-full);
  background: color-mix(in srgb, var(--c, var(--accent)) 15%, transparent);
  white-space: nowrap;
  transition: opacity 0.12s;
}
.card:hover .c-days { opacity: 0; }

/* 行 2：元信息 */
.c-r2 { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 10.5px; color: var(--text-3); }
.c-meta { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-cost { flex: none; font-size: 10.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.c-pin { flex: none; font-size: 9px; color: var(--warn); }
.c-pri { flex: none; width: 5px; height: 5px; border-radius: 50%; }
.c-flag { flex: none; font-size: 9px; font-weight: 800; }

/* 悬停操作条 */
.c-acts {
  position: absolute;
  right: 5px;
  top: 5px;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.12s, transform 0.12s var(--ease);
}
.card:hover .c-acts, .card:focus-within .c-acts { opacity: 1; transform: none; }
.c-act {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.12s;
}
.c-act .ico { width: 11px; height: 11px; }
.c-act:hover { color: var(--text); border-color: var(--text-3); }
.c-act.go:hover { color: var(--info); border-color: var(--info); }
.c-act.ok:hover { color: var(--ok); border-color: var(--ok); }
.c-act.pin:hover, .c-act.on { color: var(--warn); border-color: var(--warn); }

/* 链接卡片：多一行描述 */
.c-host {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--info);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}
.c-desc {
  font-size: 11px;
  color: var(--text-2);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.c-tags { display: flex; align-items: center; gap: 3px; min-width: 0; overflow: hidden; }
.tag {
  font-size: 9.5px;
  font-weight: 600;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.tag.hash { color: var(--accent); background: var(--accent-soft); }

@media (hover: none) {
  .c-days { display: none; }
  .c-acts { position: static; opacity: 1; transform: none; background: none; padding: 0; }
}

/* ============================================================
   密集表格（最高密度视图）
   ============================================================ */
.dtable {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.dtr {
  display: grid;
  grid-template-columns:
    minmax(150px, 2.4fr) 78px minmax(70px, 1fr) 84px 66px 72px 62px;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11.5px;
  min-height: 27px;
}
.dtr:last-child { border-bottom: 0; }
.dtr.head {
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
  min-height: 24px;
  position: sticky;
  top: 0;
  z-index: 2;
}
.dtr:not(.head):hover { background: var(--surface-2); }
.dtr .c { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dtr .name { font-weight: 600; display: flex; align-items: center; gap: 5px; min-width: 0; }
.dtr .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dtr .num { text-align: right; font-variant-numeric: tabular-nums; }
.dtr .acts { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity 0.12s; }
.dtr:hover .acts, .dtr:focus-within .acts { opacity: 1; }
.dtable-wrap { overflow-x: auto; }

/* ============================================================
   模态框 / 表单（保持舒适，不压缩）
   ============================================================ */
.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: 100;
  animation: fade 0.15s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-root { position: fixed; inset: 0; z-index: 110; pointer-events: none; }
.modal-root > * { pointer-events: auto; }

.modal {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  margin-top: 32px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: rise 0.18s var(--ease);
}
.modal.wide { width: min(860px, calc(100vw - 32px)); }
.modal.narrow { width: min(440px, calc(100vw - 32px)); }
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.985); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.modal-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { font-size: 14.5px; font-weight: 700; letter-spacing: -0.2px; }
.modal-head .sub { font-size: 11px; color: var(--text-3); }
.modal-head .spacer { flex: 1; }

.modal-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.modal-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.modal-foot[hidden] { display: none; }
.modal-foot .spacer { flex: 1; }
.modal-foot .hint { font-size: 10.5px; color: var(--text-3); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.f-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 5px;
  letter-spacing: 0.2px;
}
.f-label .req { color: var(--danger); margin-left: 2px; }
.f-input, .f-select, .f-textarea {
  width: 100%;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  outline: 0;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.f-input:focus, .f-select:focus, .f-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.f-input::placeholder, .f-textarea::placeholder { color: var(--text-3); }
.f-textarea { resize: vertical; min-height: 70px; line-height: 1.55; }
.f-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7391'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 16px;
  padding-right: 28px;
}
.f-select option { background: var(--surface); }
.f-hint { font-size: 10.5px; color: var(--text-3); margin-top: 4px; }
.f-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.f-input.invalid, .f-select.invalid { border-color: var(--danger); }
.quick-dates { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

/* ============================================================
   Toast / 命令面板
   ============================================================ */
.toast-root {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 200px;
  max-width: 340px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 12px;
  animation: toastIn 0.2s var(--ease);
}
.toast.out { animation: toastOut 0.18s var(--ease) forwards; }
.toast .ti { width: 17px; height: 17px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 10px; font-weight: 800; color: #fff; }
.toast.ok .ti { background: var(--ok); }
.toast.err .ti { background: var(--danger); }
.toast.info .ti { background: var(--accent); }
.toast.warn .ti { background: var(--warn); }
.toast .undo { margin-left: auto; border: 0; background: transparent; color: var(--accent); font-size: 11.5px; font-weight: 700; cursor: pointer; }
.toast .undo:hover { text-decoration: underline; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px) scale(0.96); } }

.cmdk {
  position: absolute;
  top: 13vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.18s var(--ease);
}
.cmdk-input { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.cmdk-input .ico { color: var(--text-3); }
.cmdk-input input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.cmdk-results { max-height: 360px; overflow-y: auto; padding: 4px; }
.cmdk-group { font-size: 9.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); padding: 8px 8px 4px; }
.cmdk-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; text-align: left; cursor: pointer;
}
.cmdk-row:hover, .cmdk-row.sel { background: var(--surface-2); }
.cmdk-row.sel { box-shadow: inset 0 0 0 1px var(--accent-line); }
.cmdk-row .r-main { flex: 1; min-width: 0; }
.cmdk-row .r-t { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-row .r-s { font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-row .r-side { flex: none; font-size: 10px; color: var(--text-3); font-family: var(--mono); }
kbd { font-family: var(--mono); font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-3); }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border-soft); font-size: 12.5px; }
.shortcut-row:last-child { border-bottom: 0; }

/* ============================================================
   响应式
   ============================================================ */
.only-mobile { display: none; }
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 234px;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--shadow);
  }
  .app.nav-open .sidebar { transform: none; }
  .only-mobile { display: grid; }
  .content { padding: 10px 10px 24px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .page-head p { display: none; }
  .tabs { order: 3; flex-basis: 100%; }
  .btn-primary span { display: none; }
  .btn-primary { padding: 0 9px; }
  .hero-clock { display: none; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .dtr { grid-template-columns: minmax(120px, 2fr) 66px 74px 58px 60px; }
  .dtr .hide-sm { display: none; }
}
