/* ══════════════════════════════════════════
   烩面控制台 — 移动端优先，860px 起桌面布局
   ══════════════════════════════════════════ */

:root {
  --bg: #0e0d0b;
  --bg-soft: #151310;
  --surface: #1c1916;
  --surface-2: #242019;
  --surface-hover: #2c2822;
  --border: rgba(245, 230, 200, 0.09);
  --border-strong: rgba(245, 230, 200, 0.16);
  --text: #f7f2ea;
  --text-secondary: #d4cbc0;
  --muted: #9a9188;
  --accent: #e5a020;
  --accent-hover: #f0b840;
  --accent-soft: rgba(229, 160, 32, 0.14);
  --accent-glow: rgba(229, 160, 32, 0.35);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.25);
  --sidebar-w: 256px;
  --mobile-top-h: 3rem;
  --bottom-nav-h: 3.75rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --bp-desktop: 860px;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

/* ── 平台可见性 ── */
.mobile-only { display: block; }
.desktop-only { display: none !important; }

@media (min-width: 860px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
  .desktop-only.btn-row,
  .desktop-only.inline { display: flex !important; }
}

/* ── 页面骨架 ── */
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(229, 160, 32, 0.07), transparent),
    var(--bg);
  color: var(--text);
  line-height: 1.65;
}

@media (max-width: 859px) {
  body {
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
  }
  body:has(.mobile-top) {
    padding-top: calc(var(--mobile-top-h) + var(--safe-top));
  }
  body:has(.bottom-nav) {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }
}

.app-main {
  min-height: 100dvh;
}

@media (min-width: 860px) {
  body {
    padding: 0;
    background: var(--bg-soft);
  }
  body:has(.sidebar) .app-main {
    margin-left: var(--sidebar-w);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
  }
}

a {
  color: var(--accent-hover);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: #ffe08a; }

/* ══════════════════════════════════════════
   桌面：左侧边栏
   ══════════════════════════════════════════ */
.sidebar {
  display: none;
}

@media (min-width: 860px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 300;
    padding: 1.5rem 1rem;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.625rem 1.35rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
  }
  .sidebar-title {
    display: block;
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text);
    line-height: 1.3;
  }
  .sidebar-sub {
    display: block;
    font-size: 0.6875rem;
    color: var(--muted);
    margin-top: 0.15rem;
    font-family: ui-monospace, Consolas, monospace;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1;
    overflow-y: auto;
    padding: 0 0.25rem;
  }

  .nav-group-label {
    display: block;
    padding: 0 0.625rem 0.4rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .sidebar-nav a.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-left: none;
    transition: background 0.15s, color 0.15s;
  }
  .nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    opacity: 0.5;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  }
  .sidebar-nav a.nav-item:hover {
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
  }
  .sidebar-nav a.nav-item:hover .nav-dot {
    opacity: 0.8;
    background: var(--text-secondary);
  }
  .sidebar-nav a.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-hover);
  }
  .sidebar-nav a.nav-item.active .nav-dot {
    background: var(--accent);
    opacity: 1;
    box-shadow: 0 0 6px var(--accent-glow);
  }

  .sidebar-nav a.nav-item:active {
    background: var(--surface-hover);
    transform: scale(0.98);
  }
  .sidebar-nav a.nav-item.active:active {
    background: rgba(229, 160, 32, 0.2);
  }

  .sidebar-foot {
    padding-top: 1rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .sidebar-link {
    font-size: 0.8125rem;
    color: var(--muted);
    padding: 0.45rem 0.625rem;
    border-radius: var(--radius-xs);
  }
  .sidebar-link:hover { color: var(--accent-hover); background: var(--surface); text-decoration: none; }
  .sidebar-logout {
    font-size: 0.8125rem;
    color: var(--bad);
    padding: 0.45rem 0.625rem;
    border-radius: var(--radius-sm);
  }
  .sidebar-logout:hover {
    background: var(--bad-bg);
    text-decoration: none;
  }
}

/* 桌面顶栏 */
.desktop-top {
  flex-shrink: 0;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.desktop-top-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem 2.5rem 1.125rem;
}
.desktop-top-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.desktop-page-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}
.desktop-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--muted);
}
.bc-root { color: var(--muted); }
.bc-sep { color: var(--border-strong); user-select: none; opacity: 0.7; }
.bc-current { color: var(--text-secondary); font-weight: 500; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--accent), #c47a10);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ══════════════════════════════════════════
   手机：顶栏 + 底栏
   ══════════════════════════════════════════ */
.mobile-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--mobile-top-h) + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 1rem;
  padding-right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(14, 13, 11, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.mobile-logo { width: 1.75rem; height: 1.75rem; font-size: 0.875rem; }
.mobile-title {
  font-weight: 600;
  font-size: 1.0625rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 860px) {
  .mobile-top { display: none; }
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(20, 18, 15, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-strong);
}
.bottom-nav a,
.bottom-nav button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.4rem 0.25rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  min-height: unset;
  border-radius: var(--radius-xs);
  box-shadow: none;
  transition: color 0.12s, background 0.12s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a:hover,
.bottom-nav button:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  filter: none;
}
.bottom-nav a:active,
.bottom-nav button:active {
  color: var(--accent-hover);
  background: var(--accent-soft);
  transform: scale(0.94);
}
.bottom-nav a.active,
.bottom-nav button.active { color: var(--accent-hover); }
.bottom-nav .bn-icon { font-size: 1.3rem; line-height: 1; }

@media (min-width: 860px) {
  .bottom-nav { display: none; }
}

/* 手机「更多」抽屉 */
.nav-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.55);
}
.nav-drawer-backdrop.open { display: block; }

.nav-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 401;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1rem 1rem calc(1rem + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}
.nav-drawer.open { transform: translateY(0); }

@media (min-width: 860px) {
  .nav-drawer-backdrop,
  .nav-drawer { display: none !important; }
}

.nav-drawer h3 {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.nav-drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.nav-drawer-grid a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.9rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  min-height: 4.5rem;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-drawer-grid a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-drawer-grid a:active {
  background: var(--accent-soft);
  border-color: rgba(229, 160, 32, 0.35);
  color: var(--accent-hover);
  transform: scale(0.96);
}
.nav-drawer-grid a.active {
  border-color: rgba(229, 160, 32, 0.35);
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.nav-drawer-grid .nd-icon { font-size: 1.375rem; }
.nav-drawer-grid a.nav-logout { color: var(--bad); }

/* ══════════════════════════════════════════
   主内容区
   ══════════════════════════════════════════ */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
}

@media (min-width: 860px) {
  .wrap {
    flex: 1;
    padding: 1.75rem 2.5rem 3rem;
    max-width: 1120px;
    width: 100%;
  }
}

@media (min-width: 1400px) {
  .wrap { max-width: 1200px; }
  .desktop-top-inner { max-width: 1200px; }
}

/* 手机：页头简化（标题已在顶栏） */
.page-header {
  margin-bottom: 1rem;
}
.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}
.page-header .lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

@media (max-width: 859px) {
  .page-header h1 { display: none; }
  .page-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0;
    border: none;
  }
}

@media (min-width: 860px) {
  .page-header {
    margin-bottom: 1.25rem;
    padding-bottom: 0;
    border-bottom: none;
  }
  .page-header h1 { display: none; }
  .page-header .lead {
    font-size: 0.9375rem;
    max-width: 48rem;
    color: var(--text-secondary);
    margin: 0;
  }
}

/* ── 网格 ── */
.grid { display: grid; gap: 0.875rem; }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid { gap: 1rem; }
}

@media (min-width: 860px) {
  .grid { gap: 1.25rem; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── 卡片 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.875rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 860px) {
  .card {
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    background: var(--surface);
    border-color: var(--border);
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
  }
  .card h2 {
    margin-bottom: 1rem;
    padding-left: 0;
    border-left: none;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .card-link { margin: 0.75rem 0 0; }
  .info-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9375rem;
  }
  .info-highlight {
    font-size: 1.0625rem;
    margin: 0 0 0.75rem;
  }
  .card-filter .filter-bar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
  }
}

.card:last-child { margin-bottom: 0; }

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card h3 {
  margin: 1rem 0 0.65rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

/* ══════════════════════════════════════════
   手机：卡片列表（替代宽表格）
   ══════════════════════════════════════════ */
.service-list,
.record-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.service-card,
.record-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

.service-card-head,
.record-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.record-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.record-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
}
.record-meta div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.record-meta-full { grid-column: 1 / -1; }
.record-meta dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.record-meta dd {
  margin: 0;
  color: var(--text-secondary);
  word-break: break-word;
}

.service-card .btn-row,
.record-card .btn-row {
  margin-top: 0.25rem;
}
.service-card .btn-row .inline,
.record-card .btn-row .inline {
  flex: 1;
}
.service-card .btn-row button,
.record-card .btn-row button,
.record-card .btn-row .btn {
  flex: 1;
  width: 100%;
}

/* ── 统计 / 磁贴 ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 860px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 0.65rem; }
}

.stat-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.75rem;
  text-align: center;
}
.stat-item .num {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
@media (min-width: 860px) {
  .stat-item .num { font-size: 1.5rem; }
}
.stat-item .label {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.stat-item.warn .num { color: var(--warn); }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  text-align: center;
  min-height: 3rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
@media (min-width: 860px) {
  .tile-grid-desktop { grid-template-columns: repeat(6, 1fr); }
  .tile {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 1rem;
    min-height: 5.5rem;
  }
  .tile-icon { font-size: 1.375rem; }
  .tile:hover {
    background: var(--surface-hover);
    border-color: rgba(229, 160, 32, 0.25);
    color: var(--text);
    text-decoration: none;
  }
  .stat-item {
    padding: 1rem 0.85rem;
  }
  .stat-item .num { font-size: 1.625rem; }
  .stat-item .label { font-size: 0.75rem; }
}
.tile:active,
a.btn.is-pressed,
.tile.is-pressed {
  transform: scale(0.97);
  background: var(--surface-hover);
}

.muted { color: var(--muted); font-size: 0.875rem; }
.small { font-size: 0.8125rem; line-height: 1.4; margin-top: 0.15rem; }
.text-warn { color: var(--warn); }
strong { color: var(--text); font-weight: 600; }

/* ══════════════════════════════════════════
   桌面：表格
   ══════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

@media (max-width: 859px) {
  .table-wrap {
    border: none;
    background: transparent;
    border-radius: 0;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
td.cell-channels {
  max-width: 14rem;
  white-space: normal;
  line-height: 1.45;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.2);
}
@media (min-width: 860px) {
  th { position: sticky; top: 0; z-index: 1; }
  th, td { padding: 0.7rem 1.1rem; }
  tbody tr:hover td { background: rgba(229, 160, 32, 0.04); }
  .col-actions { text-align: right; white-space: nowrap; width: 1%; }
  .col-actions .btn-row { justify-content: flex-end; }
  table.table-services .cell-name { font-size: 0.9375rem; min-width: 8rem; }
  table.table-services td.mono { font-size: 0.8125rem; }
  .table-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
  }
  table:not(.kv) { font-size: 0.875rem; }
}

table.kv td:first-child {
  color: var(--muted);
  width: 38%;
  white-space: nowrap;
  padding-right: 1rem;
}
table.kv td:last-child { word-break: break-word; }

a.sort-link { color: inherit; text-decoration: none; }
a.sort-link:hover { color: var(--accent-hover); }
a.sort-link.active { color: var(--accent-hover); font-weight: 600; }

/* ── 徽章 ── */
.badge {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(74, 222, 128, 0.25); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: rgba(248, 113, 113, 0.25); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(251, 191, 36, 0.25); }

/* ══════════════════════════════════════════
   表单 & 按钮
   ══════════════════════════════════════════ */
form.stack label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}
form.stack label:last-of-type { margin-bottom: 1.25rem; }

form.inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.btn-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}
.btn-row-compact { gap: 0.35rem; }

input[type=text],
input[type=password],
input[type=search],
input[type=number],
input[type=email],
input[type=url],
textarea,
select {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.625rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  line-height: 1.4;
  min-height: 2.75rem;
  max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 5rem; resize: vertical; width: 100%; }

@media (max-width: 859px) {
  form.inline {
    flex-direction: column;
    align-items: stretch;
  }
  form.inline input,
  form.inline select,
  form.inline button,
  form.inline .btn {
    width: 100%;
  }
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }

@media (min-width: 860px) {
  button, .btn {
    min-height: 2.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    box-shadow: none;
  }
  button.btn-sm, .btn.btn-sm {
    min-height: 1.875rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.8125rem;
  }
  form.inline input[type=search] { min-width: 14rem; flex: 1; max-width: 20rem; }
  form.filter-bar { flex-wrap: nowrap; }
  form.filter-bar select { min-width: 9rem; }
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  color: #1a1208;
  border: none;
  padding: 0.625rem 1.1rem;
  min-height: 2.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.12s, transform 0.08s ease-out, box-shadow 0.12s, background 0.12s;
  box-shadow: 0 2px 8px var(--accent-glow);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button:active:not(:disabled):not(.is-busy),
.btn:active:not(.is-busy) {
  transform: scale(0.96);
  filter: brightness(0.94);
  box-shadow: 0 1px 4px var(--accent-glow);
}
button:hover:not(:disabled):not(.is-busy),
.btn:hover:not(.is-busy) {
  filter: brightness(1.08);
  background: linear-gradient(180deg, #f5c050 0%, var(--accent-hover) 100%);
}
button:focus-visible,
.btn:focus-visible,
.bottom-nav button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled,
button.is-busy,
.btn.is-busy {
  opacity: 0.68;
  cursor: wait;
  pointer-events: none;
}
button.is-busy::after,
.btn.is-busy::after {
  content: "";
  width: 0.85em;
  height: 0.85em;
  margin-left: 0.15rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ui-spin 0.65s linear infinite;
}
@keyframes ui-spin {
  to { transform: rotate(360deg); }
}
button.btn-sm, .btn.btn-sm {
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
}
button.danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}
button.danger:hover { filter: brightness(1.08); }
button.danger:active:not(:disabled):not(.is-busy) {
  transform: scale(0.96);
  filter: brightness(0.92);
}
button.secondary, .btn.secondary {
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
button.secondary:hover:not(:disabled):not(.is-busy),
.btn.secondary:hover:not(.is-busy) {
  background: var(--surface-hover);
  color: var(--text);
  filter: none;
}
button.secondary:active:not(:disabled):not(.is-busy),
.btn.secondary:active:not(.is-busy) {
  background: var(--surface);
  transform: scale(0.96);
  filter: none;
  box-shadow: none;
}
a.btn { text-decoration: none; }

/* ── 代码 ── */
pre, .mono, code {
  font-family: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  font-size: 0.8125rem;
}
pre, .mono {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-soft);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  line-height: 1.55;
  color: var(--text-secondary);
}
code {
  background: var(--bg-soft);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  color: var(--accent-hover);
}

/* ── 提示 ── */
.flash {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.875rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  border: 1px solid transparent;
}
.flash.ok { background: var(--ok-bg); border-color: rgba(74, 222, 128, 0.3); color: #86efac; }
.flash.bad { background: var(--bad-bg); border-color: rgba(248, 113, 113, 0.3); color: #fca5a5; }

.log-view {
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-soft);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

@media (min-width: 860px) {
  .log-view {
    max-height: calc(100vh - 14rem);
    font-size: 0.8125rem;
  }
}

/* ── 登录（两端居中卡片） ── */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.125rem;
}
.login-box {
  width: 100%;
  max-width: 380px;
  margin: 0;
  text-align: center;
}
.login-box .brand-mark {
  width: 3rem;
  height: 3rem;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
  border-radius: var(--radius-sm);
}
.login-box h1 {
  margin: 0 0 0.35rem;
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
}
.login-box .muted { margin-bottom: 1.5rem; }
.login-box form.stack { text-align: left; }
.login-box form.stack button { width: 100%; }
.login-box input[type=password] { width: 100%; }

@media (min-width: 860px) {
  .login-page { padding: 3rem; }
  .login-box { max-width: 400px; }
}

/* ── 杂项 ── */
ul.compact {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}
ul.compact li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

details {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  background: var(--surface-2);
}
details summary {
  cursor: pointer;
  color: var(--accent-hover);
  font-weight: 500;
  font-size: 0.9375rem;
  list-style: none;
}
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: 0.65rem; }
details pre { margin: 0; border: none; padding: 0.5rem 0 0; background: transparent; }

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}
.pager .muted { margin-left: auto; }

@media (max-width: 859px) {
  .pager .muted { width: 100%; margin-left: 0; margin-top: 0.25rem; }
  .pager .btn { flex: 1; justify-content: center; }
  .record-card .btn-row .btn,
  .record-card .btn-row button { min-height: 2.875rem; }
}

@media (min-width: 860px) {
  .pager .muted { margin-left: auto; }
}
