:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --ink: #17201b;
  --muted: #66736b;
  --line: #dfe6df;
  --brand: #256a5f;
  --brand-2: #1c5149;
  --amber: #a76b00;
  --red: #b83232;
  --green: #27734f;
  --shadow: 0 18px 50px rgba(31, 48, 40, 0.08);
}

html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(37, 106, 95, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(167, 107, 0, 0.08), transparent 28%),
    var(--bg);
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-2);
}

.app-shell {
  max-width: 1440px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(223, 230, 223, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.app-nav {
  gap: 0.15rem;
  margin-left: 1.25rem;
}

.app-nav .nav-link {
  border-radius: 8px;
  color: #405047;
  font-weight: 600;
  padding: 0.6rem 0.85rem;
}

.app-nav .nav-link:hover {
  background: var(--surface-2);
  color: var(--brand-2);
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot,
.dot-success,
.dot-warning,
.dot-danger {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.status-dot,
.dot-warning {
  background: #d99614;
}

.dot-success {
  background: var(--green);
}

.dot-danger {
  background: var(--red);
}

.app-main {
  padding: 2rem 0 3rem;
}

.app-footer {
  padding: 1.5rem 0 2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-shell {
  width: min(100% - 2rem, 440px);
}

.login-panel {
  padding: 2rem;
  border: 1px solid rgba(223, 230, 223, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-heading {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.login-heading h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-error {
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(184, 50, 50, 0.18);
  border-radius: 8px;
  background: rgba(184, 50, 50, 0.08);
  color: var(--red);
  font-size: 0.88rem;
  font-weight: 700;
}

.login-submit {
  min-height: 42px;
  font-weight: 800;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0;
}

.page-subtitle,
.panel-header p,
.event-item p,
.site-summary p,
.rule-card p {
  margin: 0;
  color: var(--muted);
}

.heading-actions,
.filter-row,
.card-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.range-segmented {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.range-segmented button {
  min-height: 30px;
  padding: 0.22rem 0.65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #405047;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.range-segmented button:hover,
.range-segmented button.active {
  background: var(--brand);
  color: #ffffff;
}

.card-actions form,
.table-actions form,
.execution-log-actions form {
  margin: 0;
}

.filter-row {
  align-items: end;
  flex-wrap: wrap;
}

.dashboard-filter-panel {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.dashboard-filter-row {
  align-items: end;
}

.filter-field {
  display: grid;
  gap: 0.35rem;
  flex: 0 0 180px;
  min-width: 180px;
  margin: 0;
}

.filter-field:first-of-type {
  flex: 1 1 280px;
}

.dashboard-keyword-field {
  flex: 1 1 320px;
}

.filter-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.filter-toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 38px;
  margin: 0;
  color: #405047;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
}

.filter-toggle-field input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfb;
  color: #405047;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.filter-chip:hover,
.filter-chip.active {
  border-color: rgba(37, 106, 95, 0.5);
  background: #e8f5ee;
  color: var(--brand-2);
}

.btn {
  border-radius: 8px;
  font-weight: 700;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 1rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-card,
.panel,
.rule-card {
  border: 1px solid rgba(223, 230, 223, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 0.35rem;
  min-height: 126px;
  padding: 1.1rem;
}

.dashboard-loading-card {
  position: relative;
  overflow: hidden;
}

.dashboard-loading-card::after {
  content: "";
  position: absolute;
  inset: 1rem;
  border-radius: 8px;
  background: linear-gradient(90deg, #eef1ef 0%, #f8faf8 50%, #eef1ef 100%);
  background-size: 220% 100%;
  animation: dashboard-loading-pulse 1.2s ease-in-out infinite;
}

@keyframes dashboard-loading-pulse {
  to {
    background-position: -220% 0;
  }
}

.metric-card span {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 2rem;
  line-height: 1;
}

.metric-card small {
  font-weight: 700;
}

.good,
.success {
  color: var(--green);
}

.warning {
  color: var(--amber);
}

.danger {
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.span-7 {
  grid-column: span 7;
}

.span-5 {
  grid-column: span 5;
}

.span-8 {
  grid-column: span 8;
}

.span-4 {
  grid-column: span 4;
}

.panel {
  padding: 1.1rem;
}

.form-panel {
  max-width: 860px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header h2,
.rule-card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.panel-header a {
  font-weight: 800;
  white-space: nowrap;
}

.panel-tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-table {
  margin: 0;
}

.app-table th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-table td {
  border-color: var(--line);
  color: #26332c;
  vertical-align: middle;
}

.table-title {
  font-weight: 800;
}

.table-muted {
  color: var(--muted);
  font-size: 0.84rem;
}

.exception-log-table .reason-cell,
.exception-log-table .result-cell {
  min-width: 220px;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.exception-log-table form {
  margin: 0;
}

.badge-soft {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-soft.success {
  background: #e8f5ee;
  color: var(--green);
}

.badge-soft.warning {
  background: #fff4dc;
  color: var(--amber);
}

.badge-soft.danger {
  background: #fde9e9;
  color: var(--red);
}

.badge-soft.muted {
  background: #eef1ef;
  color: var(--muted);
}

.event-list,
.site-list {
  display: grid;
  gap: 0.85rem;
}

.event-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: start;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.event-item strong {
  display: block;
  margin-bottom: 0.15rem;
}

.event-item time {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.dashboard-channel-list,
.execution-log-list {
  display: grid;
  gap: 0.85rem;
}

.dashboard-channel-row {
  display: grid;
  gap: 0.85rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.dashboard-channel-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  min-width: 0;
}

.dashboard-channel-main h3 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-channel-main p {
  margin: 0.12rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-meta-grid.compact {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.channel-meta-grid.compact > div {
  flex: none;
  display: grid;
  gap: 0.12rem;
  align-content: center;
  min-height: 3.15rem;
}

.execution-log-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.execution-log-item strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.execution-log-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.execution-log-content {
  display: grid;
  gap: 0.55rem;
  min-width: 0;
}

.execution-log-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.execution-log-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.execution-log-meta span {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
  padding: 0.48rem 0.55rem;
  border: 1px solid rgba(223, 230, 223, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.execution-log-item small {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
}

.execution-log-item b {
  min-width: 0;
  color: #405047;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.execution-log-result {
  padding: 0.52rem 0.62rem;
  border-radius: 8px;
  background: var(--surface-2);
  color: #405047;
  font-size: 0.82rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.success {
  color: var(--green);
}

.status-pill.warning {
  color: var(--amber);
}

.status-pill.danger {
  color: var(--red);
}

.execution-log-actions {
  display: grid;
  justify-items: end;
  gap: 0.45rem;
}

.site-block {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.site-summary {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.site-summary h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.site-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-stats span {
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: var(--surface-2);
  color: #405047;
  font-weight: 700;
}

.channel-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 0.85rem;
}

.channel-card {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.channel-card-top,
.channel-card-subhead,
.channel-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.channel-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.channel-mark {
  display: block;
  min-width: 48px;
  max-width: 96px;
  min-height: 28px;
  padding: 0.32rem 0.55rem;
  border-radius: 8px;
  background: #e8f5ee;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.15;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-card h4 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-card p {
  margin: 0.15rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.channel-meta-grid > div {
  flex: 1 1 5.3rem;
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  min-width: 0;
  min-height: 2.15rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.channel-code-meta {
  flex-basis: 6.6rem;
}

.channel-rule-meta {
  flex-basis: 7.2rem;
}

.channel-meta-grid span,
.channel-card-subhead span,
.channel-log-axis {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.channel-meta-grid strong {
  display: block;
  overflow: hidden;
  min-width: 0;
  margin-top: 0;
  color: #26332c;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-meta-grid form {
  margin: 0;
  min-width: 0;
}

.channel-log-strip-wrap {
  display: grid;
  gap: 0.45rem;
  padding-top: 0.25rem;
  overflow: visible;
}

.channel-log-strip {
  display: grid;
  grid-template-columns: repeat(50, minmax(2px, 1fr));
  gap: 3px;
  align-items: end;
  min-height: 36px;
  overflow: visible;
}

.log-bar {
  display: block;
  position: relative;
  width: 100%;
  height: 28px;
  min-height: 18px;
  border-radius: 999px;
  background: #d7dfd9;
  cursor: help;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.log-bar:hover,
.log-bar:focus-visible {
  z-index: 5;
  transform: translateY(-2px);
  box-shadow: 0 7px 16px rgba(23, 32, 27, 0.18);
}

.log-bar.success {
  background: #1fbf70;
}

.log-bar.danger {
  background: #d64b4b;
}

.log-bar.warning {
  background: #e5a21a;
}

.log-bar.muted {
  background: #cbd5cf;
}

.log-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.55rem);
  z-index: 12;
  display: none;
  width: max-content;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.72rem;
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(23, 32, 27, 0.18);
  color: var(--ink);
  transform: translateX(-50%);
  pointer-events: auto;
}

.log-tooltip::before {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.7rem;
  height: 0.7rem;
  content: "";
}

.log-tooltip::after {
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(23, 32, 27, 0.08);
  border-bottom: 1px solid rgba(23, 32, 27, 0.08);
  background: rgba(255, 255, 255, 0.98);
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.log-bar:hover .log-tooltip,
.log-bar:focus-visible .log-tooltip {
  display: grid;
  gap: 0.58rem;
}

.log-tooltip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.log-tooltip-head strong {
  font-size: 0.92rem;
}

.log-tooltip-head em {
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.log-tooltip-head em.success {
  background: #e8f5ee;
  color: var(--green);
}

.log-tooltip-head em.warning {
  background: #fff4dc;
  color: var(--amber);
}

.log-tooltip-head em.danger {
  background: #fde9e9;
  color: var(--red);
}

.log-tooltip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 0.45rem;
}

.log-tooltip-grid span {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.42rem;
  border-radius: 8px;
  background: var(--surface-2);
}

.log-tooltip-grid small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.log-tooltip-grid b {
  overflow: visible;
  color: #26332c;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  white-space: normal;
}

.log-tooltip-error {
  grid-column: 1 / -1;
}

.channel-log-strip .log-bar:nth-child(-n+4) .log-tooltip {
  left: 0;
  transform: none;
}

.channel-log-strip .log-bar:nth-last-child(-n+4) .log-tooltip {
  left: auto;
  right: 0;
  transform: none;
}

.channel-log-axis {
  display: flex;
  justify-content: space-between;
}

.channel-updated {
  text-align: right;
  white-space: nowrap;
}

.channel-card-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.rule-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.policy-exception-panel {
  margin-top: 1rem;
}

.exception-log-list {
  display: grid;
  gap: 0.75rem;
}

.exception-log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
}

.exception-log-main {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.exception-log-identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.exception-log-identity strong {
  display: block;
  overflow-wrap: anywhere;
}

.exception-log-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 0.75rem;
}

.exception-info,
.exception-summary {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.exception-info span,
.exception-summary span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.exception-info strong {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.exception-info small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.exception-log-sections {
  display: grid;
  grid-template-columns: minmax(260px, 1.35fr) minmax(210px, 0.8fr) minmax(260px, 1fr);
  gap: 0.75rem;
}

.exception-summary {
  align-content: start;
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(223, 230, 223, 0.9);
  border-left: 3px solid rgba(37, 106, 95, 0.28);
  border-radius: 8px;
  background: rgba(238, 243, 239, 0.68);
}

.exception-summary p {
  margin: 0;
  color: #26332c;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.exception-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.exception-summary small {
  color: var(--red);
  font-weight: 800;
}

.exception-summary-plan {
  border-left-color: rgba(167, 107, 0, 0.42);
}

.exception-summary-recovery.is-success {
  border-left-color: rgba(39, 115, 79, 0.52);
}

.exception-summary-recovery.is-success p {
  color: var(--green);
  font-weight: 700;
}

.exception-summary-recovery.is-danger {
  border-left-color: rgba(184, 50, 50, 0.56);
  background: rgba(255, 243, 243, 0.72);
}

.exception-summary-recovery.is-danger p {
  color: #7f1d1d;
}

.exception-summary-recovery.is-pending p {
  color: var(--muted);
}

.exception-log-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 88px;
}

.exception-action-button {
  min-width: 86px;
  white-space: nowrap;
}

.exception-muted-action {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.rule-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.rule-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.rule-card dl {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.rule-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.rule-card dt {
  color: var(--muted);
  font-weight: 700;
}

.rule-card dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.rule-remark {
  padding: 0.65rem;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 0.9rem;
}

.assign-policy-modal .modal-header {
  align-items: flex-start;
}

.assign-policy-modal {
  max-height: calc(100vh - 3.5rem);
}

.assign-policy-modal .modal-body {
  overflow-y: auto;
}

.assign-policy-modal .modal-header p {
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.assign-policy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.channel-assign-list {
  display: grid;
  gap: 0.65rem;
}

.channel-assign-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  cursor: pointer;
}

.channel-assign-item:hover {
  border-color: rgba(37, 106, 95, 0.45);
  background: #f7faf8;
}

.channel-assign-item input {
  margin-top: 0.2rem;
}

.channel-assign-item span {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.channel-assign-item strong,
.channel-assign-item small,
.channel-assign-item em {
  overflow-wrap: anywhere;
}

.channel-assign-item strong {
  color: var(--ink);
  font-weight: 800;
}

.channel-assign-item small {
  color: var(--brand);
  font-weight: 800;
}

.channel-assign-item em {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: normal;
}

.app-form {
  display: grid;
  gap: 0.95rem;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.align-end {
  align-items: end;
}

.form-field {
  display: grid;
  gap: 0.35rem;
}

.form-field > span:first-child {
  color: #405047;
  font-weight: 800;
}

.form-actions,
.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.form-switch-row {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-weight: 700;
}

.policy-form-panel {
  max-width: 980px;
}

.policy-form {
  gap: 1.1rem;
}

.form-section {
  display: grid;
  gap: 0.85rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
  padding-bottom: 0;
  border-bottom: 0;
}

.form-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.form-section-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.form-section-title span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.compact-field {
  max-width: 320px;
}

.policy-alert-switch {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: min(100%, 460px);
  min-height: 44px;
  align-self: end;
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  cursor: pointer;
  touch-action: manipulation;
}

.policy-alert-switch.form-switch {
  padding-left: 0.75rem;
}

.policy-alert-switch.form-switch .form-check-input {
  flex: 0 0 auto;
  margin-left: 0;
  margin-top: 0;
}

.policy-alert-switch .form-check-label {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.2;
}

.policy-form-actions {
  padding-top: 0.2rem;
}

.policy-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  min-height: 36px;
  margin: 0;
  cursor: pointer;
}

.policy-toggle .form-check-input {
  margin: 0;
  cursor: pointer;
}

.policy-toggle .form-check-input:disabled {
  cursor: wait;
}

.policy-toggle-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 26px;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.policy-toggle-status.is-on {
  background: rgba(37, 106, 95, 0.12);
  color: #1e6358;
}

.policy-toggle-status.is-off {
  background: #eef1ef;
  color: #6b746e;
}

.policy-toggle-status.is-error {
  box-shadow: 0 0 0 2px rgba(185, 65, 65, 0.18);
}

.policy-toggle-spinner {
  width: 0.85rem;
  height: 0.85rem;
  border-width: 0.12rem;
  color: var(--brand);
}

.ajax-button-spinner {
  margin-right: 0.35rem;
  vertical-align: -0.1em;
}

.channel-rule-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  margin: 0;
  padding-left: 0;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.channel-rule-switch .form-check-input {
  margin-left: 0;
}

.channel-rule-switch .form-check-label {
  color: #26332c;
  font-size: 0.82rem;
}

.empty-state,
.empty-inline {
  border: 1px dashed #b9c7be;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 2rem;
}

.empty-state.compact {
  padding: 1rem;
}

.empty-state h2 {
  margin: 0 0 0.35rem;
  color: var(--ink);
  font-size: 1.1rem;
}

.empty-state p,
.empty-inline {
  margin: 0;
}

.empty-inline {
  padding: 1rem;
  text-align: center;
}

.rule-select-list {
  display: grid;
  gap: 0.75rem;
}

.rule-select-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  cursor: pointer;
}

.rule-select-item:hover {
  border-color: rgba(37, 106, 95, 0.45);
  background: #f7faf8;
}

.rule-select-item input {
  margin-top: 0.2rem;
}

.rule-select-item span {
  display: grid;
  gap: 0.2rem;
}

.rule-select-item strong {
  color: var(--ink);
  font-weight: 800;
}

.rule-select-item small {
  color: var(--brand);
  font-weight: 800;
}

.rule-select-item em {
  color: var(--muted);
  font-size: 0.88rem;
  font-style: normal;
}

.sticky-actions {
  position: sticky;
  bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.sticky-actions p {
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.status-panel {
  margin-bottom: 1rem;
  border-color: rgba(39, 115, 79, 0.35);
  color: var(--green);
}

.status-panel.warning {
  border-color: rgba(217, 150, 20, 0.35);
  color: var(--amber);
}

.status-panel.danger {
  border-color: rgba(190, 64, 64, 0.35);
  color: var(--red);
}

.channel-sync-status[hidden] {
  display: none;
}

.channel-performance-panel {
  overflow: hidden;
}

.channel-performance-table {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.channel-performance-head,
.channel-performance-summary {
  display: grid;
  grid-template-columns: 64px minmax(160px, 1.2fr) repeat(5, minmax(108px, 0.8fr));
  align-items: center;
  gap: 0.75rem;
}

.channel-performance-head {
  min-height: 42px;
  padding: 0 0.85rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.channel-performance-head button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 0.25rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.channel-performance-head button::after {
  content: "↕";
  color: #a3ada7;
  font-size: 0.7rem;
  line-height: 1;
}

.channel-performance-head button.is-active {
  color: var(--ink);
}

.channel-performance-head button.is-active::after {
  content: "↓";
  color: var(--primary);
}

.channel-performance-head button.is-active[data-sort-direction="asc"]::after {
  content: "↑";
}

.channel-performance-head button:focus-visible {
  outline: 2px solid rgba(36, 133, 103, 0.25);
  outline-offset: 3px;
  border-radius: 4px;
}

.channel-performance-list {
  display: grid;
}

.channel-performance-row + .channel-performance-row {
  border-top: 1px solid var(--line);
}

.channel-performance-summary {
  width: 100%;
  min-height: 54px;
  padding: 0.5rem 0.85rem;
  border: 0;
  background: #ffffff;
  color: #26332c;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.channel-performance-summary:hover,
.channel-performance-row.is-open .channel-performance-summary {
  background: #fbfcfb;
}

.channel-performance-summary > span:not(.channel-performance-name) {
  font-family: Consolas, "SFMono-Regular", monospace;
  white-space: nowrap;
}

.channel-performance-code {
  overflow: hidden;
  color: #405047;
  font-size: 0.9rem;
  font-weight: 800;
  text-overflow: ellipsis;
}

.channel-performance-value {
  display: grid;
  gap: 0.08rem;
  align-content: center;
  min-width: 0;
  white-space: nowrap;
}

.channel-performance-value strong {
  color: #26332c;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.92rem;
  font-weight: 800;
}

.channel-performance-value small {
  color: var(--muted);
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
}

.channel-performance-name {
  display: grid;
  gap: 0.14rem;
  align-content: center;
  min-width: 0;
  color: var(--brand);
}

.channel-performance-title-line,
.channel-performance-group-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.channel-performance-title-line i {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.channel-performance-name.warm {
  color: #f35a1b;
}

.channel-performance-name.blue {
  color: #0788d8;
}

.channel-performance-name.green {
  color: var(--green);
}

.channel-performance-title-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-performance-title-line em {
  flex: 0 0 auto;
  padding: 0.08rem 0.38rem;
  border-radius: 999px;
  background: rgba(37, 106, 95, 0.1);
  color: var(--brand-2);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 800;
}

.channel-performance-group-line {
  padding-left: 1.05rem;
  color: var(--muted);
}

.channel-performance-group-line small {
  padding: 0.02rem 0.18rem;
  border-radius: 5px;
  background: rgba(102, 115, 107, 0.08);
  font-size: 0.7rem;
  font-weight: 700;
}

.channel-performance-detail {
  display: none;
  gap: 0.85rem;
  padding: 0.9rem;
  border-top: 1px solid rgba(223, 230, 223, 0.72);
  background: #fbfcfb;
}

.channel-performance-row.is-open .channel-performance-detail {
  display: grid;
}

.channel-performance-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.metric-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.metric-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 30px;
  margin: 0;
  padding: 0.22rem 0.58rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #405047;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.metric-toggle input {
  width: 0.9rem;
  height: 0.9rem;
  accent-color: var(--metric-color);
}

.metric-toggle:has(input:checked) {
  border-color: color-mix(in srgb, var(--metric-color) 55%, #ffffff);
  background: color-mix(in srgb, var(--metric-color) 12%, #ffffff);
  color: var(--metric-color);
}

.channel-performance-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  gap: 0.45rem;
  min-width: min(520px, 100%);
}

.channel-performance-stats span {
  display: grid;
  gap: 0.1rem;
  min-height: 46px;
  padding: 0.42rem 0.5rem;
  border: 1px solid rgba(223, 230, 223, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.channel-performance-stats small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.channel-performance-stats b {
  color: #26332c;
  font-size: 0.86rem;
  white-space: nowrap;
}

.performance-chart-wrap {
  position: relative;
  min-height: 250px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.performance-chart-wrap canvas {
  display: block;
  width: 100%;
  height: 260px;
}

.performance-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.performance-chart-card {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.performance-chart-card[hidden] {
  display: none;
}

.performance-chart-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.performance-chart-title span {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  color: #405047;
  font-size: 0.86rem;
  font-weight: 800;
}

.performance-chart-title i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--metric-color);
}

.performance-chart-title b {
  color: #26332c;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.86rem;
  white-space: nowrap;
}

.performance-chart-tooltip {
  position: absolute;
  z-index: 3;
  display: grid;
  gap: 0.34rem;
  width: 220px;
  padding: 0.65rem;
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(23, 32, 27, 0.14);
  pointer-events: none;
}

.performance-chart-tooltip[hidden] {
  display: none;
}

.performance-chart-tooltip strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.performance-chart-tooltip span {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.38rem;
}

.performance-chart-tooltip i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.performance-chart-tooltip small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.performance-chart-tooltip b {
  color: #26332c;
  font-size: 0.8rem;
}

.image-test-config-panel {
  margin-bottom: 1rem;
}

.image-api-editor-panel {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.image-api-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.image-api-editor-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.image-api-editor-head p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.image-api-editor-form {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
  gap: 0.7rem;
  min-width: 0;
}

.image-api-editor-form [hidden] {
  display: none !important;
}

.image-api-editor-form .filter-field {
  flex: none;
  min-width: 0;
}

.image-api-field-source,
.image-api-field-name {
  grid-column: span 3;
}

.image-api-field-manual {
  grid-column: span 4;
}

.image-api-field-group,
.image-api-field-price {
  grid-column: span 2;
}

.image-api-field-remark {
  grid-column: span 3;
}

.image-api-form-actions {
  display: inline-flex;
  align-items: end;
  justify-content: flex-end;
  gap: 0.45rem;
  grid-column: span 2;
  min-width: 0;
}

.image-api-form-actions .btn {
  min-height: 38px;
  white-space: nowrap;
}

.image-api-form-actions .btn-primary {
  min-width: 132px;
}

.image-api-config-toolbar {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

#apiConfigModal .modal-dialog {
  width: min(1280px, calc(100vw - 2rem));
  max-width: none;
}

.image-api-config-modal .modal-header {
  align-items: flex-start;
}

.image-api-config-modal {
  overflow: hidden;
}

.image-api-config-modal .modal-body {
  overflow-x: hidden;
}

.image-api-config-modal .modal-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.image-api-table-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.85rem 0 0.55rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.image-api-table-toolbar .filter-field:first-of-type {
  flex: 1 1 320px;
}

.image-api-table-toolbar .filter-field {
  min-width: 0;
}

.image-api-table-toolbar .panel-tag {
  margin-left: auto;
}

.image-api-config-table-wrap {
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow-x: auto;
}

.image-api-config-table-wrap table {
  min-width: 940px;
}

.image-api-config-table-wrap thead th {
  border-bottom-color: var(--line);
  background: #f8faf8;
}

.image-api-config-table-wrap th button {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.image-api-config-table-wrap th button::after {
  color: #9aa59f;
  font-size: 0.74rem;
  content: "↕";
}

.image-api-config-table-wrap th button.is-active {
  color: var(--brand-2);
}

.image-api-config-table-wrap th button.is-active[data-sort-direction="asc"]::after {
  content: "↑";
}

.image-api-config-table-wrap th button.is-active[data-sort-direction="desc"]::after {
  content: "↓";
}

.image-api-config-table-wrap th button:focus-visible {
  outline: 2px solid rgba(37, 106, 95, 0.18);
  outline-offset: 3px;
  border-radius: 4px;
}

.image-api-config-table-wrap tr.is-removing {
  opacity: 0.55;
}

.image-api-key-cell {
  max-width: 360px;
  color: #26332c;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.78rem;
}

@media (max-width: 1180px) {
  .image-api-editor-form {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .image-api-field-source,
  .image-api-field-manual,
  .image-api-field-name,
  .image-api-field-remark {
    grid-column: span 3;
  }

  .image-api-field-group,
  .image-api-field-price,
  .image-api-form-actions {
    grid-column: span 2;
  }

  .image-api-form-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .image-api-editor-head,
  .image-api-table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .image-api-editor-form {
    grid-template-columns: 1fr;
  }

  .image-api-field-source,
  .image-api-field-manual,
  .image-api-field-name,
  .image-api-field-group,
  .image-api-field-price,
  .image-api-field-remark,
  .image-api-form-actions {
    grid-column: auto;
  }

  .image-api-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .image-api-table-toolbar .panel-tag {
    margin-left: 0;
  }
}

.status-panel.compact {
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
}

.image-test-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.image-test-source-field {
  flex: 0 1 180px;
}

.image-test-manual-field {
  flex: 1 1 320px;
}

.image-test-baseurl-field {
  flex: 1 1 300px;
}

.image-test-key-field {
  flex: 1 1 360px;
}

.image-test-model-field {
  flex: 0 1 220px;
}

.image-test-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.image-test-picker-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.image-test-picker-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.image-test-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.image-test-card {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.image-test-card.is-running {
  border-color: rgba(37, 106, 95, 0.35);
  background: #f6fbf8;
}

.image-test-card.is-success {
  border-color: rgba(39, 115, 79, 0.3);
}

.image-test-card.is-failed {
  border-color: rgba(184, 50, 50, 0.35);
  background: #fffafa;
}

.image-test-card.is-skipped {
  opacity: 0.72;
}

.image-test-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.image-test-card-header div {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.image-test-card-header strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.image-test-card-header small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.image-test-card-actions {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 0.5rem;
}

.image-test-select {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  margin: 0;
  padding: 0.18rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #405047;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.image-test-select input {
  width: 1.35rem;
  height: 1.35rem;
  accent-color: var(--brand);
}

.image-test-state {
  flex: 0 0 auto;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: #edf2ef;
  color: #58655d;
  font-size: 0.74rem;
  font-weight: 800;
}

.image-test-state.running {
  background: rgba(37, 106, 95, 0.12);
  color: var(--brand);
}

.image-test-state.success {
  background: rgba(39, 115, 79, 0.12);
  color: var(--green);
}

.image-test-state.failed {
  background: rgba(184, 50, 50, 0.12);
  color: var(--red);
}

.image-test-json-panel {
  display: grid;
  gap: 0.45rem;
}

.image-test-json-panel summary {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.image-test-json-input,
.image-test-json-output {
  margin: 0;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #25342d;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  resize: vertical;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.image-test-json-input.form-control {
  height: 340px;
  min-height: 340px;
}

.image-test-json-output {
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
}

.image-test-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 0;
}

.image-test-metrics div {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  padding: 0.5rem;
  border-radius: 8px;
  background: #ffffff;
}

.image-test-metrics dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.image-test-metrics dd {
  margin: 0;
  color: var(--ink);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.88rem;
  font-weight: 800;
}

.image-test-preview {
  display: grid;
  min-height: 220px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed #cbd6cf;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #eef3ef 25%, transparent 25%),
    linear-gradient(-45deg, #eef3ef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef3ef 75%),
    linear-gradient(-45deg, transparent 75%, #eef3ef 75%),
    #ffffff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.image-test-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.image-test-preview-result {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 220px;
}

.image-test-preview-button {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 220px;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
}

.image-test-save-button {
  position: absolute;
  right: 0.65rem;
  top: 0.65rem;
  z-index: 2;
  background: rgba(255, 255, 255, 0.92);
}

.image-test-preview-button img {
  pointer-events: none;
}

.image-test-preview-button span {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  padding: 0.2rem 0.52rem;
  border-radius: 999px;
  background: rgba(23, 32, 27, 0.72);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.image-test-preview-button:hover span,
.image-test-preview-button:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.image-preview-modal .modal-content {
  min-height: 100vh;
  background: #101511;
  color: #ffffff;
}

.image-preview-modal:not(.is-open) {
  display: none;
}

.image-preview-modal.is-open {
  position: fixed;
  inset: 0;
  z-index: 1060;
  display: block;
  overflow: hidden;
  background: rgba(16, 21, 17, 0.96);
}

.image-preview-modal .modal-header {
  position: relative;
  z-index: 2;
  border-bottom-color: rgba(255, 255, 255, 0.12);
  background: rgba(16, 21, 17, 0.96);
}

.image-preview-modal .modal-header p {
  margin: 0.18rem 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.84rem;
}

.image-preview-modal .modal-body {
  min-height: 0;
  padding: 0;
}

.image-preview-modal .btn-close {
  filter: invert(1) grayscale(1);
}

.image-preview-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.image-preview-viewport {
  display: grid;
  width: 100%;
  height: calc(100vh - 76px);
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.035) 75%),
    #101511;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-size: 28px 28px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.image-preview-viewport.is-dragging {
  cursor: grabbing;
}

.image-preview-viewport img {
  display: block;
  max-width: 92vw;
  max-height: calc(100vh - 116px);
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  pointer-events: none;
}

.image-test-message {
  min-height: 1.2rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.form-control,
.form-select {
  border-color: var(--line);
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus,
.btn:active:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(37, 106, 95, 0.15);
}

@media (max-width: 1100px) {
  .metric-grid,
  .rule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exception-log-grid,
  .exception-log-sections {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-grid.compact {
    grid-template-columns: 1fr;
  }

  .span-7,
  .span-5,
  .span-8,
  .span-4 {
    grid-column: 1 / -1;
  }

  .channel-meta-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .channel-performance-toolbar {
    flex-direction: column;
  }

  .channel-performance-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    min-width: 0;
    width: 100%;
  }

  .image-test-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 768px) {
  .app-nav {
    margin-left: 0;
    margin-top: 0.75rem;
  }

  .header-status {
    margin: 0.75rem 0 0;
  }

  .page-heading,
  .panel-header,
  .site-summary,
  .channel-card-top,
  .channel-card-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .heading-actions,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .range-segmented {
    width: 100%;
  }

  .range-segmented button {
    flex: 1 1 0;
  }

  .filter-actions {
    flex-direction: column;
  }

  .metric-grid,
  .rule-grid,
  .form-grid.two,
  .form-grid.three,
  .channel-card-grid,
  .exception-log-grid,
  .exception-log-sections {
    grid-template-columns: 1fr;
  }

  .exception-log-item {
    grid-template-columns: 1fr;
  }

  .exception-log-actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .exception-action-button {
    width: 100%;
  }

  .event-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .event-item time {
    grid-column: 2;
  }

  .dashboard-channel-main {
    align-items: stretch;
    flex-direction: column;
  }

  .channel-meta-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .channel-performance-table {
    overflow-x: auto;
  }

  .channel-performance-head,
  .channel-performance-summary {
    grid-template-columns: 56px minmax(140px, 1.2fr) repeat(5, minmax(96px, 0.8fr));
    min-width: 780px;
  }

  .channel-performance-detail {
    min-width: 780px;
  }

  .channel-performance-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .performance-chart-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .image-test-form {
    align-items: stretch;
    flex-direction: column;
  }

  .image-test-grid,
  .image-test-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .execution-log-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .execution-log-actions {
    grid-column: 2;
    justify-self: start;
  }

  .execution-log-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .execution-log-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .execution-log-actions {
    justify-items: start;
  }

  .sticky-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
