:root {
	color-scheme: light;
	--bg: #f4f7f6;
	--surface: #ffffff;
	--surface-soft: #eef4f2;
	--sidebar: #102a27;
	--sidebar-soft: #183b36;
	--text: #182220;
	--muted: #64736f;
	--line: #d9e2df;
	--accent: #0d7668;
	--accent-strong: #085e54;
	--focus: #2d8cff;
	--ok: #176b42;
	--warning: #946200;
	--error: #b42318;
	--unknown: #59646b;
	--progress: #4f46a5;
	--shadow: 0 8px 26px rgba(16, 42, 39, 0.07);
}

* {
	box-sizing: border-box;
}

html {
	min-width: 320px;
	background: var(--bg);
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
	font: inherit;
}

a {
	color: var(--accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

a:hover {
	color: var(--accent-strong);
}

:focus-visible {
	outline: 3px solid var(--focus);
	outline-offset: 2px;
}

.skip-link {
	position: fixed;
	top: 8px;
	left: 8px;
	z-index: 100;
	transform: translateY(-150%);
	background: var(--surface);
	border-radius: 8px;
	padding: 9px 12px;
	box-shadow: var(--shadow);
}

.skip-link:focus {
	transform: translateY(0);
}

.app-shell {
	min-height: 100vh;
}

.sidebar {
	position: fixed;
	inset: 0 auto 0 0;
	z-index: 30;
	display: flex;
	width: 252px;
	flex-direction: column;
	background: var(--sidebar);
	color: #dce9e6;
}

.brand-block {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 76px;
	padding: 14px 18px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
	display: inline-flex;
	align-items: center;
	gap: 11px;
	color: #fff;
	text-decoration: none;
}

.brand:hover {
	color: #fff;
}

.brand-mark,
.login-brand {
	display: grid;
	width: 36px;
	height: 36px;
	place-items: center;
	border-radius: 10px;
	background: linear-gradient(145deg, #20a28f, #0b6b60);
	color: #fff;
	font-size: 18px;
	font-weight: 800;
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

.brand strong,
.brand small {
	display: block;
}

.brand strong {
	font-size: 16px;
	letter-spacing: 0.01em;
}

.brand small {
	color: #a9c1bc;
	font-size: 11px;
}

.main-nav {
	display: grid;
	gap: 5px;
	padding: 18px 12px;
}

.main-nav a {
	display: flex;
	align-items: center;
	min-height: 42px;
	padding: 9px 12px;
	border-radius: 9px;
	color: #c4d7d3;
	font-weight: 600;
	text-decoration: none;
}

.main-nav a:hover {
	background: rgba(255, 255, 255, 0.07);
	color: #fff;
}

.main-nav a.active {
	background: var(--sidebar-soft);
	box-shadow: inset 3px 0 #3ac0ab;
	color: #fff;
}

.sidebar-footer {
	display: grid;
	gap: 10px;
	margin-top: auto;
	padding: 18px;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	color: #9eb6b1;
}

.readonly-badge,
.environment-badge {
	display: inline-flex;
	width: fit-content;
	align-items: center;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 750;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.readonly-badge {
	border: 1px solid rgba(255, 255, 255, 0.18);
	padding: 4px 8px;
	color: #dce9e6;
}

.workspace {
	display: flex;
	min-height: 100vh;
	margin-left: 252px;
	flex-direction: column;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 20;
	display: flex;
	min-height: 68px;
	align-items: center;
	gap: 18px;
	padding: 10px 28px;
	border-bottom: 1px solid var(--line);
	background: rgba(255, 255, 255, 0.95);
	backdrop-filter: blur(10px);
}

.runtime-meta,
.user-menu {
	display: flex;
	align-items: center;
	gap: 10px;
}

.runtime-meta {
	color: var(--muted);
	font-size: 12px;
}

.environment-badge {
	padding: 4px 8px;
	background: #e4f4f0;
	color: var(--accent-strong);
}

.user-menu {
	margin-left: auto;
}

.username {
	max-width: 220px;
	overflow: hidden;
	font-weight: 650;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.user-menu form {
	margin: 0;
}

.button,
.icon-button {
	border: 0;
	cursor: pointer;
}

.button {
	display: inline-flex;
	min-height: 38px;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	padding: 8px 14px;
	font-weight: 700;
}

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

.button-primary:hover {
	background: var(--accent-strong);
}

.button-secondary {
	border: 1px solid var(--line);
	background: var(--surface);
	color: var(--text);
}

.button-secondary:hover {
	background: var(--surface-soft);
}

.quick-export-form {
	display: inline-flex;
	margin: 0 0 16px;
}

.page-action .quick-export-form {
	margin: 0;
}

.analysis-export-form {
	display: grid;
	max-width: 720px;
	gap: 14px;
}

.analysis-export-form label {
	display: grid;
	gap: 6px;
	font-weight: 650;
}

.analysis-export-form input,
.analysis-export-form select {
	min-height: 40px;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 8px 10px;
	background: var(--surface);
	color: var(--text);
}

.analysis-export-form .checkbox {
	display: flex;
	align-items: center;
}

.analysis-export-form .checkbox input {
	min-height: auto;
}

.icon-button {
	display: grid;
	width: 42px;
	height: 42px;
	place-items: center;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font-size: 22px;
}

.menu-button,
.sidebar-close,
.sidebar-overlay {
	display: none;
}

main {
	width: min(100%, 1500px);
	margin: 0 auto;
	padding: 30px 30px 48px;
	flex: 1;
}

.page-heading {
	margin-bottom: 22px;
}

.eyebrow {
	margin: 0 0 5px;
	color: var(--accent);
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}

h1,
h2,
h3 {
	line-height: 1.25;
}

h1 {
	margin: 0;
	font-size: clamp(24px, 3vw, 32px);
	font-weight: 780;
	letter-spacing: -0.02em;
}

h2 {
	margin: 0 0 14px;
	font-size: 17px;
}

h3 {
	margin: 0 0 12px;
	font-size: 15px;
}

.metric-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
	gap: 14px;
	margin-bottom: 18px;
}

.metric,
.panel {
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--surface);
	box-shadow: var(--shadow);
}

.metric {
	display: grid;
	min-height: 116px;
	align-content: start;
	gap: 9px;
	padding: 16px;
}

.metric-label {
	color: var(--muted);
	font-size: 11px;
	font-weight: 750;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.metric strong {
	font-size: 20px;
	overflow-wrap: anywhere;
}

.panel {
	margin-bottom: 18px;
	padding: 19px;
}

.json-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 18px;
	margin-bottom: 18px;
}

.json-grid .panel {
	margin-bottom: 0;
}

.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: 9px;
}

table {
	width: 100%;
	min-width: 760px;
	border-collapse: collapse;
	background: var(--surface);
}

.definition {
	min-width: 420px;
}

th,
td {
	padding: 10px 11px;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

th {
	background: #f6f9f8;
	color: var(--muted);
	font-size: 11px;
	font-weight: 750;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

td {
	overflow-wrap: anywhere;
}

tr:last-child th,
tr:last-child td {
	border-bottom: 0;
}

code,
pre {
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 12px;
	overflow-wrap: anywhere;
	white-space: pre-wrap;
}

pre {
	max-height: 420px;
	margin: 0;
	overflow: auto;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #f5f8f7;
	padding: 13px;
}

.status {
	display: inline-flex;
	align-items: center;
	border: 1px solid transparent;
	border-radius: 999px;
	padding: 3px 8px;
	font-size: 12px;
	font-weight: 700;
	white-space: nowrap;
}

.status-ok {
	border-color: #b8dfca;
	background: #e9f7ef;
	color: var(--ok);
}

.status-warning {
	border-color: #edd28f;
	background: #fff4d9;
	color: var(--warning);
}

.status-error {
	border-color: #efbbb4;
	background: #fdebea;
	color: var(--error);
}

.status-unknown {
	border-color: #d3dade;
	background: #edf0f2;
	color: var(--unknown);
}

.status-in_progress {
	border-color: #cfcbf4;
	background: #eeedfb;
	color: var(--progress);
}

.empty {
	margin: 0;
	border: 1px dashed var(--line);
	border-radius: 8px;
	padding: 14px;
	color: var(--muted);
}

.section-title {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 14px;
	flex-wrap: wrap;
}

.section-title h2 {
	margin: 0;
}

.section-title h3 {
	margin: 0;
}

.page-alerts {
	display: grid;
	gap: 10px;
	margin-bottom: 18px;
}

.page-alert {
	display: flex;
	align-items: flex-start;
	gap: 8px 14px;
	border: 1px solid var(--line);
	border-left-width: 4px;
	border-radius: 9px;
	background: var(--surface);
	padding: 12px 14px;
	flex-wrap: wrap;
}

.page-alert strong {
	font-weight: 780;
}

.page-alert span {
	color: var(--muted);
}

.page-alert-ok {
	border-left-color: var(--ok);
}

.page-alert-warning {
	border-left-color: var(--warning);
}

.page-alert-error {
	border-left-color: var(--error);
}

.page-alert-panel {
	border-left: 4px solid var(--warning);
}

.admin-tabs {
	min-width: 0;
}

.admin-tab-list {
	display: flex;
	max-width: 100%;
	gap: 5px;
	margin-bottom: 14px;
	overflow-x: auto;
	border-bottom: 1px solid var(--line);
	padding: 0 2px 7px;
	scrollbar-width: thin;
}

.admin-tab {
	display: inline-flex;
	min-height: 44px;
	align-items: center;
	gap: 8px;
	border: 1px solid transparent;
	border-radius: 9px;
	background: transparent;
	padding: 9px 13px;
	color: var(--muted);
	cursor: pointer;
	font-weight: 720;
	white-space: nowrap;
}

.admin-tab:hover {
	background: var(--surface-soft);
	color: var(--text);
}

.admin-tab[aria-selected="true"] {
	border-color: var(--line);
	background: var(--surface);
	box-shadow: 0 3px 12px rgba(16, 42, 39, 0.07);
	color: var(--accent-strong);
}

.admin-tab-badge {
	display: inline-grid;
	min-width: 23px;
	height: 23px;
	place-items: center;
	border-radius: 999px;
	background: var(--surface-soft);
	padding: 0 6px;
	color: var(--muted);
	font-size: 11px;
}

.admin-tab[aria-selected="true"] .admin-tab-badge {
	background: #e4f4f0;
	color: var(--accent-strong);
}

.admin-tab-panel {
	min-width: 0;
}

.admin-tabs.is-enhanced .admin-tab-panel[hidden] {
	display: none;
}

.panel-subsection + .panel-subsection {
	margin-top: 22px;
	border-top: 1px solid var(--line);
	padding-top: 20px;
}

.architecture-graph-description {
	max-width: 900px;
	margin: 0 0 12px;
	color: var(--muted);
}

.architecture-graph-meta {
	display: flex;
	align-items: center;
	gap: 8px 12px;
	margin-bottom: 14px;
	color: var(--muted);
	flex-wrap: wrap;
}

.architecture-graph {
	min-width: 0;
}

.architecture-graph-canvas {
	min-height: 280px;
	max-width: 100%;
	overflow: auto;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--surface-soft);
	padding: 10px;
	overscroll-behavior-inline: contain;
}

.architecture-graph-placeholder {
	margin: 0;
	border: 1px dashed var(--line);
	border-radius: 8px;
	background: var(--surface);
	padding: 14px;
	color: var(--muted);
}

.architecture-graph-svg {
	display: block;
	max-width: none;
}

.architecture-group rect {
	fill: rgba(255, 255, 255, 0.55);
	stroke: #b9c8c4;
	stroke-dasharray: 6 5;
}

.architecture-group[data-group-type="application"] rect,
.architecture-group[data-group-type="runtime"] rect,
.architecture-group[data-group-type="agent"] rect {
	fill: rgba(228, 244, 240, 0.7);
	stroke: var(--accent);
}

.architecture-group[data-group-type="database"] rect,
.architecture-group[data-group-type="data"] rect {
	fill: rgba(238, 237, 251, 0.75);
	stroke: var(--progress);
}

.architecture-group[data-group-type="approval"] rect,
.architecture-group[data-group-type="safety"] rect {
	fill: rgba(255, 244, 217, 0.72);
	stroke: var(--warning);
}

.architecture-group > text {
	fill: var(--muted);
	font-size: 12px;
	font-weight: 750;
}

.architecture-edge path {
	fill: none;
	stroke: #71817d;
	stroke-width: 1.6;
}

.architecture-edge text {
	fill: var(--muted);
	font-size: 9px;
	font-weight: 650;
	paint-order: stroke;
	stroke: var(--surface-soft);
	stroke-width: 4px;
	stroke-linejoin: round;
	text-anchor: middle;
}

.architecture-graph-svg marker path {
	fill: #71817d;
}

.architecture-node rect {
	fill: var(--surface);
	stroke: #9fb0ac;
	stroke-width: 1.5;
}

.architecture-node text {
	fill: var(--text);
	font-size: 12px;
	font-weight: 720;
}

.architecture-node[data-node-type="database"] rect,
.architecture-node[data-node-type="entity"] rect {
	fill: #eeedfb;
	stroke: var(--progress);
}

.architecture-node[data-node-type="agent"] rect,
.architecture-node[data-node-type="service"] rect,
.architecture-node[data-node-type="worker"] rect,
.architecture-node[data-node-type="ai_gateway"] rect {
	fill: #e9f7ef;
	stroke: var(--ok);
}

.architecture-node[data-node-type="approval"] rect,
.architecture-node[data-node-type="human"] rect,
.architecture-node[data-node-type="proposal"] rect {
	fill: #fff4d9;
	stroke: var(--warning);
}

.architecture-node[data-node-type="external_provider"] rect,
.architecture-node[data-node-type="external_source"] rect {
	stroke-dasharray: 5 4;
}

.architecture-text-alternative {
	margin-top: 14px;
	border: 1px solid var(--line);
	border-radius: 9px;
	background: var(--surface);
	padding: 10px 12px;
}

.architecture-text-alternative summary {
	cursor: pointer;
	font-weight: 720;
}

.architecture-text-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 20px;
	margin-top: 16px;
}

.architecture-text-grid ul {
	margin: 0;
	padding-left: 20px;
}

.architecture-text-grid li + li {
	margin-top: 7px;
}

.architecture-source .section-title {
	margin-bottom: 12px;
}

footer {
	border-top: 1px solid var(--line);
	padding: 16px 28px;
	color: var(--muted);
	font-size: 12px;
	text-align: center;
}

.login-page {
	background:
		radial-gradient(circle at 18% 12%, rgba(39, 168, 149, 0.16), transparent 32%),
		linear-gradient(145deg, #eef6f4, #f8faf9 55%, #e8f1ef);
}

.login-shell {
	display: grid;
	min-height: 100vh;
	width: 100%;
	place-items: center;
	padding: 24px;
}

.login-card {
	width: min(100%, 430px);
	border: 1px solid rgba(13, 118, 104, 0.18);
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.96);
	padding: clamp(24px, 6vw, 38px);
	box-shadow: 0 24px 65px rgba(16, 42, 39, 0.15);
}

.login-brand {
	width: 44px;
	height: 44px;
	margin-bottom: 20px;
	font-size: 22px;
}

.login-card h1 {
	margin-bottom: 22px;
}

.login-form {
	display: grid;
	gap: 9px;
}

.login-form label {
	margin-top: 6px;
	font-weight: 700;
}

.login-form input {
	width: 100%;
	height: 44px;
	border: 1px solid #b9c8c4;
	border-radius: 9px;
	background: #fff;
	padding: 9px 11px;
	color: var(--text);
}

.login-form input:focus {
	border-color: var(--focus);
	box-shadow: 0 0 0 3px rgba(45, 140, 255, 0.15);
	outline: 0;
}

.login-form .button {
	margin-top: 12px;
}

.form-error {
	margin: 0 0 15px;
	border: 1px solid #efbbb4;
	border-radius: 9px;
	background: #fdebea;
	padding: 11px 12px;
	color: var(--error);
}

@media (max-width: 840px) {
	body.nav-open {
		overflow: hidden;
	}

	.sidebar {
		width: min(82vw, 290px);
		transform: translateX(-105%);
		transition: transform 180ms ease;
		box-shadow: 18px 0 46px rgba(0, 0, 0, 0.24);
	}

	.nav-open .sidebar {
		transform: translateX(0);
	}

	.sidebar-close,
	.menu-button {
		display: grid;
	}

	.sidebar-overlay {
		position: fixed;
		inset: 0;
		z-index: 25;
		width: 100%;
		height: 100%;
		background: rgba(5, 18, 16, 0.52);
		opacity: 0;
		pointer-events: none;
		transition: opacity 180ms ease;
	}

	.nav-open .sidebar-overlay {
		display: block;
		opacity: 1;
		pointer-events: auto;
	}

	.workspace {
		margin-left: 0;
	}

	.topbar {
		padding: 9px 14px;
	}

	.runtime-meta span:not(.environment-badge),
	.username {
		display: none;
	}

	main {
		padding: 24px 14px 36px;
	}

	.panel {
		padding: 14px;
	}

	footer {
		padding-inline: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}
}
