/* IAM Panel */

.iam-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.iam-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.iam-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.iam-section h2 {
  font-size: 18px;
}

.iam-subtle {
  color: var(--text-secondary);
  font-size: 12px;
}

.iam-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.iam-agent-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  padding: 12px 14px 10px;
  position: relative;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.iam-agent-card:hover {
  border-color: rgba(88, 166, 255, 0.5);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transform: translateY(-2px);
}

.iam-agent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.iam-agent-identity {
  display: flex;
  gap: 10px;
  align-items: center;
}

.iam-agent-icon {
  font-size: 22px;
}

.iam-agent-name {
  font-weight: 600;
}

.iam-agent-role {
  font-size: 12px;
  color: var(--text-secondary);
}

.iam-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px rgba(248, 81, 73, 0.6);
}

.iam-status-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.6);
}

.iam-agent-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.iam-tier-badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}

.tier-t1 { color: #f3d68a; border-color: rgba(243, 214, 138, 0.4); background: rgba(243, 214, 138, 0.12); }
.tier-t2 { color: #7eb3ff; border-color: rgba(126, 179, 255, 0.4); background: rgba(126, 179, 255, 0.12); }
.tier-t3 { color: var(--text-secondary); border-color: rgba(139, 148, 158, 0.4); background: rgba(139, 148, 158, 0.12); }

.iam-channels {
  display: flex;
  gap: 6px;
  font-size: 14px;
}

.iam-channel {
  opacity: 0.3;
  filter: grayscale(1);
  transition: opacity 0.2s ease;
}

.iam-channel.active {
  opacity: 1;
  filter: grayscale(0);
}

.iam-kill-indicator {
  margin-top: 10px;
  height: 4px;
  border-radius: 6px;
  background: var(--green);
}

.kill-l1 { background: var(--yellow); }
.kill-l2 { background: #f59f3a; }
.kill-l3 { background: #f26d5b; }
.kill-l4 { background: var(--red); }

.iam-agent-details {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: none;
  gap: 6px;
  flex-direction: column;
}

.iam-agent-card.expanded .iam-agent-details {
  display: flex;
}

.iam-detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.iam-detail-row span:last-child {
  color: var(--text-primary);
}

.iam-matrix {
  display: grid;
  grid-template-columns: 180px repeat(var(--cols), minmax(90px, 1fr));
  gap: 8px;
}

.iam-matrix-cell {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  text-align: center;
}

.iam-matrix-head {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-secondary);
}

.iam-matrix-agent {
  text-align: left;
  font-weight: 600;
}

.iam-matrix-allowed { color: var(--green); }
.iam-matrix-denied { color: var(--red); }
.iam-matrix-restricted { color: var(--yellow); }

.iam-security-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: 16px;
  align-items: stretch;
}

.iam-score-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.iam-score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--score) * 1%), rgba(88, 166, 255, 0.15) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
}

.iam-score-ring span {
  background: var(--bg-secondary);
  border-radius: 50%;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.iam-score-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.iam-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.iam-metric-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.iam-metric-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.iam-metric-value {
  font-size: 14px;
  font-weight: 600;
}

.status-good { border-color: rgba(63, 185, 80, 0.5); }
.status-warn { border-color: rgba(210, 153, 34, 0.5); }
.status-bad { border-color: rgba(248, 81, 73, 0.5); }

.iam-kill-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.iam-kill-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.iam-kill-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.iam-kill-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

.iam-kill-btn.kill-l1 { background: var(--yellow); color: #1a1a1a; }
.iam-kill-btn.kill-l2 { background: #f59f3a; }
.iam-kill-btn.kill-l3 { background: #f26d5b; }
.iam-kill-btn.kill-l4 { background: var(--red); }

.iam-kill-btn.armed {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4), 0 0 18px rgba(255, 255, 255, 0.4);
}

@media (max-width: 900px) {
  .iam-security-grid {
    grid-template-columns: 1fr;
  }
  .iam-matrix {
    grid-template-columns: 140px repeat(var(--cols), minmax(70px, 1fr));
  }
}

@media (max-width: 700px) {
  .iam-section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .iam-matrix {
    overflow-x: auto;
    padding-bottom: 8px;
  }
}
