/* ==========================================================================
   ADM · 浅色后台设计系统
   1. Tokens          2. Base            3. Shell(sidebar/topbar)
   4. Navigation      5. Layout helpers  6. Cards & stats
   7. Forms/toolbar   8. Buttons         9. Tables
   10. Badges/tags    11. Data blocks     12. Media (photos/notes)
   13. Overlays       14. Login           15. Responsive
   ========================================================================== */

/* ---------------------------------------------------------------- 1. Tokens */
:root {
  --bg:            #f4f6fb;
  --bg-accent:     #eef2f9;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --surface-3:     #eef2f8;
  --line:          #e4e9f2;
  --line-2:        #d4dbe7;

  --text:          #16203a;
  --text-2:        #3c4a63;
  --muted:         #6b7a93;
  --muted-2:       #8d99ae;

  --accent:        #2563eb;
  --accent-2:      #1d4ed8;
  --accent-soft:   #eaf1ff;
  --accent-line:   #c7d9ff;

  --ok:            #15803d;
  --ok-soft:       #e7f6ec;
  --warn:          #b45309;
  --warn-soft:     #fdf3e3;
  --danger:        #dc2626;
  --danger-soft:   #fdecec;
  --coruna:        #4f46e5;
  --coruna-soft:   #ecebfe;
  --ds:            #0f766e;
  --ds-soft:       #e2f5f2;

  --r-xs: 6px;
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(16, 24, 40, .06);
  --sh-2: 0 2px 8px rgba(16, 24, 40, .07);
  --sh-3: 0 12px 32px rgba(16, 24, 40, .16);

  --side-w: 250px;
  --top-h:  60px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

/* ------------------------------------------------------------------ 2. Base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.35; }
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }

p { margin: 8px 0; }

code, .mono, pre { font-family: var(--mono); }
code { font-size: 12.5px; word-break: break-all; }

hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

::selection { background: var(--accent-line); color: var(--text); }

.muted { color: var(--muted); }
.ok    { color: var(--ok); }
.err   { color: var(--danger); }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }

/* Improve default focus visibility without ugly outlines on mouse use. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------- 3. Shell & topbar */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 60;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--top-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  flex: 0 0 auto;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text b { font-size: 14px; font-weight: 650; }
.brand-text span { font-size: 11px; color: var(--muted-2); }

.sidebar-scroll { padding: 12px 12px 20px; overflow-y: auto; flex: 1 1 auto; }

.sidebar-foot {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

/* ----------------------------------------------------------- 4. Navigation */
.nav-group + .nav-group { margin-top: 14px; }

.nav-group-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 10px 6px;
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background .13s ease, color .13s ease;
}

.nav a:hover { background: var(--surface-3); color: var(--text); }

.nav a.on {
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 600;
}

.nav a.on::before {
  content: "";
  position: absolute;
  left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav .ico { width: 17px; height: 17px; flex: 0 0 auto; opacity: .85; }
.nav a.on .ico { opacity: 1; }
.nav .nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav .pill {
  flex: 0 0 auto;
  background: var(--surface-3);
  color: var(--muted);
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 650;
  padding: 1px 7px;
}
.nav a.on .pill { background: #fff; color: var(--accent-2); }

.main {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--side-w);
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--top-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title h1 { font-size: 17px; }
.topbar-title .crumb { font-size: 12px; color: var(--muted-2); }

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 13px;
}

.user-chip .avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}

.user-chip a { color: var(--muted); padding: 0 6px; }
.user-chip a:hover { color: var(--danger); }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--surface-3); }

.burger { display: none; }

.content { padding: 22px 24px 56px; flex: 1 1 auto; }
.content > * { max-width: 1600px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------- 6. Cards/stats */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-pad { padding: 16px 18px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.card-head h2, .card-head h3 { font-size: 14px; }
.card-head .card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

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

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

.stat {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  transition: box-shadow .15s ease, transform .15s ease;
}
a.stat:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }

.stat-ico {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex: 0 0 auto;
  background: var(--accent-soft);
  color: var(--accent);
}
.stat-ico.ok     { background: var(--ok-soft);     color: var(--ok); }
.stat-ico.warn   { background: var(--warn-soft);   color: var(--warn); }
.stat-ico.danger { background: var(--danger-soft); color: var(--danger); }
.stat-ico.coruna { background: var(--coruna-soft); color: var(--coruna); }
.stat-ico.ds     { background: var(--ds-soft);     color: var(--ds); }

/* 三行文字必须竖排，否则会挤成一行 */
.stat-body { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; }
.stat-label { display: block; font-size: 12px; color: var(--muted); font-weight: 550; }
.stat-val {
  display: block;
  font-size: 24px;
  font-weight: 680;
  line-height: 1.25;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.stat-sub { display: block; font-size: 12px; color: var(--muted-2); line-height: 1.5; }

.stat-val .unit { font-size: 13px; font-weight: 550; color: var(--muted); margin-left: 3px; }

.kv { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 9px 14px; font-size: 13.5px; }
.kv b { color: var(--muted); font-weight: 550; }
.kv > span { word-break: break-word; }

/* ------------------------------------------------------- 7. Forms/toolbar */
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 12px; color: var(--muted); font-weight: 550; }

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

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  min-height: 36px;
  transition: border-color .13s ease, box-shadow .13s ease;
  max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); }

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

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.w-160 { width: 160px; }
.w-200 { width: 200px; }
.w-240 { width: 240px; }
.w-280 { width: 280px; }
.w-full { width: 100%; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { min-height: 0; }

/* --------------------------------------------------------------- 8. Buttons */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .13s ease, border-color .13s ease, color .13s ease, box-shadow .13s ease;
}
.btn:hover, button:hover { background: var(--accent-2); color: #fff; }
.btn:active, button:active { transform: translateY(1px); }
.btn[disabled], button[disabled] { opacity: .55; cursor: not-allowed; }

.btn.ghost, button.ghost {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--line-2);
}
.btn.ghost:hover, button.ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-2); }

.btn.danger, button.danger { background: var(--danger); color: #fff; }
.btn.danger:hover, button.danger:hover { background: #b91c1c; }

.btn.danger-ghost, button.danger-ghost {
  background: var(--surface);
  color: var(--danger);
  border-color: #f3c9c9;
}
.btn.danger-ghost:hover, button.danger-ghost:hover { background: var(--danger-soft); color: var(--danger); }

.btn.soft, button.soft { background: var(--accent-soft); color: var(--accent-2); }
.btn.soft:hover, button.soft:hover { background: var(--accent-line); color: var(--accent-2); }

.btn.sm, button.sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn.xs, button.xs { min-height: 26px; padding: 2px 8px; font-size: 12px; border-radius: var(--r-xs); }
.btn.block, button.block { width: 100%; }

.btn.on { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); }

.btn .ico, button .ico { width: 15px; height: 15px; flex: 0 0 auto; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- 9. Tables */
.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }

.table th,
.table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .02em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-2);
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table td.tight { width: 1%; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .sub { display: block; font-size: 12px; color: var(--muted-2); }

.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------------------------------------ 10. Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 620;
  line-height: 1.7;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--muted);
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.no-dot::before { display: none; }

.badge.on       { background: var(--ok-soft);     color: var(--ok); }
.badge.off      { background: var(--surface-3);   color: var(--muted); }
.badge.pending  { background: var(--warn-soft);   color: var(--warn); }
.badge.sent     { background: var(--accent-soft); color: var(--accent); }
.badge.done     { background: var(--ok-soft);     color: var(--ok); }
.badge.failed   { background: var(--danger-soft); color: var(--danger); }
.badge.likely   { background: var(--danger-soft); color: var(--danger); }
.badge.coruna   { background: var(--coruna-soft); color: var(--coruna); }
.badge.darksword{ background: var(--ds-soft);     color: var(--ds); }
.badge.muted    { background: var(--surface-3);   color: var(--muted); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--mono);
}

/* ------------------------------------------------------- 11. Data blocks */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .ico { width: 30px; height: 30px; opacity: .4; }
.empty b { color: var(--text-2); font-weight: 600; }
.empty span { font-size: 13px; }

.pager { display: flex; justify-content: center; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); }
.pager:empty { display: none; }

.pagination { display: flex; gap: 5px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.pagination li a,
.pagination li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
}
.pagination li a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.pagination li.active span { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
.pagination li.disabled span { opacity: .45; }

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--surface-3);
  border-radius: var(--r);
  margin-bottom: 16px;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
}
.tabs a:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.tabs a.on { background: var(--surface); color: var(--accent-2); font-weight: 650; box-shadow: var(--sh-1); }
.tabs a .pill {
  background: var(--surface-3);
  color: var(--muted);
  border-radius: var(--r-pill);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 650;
}
.tabs a.on .pill { background: var(--accent-soft); color: var(--accent-2); }

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
  margin-bottom: 16px;
}
.hero .hero-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.hero .hero-main code { font-size: 13px; color: var(--text); }
.hero .hero-sep { width: 1px; height: 22px; background: var(--line); }
.hero .hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.secret {
  background: var(--warn-soft);
  border: 1px solid #f0dcbb;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 8px;
  font-size: 13px;
}
.secret:last-child { margin-bottom: 0; }
.secret code { color: #7c4a03; overflow-wrap: anywhere; }
.secret .secret-key { color: var(--muted); font-size: 12px; }

.pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  max-height: 340px;
  overflow: auto;
  margin: 0;
}

.secret-cell { min-width: 260px; max-width: 520px; }

.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* 柱状图：.bar-track 必须有确定高度，否则百分比高度会塌成 min-height */
.chart { display: flex; align-items: flex-end; gap: 10px; padding: 4px 2px 0; }
.chart .bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart .bar-track { width: 100%; max-width: 44px; height: 108px; display: flex; align-items: flex-end; }
.chart .bar {
  width: 100%;
  min-height: 3px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #60a5fa, var(--accent));
}
.chart .bar.zero { background: var(--surface-3); }
.chart .bar-val { font-size: 11.5px; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.chart .bar-label { font-size: 11px; color: var(--muted-2); white-space: nowrap; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--surface-2); }
.list .li-main { flex: 1 1 auto; min-width: 0; }
.list .li-main b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .li-main span { font-size: 12px; color: var(--muted-2); }
.list .li-side { flex: 0 0 auto; font-size: 12px; color: var(--muted); text-align: right; }

.wallet-group h3 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wallet-pair { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; background: var(--surface-2); }
.wallet-pair:last-child { margin-bottom: 0; }
.wallet-pair .secret { margin-bottom: 10px; }

.wallet-fold { border: 1px solid var(--line); border-radius: var(--r-sm); margin: 10px 0 0; background: var(--surface); overflow: hidden; }
.wallet-fold summary {
  cursor: pointer;
  padding: 9px 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  list-style: none;
  font-size: 13px;
  background: var(--surface-2);
}
.wallet-fold summary::-webkit-details-marker { display: none; }
.wallet-fold summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid var(--muted-2);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .15s ease;
}
.wallet-fold[open] summary::before { transform: rotate(90deg); }
.wallet-fold .table th, .wallet-fold .table td { padding: 8px 13px; }

/* ------------------------------------------------- 12. Media & note lists */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }

.photo-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-1);
  transition: box-shadow .15s ease, transform .15s ease;
}
.photo-item:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }

.photo-thumb { position: relative; display: block; background: var(--surface-3); cursor: zoom-in; }
.photo-item .photo-thumb img { width: 100%; height: 158px; object-fit: cover; display: block; }

.photo-scan-badge {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .22);
  background: rgba(255, 255, 255, .94);
}
.photo-scan-badge.likely { max-width: 90%; overflow: hidden; text-overflow: ellipsis; }

.photo-meta { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 3px; }
.photo-meta code { font-size: 11.5px; }
.photo-meta .muted { font-size: 12px; }

.note-list { display: flex; flex-direction: column; }
.note-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.note-row:last-child { border-bottom: 0; }
.note-row:hover { background: var(--surface-2); }
.note-row-device { flex: 0 0 auto; max-width: 30%; }
.note-row-device code { font-size: 11.5px; }
.note-row-main { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-row-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }

.note-detail-block p { margin: 0 0 10px; text-align: left; }
.note-detail-body { max-height: 50vh; text-align: left; margin: 0; }

.promo-url {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 6px 9px;
  word-break: break-all;
}

.promo-iframe-wrap { margin-top: 10px; }
.promo-iframe-snippet {
  display: block;
  font-size: 11.5px;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-2);
}

.channel-card .card-head { background: var(--surface); }
.channel-card .channel-code { background: var(--accent-soft); color: var(--accent-2); font-weight: 650; }
.tg-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

/* ------------------------------------------------------------- 13. Overlays */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: rgba(15, 23, 42, .82);
  backdrop-filter: blur(3px);
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r); box-shadow: var(--sh-3); }
.lightbox-close {
  position: absolute;
  top: 18px; right: 20px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  border: 0;
  font-size: 20px;
  display: grid; place-items: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .26); color: #fff; }

.toast-stack {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-2);
  font-size: 13.5px;
  animation: toast-in .18s ease-out;
}
.toast.ok     { border-left-color: var(--ok); }
.toast.err    { border-left-color: var(--danger); }
.toast.warn   { border-left-color: var(--warn); }
.toast .ico   { width: 16px; height: 16px; flex: 0 0 auto; }

@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* SweetAlert2 · 浅色皮肤 */
.swal2-popup.adm-swal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  font-family: var(--font);
}
.swal2-popup.adm-swal .swal2-title { color: var(--text); font-size: 17px; font-weight: 650; }
.swal2-popup.adm-swal .swal2-html-container { color: var(--muted); font-size: 13.5px; }
.swal2-popup.adm-swal .swal2-actions { gap: 10px; }
.swal2-popup.adm-swal code { color: var(--text); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.swal2-popup.adm-swal .swal2-input,
.swal2-popup.adm-swal .swal2-select,
.swal2-popup.adm-swal .swal2-textarea { border-color: var(--line-2); }

.swal-json {
  max-height: 66vh;
  overflow: auto;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12.5px/1.6 var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin: 0;
  color: var(--text-2);
}
.swal-json .jk { color: #1d4ed8; font-weight: 600; }
.swal-json .js { color: #15803d; }
.swal-json .jn { color: #b45309; }
.swal-json .jl { color: #be185d; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(15, 23, 42, .38);
  display: none;
}
.overlay.open { display: block; }

/* ---------------------------------------------------------------- 14. Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -12%, #e5edff 0%, transparent 62%),
    radial-gradient(900px 480px at 96% 6%, #eae4ff 0%, transparent 58%),
    var(--bg);
}

.login-box {
  width: 100%;
  max-width: 388px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  padding: 30px 30px 26px;
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box > p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-box form > .field { margin-bottom: 14px; }
.login-box .btn { width: 100%; margin-top: 6px; min-height: 40px; }
.login-note { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted-2); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid;
}
.alert.err { background: var(--danger-soft); border-color: #f3c9c9; color: #991b1b; }
.alert.ok  { background: var(--ok-soft);     border-color: #bfe6cd; color: #14532d; }
.alert.info{ background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-2); }
.alert.warn{ background: var(--warn-soft);   border-color: #f0dcbb; color: #7c4a03; }

/* ----------------------------------------------------------- 15. Responsive */
@media (max-width: 1180px) {
  .grid-2-1, .grid-1-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--sh-3); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .burger { display: grid; }
  .topbar { padding: 0 16px; gap: 10px; }
  .content { padding: 16px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 108px minmax(0, 1fr); }
  .topbar-title .crumb { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 窄屏：表格按内容撑开并横向滚动，而不是把列挤成竖排文字 */
  .table-wrap > .table { width: max-content; min-width: 100%; }
}

@media (max-width: 620px) {
  .user-chip .user-name { display: none; }
  /* 顶栏挤不下时只留图标 */
  .reveal-label { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-ico { width: 30px; height: 30px; border-radius: 8px; }
  .stat-val { font-size: 19px; }
  .stat-sub { font-size: 11.5px; }
  .chart .bar-track { height: 84px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .note-row { flex-wrap: wrap; gap: 6px 10px; }
  .note-row-device { max-width: 100%; }
  .note-row-main { flex-basis: 100%; }
  .hero .hero-actions { margin-left: 0; width: 100%; }
}

@media print {
  .sidebar, .topbar, .toolbar, .pager, .btn, button { display: none !important; }
  .main { margin-left: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
