/* ── Layout ───────────────────────────────────────────────────────────────── */

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

#root {
  display: contents;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Navbar ───────────────────────────────────────────────────────────────── */

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 10;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.85); }
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.sidebar-top,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
}

.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  padding: var(--space-4) var(--space-5) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px var(--space-5);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0;
  transition: color var(--transition), background var(--transition);
  position: relative;
}

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

.nav-item.active {
  color: var(--text);
  background: var(--surface2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

/* ── Main content ─────────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}

/* ── Controls bar ─────────────────────────────────────────────────────────── */

.controls-bar {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: var(--space-3);
  flex-shrink: 0;
}

.controls-spacer { flex: 1; }

.filters-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.filters-toggle:hover,
.filters-toggle.active {
  color: var(--text);
  background: var(--surface3);
  border-color: rgba(255,255,255,0.12);
}

.filters-toggle.active .chevron { transform: rotate(180deg); }
.chevron { transition: transform var(--transition); }

.time-picker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color var(--transition);
}

.time-picker:focus-within { border-color: var(--border-focus); color: var(--text); }

.time-picker select {
  background: none;
  border: none;
  color: inherit;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--space-4);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%237a82a0' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0 center;
}

/* ── Filters panel ────────────────────────────────────────────────────────── */

.filters-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
  background: var(--surface);
  border-bottom: 0px solid var(--border);
  flex-shrink: 0;
}

.filters-panel.open {
  max-height: 200px;
  border-bottom: 1px solid var(--border);
}

.filters-inner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  padding: var(--space-4) var(--space-6);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.filter-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.filter-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.filter-check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-clear-filters {
  margin-left: auto;
  align-self: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-clear-filters:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }

/* ── KPI row ──────────────────────────────────────────────────────────────── */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  flex-shrink: 0;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.kpi-card--alert { border-color: rgba(248, 113, 113, 0.15); }

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--text);
  line-height: 1.1;
}

.kpi-card--alert .kpi-value { color: var(--red); }

/* ── Chart ────────────────────────────────────────────────────────────────── */

.chart-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0 var(--space-6) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--space-3);
  flex-shrink: 0;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}

.legend-item:hover { color: var(--text); }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-wrap {
  flex: 1;
  position: relative;
  padding: var(--space-4) var(--space-5);
  min-height: 0;
}

/* ── Stub / inner pages ───────────────────────────────────────────────────── */

#view {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
}

.page-header {
  padding: var(--space-6) var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text);
}

.page-desc {
  margin-top: var(--space-1);
  font-size: 13px;
  color: var(--text-muted);
}

.page-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--text-dim);
}

.page-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-empty-text {
  font-size: 13px;
}

/* ── AI Agents page ───────────────────────────────────────────────────────── */

.agents-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.agents-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-muted);
  min-width: 220px;
  transition: border-color var(--transition);
}

.agents-search-wrap:focus-within {
  border-color: var(--border-focus);
  color: var(--text);
}

.agents-search {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}

.agents-search::placeholder { color: var(--text-dim); }

.agents-tag-filters {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.tag-filter-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.tag-filter-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }

.tag-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.agents-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  overflow-y: auto;
}

.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color var(--transition);
}

.agent-card:hover { border-color: rgba(255,255,255,0.12); }

.agent-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.agent-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.agent-badge img { display: block; }
.agent-badge-letter { font-size: 16px; font-weight: 700; }
.agent-favicon { border-radius: 4px; }

.agent-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.agent-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.agent-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.agent-verified {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  background: rgba(52,211,153,0.1);
  border: 1px solid rgba(52,211,153,0.2);
  padding: 1px 6px;
  border-radius: 20px;
}

.agent-company {
  font-size: 12px;
  color: var(--text-muted);
}

.agent-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
}

.agent-note {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 11px;
  color: var(--yellow);
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.15);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  line-height: 1.4;
}

.agent-note svg { flex-shrink: 0; margin-top: 1px; }

.agent-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: auto;
}

.agent-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.agent-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}

.agent-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition);
  flex-shrink: 0;
}

.agent-url:hover { color: var(--accent); text-decoration: none; }

/* ── Agent card 3-dots menu ──────────────────────────────────────────────────── */

.agent-card-menu-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
  align-self: flex-start;
}

.agent-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.agent-card:hover .agent-menu-btn,
.agent-card-menu-wrap:has(.agent-dropdown.open) .agent-menu-btn {
  opacity: 1;
}

.agent-menu-btn:hover {
  background: var(--surface3);
  color: var(--text);
}

.agent-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
  min-width: 168px;
  z-index: 200;
  display: none;
  overflow: hidden;
  animation: dropdownIn 0.12s ease;
}

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

.agent-dropdown.open { display: block; }

.agent-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.agent-menu-item:hover { background: var(--surface3); }
.agent-menu-item svg   { color: var(--text-muted); flex-shrink: 0; }

/* ── Policy wizard ────────────────────────────────────────────────────────────── */

.policy-wizard-wrap {
  padding: var(--space-6);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.policy-wizard-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: var(--space-6);
  flex: 1;
  min-height: 0;
  max-width: 920px;
}

/* Stepper */
.wizard-stepper {
  display: flex;
  flex-direction: column;
  padding-top: var(--space-1);
}

.wizard-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  position: relative;
  padding-bottom: var(--space-5);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: opacity 0.12s;
}

.wizard-step:not(.active):hover { opacity: 0.8; }

.wizard-step:last-child { padding-bottom: 0; }

.wizard-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 12px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.wizard-step.completed::after { background: var(--accent); }

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  position: relative;
  z-index: 1;
  transition: all 0.2s;
}

.wizard-step.active .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(108,142,245,0.15);
}

.wizard-step.completed .step-num {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.step-info { padding-top: 3px; }

.step-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  line-height: 1.4;
}

.wizard-step.active    .step-label { color: var(--text); font-weight: 600; }
.wizard-step.completed .step-label { color: var(--accent); }

/* Panel */
.wizard-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.wizard-panel-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--space-6);
  gap: var(--space-5);
  min-height: 520px;
  overflow: hidden;
}

.wiz-step-hd {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.wiz-step-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.wiz-step-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.wiz-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.wiz-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.wiz-req { color: #f87171; }

.wiz-optional {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

.wiz-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wiz-regen-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.6;
}

.wiz-regen-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.wiz-status-select-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.wiz-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s;
}

.wiz-status-select {
  flex: 1;
  min-width: 0;
}

/* Two-column layout for steps 1 and 2 */
.wiz-two-col {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.wiz-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.wiz-col-divider {
  width: 1px;
  background: var(--border);
  margin: 0 var(--space-5);
  flex-shrink: 0;
  align-self: stretch;
}

.wiz-col-heading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.wiz-textarea {
  resize: vertical;
  min-height: 130px;
  font-family: inherit;
  line-height: 1.5;
}

.input-error {
  border-color: #f87171 !important;
  box-shadow: 0 0 0 2px rgba(248,113,113,0.2) !important;
}

/* Status cards */
.status-cards { display: flex; flex-direction: column; gap: var(--space-3); }

.status-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
}

.status-card input[type="radio"] { display: none; }
.status-card:hover { border-color: rgba(108,142,245,0.4); background: var(--surface2); }
.status-card.selected { border-color: var(--accent); background: rgba(108,142,245,0.07); }

.status-dot-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-card-label { font-size: 14px; font-weight: 600; color: var(--text); }
.status-card-desc  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Priority */
.priority-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.priority-center { flex: 1; display: flex; flex-direction: column; gap: var(--space-3); }

.priority-val-badge {
  text-align: center;
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  line-height: 1;
  transition: color 0.15s;
}

.priority-val-badge.pri-low  { color: #34d399; }
.priority-val-badge.pri-med  { color: #fbbf24; }
.priority-val-badge.pri-high { color: #fb923c; }
.priority-val-badge.pri-crit { color: #f87171; }

.priority-ticks span.active { color: var(--text); font-weight: 600; }
.priority-ticks span.pri-low.active  { color: #34d399; }
.priority-ticks span.pri-med.active  { color: #fbbf24; }
.priority-ticks span.pri-high.active { color: #fb923c; }
.priority-ticks span.pri-crit.active { color: #f87171; }

.priority-side-label {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.8;
}

.priority-side-label span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }

.wiz-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: var(--surface3);
  outline: none;
  cursor: pointer;
  --pri-color: var(--accent);
  transition: --pri-color 0.15s;
}

.wiz-slider.pri-low  { --pri-color: #34d399; }
.wiz-slider.pri-med  { --pri-color: #fbbf24; }
.wiz-slider.pri-high { --pri-color: #fb923c; }
.wiz-slider.pri-crit { --pri-color: #f87171; }

.wiz-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pri-color);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--pri-color);
  cursor: pointer;
}

.wiz-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pri-color);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--pri-color);
  cursor: pointer;
}

.priority-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.2px;
}

/* Schedule */
.day-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.day-chip {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.day-chip:hover   { border-color: rgba(108,142,245,0.5); color: var(--text); }
.day-chip.active  { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-chip-all     { margin-left: auto; }

.time-toggle {
  display: flex;
  gap: var(--space-5);
}

.time-radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.time-radio-label input { accent-color: var(--accent); }

.time-range-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface2);
  border-radius: var(--radius);
  width: fit-content;
}

.wiz-hidden { display: none !important; }

.time-range-lbl { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.time-input { width: 110px; }

/* Rule builder */
.rule-builder {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.rule-where {
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.rule-connector-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: var(--space-1);
}

.connector-btn {
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  cursor: pointer;
  transition: all 0.12s;
}

.connector-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
}

.rule-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  padding: 5px var(--space-2);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: auto;
}

.rule-select:focus   { border-color: var(--accent); }
.rule-field-sel      { min-width: 110px; }
.rule-op-sel         { min-width: 150px; }

.rule-val {
  flex: 1;
  font-size: 12px !important;
  padding: 5px var(--space-2) !important;
  min-width: 0;
}

.rule-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.rule-remove:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* Agent multiselect */
.agent-multi {
  position: relative;
  flex: 1;
  min-width: 0;
}

.agent-multi-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  min-height: 28px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s;
}

.agent-multi-trigger:hover { border-color: var(--accent-dim); }
.agent-multi.open .agent-multi-trigger { border-color: var(--accent); }

.agent-multi-pills {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.agent-multi-placeholder {
  color: var(--text-dim);
  font-size: 12px;
  padding: 2px 0;
}

.agent-multi-caret {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.agent-multi.open .agent-multi-caret { transform: rotate(180deg); }

.agent-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 4px 2px 4px;
  font-size: 11px;
  color: var(--text);
  max-width: 100%;
}

.agent-pill-ico {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.agent-pill-ico img,
.agent-pill-ico svg { width: 16px; height: 16px; }
.agent-pill-ico .agent-badge-letter {
  width: 16px; height: 16px;
  font-size: 9px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}

.agent-pill-lbl {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.agent-pill-x {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 1px;
  display: inline-flex;
  align-items: center;
  border-radius: 50%;
  transition: color 0.12s, background 0.12s;
}
.agent-pill-x:hover { color: #f87171; background: rgba(248,113,113,0.15); }

.agent-multi-pop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-width: 260px;
}

.agent-multi.open .agent-multi-pop { display: flex; }

.agent-multi-search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.agent-multi-search {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  padding: 2px 0;
}
.agent-multi-search::placeholder { color: var(--text-dim); }

.agent-multi-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.agent-multi-opt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.1s;
}

.agent-multi-opt:hover { background: var(--surface2); }
.agent-multi-opt.selected { background: rgba(108,142,245,0.08); }

.agent-multi-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.agent-multi-opt.selected .agent-multi-check {
  background: var(--accent);
  border-color: var(--accent);
}

.agent-multi-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.agent-multi-ico img,
.agent-multi-ico svg { width: 18px; height: 18px; }
.agent-multi-ico .agent-badge-letter {
  width: 18px; height: 18px;
  font-size: 10px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}

.agent-multi-lbl {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-multi-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.agent-multi-clear {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.agent-multi-clear:hover { text-decoration: underline; }

.wiz-add-row-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
  align-self: flex-start;
}

.wiz-add-row-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Action pipeline */
.action-pipeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.action-arrow {
  display: flex;
  justify-content: flex-start;
  padding: 2px 0 2px var(--space-4);
  color: var(--text-dim);
}

.action-block {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
}

.action-block-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface3);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.action-block-body { flex: 1; min-width: 0; }
.action-block-label { font-size: 13px; font-weight: 600; color: var(--text); }
.action-block-desc  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.action-cfg {
  margin-top: var(--space-2);
  width: 100%;
  font-size: 12px !important;
  padding: 5px var(--space-2) !important;
}

.action-block-tools {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
}

.action-move {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color 0.12s, background 0.12s;
}
.action-move:hover:not(:disabled) { color: var(--accent); background: rgba(108,142,245,0.1); }
.action-move:disabled { opacity: 0.3; cursor: not-allowed; }

.action-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.alert-targets {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.alert-target-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.alert-target-channel {
  min-width: 110px;
  flex-shrink: 0;
}

.alert-target-value {
  flex: 1;
  font-size: 12px !important;
  padding: 5px var(--space-2) !important;
  min-width: 0;
}

.email-chip-input {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  cursor: text;
  transition: border-color 0.15s;
}

.email-chip-input:focus-within { border-color: var(--accent); }

.email-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(108,142,245,0.15);
  border: 1px solid rgba(108,142,245,0.35);
  color: var(--text);
  border-radius: 999px;
  padding: 1px 4px 1px 8px;
  font-size: 11px;
  line-height: 1.4;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-chip-x {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 1px;
  display: inline-flex;
  align-items: center;
  border-radius: 50%;
  transition: color 0.12s, background 0.12s;
}
.email-chip-x:hover { color: #f87171; background: rgba(248,113,113,0.18); }

.email-chip-entry {
  flex: 1;
  min-width: 100px;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  padding: 2px 2px;
}
.email-chip-entry::placeholder { color: var(--text-dim); }

.alert-target-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}
.alert-target-remove:hover { color: #f87171; background: rgba(248,113,113,0.1); }

.alert-target-add {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 4px var(--space-3);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.12s;
}
.alert-target-add:hover { border-color: var(--accent); color: var(--accent); }

.alert-targets-empty {
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 0;
}

.action-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
}

.action-remove:hover { color: #f87171; background: rgba(248,113,113,0.1); }

.action-add-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--border);
}

.action-add-label { font-size: 12px; color: var(--text-muted); font-weight: 500; flex-shrink: 0; }
.action-type-btns { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.action-type-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.action-type-btn:hover {
  border-color: var(--action-color, var(--accent));
  background: color-mix(in srgb, var(--action-color, var(--accent)) 8%, transparent);
  color: var(--action-color, var(--accent));
}

.action-type-icon { display: flex; align-items: center; }

/* Toasts */
#toast-host {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  font-size: 13px;
  color: var(--text);
  min-width: 280px;
  max-width: 420px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.toast.visible { opacity: 1; transform: translateY(0); }

.toast-success { border-left-color: #34d399; }
.toast-success svg { color: #34d399; }

.toast-error { border-left-color: #f87171; }
.toast-error svg { color: #f87171; }

/* Soft-disabled nav button (clickable to surface validation errors) */
.btn.wiz-blocked {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.wiz-blocked:hover { background: var(--accent); }

/* Wizard validation errors */
.wiz-errors {
  margin-top: auto;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  color: #f87171;
  font-size: 12px;
}

.wiz-errors-hd {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.wiz-errors ul {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--text);
  font-weight: 400;
}

.wiz-errors li { margin: 2px 0; }

.wiz-errors + .wizard-nav { margin-top: var(--space-3); border-top: none; padding-top: 0; }

/* Wizard nav */
.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.wizard-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.wiz-step-counter {
  font-size: 12px;
  color: var(--text-dim);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: rgba(255,255,255,0.15);
  color: var(--text);
  background: var(--surface2);
}

/* ── Policies page ───────────────────────────────────────────────────────────── */

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.policies-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.policy-status-filters {
  display: flex;
  gap: var(--space-2);
}

.policies-table-wrap {
  overflow-x: auto;
}

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

.policies-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.col-sort {
  cursor: pointer;
  user-select: none;
  transition: color 0.12s;
}

.col-sort:hover { color: var(--text); }

.sort-icon {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 3px;
}

.col-right { text-align: right !important; }

.policies-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.policies-table tbody tr:hover { background: var(--surface2); }

.policies-table tbody td {
  padding: var(--space-3) var(--space-4);
  vertical-align: middle;
}

.policy-name-cell { max-width: 320px; }

.policy-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.policy-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.policy-group-cell { white-space: nowrap; }

.policy-group {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.policy-behavior {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.policy-actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.policy-action-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.policy-status-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.policy-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.policy-priority {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.policy-date {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.policy-row-actions {
  width: 40px;
  text-align: right;
}

.policy-menu-btn { opacity: 0; }
.policy-row:hover .policy-menu-btn,
.policy-row-actions:has(.agent-dropdown.open) .policy-menu-btn { opacity: 1; }

.policy-menu-delete { color: #f87171 !important; }
.policy-menu-delete svg { color: #f87171 !important; }

.policies-empty {
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
