/* ---------------------------------------------------------------------------
   Vhome 色彩系统 · 基于 Pantone 2026 年度色 Cloud Dancer (11-4201, #F0EEE9)
--------------------------------------------------------------------------- */
:root {
  --cloud: #FFFFFF;          /* 页面背景（原为 Cloud Dancer #F0EEE9，按需求改为纯白） */
  --cloud-deep: #F0EEE9;
  --paper: #FFFFFF;
  --linen: #E6E1D8;
  --linen-soft: #EFEBE4;
  --stone: #8C877E;
  --stone-soft: #B3AEA5;
  --charcoal: #2B2926;
  --ink: #141311;
  --ink-soft: #24221F;

  --terracotta: #D2603A;
  --terracotta-soft: #F6E3DA;
  --sage: #5F9A72;
  --sage-soft: #E1EEE4;
  --amber: #E0A43A;
  --amber-soft: #F9EBD1;
  --brick: #C4473A;
  --brick-soft: #F5DBD7;
  --mist: #6D93B8;
  --mist-soft: #E0E9F2;

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(20, 19, 17, 0.03), 0 8px 24px -12px rgba(20, 19, 17, 0.10);
  --shadow-float: 0 20px 60px -20px rgba(20, 19, 17, 0.35);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--charcoal);
  background: var(--cloud);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
code, .mono { font-family: var(--font-mono); font-size: 12.5px; }
svg[aria-hidden="true"] { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.muted { color: var(--stone); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------------------------------------------------------- Layout */
.app { min-height: 100%; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--ink);
  color: #fff;
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 2px 6px 28px;
  font-size: 20px; font-weight: 800; letter-spacing: -0.02em;
}
.brand-mark { width: 34px; height: 34px; border-radius: 10px; flex: none; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-pill);
  color: rgba(255,255,255,.78);
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--paper); color: var(--ink); font-weight: 600; }
.nav a.active svg { color: var(--terracotta); }
.nav .badge {
  margin-left: auto;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--sage-soft); color: var(--sage);
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.nav .badge.warn { background: var(--amber-soft); color: #9A6A12; }
.nav .badge.danger { background: var(--brick-soft); color: var(--brick); }

.sidebar-foot { margin-top: auto; padding: 14px 6px 0; font-size: 13px; }
.sidebar-foot .link { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.6); }
.sidebar-foot .link:hover { color: #fff; }
/* 折叠菜单的容器：桌面端不产生盒子，导航与退出仍直接参与侧栏的纵向排布 */
.sidebar-menu, .sidebar-menu-inner { display: contents; }
.nav-toggle, .menu-backdrop { display: none; }

.main { padding: 26px 34px 40px; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 26px;
}
.topbar h1 { font-size: 26px; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.topbar .spacer { flex: 1; }
/* 页面操作按钮组：桌面端不额外占位，手机端整体换到下一行 */
.topbar-actions { display: contents; }
.search {
  display: flex; align-items: center; gap: 10px;
  width: 320px; height: 44px; padding: 0 16px;
  background: var(--paper); border-radius: var(--radius-pill);
  border: 1px solid var(--linen-soft);
  box-shadow: var(--shadow-card);
}
.search svg { width: 18px; height: 18px; stroke: var(--stone); flex: none; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 14px; }
.search input::placeholder { color: var(--stone-soft); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--paper); box-shadow: var(--shadow-card);
  border: 1px solid var(--linen-soft);
  display: grid; place-items: center; position: relative;
}
.icon-btn svg { width: 18px; height: 18px; stroke: var(--charcoal); }
.icon-btn .dot { position: absolute; top: 11px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--terracotta); border: 2px solid var(--paper); }
.user-pill {
  display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 14px 0 6px;
  background: var(--paper); border-radius: var(--radius-pill); box-shadow: var(--shadow-card);
  border: 1px solid var(--linen-soft);
}
.user-pill .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--terracotta), #E9A07D); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-pill .name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-pill .role { font-size: 11px; color: var(--stone); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 6px 0 16px; }
.section-head h2 { font-size: 18px; }

/* ----------------------------------------------------------------- Cards */
.card {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--linen-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px 24px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 12px; margin-bottom: 14px; }
.card-head > div:first-child { min-width: 0; }
.card-head h3 { font-size: 16px; }
.card-tools { display: flex; gap: 8px; align-items: center; flex: none; }

/* 统计卡片固定宽度，列数随画布宽度自动增减，放不下才换行 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, 260px); gap: 16px; margin-bottom: 20px; }
.stat { width: 260px; }
.stat { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat .icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 10px; }
.stat .icon svg { width: 20px; height: 20px; }
.stat .icon.terracotta { background: var(--terracotta-soft); color: var(--terracotta); }
.stat .icon.sage { background: var(--sage-soft); color: var(--sage); }
.stat .icon.mist { background: var(--mist-soft); color: var(--mist); }
.stat .icon.amber { background: var(--amber-soft); color: #B37E19; }
.stat .icon.brick { background: var(--brick-soft); color: var(--brick); }
.stat .label { color: var(--stone); font-size: 13px; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat .value small { font-size: 14px; color: var(--stone); font-weight: 500; margin-left: 4px; }
.stat .trend { font-size: 12px; color: var(--stone); display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.stat .trend.up { color: var(--sage); }
.stat .trend.down { color: var(--brick); }

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

/* ----------------------------------------------------------------- Table */
/* 表格外层：窄屏时允许横向滚动，避免撑破卡片 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table .center { text-align: center; }
.cb { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); vertical-align: middle; }
.alias-input { height: 32px; width: 150px; font-size: 12px; }
.table th {
  text-align: left; font-weight: 600; font-size: 13px; color: var(--charcoal);
  padding: 8px 10px 12px; border-bottom: 1px solid var(--linen);
  white-space: nowrap;
}
.table td { padding: 13px 10px; border-bottom: 1px solid var(--linen-soft); vertical-align: middle; white-space: nowrap; }
.table td .sub { white-space: normal; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #FAF9F6; }
.table .name { font-weight: 600; }
.table .sub { font-size: 12px; color: var(--stone); }
.table td.num, .table th.num { text-align: right; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-empty { text-align: center; color: var(--stone); padding: 36px 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip.ok { background: var(--sage-soft); color: #3F7A52; }
.chip.warn { background: var(--amber-soft); color: #9A6A12; }
.chip.danger { background: var(--brick-soft); color: var(--brick); }
.chip.info { background: var(--mist-soft); color: #45688B; }
.chip.neutral { background: var(--linen-soft); color: var(--charcoal); }
.chip.terracotta { background: var(--terracotta-soft); color: var(--terracotta); }

.tag { display: inline-block; padding: 2px 9px; border-radius: 8px; font-size: 11.5px; background: var(--linen-soft); color: var(--charcoal); margin-right: 4px; }

.ring { display: inline-flex; align-items: center; gap: 8px; }
.ring svg { width: 30px; height: 30px; transform: rotate(-90deg); }
.ring .track { stroke: var(--linen); }
.ring .bar { stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring .pct { font-size: 12px; color: var(--stone); font-variant-numeric: tabular-nums; }

.select-chip, .btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--paper);
  border: 1px solid var(--linen);
  font-size: 13px; font-weight: 500;
  color: var(--charcoal);
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
  white-space: nowrap;
}
.select-chip:hover, .btn:hover { border-color: var(--stone-soft); background: #FBFAF8; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: var(--ink-soft); }
.btn.accent { background: var(--terracotta); color: #fff; border-color: var(--terracotta); font-weight: 600; }
.btn.accent:hover { background: #BE5430; }
.btn.danger { color: var(--brick); }
.btn.danger:hover { background: var(--brick-soft); border-color: var(--brick-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--linen-soft); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; justify-content: center; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.icon-only { width: 32px; height: 32px; padding: 0; justify-content: center; border-color: transparent; }
.btn.icon-only:hover { background: var(--linen-soft); }
select.select-chip { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232B2926' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }

/* ------------------------------------------------------------- Countdown */
.countdown { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.countdown-hero {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 22px 26px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  border: 1.5px solid var(--linen);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.countdown-hero.warn { border-color: var(--amber); background: linear-gradient(90deg, #FFF8EC, var(--paper)); }
.countdown-hero.danger { border-color: var(--brick); background: linear-gradient(90deg, #FDF0EE, var(--paper)); }
.countdown-hero.ok { border-color: var(--sage-soft); }
.countdown-hero .big { font-size: 34px; font-weight: 700; letter-spacing: 0.02em; }
.countdown-hero .big .unit { font-family: var(--font-sans); font-size: 16px; font-weight: 600; margin: 0 8px 0 2px; color: var(--stone); }
.countdown-hero .meta { color: var(--stone); font-size: 13px; }
.countdown-hero .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.progress { height: 6px; border-radius: 3px; background: var(--linen); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 3px; background: var(--sage); transition: width .6s ease; }
.progress > i.warn { background: var(--amber); }
.progress > i.danger { background: var(--brick); }

.expiry-list { display: flex; flex-direction: column; gap: 10px; }
.expiry-row {
  display: grid; grid-template-columns: 1.4fr 2fr auto auto; gap: 18px; align-items: center;
  padding: 14px 18px; border-radius: var(--radius-md); background: var(--paper); box-shadow: var(--shadow-card); border: 1px solid var(--linen-soft);
}
.expiry-row .n { font-weight: 600; }
.expiry-row .s { font-size: 12px; color: var(--stone); }
.expiry-row .cd { font-size: 14px; font-weight: 600; text-align: right; min-width: 150px; }

/* ------------------------------------------------------------- Key/Value */
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); row-gap: 12px; column-gap: 12px; font-size: 13.5px; }
.kv dt { color: var(--stone); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--linen-soft); }
.list-item:last-child { border-bottom: 0; }
.list-item .ic { width: 42px; height: 42px; border-radius: 12px; background: var(--linen-soft); display: grid; place-items: center; color: var(--charcoal); flex: none; }
.list-item .ic svg { width: 20px; height: 20px; }
.list-item .t { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-item .d { font-size: 12.5px; color: var(--stone); overflow-wrap: anywhere; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .ops { display: flex; gap: 4px; flex-wrap: wrap; }
/* 指纹等不可分割的长字符串：允许在任意位置断行 */
.fp { overflow-wrap: anywhere; word-break: break-all; }

.callout { padding: 16px 20px; border-radius: var(--radius-md); display: flex; gap: 14px; align-items: flex-start; }
.callout.ok { background: var(--sage-soft); color: #2F5E3D; }
.callout.warn { background: var(--amber-soft); color: #7A5410; }
.callout.info { background: var(--mist-soft); color: #38587A; }
.callout.danger { background: var(--brick-soft); color: #8E2F26; }
.callout svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.callout .t { font-weight: 700; }
.callout .grow { flex: 1; }

.code-block {
  background: var(--ink); color: #E8E4DC;
  border-radius: var(--radius-md); padding: 16px 18px;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.7;
  overflow-x: auto; white-space: pre;
}
.code-block .c { color: #8C877E; }
.code-block .g { color: #8FCFA0; }
.code-block .y { color: #F1C87A; }
.code-block .p { color: #D2603A; }

/* ------------------------------------------------------------------ Form */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--charcoal); }
.field .hint { font-size: 12px; color: var(--stone); }
.field .hint.warn { color: #B37E19; }
.field .hint.danger { color: var(--brick); }
.input, .field input[type="text"], .field input[type="number"], .field input[type="date"], .field input[type="password"], .field select, .field textarea {
  height: 42px; padding: 0 14px;
  border: 1px solid var(--linen); border-radius: 12px;
  background: #FBFAF8; outline: none; width: 100%; min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.field textarea { height: auto; min-height: 84px; padding: 10px 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--ink); background: var(--paper); box-shadow: 0 0 0 3px rgba(20,19,17,.06); }
.field input::placeholder { color: var(--stone-soft); }
.quick-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-chips button { height: 28px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--linen); background: var(--paper); font-size: 12px; }
.quick-chips button:hover { border-color: var(--ink); }
.segmented { display: inline-flex; background: var(--linen-soft); border-radius: var(--radius-pill); padding: 3px; }
.segmented button { height: 32px; padding: 0 14px; border-radius: var(--radius-pill); font-size: 13px; font-weight: 500; color: var(--stone); }
.segmented button.active { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-card); }
.switch { position: relative; width: 42px; height: 24px; border-radius: 12px; background: var(--linen); transition: background .2s ease; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s ease; }
.switch.on { background: var(--sage); }
.switch.on::after { transform: translateX(18px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; }
.switch-row .t { font-weight: 600; }
.switch-row .d { font-size: 12.5px; color: var(--stone); }

/* ----------------------------------------------------------------- Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 19, 17, 0.45);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
  animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 640px; max-height: calc(100vh - 48px); overflow: auto;
  background: var(--paper); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float); padding: 26px 28px 22px;
  animation: pop .18s ease;
}
.modal.sm { max-width: 440px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.modal-head h3 { font-size: 20px; }
.modal-head .sub { color: var(--stone); font-size: 13px; margin-top: 4px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.modal-foot .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------------- Toast */
.toast-root { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 380px;
  padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow-float);
  display: flex; gap: 10px; align-items: center;
  animation: pop .2s ease;
}
.toast.ok { border-left: 4px solid var(--sage); }
.toast.error { border-left: 4px solid var(--brick); }
.toast.warn { border-left: 4px solid var(--amber); }

/* ------------------------------------------------------------- Auth page */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-left { display: grid; place-items: center; padding: 40px; }
.auth-panel { width: 100%; max-width: 400px; }
.auth-panel .brand { padding: 0 0 36px; color: var(--ink); }
.auth-panel h1 { font-size: 34px; margin-bottom: 8px; }
.auth-panel .lead { color: var(--stone); margin-bottom: 30px; }
.auth-panel .or { display: flex; align-items: center; gap: 14px; color: var(--stone-soft); font-size: 12px; margin: 18px 0; }
.auth-panel .or::before, .auth-panel .or::after { content: ""; flex: 1; height: 1px; background: var(--linen); }
.auth-panel .foot { margin-top: 26px; font-size: 12px; color: var(--stone); line-height: 1.7; }
.auth-right {
  margin: 16px 16px 16px 0; border-radius: var(--radius-xl);
  background: var(--ink); color: #fff; position: relative; overflow: hidden;
  display: flex; align-items: flex-end; padding: 48px;
}
.auth-right .glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(80px); opacity: .55; }
.auth-right .glow.a { background: var(--terracotta); top: -160px; right: -120px; }
.auth-right .glow.b { background: var(--mist); bottom: -220px; left: -160px; opacity: .35; }
.auth-right .quote { position: relative; max-width: 460px; }
.auth-right .quote .k { font-size: 12px; letter-spacing: .12em; color: rgba(255,255,255,.55); text-transform: uppercase; margin-bottom: 14px; }
.auth-right .quote h2 { font-size: 30px; font-weight: 700; line-height: 1.25; margin-bottom: 14px; }
.auth-right .quote p { color: rgba(255,255,255,.7); }
.auth-right .cards { position: absolute; top: 56px; right: 48px; left: 48px; display: flex; flex-direction: column; gap: 12px; }
.auth-right .mini { background: rgba(255,255,255,.96); color: var(--ink); border-radius: 16px; padding: 14px 18px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-float); transform: rotate(-1.5deg); }
.auth-right .mini:nth-child(2) { transform: rotate(1deg) translateX(30px); }
.auth-right .mini:nth-child(3) { transform: rotate(-.5deg) translateX(10px); }
.auth-right .mini .n { font-weight: 700; }
.auth-right .mini .s { font-size: 12px; color: var(--stone); }
.auth-right .mini .chip { margin-left: auto; }

/* ------------------------------------------------------------- Misc */
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.breadcrumb { color: var(--stone); font-size: 13px; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.breadcrumb a:hover { color: var(--ink); }
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.detail-head > div:first-child { min-width: 0; }
.detail-head h1 { font-size: 28px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; overflow-wrap: anywhere; }
.detail-head .meta { color: var(--stone); margin-top: 4px; overflow-wrap: anywhere; }
.detail-head .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.copy-row { display: flex; align-items: center; gap: 8px; background: var(--linen-soft); border-radius: 12px; padding: 8px 8px 8px 14px; }
.copy-row code { flex: 1; min-width: 0; overflow: auto; white-space: nowrap; }
.copy-row .btn { flex: none; }
.empty { text-align: center; padding: 56px 20px; color: var(--stone); }
.empty .ic { width: 64px; height: 64px; border-radius: 20px; background: var(--paper); display: grid; place-items: center; margin: 0 auto 16px; box-shadow: var(--shadow-card); border: 1px solid var(--linen-soft); }
.empty .ic svg { width: 28px; height: 28px; stroke: var(--terracotta); }
.empty h3 { color: var(--charcoal); margin-bottom: 6px; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline .ev { display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding: 8px 0; }
.timeline .ev .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sage); margin-top: 6px; }
.timeline .ev .dot.warn { background: var(--amber); } .timeline .ev .dot.danger { background: var(--brick); } .timeline .ev .dot.info { background: var(--mist); }
.timeline .ev .w { font-size: 12px; color: var(--stone); }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--radius-md); background: var(--amber-soft); color: #7A5410; margin-bottom: 18px; }
.banner .grow { flex: 1; }
.kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--linen); border-bottom-width: 2px; border-radius: 6px; font-family: var(--font-mono); font-size: 11.5px; background: var(--paper); }
.spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- Monitor cards */
/* 运行状态卡片：固定宽度，列数随画布自动增减，与上方统计卡片一致 */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, 260px); gap: 16px; }
.monitor-card { width: 260px; display: flex; flex-direction: column; gap: 14px; color: inherit; transition: transform .15s ease, box-shadow .15s ease; }
.lat-gauge { display: flex; flex-direction: column; align-items: center; margin: -4px 0 -2px; }
.lat-gauge svg { width: 170px; height: auto; display: block; }
.lat-gauge .lat-value { display: flex; align-items: baseline; gap: 5px; margin-top: 2px; }
.lat-gauge .lat-value b { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.lat-gauge .lat-value span { font-size: 12px; color: var(--stone); }
.monitor-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); }
.monitor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.monitor-head .n { font-weight: 700; font-size: 15px; }
.monitor-head .s { font-size: 12px; color: var(--stone); margin-top: 2px; }
.monitor-meters { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.meter { display: flex; flex-direction: column; gap: 7px; }
.meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; color: var(--stone); }
.meter-top b { color: var(--charcoal); font-variant-numeric: tabular-nums; font-weight: 650; }

/* ===========================================================================
   自适应布局
   断点：≤1200 双栏并单 · ≤900 平板（侧栏变顶栏）· ≤720 手机 · ≤400 小屏手机
   原则：桌面端样式不变；窄屏下所有内容都不得超出视口，宁可换行 / 堆叠，也不横向溢出。
=========================================================================== */

@media (max-width: 1200px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------ 平板 / 窄窗口 ≤900 */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  /* 侧栏 → 置顶应用栏：品牌 + 汉堡按钮；菜单折叠在应用栏下方，展开时覆盖在内容之上 */
  .sidebar {
    position: sticky; top: 0; z-index: 30;
    height: auto; min-height: 56px;
    flex-direction: row; align-items: center; justify-content: space-between; gap: 10px;
    border-radius: 0;
    padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
    box-shadow: 0 8px 24px -16px rgba(20, 19, 17, .6);
  }
  .brand { padding: 0; gap: 8px; font-size: 17px; flex: none; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }

  /* 汉堡按钮：三条线，展开时变为 × */
  .nav-toggle {
    display: block; position: relative; flex: none;
    width: 44px; height: 44px; border-radius: 50%; color: #fff;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-toggle:hover, .nav-toggle:active { background: rgba(255,255,255,.08); }
  .nav-toggle i {
    position: absolute; left: 13px; width: 18px; height: 2px; border-radius: 1px; background: currentColor;
    transition: transform .22s ease, opacity .16s ease, top .22s ease;
  }
  .nav-toggle i:nth-child(1) { top: 15px; }
  .nav-toggle i:nth-child(2) { top: 21px; }
  .nav-toggle i:nth-child(3) { top: 27px; }
  .menu-open .nav-toggle i:nth-child(1) { top: 21px; transform: rotate(45deg); }
  .menu-open .nav-toggle i:nth-child(2) { opacity: 0; transform: scaleX(.3); }
  .menu-open .nav-toggle i:nth-child(3) { top: 21px; transform: rotate(-45deg); }
  .nav-toggle.has-badge::after {
    content: ""; position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%;
    background: var(--amber); border: 2px solid var(--ink);
    transition: opacity .16s ease;
  }
  .nav-toggle.has-badge.danger::after { background: var(--brick); }
  .menu-open .nav-toggle::after { opacity: 0; }

  /* 折叠面板：用 grid 行高 0fr → 1fr 做高度动画 */
  .sidebar-menu {
    display: grid; grid-template-rows: 0fr;
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1;
    background: var(--ink); color: #fff;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 24px 48px -20px rgba(20, 19, 17, .55);
    transition: grid-template-rows .28s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .28s;
    visibility: hidden;
  }
  .sidebar-menu-inner {
    display: block; min-height: 0; overflow: hidden;
    padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  }
  .menu-open .sidebar-menu { grid-template-rows: 1fr; visibility: visible; transition-delay: 0s; }
  .menu-open .sidebar-menu-inner { overflow-y: auto; max-height: calc(100dvh - 56px - env(safe-area-inset-top, 0px)); scrollbar-width: none; }
  .menu-open .sidebar-menu-inner::-webkit-scrollbar { display: none; }

  .nav { flex-direction: column; gap: 2px; padding: 6px 0 8px; border-top: 1px solid rgba(255,255,255,.08); }
  .nav a { padding: 12px 14px; border-radius: 14px; font-size: 15px; gap: 12px; }
  .nav a svg { width: 18px; height: 18px; }
  .nav .badge { margin-left: auto; }
  .sidebar-foot { margin: 0; padding: 6px 0 calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255,255,255,.08); font-size: 14px; }
  .sidebar-foot .link { padding: 12px 14px; border-radius: 14px; gap: 12px; }
  .sidebar-foot .link:hover { background: rgba(255,255,255,.07); }

  /* 展开时压暗页面内容，点击即收起 */
  .menu-backdrop {
    display: block; position: fixed; inset: 0; z-index: 29;
    background: rgba(20, 19, 17, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; pointer-events: none; transition: opacity .25s ease;
  }
  .menu-open .menu-backdrop { opacity: 1; pointer-events: auto; }
  @media (prefers-reduced-motion: reduce) {
    .sidebar-menu, .menu-backdrop, .nav-toggle i { transition: none; }
  }

  .main { padding: 22px 22px 40px; }
  .search { width: 100%; }
  .grid-2-even { grid-template-columns: 1fr; }

  /* 卡片改为流式宽度，随屏幕自动分栏 */
  .stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .stat { width: auto; }
  .monitor-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .monitor-card { width: auto; }

  .expiry-row { grid-template-columns: 1fr; gap: 8px; }
  .expiry-row .cd { text-align: left; min-width: 0; }

  .auth { grid-template-columns: 1fr; min-height: 100dvh; }
  .auth-right { display: none; }
}

/* ------------------------------------------------------------- 手机 ≤720 */
@media (max-width: 720px) {
  .main { padding: 16px 16px calc(36px + env(safe-area-inset-bottom, 0px)); }

  /* 顶栏：标题 + 图标按钮一行，搜索与操作按钮各占一行 */
  .topbar { gap: 10px 10px; margin-bottom: 18px; }
  .topbar h1 { font-size: 22px; flex: 1 1 auto; }
  .topbar .spacer { display: none; }
  .topbar .icon-btn { order: 2; width: 40px; height: 40px; }
  .topbar .icon-btn .dot { top: 9px; right: 10px; }
  .topbar .user-pill { order: 3; width: 40px; height: 40px; padding: 0; gap: 0; justify-content: center; border-radius: 50%; }
  .topbar .user-pill > div:not(.avatar) { display: none; }
  .topbar .user-pill .avatar { width: 30px; height: 30px; font-size: 12.5px; }
  .topbar .search { order: 5; flex: 1 1 100%; height: 42px; }
  .topbar .topbar-actions { order: 6; display: flex; flex: 1 1 100%; gap: 8px; flex-wrap: wrap; }
  .topbar .topbar-actions .btn { flex: 1 1 auto; justify-content: center; height: 40px; }

  .section-head { margin: 4px 0 12px; flex-wrap: wrap; }
  .card { padding: 16px; border-radius: 16px; }
  .card-head { margin-bottom: 12px; flex-wrap: wrap; }
  .card-head h3 { font-size: 15px; }
  .card-tools { width: 100%; flex-wrap: wrap; }
  .card-tools .btn { flex: 1 1 auto; justify-content: center; }
  .card-tools .select-chip { flex: 1 1 auto; }

  /* 统计卡片两列 */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
  .stat { padding: 16px 16px 14px; gap: 4px; }
  .stat .icon { width: 38px; height: 38px; margin-bottom: 6px; }
  .stat .icon svg { width: 18px; height: 18px; }
  .stat .value { font-size: 24px; overflow-wrap: anywhere; }
  .stat .value small { font-size: 12px; }
  .monitor-grid { gap: 12px; }

  /* 列表项：操作按钮换到下一行，与文字左对齐 */
  .list-item { gap: 10px 12px; padding: 12px 0; }
  .list-item .ic { width: 38px; height: 38px; border-radius: 10px; }
  .list-item .ops { flex: 1 1 100%; padding-left: 50px; gap: 6px; }
  .list-item .ops .btn.sm:not(.icon-only) { flex: 1 1 auto; justify-content: center; }

  /* 表格：默认横向滚动；带 .stack 的表格堆叠成卡片，单元格用 data-label 显示表头 */
  .table:not(.stack) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; }
  .table.stack thead { display: none; }
  .table.stack tr {
    border: 1px solid var(--linen-soft); border-radius: var(--radius-md);
    padding: 12px 14px 12px; margin-bottom: 10px; background: var(--paper);
  }
  .table.stack tr:last-child { margin-bottom: 0; }
  .table.stack tbody tr.clickable:hover { background: #FAF9F6; }
  .table.stack td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 6px 0; border: 0; white-space: normal; text-align: left; min-width: 0;
  }
  .table.stack td > * { min-width: 0; }
  .table.stack td.num { text-align: right; }
  .table.stack td[data-label]::before { content: attr(data-label); color: var(--stone); font-size: 12.5px; flex: none; }
  .table.stack td.stack-head { display: block; padding: 0 0 10px; margin-bottom: 4px; border-bottom: 1px solid var(--linen-soft); }
  .table.stack td.stack-head .name { font-size: 15px; }
  .table.stack td.stack-head .sub { margin-top: 2px; overflow-wrap: anywhere; }
  .table.stack td.stack-actions { display: block; padding: 10px 0 0; }
  .table.stack td.stack-actions .actions { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  .table.stack td.stack-actions .actions .btn:not(.icon-only) { flex: 1 1 auto; justify-content: center; }
  .table.stack td.stack-actions .actions .btn.icon-only { width: 38px; height: 38px; border-color: var(--linen); }
  .table.stack td:empty { display: none; }
  .table.stack td.center { cursor: pointer; padding: 8px 0; }
  .table.stack td.center .cb { width: 20px; height: 20px; }
  .alias-input { width: 100%; max-width: 220px; height: 36px; }

  /* 键值对：标签列收窄 */
  .kv { grid-template-columns: minmax(72px, max-content) minmax(0, 1fr); column-gap: 10px; row-gap: 10px; }
  .copy-row { flex-wrap: wrap; padding: 10px 10px 10px 12px; }
  .copy-row code { flex: 1 1 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; }
  .copy-row .btn { margin-left: auto; }

  .code-block { padding: 14px; font-size: 12px; border-radius: 12px; }
  .callout { padding: 14px 16px; gap: 10px; }

  /* 到期倒计时英雄区 */
  .countdown-hero { padding: 18px 16px; gap: 14px; }
  .countdown-hero .big { font-size: 26px; }
  .countdown-hero .big .unit { font-size: 13px; margin: 0 6px 0 2px; }
  .countdown-hero .right { margin-left: auto; }

  .detail-head { gap: 12px; margin-bottom: 18px; }
  .detail-head h1 { font-size: 22px; gap: 8px; }
  .detail-head .right { margin-left: 0; width: 100%; }
  .detail-head .right .btn { flex: 1 1 auto; justify-content: center; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* 表单单列；输入框字号 ≥16px 防止 iOS 聚焦时自动放大页面 */
  .form { grid-template-columns: 1fr; gap: 14px; }
  .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .input, .search input, .alias-input { font-size: 16px; }

  /* 弹窗 → 底部抽屉 */
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal {
    max-width: none; width: 100%;
    max-height: calc(100dvh - 20px);
    border-radius: 22px 22px 0 0;
    padding: 12px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    animation: sheet .22s ease;
  }
  .modal::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--linen); margin: 0 auto 14px; }
  .modal.sm { max-width: none; }
  .modal-head { margin-bottom: 14px; }
  .modal-head h3 { font-size: 18px; }
  .modal-foot { gap: 8px; margin-top: 18px; }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; height: 42px; }
  .modal-foot .left { margin-right: 0; flex: 1 1 100%; }

  /* Toast 贴底铺满 */
  .toast-root { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); align-items: stretch; }
  .toast { min-width: 0; max-width: none; }

  /* 登录页 */
  .auth-left { padding: 32px 20px; align-items: start; }
  .auth-panel h1 { font-size: 28px; }
  .auth-panel .brand { padding-bottom: 28px; }
}

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

/* --------------------------------------------------------- 小屏手机 ≤400 */
@media (max-width: 400px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  .topbar h1 { font-size: 20px; }
  .table.stack tr { padding: 10px 12px; }
  .list-item .ops { padding-left: 0; }
  .code-block { font-size: 11.5px; }
}
@media (max-width: 340px) {
  .stats { grid-template-columns: 1fr; }
}
