:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: #e5e7eb;
  --line-strong: #cbd5e1;
  --heading: #0f172a;
  --text: #1f2937;
  --text-2: #475569;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --green: #15803d;
  --green-soft: #f0fdf4;
  --green-border: #bbf7d0;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --red-border: #fecaca;
  --violet: #6d28d9;
  --violet-soft: #f5f3ff;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

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

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--heading);
  line-height: 1.3;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: #dbeafe;
  color: #1e3a8a;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.text-2 {
  color: var(--text-2);
}

.mono {
  font-family: var(--mono);
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.pb-0 { padding-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.field-sm { max-width: 260px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: -3px;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

.icon-lg {
  width: 22px;
  height: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.btn:active {
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: #fff;
}

.btn-outline {
  border-color: var(--primary-border);
  background: var(--surface);
  color: var(--primary);
}

.btn-outline:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

.btn-ghost:hover {
  border-color: transparent;
  background: var(--surface-3);
  color: var(--text);
}

.btn-danger {
  border-color: var(--red-border);
  background: var(--surface);
  color: var(--red);
}

.btn-danger:hover {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.btn-sm {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12.5px;
}

.btn-xs {
  min-height: 28px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 12px;
}

.btn-xs .icon {
  width: 14px;
  height: 14px;
}

.btn-lg {
  padding: 10px 22px;
  font-size: 14.5px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

.btn.is-loading {
  cursor: progress;
}

.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btnSpin 0.7s linear infinite;
}

.btn.is-loading .btn-spinner {
  display: inline-block;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 20px;
}

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  font-size: 14px;
  font-weight: 600;
}

.panel-body {
  padding: 18px;
}

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 18px 0;
}

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

.stat-card {
  position: relative;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
}

.stat-label .icon {
  color: var(--primary);
}

.stat-value {
  margin-top: 8px;
  color: var(--heading);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-value .unit {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 400;
}

.stat-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stat-delta {
  color: var(--green);
  font-weight: 600;
}

.stat-delta.down {
  color: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-cyan {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-green {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.badge-amber {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-red {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

.badge-gray {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--muted);
}

.badge-violet {
  border-color: #ddd6fe;
  background: var(--violet-soft);
  color: var(--violet);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrap-flush {
  border: 0;
  border-radius: 0;
}

.engine-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

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

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  line-height: 1.55;
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover td {
  background: var(--surface-2);
}

.table tbody tr:has(.row-check:checked) td {
  background: var(--primary-soft);
}

.table tbody tr:has(.row-check:checked):hover td {
  background: #dbeafe;
}

.table .cell-strong {
  color: var(--heading);
  font-weight: 600;
}

.table .cell-url {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--primary);
}

.table .cell-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.table-empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

.table-empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
}

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

.field > label,
.field-label {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.field .optional {
  color: var(--muted);
  font-weight: 400;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: #94a3b8;
}

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

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.textarea {
  min-height: 150px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.error-text {
  min-height: 16px;
  color: var(--red);
  font-size: 12px;
  line-height: 1.5;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 0;
}

.checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  flex: none;
  width: 38px;
  height: 21px;
  vertical-align: middle;
}

.switch input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--primary);
}

.switch input:checked + span::after {
  transform: translateX(17px);
}

.switch input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.progress {
  position: relative;
  width: 100%;
  min-width: 84px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.3s ease;
}

.progress.is-done > i {
  background: #16a34a;
}

.progress.is-paused > i {
  background: #d97706;
}

.progress.is-stopped > i {
  background: #dc2626;
}

.progress-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.progress-line .pct {
  min-width: 40px;
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

body.has-modal {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.16s ease both;
}

.modal-dialog.modal-lg {
  max-width: 680px;
}

.modal-dialog.modal-wide {
  max-width: 940px;
}

.modal-dialog.modal-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 15.5px;
  font-weight: 600;
}

.modal-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 10px 10px;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(-6px);
  animation: toastIn 0.18s ease forwards;
  pointer-events: auto;
}

.toast.is-out {
  animation: toastOut 0.18s ease forwards;
}

.toast-dot {
  flex: none;
  width: 7px;
  height: 7px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.toast-success { border-left-color: var(--green); }
.toast-success .toast-dot { background: var(--green); }
.toast-warn { border-left-color: var(--amber); }
.toast-warn .toast-dot { background: var(--amber); }
.toast-error { border-left-color: var(--red); }
.toast-error .toast-dot { background: var(--red); }

@keyframes toastIn {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-6px); }
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--primary);
}

.empty strong {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-size: 13.5px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 2px 0;
  color: var(--muted);
  font-size: 12.5px;
}

.pagination-summary {
  white-space: nowrap;
}

.pagination-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.select-sm {
  width: auto;
  height: 30px;
  padding: 3px 26px 3px 8px;
  border-radius: 5px;
  font-size: 12.5px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-ellipsis {
  padding: 0 4px;
  color: var(--muted);
}

.pagination-inset {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary-border);
  color: var(--primary);
}

.page-btn.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-chips {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chip:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.chip.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 13px;
  margin-bottom: 12px;
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
}

.bulk-bar strong {
  font-weight: 700;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.check-col {
  width: 44px;
  text-align: center;
}

.check-col input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.topbar-search:hover {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
}

.topbar-search .icon {
  width: 15px;
  height: 15px;
}

.topbar-search kbd {
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 16px;
}

.search-modal .modal-dialog {
  max-width: 620px;
  padding: 0;
  overflow: hidden;
}

.search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.search-head .icon {
  color: var(--muted);
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}

.search-input::placeholder {
  color: #94a3b8;
}

.search-esc {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.search-body {
  max-height: 420px;
  overflow: auto;
  padding: 8px;
}

.search-group {
  margin-bottom: 4px;
}

.search-group-title {
  padding: 6px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
}

.search-result:hover,
.search-result.is-active {
  background: var(--primary-soft);
  color: var(--primary);
}

.search-result .icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.search-result .sr-main {
  min-width: 0;
  flex: 1;
}

.search-result strong {
  display: block;
  overflow: hidden;
  color: inherit;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result .sr-type {
  flex: none;
  color: var(--muted);
  font-size: 11px;
}

.search-empty {
  padding: 30px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.search-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
}

.kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.dot.is-warn { background: var(--amber); }
.dot.is-danger { background: var(--red); }
.dot.is-idle { background: var(--muted); }

.pulse {
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.fade-up {
  animation: fadeUp 0.3s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 18px;
  }

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

  .card-pad,
  .panel-body {
    padding: 15px;
  }

  .stat-value {
    font-size: 24px;
  }

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

  .modal-dialog {
    max-height: calc(100vh - 24px);
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .bulk-bar {
    align-items: flex-start;
  }

  .pagination {
    align-items: flex-start;
  }

  .pagination-right {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  line-height: 1.75;
}

.notice .icon {
  flex: none;
  margin-top: 2px;
  color: var(--amber);
}

.notice strong {
  color: var(--amber);
}

.notice-cyan {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--text-2);
}

.notice-cyan .icon {
  color: var(--primary);
}

.notice-success {
  border-color: rgba(34, 211, 166, 0.35);
  background: rgba(34, 211, 166, 0.08);
}

.notice-success .icon {
  color: var(--green);
}

.notice-error {
  border-color: rgba(255, 77, 109, 0.35);
  background: rgba(255, 77, 109, 0.08);
}

.notice-error .icon {
  color: var(--red);
}

body.flash-open {
  overflow: hidden;
}

.flash-layer {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.flash-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.2);
}

.flash-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, 100%);
  pointer-events: none;
}

.flash-popup {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  pointer-events: auto;
  animation: flashIn 0.16s ease both;
}

.flash-popup.is-dismissed {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.flash-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.flash-icon .icon {
  width: 14px;
  height: 14px;
}

.flash-success .flash-icon {
  background: rgba(34, 211, 166, 0.12);
  color: var(--green);
}

.flash-error .flash-icon {
  background: rgba(255, 77, 109, 0.12);
  color: var(--red);
}

.flash-info .flash-icon {
  background: var(--primary-soft);
  color: var(--primary);
}

.flash-message {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flash-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

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

.flash-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

a.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

a.page-btn:hover {
  border-color: var(--primary);
}

.topbar-logout-form {
  display: inline-flex;
  margin: 0;
}

.topbar-logout-form button {
  border: 0;
}

.side-foot form {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .btn-spinner {
    animation: btnSpin 0.7s linear infinite !important;
  }
}

.legal-modal-dialog {
  max-width: 980px;
  overflow: hidden;
}

.legal-modal-tabs {
  display: flex;
  gap: 2px;
  padding: 9px 16px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.legal-modal-tab {
  flex: 0 0 auto;
  padding: 9px 12px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
}

.legal-modal-tab:hover {
  color: var(--heading);
}

.legal-modal-tab.is-active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.legal-modal-body {
  max-height: calc(100vh - 260px);
  overflow-y: auto;
  padding: 22px 28px 26px;
}

.legal-modal-open {
  margin-right: auto;
}

.legal-modal-body .legal-body {
  padding-top: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.85;
}

.legal-modal-body .legal-body h2 {
  margin: 26px 0 8px;
  color: var(--heading);
  font-size: 17px;
}

.legal-modal-body .legal-body h2:first-child {
  margin-top: 0;
}

.legal-modal-body .legal-body p {
  margin-top: 8px;
}

.legal-modal-body .legal-body ul {
  margin: 8px 0 0;
  padding-left: 20px;
  list-style: disc;
}

.legal-modal-body .legal-body li {
  margin-top: 5px;
}

.legal-modal-body .legal-body strong {
  color: var(--heading);
}

.legal-modal-body .legal-lead {
  padding: 14px 16px;
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  background: var(--primary-soft);
  color: #1e3a8a;
}

.legal-modal-body .legal-note {
  margin-top: 24px !important;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.legal-modal-body .legal-operator {
  display: grid;
  gap: 4px;
  margin-top: 30px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.legal-modal-body .legal-operator strong {
  color: var(--heading);
  font-size: 13px;
}

@media (max-width: 720px) {
  .modal.legal-modal {
    padding: 0;
  }

  .legal-modal-dialog {
    display: flex;
    flex-direction: column;
    max-width: none;
    height: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .legal-modal .modal-header,
  .legal-modal-tabs,
  .legal-modal .modal-footer {
    flex: 0 0 auto;
  }

  .legal-modal .modal-header {
    padding: 14px 16px;
  }

  .legal-modal-tabs {
    padding-left: 10px;
    padding-right: 10px;
  }

  .legal-modal-body {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 18px 16px 22px;
  }

  .legal-modal .modal-footer {
    flex-direction: row;
    align-items: center;
    border-radius: 0;
  }

  .legal-modal .modal-footer .btn {
    width: auto;
  }
}
