:root {
  --bg: #f8f9fa;
  --panel: #ffffff;
  --panel-soft: #fafbfc;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 5px;
  color: var(--muted);
  transition: 0.15s ease;
  font-size: 13px;
}

.nav-item:hover,
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: #f3f4f6;
  font-size: 10px;
  font-weight: 600;
}

.main {
  padding: 16px 20px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

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

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

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

.card-head {
  padding: 12px 14px 0;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.card-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.card-body {
  padding: 12px 14px 14px;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.metric {
  font-size: 24px;
  font-weight: 600;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
  font-size: 12px;
}

.btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
}

.btn:hover {
  filter: brightness(0.95);
}

.btn-secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 32px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.rule-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--panel-soft);
}

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

.empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}

.rule-type {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(15, 23, 42, 0.38);
}

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

.modal-panel {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.2);
}

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

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0;
}

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

.modal-body {
  padding: 12px 14px 14px;
}

.rule-modal-note {
  color: var(--muted);
  font-size: 12px;
}

.rule-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 99;
}

.toast {
  min-width: 200px;
  max-width: 340px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.success {
  border-color: #bbf7d0;
}

.toast.error {
  border-color: #fecaca;
}

.inline-kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}



.output-log-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.inline-field {
  min-width: 150px;
  margin: 0;
}

.inline-field span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.output-log-box {
  min-height: 560px;
  width: 100%;
  resize: vertical;
  white-space: pre;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.request-log-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.request-log-entry {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.request-log-entry.has-error {
  border-color: #fecaca;
  background: #fffafa;
}

.request-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.request-log-title,
.request-log-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.request-log-title .code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-log-output {
  padding: 9px 10px 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.request-log-line {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

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

.request-log-value {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.log-status.ok {
  color: var(--success);
}

.log-status.err {
  color: var(--danger);
}

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

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-3,
  .span-4,
  .span-6,
  .span-8,
  .span-12 {
    grid-column: span 1;
  }

  .modal-panel {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .rule-modal-actions {
    justify-content: flex-start;
  }
}
/* Rules page refinement */
.rules-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rules-hero,
.settings-shell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

.hero-kicker {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-title,
.settings-shell-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.hero-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.btn-hero {
  height: 34px;
  padding: 0 16px;
  white-space: nowrap;
}

.rules-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.rules-meta-row span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.rules-meta-row strong {
  margin-left: 3px;
  color: var(--text);
}

.rules-table-wrap {
  border-radius: 8px;
}

.rules-table th,
.rules-table td {
  vertical-align: top;
}

.settings-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 72px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.settings-section + .settings-section {
  margin-top: 10px;
}

.route-subcards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.route-subcard {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.route-subcard-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.section-desc,
.compact-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.section-desc {
  margin-top: 2px;
}

.section-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.switch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.switch-grid-compact {
  grid-template-columns: 1fr;
}

.switch-tile {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.switch-tile:hover {
  border-color: #bfdbfe;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.switch-tile.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.switch-tile.is-disabled:hover {
  border-color: var(--line);
  box-shadow: none;
  transform: none;
}

.switch-tile input {
  margin-top: 2px;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.switch-title {
  font-weight: 650;
  color: var(--text);
}

.switch-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.relaxed-grid {
  gap: 12px;
}

.identity-replies-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.identity-replies-count {
  font-weight: 700;
  color: var(--text);
}

.compact-toolbar {
  justify-content: flex-end;
  margin: 0;
}

@media (max-width: 720px) {
  .rules-hero,
  .settings-shell-head,
  .identity-replies-panel {
    align-items: stretch;
    flex-direction: column;
  }

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

  .route-subcards {
    grid-template-columns: 1fr;
  }

  .btn-hero {
    width: 100%;
  }
}

/* Compact rules page: function-first, no explanatory hero text. */
.rules-toolbar-simple {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.rules-count {
  color: var(--muted);
  font-size: 12px;
}

.settings-section {
  padding: 8px;
}

.settings-section + .settings-section {
  margin-top: 8px;
}

.settings-section .section-title {
  margin-bottom: 8px;
}

.switch-tile {
  min-height: 40px;
  align-items: center;
  padding: 8px 10px;
}

.switch-title {
  font-size: 13px;
}

.identity-replies-panel {
  padding: 8px 10px;
}

@media (max-width: 720px) {
  .rules-toolbar-simple {
    align-items: stretch;
    flex-direction: column;
  }
}

.identity-conversation-btn,
.identity-conversation-static {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  display: block;
}

.identity-conversation-btn {
  cursor: pointer;
}

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

.identity-conversation-line {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  margin: 2px 0;
}

.identity-conversation-line span {
  color: var(--muted);
  font-weight: 700;
}

.identity-conversation-line strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.identity-conversation-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.identity-log-modal-panel {
  max-width: 860px;
}

.identity-dialog-meta {
  margin-bottom: 14px;
  color: var(--muted);
}

.identity-dialog-section + .identity-dialog-section {
  margin-top: 14px;
}

.identity-dialog-label {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 6px;
}

.identity-dialog-text {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.6;
}

.settings-actions {
  position: fixed;
  left: 200px;
  right: 0;
  bottom: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 56px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: rgba(248, 249, 250, 0.96);
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.04);
}

.settings-actions .btn {
  min-width: 128px;
}

@media (max-width: 980px) {
  .settings-actions {
    left: 0;
  }
}

@media (max-width: 720px) {
  .settings-actions {
    padding: 10px 12px;
  }

  .settings-actions .btn {
    width: 100%;
  }
}

/* Login */
.auth-locked {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #eef2f7 100%);
}


.detector-fasttext[hidden],
.detector-newapi[hidden] {
  display: none !important;
}

.login-screen[hidden],
.app[hidden] {
  display: none !important;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 24px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
}

.login-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-form label {
  font-weight: 600;
  color: var(--text);
}

.login-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-weight: 500 !important;
  color: var(--muted) !important;
}

.login-error {
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 8px 10px;
}

.login-button {
  width: 100%;
  margin-top: 6px;
}

.auth-actions {
  display: flex;
}

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

/* Token rewrite diff view */
.token-diff-btn {
  min-width: 112px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.token-diff-btn:hover {
  filter: brightness(0.98);
}

.token-diff-percent {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.token-diff-level {
  min-width: 30px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.14);
  color: inherit;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.token-diff-low {
  background: #16a34a;
  color: #ffffff;
}

.token-diff-medium {
  background: #f59e0b;
  color: #111827;
}

.token-diff-high {
  background: #ea580c;
  color: #ffffff;
}

.token-diff-extreme {
  background: #b91c1c;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.24);
}

.token-diff-modal-panel {
  width: min(980px, calc(100vw - 24px));
}

.diff-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.diff-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.diff-summary-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.diff-summary-title {
  color: var(--muted);
  font-size: 12px;
}

.diff-summary-value {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 600;
}

.diff-summary-extra {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.token-diff-card-low {
  background: #dcfce7;
  border-color: #22c55e;
}

.token-diff-card-medium {
  background: #fef3c7;
  border-color: #f59e0b;
}

.token-diff-card-high {
  background: #fed7aa;
  border-color: #f97316;
}

.token-diff-card-extreme {
  background: #fee2e2;
  border-color: #dc2626;
  color: #7f1d1d;
}

.diff-table-wrap {
  margin-bottom: 10px;
}

.diff-positive {
  color: var(--danger);
  font-weight: 600;
}

.diff-negative {
  color: var(--accent);
  font-weight: 600;
}

.diff-hint {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.json-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.json-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.json-panel-title {
  padding: 7px 9px;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.json-block {
  margin: 0;
  max-height: 260px;
  overflow: auto;
  padding: 9px;
  background: #fff;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 980px) {
  .diff-summary-grid,
  .json-grid {
    grid-template-columns: 1fr;
  }
}

/* Claude pool health */
.pool-health {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.pool-health-ok,
.pool-health-bad,
.pool-health-checking {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pool-health-ok {
  background: #16a34a;
  color: #fff;
}

.pool-health-bad {
  background: #b91c1c;
  color: #fff;
}

.pool-health-checking {
  background: #f59e0b;
  color: #111827;
}


.rules-toolbar-left,
.rules-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.rules-inline-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.rules-inline-switch input {
  margin: 0;
}

@media (max-width: 720px) {
  .rules-toolbar-left,
  .rules-toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
}

.rule-channel-select {
  position: relative;
}

.multi-select-button {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.multi-select-menu {
  display: none;
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.rule-channel-select.open .multi-select-menu {
  display: block;
}

.multi-select-option {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.multi-select-option:hover {
  background: var(--panel-soft);
}

.multi-select-option small {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.multi-select-clear {
  width: 100%;
  margin-bottom: 4px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.multi-select-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}


/* Rule modal channel dropdown: overlay the form and keep about 10 channels visible. */
.rule-modal-panel {
  width: min(1040px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: visible;
}

.rule-modal-panel .modal-body {
  overflow: visible;
}

.rule-modal-panel .rule-channel-select {
  position: relative;
  z-index: 80;
}

.rule-modal-panel .multi-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 120;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 0;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
  overscroll-behavior: contain;
}

.rule-modal-panel .multi-select-option {
  min-height: 36px;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--text);
}

.text-success {
  color: #0f7b3a !important;
}

.text-danger {
  color: #b42318 !important;
}


.compat-modal-panel {
  overflow: hidden;
}

.compat-modal-panel .modal-body {
  max-height: calc(100vh - 96px);
  overflow: auto;
}

.compat-modal-panel .rule-channel-select {
  position: relative;
  z-index: 80;
}

.compat-modal-panel .multi-select-menu {
  max-height: 420px;
  z-index: 120;
}
