:root {
  --bg: #f8fafc;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --surface: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #3b82f6;
  --accent-fg: #ffffff;
  --accent-bg: #eff6ff;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "Plus Jakarta Sans", "PingFang SC", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: 150ms ease;
  --space: 8px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  padding: 4px 8px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.16), var(--shadow-sm);
}

.brand-name {
  font-weight: 750;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.nav-close,
.menu-toggle,
.mobile-quick-nav {
  display: none;
}

.sidebar-backdrop[hidden] {
  display: none !important;
}

.sidebar-logout {
  margin-top: auto;
  padding: 16px 8px 4px;
  border-top: 1px solid var(--border);
}

.nav {
  flex: 1;
  min-height: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 8px;
}

.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--ease), color var(--ease);
}

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

.nav a.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 650;
}

.main {
  flex: 1;
  padding: 24px 28px 32px;
  min-width: 0;
  background:
    radial-gradient(1200px 400px at 0% -10%, rgba(37, 99, 235, 0.05), transparent 55%),
    var(--bg);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-title {
  min-width: 0;
}

.topbar-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
  margin-top: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  --stat-tone: #2563eb;
  --stat-soft: #eff6ff;
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}

.stat:hover {
  border-color: color-mix(in srgb, var(--stat-tone) 28%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--stat-soft);
  color: var(--stat-tone);
}

.stat-icon svg {
  width: 17px;
  height: 17px;
}

.stat .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  min-width: 0;
}

.stat .value {
  margin-top: 12px;
  padding-left: 2px;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.stat .value.good { color: var(--ok); }

.stat .unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--font);
  margin-left: 0;
}

.stat-balance { --stat-tone: #2563eb; --stat-soft: #eff6ff; }
.stat-keys { --stat-tone: #7c3aed; --stat-soft: #f5f3ff; }
.stat-today { --stat-tone: #0284c7; --stat-soft: #f0f9ff; }
.stat-success { --stat-tone: #059669; --stat-soft: #ecfdf5; }
.stat-rate { --stat-tone: #0d9488; --stat-soft: #f0fdfa; }
.stat-week { --stat-tone: #4f46e5; --stat-soft: #eef2ff; }
.stat-latency { --stat-tone: #d97706; --stat-soft: #fffbeb; }
.stat-users { --stat-tone: #db2777; --stat-soft: #fdf2f8; }
.stat-danger { --stat-tone: #dc2626; --stat-soft: #fef2f2; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.panel-body { padding: 16px 18px; }

.types-panel {
  overflow: hidden;
}

.types-table tr.is-disabled {
  opacity: 0.65;
}

.types-table .type-code {
  display: inline-block;
  margin: 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.types-table .type-status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  white-space: nowrap;
}

.types-table .type-status.ok {
  color: var(--ok);
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.types-table .type-status.bad {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.status-summary .value.status-warn-num { color: #d97706; }
.status-summary .value.status-bad-num { color: var(--danger); }

.status-checked {
  margin: 0;
}

.status-health {
  padding: 14px 16px;
  margin-bottom: 16px;
}

.status-health-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.status-health-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.status-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.status-health-dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.status-health-dot.warn {
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.status-health-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.status-health-bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  gap: 2px;
}

.status-health-bar > span {
  min-width: 0;
  border-radius: 999px;
}

.status-health-bar > span.ok { background: #34d399; }
.status-health-bar > span.warn { background: #fbbf24; }
.status-health-bar > span.bad { background: #f87171; }
.status-health-bar > span[style="flex: 0"] { display: none; }

.status-section.panel {
  padding: 0;
  margin-bottom: 16px;
  overflow: hidden;
}

.status-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}

.status-section-heading {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.status-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #eff6ff;
  color: var(--accent);
  flex-shrink: 0;
}

.status-section-icon svg {
  width: 15px;
  height: 15px;
}

.status-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.status-section-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 14px;
}

.status-empty {
  padding: 28px 16px;
  text-align: center;
}

.status-card {
  --status-tone: #94a3b8;
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.status-card:hover {
  border-color: color-mix(in srgb, var(--status-tone) 35%, var(--border));
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.status-card.status-ok {
  --status-tone: #10b981;
  background: #fff;
}

.status-card.status-warn {
  --status-tone: #f59e0b;
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffbeb 0%, #fff 70%);
}

.status-card.status-bad {
  --status-tone: #ef4444;
  border-color: #fecaca;
  background: linear-gradient(180deg, #fef2f2 0%, #fff 70%);
}

.status-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.status-card-name {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.status-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--status-tone);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-tone) 18%, transparent);
}

.status-card-top h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--text);
}

.status-pill {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  line-height: 1.45;
}

.status-pill.ok {
  color: var(--ok);
  background: #ecfdf5;
}

.status-pill.warn {
  color: #b45309;
  background: #fffbeb;
  border-color: #fde68a;
}

.status-pill.bad {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

.status-card-detail {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
  word-break: break-word;
}

.status-card-meta {
  margin: 0;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}

.dash-charts {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.dash-chart-wide {
  grid-column: 1 / -1;
}

.dash-chart-panel {
  overflow: hidden;
}

.dash-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 0;
}

.dash-chart-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.dash-chart-body {
  position: relative;
  height: 280px;
  padding: 8px 16px 16px;
}

.dash-chart-body-sm {
  height: 260px;
}

.dash-recent-panel {
  display: flex;
  flex-direction: column;
}

.dash-recent-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.dash-recent-link:hover {
  text-decoration: underline;
}

.dash-recent-body {
  flex: 1;
  padding: 10px 12px 14px;
  min-height: 260px;
}

.dash-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dash-recent-item:hover {
  background: #fff;
  border-color: var(--border);
}

.dash-recent-type {
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-recent-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
}

.dash-recent-status.ok {
  color: var(--ok);
  background: #ecfdf5;
}

.dash-recent-status.bad {
  color: var(--danger);
  background: #fef2f2;
}

.dash-recent-lat,
.dash-recent-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dash-recent-lat {
  min-width: 52px;
  text-align: right;
}

.dash-chart-empty {
  height: 100%;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 640px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}

tr:last-child td { border-bottom: 0; }
tbody tr {
  transition: background var(--ease);
}
tbody tr:hover {
  background: rgba(37, 99, 235, 0.03);
}

.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--danger); font-weight: 600; }
.mono { font-family: var(--mono); word-break: break-all; }

.result-cell {
  max-width: 14rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  padding: 0 14px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  transition: background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.btn:hover {
  background: var(--accent-soft);
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.secondary:hover {
  background: var(--surface);
  border-color: #cbd5e1;
  box-shadow: none;
  filter: none;
}
.btn.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid #fecaca;
  box-shadow: none;
}
.btn.danger:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
  filter: none;
  box-shadow: none;
}
.btn-block { width: 100%; }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  transition: border-color var(--ease), box-shadow var(--ease);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea { min-height: 100px; font-family: var(--mono); font-size: 12px; }

.flash {
  background: var(--accent-bg);
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.key-reveal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.key-reveal .mono {
  font-size: 12px;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.10), transparent 42%),
    radial-gradient(circle at 80% 0%, rgba(59, 130, 246, 0.08), transparent 36%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.password-form {
  max-width: 360px;
}

.password-form .btn {
  margin-top: 4px;
}

.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  align-items: center;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  align-items: flex-end;
}

.filter-bar .filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 128px;
}

.filter-bar .filter-field label,
.filter-bar .filter-label {
  font-size: 12px;
  color: var(--muted);
}

.filter-bar .filter-field input,
.filter-bar .filter-field select {
  width: auto;
  min-width: 128px;
  padding: 8px 10px;
}

.filter-bar .filter-field input.mono {
  min-width: 160px;
  font-family: var(--mono);
  font-size: 12px;
}

.filter-bar .filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-bottom: 1px;
}

/* —— 识别日志筛选（紧凑自适应） —— */
.main:has(.logs-panel) .topbar {
  margin-bottom: 12px;
}

.logs-filter {
  --lf-h: 38px;
  --lf-gap: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.lf-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--lf-gap);
  width: 100%;
}

.lf-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.lf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.lf-field > input,
.lf-field > select,
.lf-date-box > input[type="text"],
.lf-preset,
.lf-actions .btn {
  height: var(--lf-h);
  box-sizing: border-box;
}

.lf-field > input,
.lf-field > select {
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.lf-field > input:focus,
.lf-field > select:focus,
.lf-date-box:focus-within {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.lf-status { flex: 0 0 auto; }
.lf-type { flex: 0 0 148px; width: 148px; }
.lf-user { flex: 0 0 128px; width: 128px; }
.lf-task { flex: 1 1 200px; min-width: 160px; }

.lf-chips {
  display: inline-flex;
  align-items: stretch;
  height: var(--lf-h);
  padding: 3px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-sizing: border-box;
}

.lf-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.lf-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lf-chip.is-active,
.lf-chip:has(input:checked) {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.lf-date {
  flex: 0 0 auto;
}

.lf-date-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.lf-date-box {
  position: relative;
  width: 148px;
  flex: 0 0 148px;
}

.lf-date-box > input[type="text"] {
  display: block;
  width: 100%;
  padding: 0 32px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  caret-color: transparent;
}

.lf-date-box > input[type="text"]::placeholder {
  color: #94a3b8;
  text-transform: uppercase;
  opacity: 1;
}

.lf-date-icon {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #94a3b8;
  pointer-events: none;
  display: inline-flex;
}

.lf-date-icon svg { width: 15px; height: 15px; }
.lf-date-box:hover .lf-date-icon { color: var(--accent); }

.lf-date-box > input[type="date"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  margin: 0;
}

.lf-date-sep {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  line-height: var(--lf-h);
}

.lf-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 0 0 auto;
}

.lf-preset {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.lf-preset:hover {
  color: var(--accent);
  border-color: #bfdbfe;
  background: #eff6ff;
}

.lf-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex: 0 0 auto;
}

.lf-actions .btn {
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lf-active {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 2px;
  border-top: 1px dashed var(--border);
}

.lf-active-label {
  font-size: 12px;
  color: var(--muted);
}

.lf-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  max-width: 100%;
  word-break: break-all;
  transition: background 0.15s ease;
}

.lf-tag:hover {
  background: #dbeafe;
  text-decoration: none;
}

.lf-tag-clear {
  background: #fff;
  border-color: var(--border);
  color: var(--muted);
}

.lf-tag-clear:hover {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

/* 中宽：日期行内不够时，操作按钮整行 */
@media (max-width: 1100px) {
  .lf-actions {
    margin-left: 0;
  }
}

.logs-cards {
  display: none;
}

.logs-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.logs-empty {
  margin: 0;
  padding: 20px 16px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
  vertical-align: middle;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.actions .btn,
.actions .inline-form .btn {
  min-width: 52px;
  height: 28px;
  padding: 0 10px;
  box-sizing: border-box;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* 操作列固定宽度，避免「详情/删除」被挤扁或错位 */
.logs-table-wrap table th:last-child,
.logs-table-wrap table td:last-child {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);
}

.modal.modal-lg {
  width: min(560px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 18px;
}

/* ===== Tablet ===== */
@media (max-width: 960px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px; }
  .topbar h1 { font-size: 20px; }
}

/* ===== Phone / narrow: drawer sidebar ===== */
@media (max-width: 1024px) {
  .layout {
    display: block;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #eff6ff;
    color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
  }

  .menu-toggle-bars {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    width: 16px;
  }

  .menu-toggle-bars i {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--accent);
    border-radius: 1px;
  }

  .menu-toggle-label {
    line-height: 1;
  }

  .mobile-quick-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: -8px 0 18px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .mobile-quick-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-quick-nav a {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
  }

  .mobile-quick-nav a.active,
  .mobile-quick-nav a:hover {
    color: var(--accent);
    border-color: #bfdbfe;
    background: #eff6ff;
  }

  .nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 24px;
    cursor: pointer;
    flex-shrink: 0;
  }

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

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 850;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    width: min(288px, 86vw);
    z-index: 900;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    box-shadow: var(--shadow-md);
  }

  .layout.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-lock {
    overflow: hidden;
  }

  .main {
    padding: 14px 12px 28px;
    width: 100%;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
    min-height: 42px;
  }

  .status-cards {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .status-card {
    padding: 12px;
    border-radius: 10px;
  }

  .status-section.panel {
    margin-bottom: 12px;
  }

  .status-section-head {
    padding: 12px;
  }

  .status-health {
    padding: 12px;
  }

  .status-health-top {
    margin-bottom: 10px;
  }

  .dash-charts {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .dash-chart-wide {
    grid-column: 1 / -1;
  }

  .dash-chart-body {
    height: 240px;
    padding: 6px 12px 14px;
  }

  .dash-chart-body-sm {
    height: 220px;
  }

  .dash-chart-head {
    padding: 12px 12px 0;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat {
    padding: 14px 12px 12px;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .stat-icon svg {
    width: 15px;
    height: 15px;
  }

  .stat .value {
    margin-top: 10px;
    font-size: 20px;
  }

  .panel {
    border-radius: 10px;
  }

  .panel > table,
  .panel .table-scroll table {
    min-width: 560px;
  }

  .panel:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th, td {
    padding: 10px 12px;
    font-size: 12px;
  }

  .login-card {
    padding: 22px 18px;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal,
  .modal.modal-lg {
    width: 100%;
    max-height: min(92vh, 100%);
    border-radius: 14px 14px 10px 10px;
  }

  /* —— 识别日志 · 手机 —— */
  .logs-panel .logs-filter {
    padding: 12px;
    gap: 12px;
  }

  .logs-panel .lf-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .logs-panel .lf-status {
    grid-column: 1 / -1;
  }

  .logs-panel .lf-status .lf-chips {
    width: 100%;
  }

  .logs-panel .lf-chip {
    flex: 1 1 0;
  }

  .logs-panel .lf-type,
  .logs-panel .lf-user {
    width: auto;
    flex: none;
  }

  .logs-panel .lf-task {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .logs-panel .lf-dates {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .logs-panel .lf-date {
    width: 100%;
  }

  .logs-panel .lf-date-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .logs-panel .lf-date-sep {
    display: none;
  }

  .logs-panel .lf-date-box {
    width: 100%;
    max-width: 220px;
    flex: none;
  }

  .logs-panel .lf-presets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 8px;
  }

  .logs-panel .lf-preset {
    width: 100%;
    text-align: center;
  }

  .logs-panel .lf-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-left: 0;
    gap: 8px;
  }

  .logs-panel .lf-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .logs-panel .logs-table-wrap {
    display: none;
  }

  .logs-panel .logs-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  .log-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .log-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }

  .log-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .log-card-id-num {
    font-size: 12px;
    color: var(--muted);
  }

  .log-card-type {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
  }

  .log-card-user {
    font-size: 12px;
    color: var(--muted);
  }

  .log-card-kv {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .log-card-k {
    font-size: 11px;
    color: var(--muted);
  }

  .log-card-v {
    font-size: 12px;
    word-break: break-all;
    color: var(--text);
  }

  .log-card-status {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
  }

  .log-card-status.ok {
    color: var(--ok);
    border-color: #a7f3d0;
    background: #ecfdf5;
  }

  .log-card-status.bad {
    color: var(--danger);
    border-color: #fecaca;
    background: #fef2f2;
  }

  .log-card-result {
    font-size: 12px;
    line-height: 1.45;
    word-break: break-all;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    max-height: 4.2em;
    overflow: hidden;
  }

  .log-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 12px;
    color: var(--muted);
  }

  .log-card-actions {
    padding-top: 2px;
  }

  .log-card-actions .btn {
    min-height: 34px;
    padding: 0 12px;
  }

  .logs-panel .pager {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
  }

  .logs-panel .pager .btn {
    width: 100%;
    justify-content: center;
  }

  .logs-panel .pager .meta {
    text-align: center;
    order: -1;
  }

  .log-images img {
    max-width: 100%;
    max-height: 220px;
  }

  .modal-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
}


@media (max-width: 640px) {
  .dash-charts {
    grid-template-columns: 1fr;
  }

  .dash-chart-wide {
    grid-column: auto;
  }
}

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

  .meta {
    font-size: 12px;
  }

}

/* —— 系统设置切换卡 —— */
.settings-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
}

.settings-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.settings-tab:hover {
  color: var(--text);
}

.settings-tab.active {
  background: #eff6ff;
  color: var(--accent);
}

.settings-pane {
  display: none;
}

.settings-pane.active {
  display: block;
}

.settings-pane-head {
  margin-bottom: 18px;
}

.settings-pane-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.settings-pane-head .meta {
  margin: 0;
}

.settings-form .settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
}

.settings-form .form-row.full {
  grid-column: 1 / -1;
}

.settings-form .form-row .meta {
  margin: 0;
  font-size: 12px;
}

.settings-form textarea {
  min-height: 84px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.settings-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .settings-form .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    width: 100%;
  }
}

/* —— 账户页 —— */
.account-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.account-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.account-section-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.account-section-head .meta {
  margin: 0;
}

.account-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.account-badge.on {
  color: var(--accent);
  background: #eff6ff;
  border-color: #bfdbfe;
}

.account-badge.off {
  color: var(--muted);
  background: var(--surface);
}

.account-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}

.account-form {
  max-width: none;
}

.account-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  align-items: end;
}

.account-form-submit {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.account-form-submit .btn {
  width: fit-content;
}

.account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.totp-setup {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
  padding-top: 4px;
}

.totp-qr-wrap {
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  border: 1px solid var(--border);
}

.totp-qr {
  display: block;
  width: 180px;
  height: 180px;
}

.totp-secret {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  word-break: break-all;
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-item .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.detail-item .value {
  font-size: 14px;
  word-break: break-word;
}

.detail-pre {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 12rem;
  overflow: auto;
}

.log-images {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-start;
}

.log-images figure {
  margin: 0;
  max-width: 100%;
}

.log-images img {
  display: block;
  max-width: min(100%, 360px);
  max-height: 280px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  object-fit: contain;
}

.log-images figcaption {
  margin-top: 6px;
}


@media (max-width: 720px) {
  .account-form-grid {
    grid-template-columns: 1fr;
  }

  .totp-setup {
    grid-template-columns: 1fr;
  }

  .totp-qr {
    width: 160px;
    height: 160px;
  }

  .account-section-head {
    flex-direction: column;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
