/* ACP Governance Command Center — enterprise UI tokens */
:root {
  --bg-app: #0c0e12;
  --bg-sidebar: #111318;
  --bg-surface: #161a22;
  --bg-elevated: #1c212b;
  --bg-hover: #232933;
  --bg-inset: #0a0c10;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #f4f6f9;
  --text-secondary: #9aa4b2;
  --text-tertiary: #6b7585;

  --accent: #3b82f6;
  --accent-muted: rgba(59, 130, 246, 0.12);

  --semantic-allow: #22c55e;
  --semantic-deny: #ef4444;
  --semantic-escalate: #f59e0b;
  --semantic-info: #60a5fa;

  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --sidebar-width: 248px;
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* —— Sidebar —— */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
}

.logo-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.logo-subtitle {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.env-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.env-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--semantic-allow);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem;
}

.nav-group {
  margin-bottom: 1.25rem;
}

.nav-group-bottom {
  margin-top: auto;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-subtle);
}

.nav-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: 0 0.65rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  margin: 1px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--text-primary);
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav-icon {
  width: 1.1rem;
  text-align: center;
  font-size: 0.7rem;
  opacity: 0.7;
}

.sidebar-footer {
  padding: 0.85rem 1rem;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  line-height: 1.45;
  border-top: 1px solid var(--border-subtle);
}

/* —— Main —— */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1.25rem 1.75rem 0.75rem;
  flex-shrink: 0;
}

.breadcrumb {
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.breadcrumb span {
  color: var(--text-secondary);
}

.app-header h1 {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.meta-text {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.btn {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-ghost {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

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

.btn-sm {
  font-size: 0.75rem;
  padding: 0.28rem 0.55rem;
}

.btn-approve {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.45);
  color: #86efac;
}

.btn-approve:hover {
  background: rgba(34, 197, 94, 0.28);
}

.btn-deny {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.btn-deny:hover {
  background: rgba(239, 68, 68, 0.22);
}

.approval-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.approvals-queue-hint {
  margin: 0 0 1rem;
  padding: 0 1rem;
}

.approvals-page-intro {
  margin: 0 0 1.25rem;
  padding: 0 1rem;
}

.approval-queue-section {
  margin-bottom: 1.75rem;
}

.approval-queue-section .section-heading {
  padding: 0 1rem;
}

.approval-count {
  font-weight: 500;
  color: var(--text-tertiary);
}

.approval-empty-row {
  text-align: center;
  font-style: italic;
  padding: 1.25rem !important;
}

.approval-queue-section .table-wrap {
  max-height: 220px;
}

.approval-row {
  cursor: pointer;
}

table.data tbody tr.approval-row:hover {
  background: var(--bg-hover);
}

table.data tbody tr.approval-row.selected {
  background: var(--accent-muted);
}

table.data tbody tr.approval-row.selected td {
  color: var(--text-primary);
}

.approval-review-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--semantic-escalate);
  margin: 0 0 0.75rem;
}

.approval-review-label.approved {
  color: var(--semantic-allow);
}

.approval-review-label.denied {
  color: var(--semantic-deny);
}

.approval-decided-msg {
  margin: 0 0 1rem;
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.approval-error {
  color: var(--semantic-deny);
  margin: 0 0 0.5rem;
}

.approval-inspector-actions {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
  flex-wrap: wrap;
}

.btn-review {
  font-size: 0.875rem;
  padding: 0.5rem 1.1rem;
  font-weight: 600;
}

.btn-approve.btn-review {
  background: var(--semantic-allow);
  border-color: var(--semantic-allow);
  color: #0c0e12;
}

.btn-deny.btn-review {
  background: transparent;
}

.approval-inspector-hint {
  margin-top: 0.5rem;
}

.approval-trace-full {
  word-break: break-all;
  font-size: 0.75rem;
}

.trace-summary .approval-inspector-hint code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.btn-icon {
  font-size: 0.9rem;
  opacity: 0.85;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.status-pill[data-state="live"] .status-dot {
  background: var(--semantic-allow);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
}

.status-pill[data-state="live"] .status-label {
  color: var(--semantic-allow);
}

.status-pill[data-state="offline"] .status-dot {
  background: var(--semantic-deny);
}

.status-pill[data-state="offline"] .status-label {
  color: var(--semantic-deny);
}

/* —— KPI row —— */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.65rem;
  padding: 0 1.75rem 1rem;
  flex-shrink: 0;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-panel);
  position: relative;
  overflow: hidden;
}

.kpi-card.kpi-clickable {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.kpi-card.kpi-clickable:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.kpi-card.kpi-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-muted);
}

.kpi-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.625rem;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

.drill-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}

.drill-toolbar .btn-back {
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
}

.drill-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.agent-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.agent-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.agent-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-family: var(--font-mono);
  font-weight: 500;
}

.agent-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

.agent-card dt {
  color: var(--text-tertiary);
}

.agent-card dd {
  margin: 0;
  color: var(--text-secondary);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-default);
}

.kpi-card.kpi-accent-allow::before { background: var(--semantic-allow); }
.kpi-card.kpi-accent-deny::before { background: var(--semantic-deny); }
.kpi-card.kpi-accent-escalate::before { background: var(--semantic-escalate); }

.kpi-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.kpi-value {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* —— Content grid —— */
.content-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr minmax(300px, 360px);
  gap: 0.75rem;
  padding: 0 1.75rem 1.25rem;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  padding: 1rem 1.15rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel-subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.panel-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.panel-body-flush {
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* —— Tables —— */
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

table.data thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-elevated);
}

table.data th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

table.data td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

table.data tbody tr[data-idx] {
  cursor: pointer;
  transition: background 0.1s ease;
}

table.data tbody tr[data-idx]:hover {
  background: var(--bg-hover);
}

table.data tbody tr.selected {
  background: var(--accent-muted);
}

table.data tbody tr.selected td {
  color: var(--text-primary);
}

.cell-mono {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
}

.risk-high {
  color: var(--semantic-escalate);
  font-weight: 500;
}

.cell-agent {
  font-weight: 500;
  color: var(--text-primary);
}

.cell-muted {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

/* Decision badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

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

.badge-allow {
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.25);
}
.badge-allow::before { background: var(--semantic-allow); }

.badge-deny {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.25);
}
.badge-deny::before { background: var(--semantic-deny); }

.badge-escalate {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.25);
}
.badge-escalate::before { background: var(--semantic-escalate); }

.badge-trust {
  font-size: 0.625rem;
  padding: 0.15rem 0.4rem;
  text-transform: capitalize;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}
.badge-trust::before { display: none; }

.badge-sample {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-muted);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Trace inspector */
.trace-summary {
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  line-height: 1.5;
}

.trace-summary.empty-inspector {
  color: var(--text-tertiary);
  font-style: italic;
}

.trace-summary dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
}

.trace-summary dt {
  color: var(--text-tertiary);
  font-weight: 500;
}

.trace-summary dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
  word-break: break-all;
}

.trace-json {
  margin: 0;
  flex: 1;
  padding: 0.85rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1.55;
  color: var(--text-secondary);
  background: var(--bg-inset);
  border: none;
  overflow: auto;
  min-height: 200px;
}

/* Section blocks */
.section-block {
  padding: 1rem 1.15rem;
}

.section-block + .section-block {
  border-top: 1px solid var(--border-subtle);
}

.section-heading {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

/* Charts */
.chart-bars {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 72px 1fr 40px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
}

.bar-row > span:first-child {
  color: var(--text-secondary);
  font-weight: 500;
}

.bar-row > span:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.bar-track {
  height: 6px;
  background: var(--bg-inset);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 3px;
  opacity: 0.9;
}

.bar-fill.allow { background: var(--semantic-allow); }
.bar-fill.deny { background: var(--semantic-deny); }
.bar-fill.escalate { background: var(--semantic-escalate); }

.risk-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.risk-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.risk-list li:last-child {
  border-bottom: none;
}

/* Policy cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.policy-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.policy-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.policy-card.policy-card-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-muted);
}

.policy-card .policy-card-hint {
  margin: 0.5rem 0 0;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.policy-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.policy-card h3 small {
  font-weight: 500;
  color: var(--text-tertiary);
}

.policy-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.policy-path {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin: 0;
}

.policy-detail-meta {
  margin: -0.25rem 0 1.25rem;
}

.policy-rule-row {
  cursor: pointer;
}

.policy-rule-row:hover td {
  background: var(--bg-hover);
}

.cell-cond {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  max-width: 280px;
}

.rule-cond-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.75rem;
}

.rule-cond-list code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  min-height: 280px;
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-tertiary);
}

.empty-state h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state p {
  margin: 0;
  max-width: 360px;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}

.empty-state a {
  color: var(--accent);
  text-decoration: none;
}

.empty-state a:hover {
  text-decoration: underline;
}

/* Settings form */
.form-field {
  margin-bottom: 1rem;
  max-width: 420px;
}

.form-field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 0.35rem;
}

.form-field input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-primary);
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.form-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

.form-hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

@media (max-width: 1280px) {
  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

  .panel-inspector {
    max-height: 320px;
  }
}
