/* Aiden 2.0 theme — matched to stage.dev.stackgen.com (devops-copilot) */
:root {
  --bg-app: #0f1115;
  --bg-sidebar: #16181d;
  --bg-elevated: #1c1f26;
  --bg-hover: #22262e;
  --bg-active: #2a2f38;
  --border: #2a2f38;
  --border-subtle: #1e2229;
  --text-primary: #e8eaed;
  --text-secondary: #a8b0bc;
  --text-muted: #8b919a;
  --text-dim: #6b7280;
  --accent: #1ec8e0;
  --accent-hover: #3ad4e8;
  --accent-soft: rgba(30, 200, 224, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #f5c842;
  --warn-soft: rgba(245, 200, 66, 0.14);
  --info: #7dd3fc;
  --info-soft: rgba(125, 211, 252, 0.12);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --sidebar-w: 248px;
  --rail-w: 300px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* —— Sidebar —— */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 12px 10px 14px;
  height: 100vh;
  overflow-y: auto;
}

.org {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}
.org-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1ec8e0, #7c6af5);
  flex-shrink: 0;
}
.org-chevron {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
}

.nav-group { margin-top: 14px; }
.nav-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 4px 10px 6px;
  letter-spacing: 0.01em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: default;
  user-select: none;
}
.nav-item svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  flex-shrink: 0;
}
.nav-item.active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}
.nav-item.muted { opacity: 0.55; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
}
.sidebar-foot .nav-item { flex: 1; font-size: 12.5px; color: var(--text-muted); }

/* —— Main —— */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-app);
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 24px;
  flex-shrink: 0;
}
.topbar-org {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.topbar-org .org-avatar { width: 18px; height: 18px; }

.workspace {
  display: grid;
  grid-template-columns: 1fr var(--rail-w);
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--border-subtle);
}

.list-pane {
  overflow-y: auto;
  padding: 8px 28px 32px;
  min-width: 0;
}

.rail {
  border-left: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
  overflow-y: auto;
  padding: 16px 14px 24px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 8px 0 6px;
}
.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: #fff;
}
.count-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.page-sub {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.45;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
}
.search svg {
  width: 15px;
  height: 15px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 1.7;
  flex-shrink: 0;
}
.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13.5px;
}
.search input::placeholder { color: var(--text-dim); }

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 3px;
}
.filter-tabs button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.filter-tabs button:hover { color: var(--text-primary); }
.filter-tabs button.active {
  background: var(--bg-active);
  color: var(--text-primary);
}

/* Vertical stage gates in right rail */
.legend-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.legend-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.legend-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.legend-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.legend-item .pill { align-self: flex-start; }
.legend-item .help {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.rail.detail-open .rail-legend { display: none; }
.rail.detail-open .rail-detail { display: flex; }

.rail-detail {
  display: none;
  flex-direction: column;
  gap: 0;
  min-height: 100%;
}
.rail-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.rail-detail-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
}
.rail-close {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
.rail-close:hover { color: var(--text-primary); background: var(--bg-active); }

.rail-detail .id-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 12px;
}
.rail-detail > p {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.55;
}
.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detail-kv {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.detail-kv .k {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.detail-kv .v {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* —— Policy list —— */
.list {
  margin-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.cat-header {
  margin: 22px 0 4px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.cat-header:first-child { margin-top: 14px; }

.policy-row {
  display: block;
  padding: 14px 6px 14px 4px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.12s;
  text-decoration: none;
  color: inherit;
}
.policy-row:hover { background: rgba(255, 255, 255, 0.02); }
.policy-row.selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.policy-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
  line-height: 1.35;
}
.policy-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.policy-meta .sep { color: var(--text-dim); }
.policy-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  color: var(--accent);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill.block { background: var(--ok-soft); color: var(--ok); }
.pill.block_prod { background: rgba(52, 211, 153, 0.1); color: #6ee7b7; }
.pill.justify_lower { background: rgba(245, 139, 63, 0.16); color: #f58b3f; }
.pill.exception { background: rgba(167, 139, 250, 0.16); color: #a78bfa; }
.pill.remediate { background: rgba(59, 130, 246, 0.16); color: #60a5fa; }
.pill.monitor { background: var(--warn-soft); color: var(--warn); }
.pill.process { background: var(--info-soft); color: var(--info); }

.pager {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 20px;
  padding-top: 4px;
}
.show-more {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.show-more:hover { background: var(--bg-active); border-color: var(--text-dim); }
.pager-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.empty {
  padding: 40px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .rail {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 92vw);
    z-index: 40;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
    transform: translateX(100%);
    transition: transform 0.2s ease;
  }
  .rail.detail-open,
  .rail.force-open {
    transform: translateX(0);
  }
  body.overflow { overflow: hidden; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .list-pane { padding: 8px 16px 32px; }
}
