:root {
	color-scheme: light;
	--bg: #f6f7f9;
	--surface: #ffffff;
	--surface-2: #fafbfc;
	--border: #e5e7eb;
	--border-strong: #d1d5db;
	--text: #0f172a;
	--muted: #64748b;
	--muted-2: #94a3b8;
	--accent: #0e0e10;
	--accent-hover: #1f1f23;
	--success: #10b981;
	--success-soft: #d1fae5;
	--success-ink: #065f46;
	--danger: #ef4444;
	--danger-soft: #fee2e2;
	--danger-ink: #991b1b;
	--warn: #f59e0b;
	--warn-soft: #fef3c7;
	--warn-ink: #92400e;
	--sidebar-bg: #0e0e10;
	--sidebar-ink: #e5e7eb;
	--sidebar-muted: #9ca3af;
	--sidebar-hover: rgba(255, 255, 255, 0.06);
	--sidebar-active: rgba(255, 255, 255, 0.1);
	--sidebar-line: rgba(255, 255, 255, 0.08);
	--sans:
		Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
		'Segoe UI', sans-serif;
	--mono:
		'SFMono-Regular', Consolas, 'Cascadia Code', 'JetBrains Mono', monospace;
	--radius: 14px;
	--radius-sm: 10px;
	--radius-xs: 8px;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-width: 320px;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p {
	margin: 0;
}

/* ------ APP SHELL ------ */

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

.sidebar {
	width: 240px;
	flex-shrink: 0;
	background: var(--sidebar-bg);
	color: var(--sidebar-ink);
	display: flex;
	flex-direction: column;
	padding: 22px 14px 18px;
	position: sticky;
	top: 0;
	height: 100vh;
	z-index: 30;
}

.sidebar-brand {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 4px 10px 20px;
	border-bottom: 1px solid var(--sidebar-line);
}

.brand-mark {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	background:
		radial-gradient(circle at 30% 30%, #b9f227, transparent 60%),
		linear-gradient(135deg, #10b981, #6366f1);
	box-shadow: 0 0 0 2px rgba(185, 242, 39, 0.15) inset;
	flex-shrink: 0;
}

.brand-name {
	font-weight: 600;
	font-size: 14px;
	color: #ffffff;
	letter-spacing: -0.01em;
}

.brand-sub {
	margin-top: 2px;
	color: var(--sidebar-muted);
	font-size: 11px;
	font-family: var(--mono);
	letter-spacing: 0.04em;
}

.sidebar-nav {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding-top: 16px;
}

.nav-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: var(--radius-xs);
	color: var(--sidebar-muted);
	text-decoration: none;
	font-weight: 500;
	font-size: 13px;
	transition:
		color 0.15s ease,
		background 0.15s ease;
}

.nav-item:hover {
	background: var(--sidebar-hover);
	color: #ffffff;
}

.nav-item.active {
	background: var(--sidebar-active);
	color: #ffffff;
}

.nav-item svg {
	width: 18px;
	height: 18px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
	flex-shrink: 0;
}

.sidebar-footer {
	margin-top: auto;
	padding-top: 14px;
	border-top: 1px solid var(--sidebar-line);
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.sidebar-user {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: var(--radius-xs);
	color: var(--sidebar-ink);
	text-decoration: none;
	transition: background 0.15s ease;
}

.sidebar-user:hover {
	background: var(--sidebar-hover);
}

.user-avatar {
	width: 30px;
	height: 30px;
	border-radius: 8px;
	background: linear-gradient(135deg, #b9f227, #10b981);
	color: #0e0e10;
	font-weight: 700;
	display: grid;
	place-items: center;
	font-size: 13px;
	flex-shrink: 0;
}

.user-name {
	display: block;
	font-weight: 600;
	font-size: 13px;
	line-height: 1.2;
	color: #ffffff;
}

.user-role {
	display: block;
	color: var(--sidebar-muted);
	font-size: 11px;
	font-family: var(--mono);
	margin-top: 2px;
}

.sidebar-logout {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 10px 12px;
	border-radius: var(--radius-xs);
	background: transparent;
	border: 0;
	color: var(--sidebar-muted);
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	text-align: left;
	cursor: pointer;
	transition:
		background 0.15s ease,
		color 0.15s ease;
}

.sidebar-logout:hover {
	background: var(--sidebar-hover);
	color: #ffffff;
}

.sidebar-logout svg {
	width: 18px;
	height: 18px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.6;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* ------ CONTENT PANEL ------ */

.content-panel {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	background: var(--bg);
}

.topbar {
	padding: 20px 32px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	position: sticky;
	top: 0;
	z-index: 10;
}

.topbar-left {
	min-width: 0;
}

.page-eyebrow {
	color: var(--muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-family: var(--mono);
}

.page-title {
	margin-top: 4px;
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--text);
}

.page-subtitle {
	margin-top: 4px;
	color: var(--muted);
	font-size: 13px;
}

.topbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.workspace-main {
	padding: 24px 32px 40px;
	flex: 1;
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 20px;
}

.workspace-main > * { margin: 0; }

.app-footer {
	padding: 20px 32px;
	color: var(--muted-2);
	border-top: 1px solid var(--border);
	text-align: center;
	font-size: 11px;
	font-family: var(--mono);
	letter-spacing: 0.04em;
	background: var(--surface);
}

.notice {
	padding: 12px 16px;
	background: var(--warn-soft);
	border: 1px solid #fde68a;
	color: var(--warn-ink);
	border-radius: var(--radius-sm);
	font-size: 13px;
}

/* ------ BUTTONS / CHIPS ------ */

.button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border: 1px solid var(--border);
	background: var(--surface);
	border-radius: var(--radius-xs);
	color: var(--text);
	font-family: inherit;
	font-weight: 600;
	font-size: 13px;
	cursor: pointer;
	text-decoration: none;
	transition:
		background 0.15s ease,
		border-color 0.15s ease,
		transform 0.15s ease;
	white-space: nowrap;
}

.button:hover {
	background: #f3f4f6;
	border-color: var(--border-strong);
}

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

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

.button-danger {
	background: var(--danger-soft);
	border-color: #fca5a5;
	color: var(--danger-ink);
}

.button-danger:hover {
	background: #fecaca;
}

.status-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border-radius: 999px;
	font-weight: 600;
	font-size: 12px;
	background: #f3f4f6;
	color: #374151;
	border: 1px solid var(--border);
	white-space: nowrap;
}

.status-chip.live {
	background: var(--success-soft);
	color: var(--success-ink);
	border-color: transparent;
}

.status-chip.paused {
	background: #f3f4f6;
	color: #374151;
}

.status-chip.danger {
	background: var(--danger-soft);
	color: var(--danger-ink);
	border-color: transparent;
}

.status-chip.neutral {
	background: #f3f4f6;
	color: var(--muted);
	border-color: var(--border);
}

.status-chip .dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.status-chip.paused .dot,
.status-chip.neutral .dot {
	box-shadow: none;
}

.status-chip.danger .dot {
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.code {
	display: inline-flex;
	align-items: center;
	padding: 4px 8px;
	border-radius: 6px;
	background: #f3f4f6;
	color: var(--muted);
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.code.ok {
	background: var(--success-soft);
	color: var(--success-ink);
}

.code.bad {
	background: var(--danger-soft);
	color: var(--danger-ink);
}

/* ------ METRIC CARDS ------ */

.metric-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 16px;
}

.metric-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px;
	display: flex;
	flex-direction: column;
	min-height: 140px;
}

.metric-card.hero {
	background:
		linear-gradient(140deg, rgba(16, 185, 129, 0.08), transparent 60%),
		var(--surface);
	border-color: rgba(16, 185, 129, 0.25);
}

.metric-label {
	display: block;
	color: var(--muted);
	font-size: 12px;
	font-weight: 600;
	margin-bottom: 10px;
	letter-spacing: 0.02em;
}

.metric-value {
	font-size: 26px;
	font-weight: 700;
	letter-spacing: -0.03em;
	color: var(--text);
	line-height: 1.1;
}

.metric-value small {
	color: var(--muted);
	font-size: 14px;
	font-weight: 500;
	margin-left: 4px;
}

.metric-note {
	margin-top: 12px;
	color: var(--muted);
	font-size: 12px;
}

.positive {
	color: var(--success) !important;
}
.negative {
	color: var(--danger) !important;
}

/* ------ CARDS ------ */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 22px;
	display: flex;
	flex-direction: column;
	min-height: 320px;
}

.card > .card-heading { flex: 0 0 auto; }

.card > .cycles-list,
.card > .table-wrap { flex: 1; }

.card-heading {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 18px;
}

.card-kicker {
	color: var(--muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	font-family: var(--mono);
	margin-bottom: 4px;
}

.card-title {
	font-size: 16px;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--text);
}

.card-copy {
	color: var(--text);
	font-size: 13px;
	line-height: 1.6;
	margin-top: 8px;
}

.two-col {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 20px;
	align-items: stretch;
}

.section-split {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
	gap: 20px;
	align-items: stretch;
}

.muted {
	color: var(--muted);
}

/* ------ POSITION ------ */

.position-title {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 16px;
}

.position-title strong {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.side {
	display: inline-flex;
	padding: 4px 10px;
	border-radius: 6px;
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
}

.side.long {
	background: var(--success-soft);
	color: var(--success-ink);
}
.side.short {
	background: var(--danger-soft);
	color: var(--danger-ink);
}

.position-data {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin: 0;
}

.position-data > div {
	padding: 12px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
}

.position-data dt {
	color: var(--muted);
	font-size: 11px;
	margin-bottom: 4px;
	font-weight: 500;
}

.position-data dd {
	margin: 0;
	font-family: var(--mono);
	font-size: 13px;
	font-weight: 600;
	color: var(--text);
}

.position-panel {
	min-height: 260px;
}

.position-panel + article .card-heading {
	margin-bottom: 12px;
}

.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 24px 16px;
	color: var(--muted);
	text-align: center;
	flex: 1;
}

.pulse-ring {
	width: 32px;
	height: 32px;
	border: 2px solid var(--success);
	border-radius: 50%;
	box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.1);
}

.cycle-summary {
	color: var(--text);
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.6;
	padding: 12px 14px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	margin-bottom: 14px;
	overflow-wrap: anywhere;
}

details {
	border-top: 1px solid var(--border);
	padding-top: 14px;
	margin-top: 14px;
}

summary {
	color: var(--muted);
	font-size: 12px;
	cursor: pointer;
	font-weight: 500;
}

summary:hover {
	color: var(--text);
}

pre {
	max-height: 260px;
	overflow: auto;
	margin: 12px 0 0;
	padding: 14px;
	background: #0e0e10;
	color: #e5e7eb;
	border-radius: var(--radius-xs);
	font-family: var(--mono);
	font-size: 11px;
	line-height: 1.6;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* ------ CYCLES LIST ------ */

.cycles-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.cycles-list li {
	display: grid;
	grid-template-columns: 130px 60px 1fr;
	gap: 12px;
	align-items: center;
	padding: 10px 12px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	font-size: 12px;
}

.cycles-list time {
	color: var(--muted);
	font-family: var(--mono);
	font-size: 11px;
}

.cycles-list .cycle-text {
	color: var(--text);
	font-family: var(--mono);
	font-size: 12px;
	overflow-wrap: anywhere;
}

.cycles-list li.muted {
	display: block;
	text-align: center;
	color: var(--muted);
	background: transparent;
	border: 1px dashed var(--border);
}

/* ------ TABLES ------ */

.table-card {
	padding: 0;
	overflow: hidden;
}

.table-card .card-heading {
	padding: 22px 22px 0;
	margin-bottom: 16px;
}

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

.data-table {
	width: 100%;
	border-collapse: collapse;
	min-width: 900px;
}

.data-table th {
	padding: 12px 20px;
	text-align: left;
	background: var(--surface-2);
	color: var(--muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	border-top: 1px solid var(--border);
	border-bottom: 1px solid var(--border);
}

.data-table td {
	padding: 14px 20px;
	border-bottom: 1px solid var(--border);
	font-size: 13px;
}

.data-table tbody tr:last-child td {
	border-bottom: 0;
}

.data-table tbody tr:hover {
	background: var(--surface-2);
}

.right {
	text-align: right;
}
.mono {
	font-family: var(--mono);
}
.nowrap {
	white-space: nowrap;
}

.empty-row {
	padding: 40px !important;
	text-align: center;
	color: var(--muted);
}

/* ------ SETTINGS FORM ------ */

.settings-form fieldset {
	margin: 0 0 20px;
	padding: 16px 18px 18px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
}

.settings-form legend {
	padding: 0 6px;
	color: var(--muted);
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.form-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(150px, 1fr));
	gap: 14px;
}

.form-grid label {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.form-grid label > span:first-child {
	color: var(--text);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.4;
}

.input-wrap {
	display: flex;
	align-items: center;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}

.input-wrap:focus-within {
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(14, 14, 16, 0.06);
}

.input-wrap input[type='number'] {
	width: 100%;
	border: 0;
	outline: 0;
	padding: 10px 12px;
	background: transparent;
	color: var(--text);
	font-family: var(--mono);
	font-size: 13px;
	font-weight: 600;
}

.input-wrap em {
	padding-right: 12px;
	color: var(--muted);
	font-style: normal;
	font-size: 12px;
	font-family: var(--mono);
}

.form-actions {
	display: flex;
	justify-content: flex-end;
	margin-top: 4px;
}

.danger-card {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.danger-card .card-copy strong {
	font-weight: 700;
}
.danger-card .muted {
	font-size: 12px;
}
.danger-card .button {
	align-self: flex-start;
	width: 100%;
	margin-top: 8px;
	text-align: center;
	justify-content: center;
}

/* ------ AUTH ------ */

.auth-body {
	min-height: 100vh;
	background: linear-gradient(160deg, #eef1f4 0%, #f6f7f9 55%);
	display: grid;
	place-items: center;
	padding: 40px 16px;
}

.auth-shell {
	width: min(100%, 460px);
}

.auth-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: clamp(28px, 5vw, 40px);
	box-shadow: 0 30px 80px -30px rgba(15, 23, 42, 0.15);
}

.auth-brand {
	display: flex;
	align-items: center;
	gap: 14px;
	margin-bottom: 20px;
}

.auth-brand .brand-mark {
	width: 40px;
	height: 40px;
	border-radius: 12px;
}

.auth-brand h1 {
	font-size: 24px;
	font-weight: 700;
	letter-spacing: -0.02em;
	color: var(--text);
}

.auth-brand .eyebrow {
	color: var(--muted);
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.auth-copy {
	color: var(--muted);
	font-size: 14px;
	line-height: 1.55;
	margin-bottom: 22px;
}

.auth-form {
	display: grid;
	gap: 14px;
}

.auth-form label {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.auth-form label > span:first-child {
	font-size: 13px;
	font-weight: 500;
	color: var(--text);
}

.auth-form input {
	width: 100%;
	border: 1px solid var(--border);
	border-radius: var(--radius-xs);
	padding: 12px 14px;
	color: var(--text);
	background: var(--surface);
	font-family: inherit;
	font-size: 14px;
	transition:
		border-color 0.15s ease,
		box-shadow 0.15s ease;
}

.auth-form input:focus {
	outline: 0;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(14, 14, 16, 0.06);
}

.auth-form .button {
	margin-top: 4px;
	min-height: 44px;
	justify-content: center;
	width: 100%;
}

.auth-hint {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--border);
	color: var(--muted);
	font-family: var(--mono);
	font-size: 11px;
	letter-spacing: 0.04em;
}

.auth-back {
	display: inline-block;
	margin-top: 18px;
	color: var(--accent);
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
}

.auth-back:hover {
	text-decoration: underline;
}

.auth-logout {
	margin-top: 14px;
}
.auth-logout .button {
	width: 100%;
	justify-content: center;
}

.account-card {
	margin: 0 auto;
}

/* ------ RESPONSIVE ------ */

@media (max-width: 1180px) {
	.metric-grid {
		grid-template-columns: repeat(2, 1fr);
	}
	.section-split {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 900px) {
	.app-shell {
		flex-direction: column;
	}
	.sidebar {
		width: 100%;
		height: auto;
		position: sticky;
		top: 0;
		flex-direction: row;
		align-items: center;
		flex-wrap: wrap;
		gap: 12px;
		padding: 12px 16px;
	}
	.sidebar-brand {
		padding: 0;
		border: 0;
	}
	.sidebar-nav {
		flex-direction: row;
		flex-wrap: wrap;
		padding: 0;
		margin-left: auto;
		gap: 4px;
	}
	.sidebar-footer {
		margin: 0;
		padding: 0;
		border: 0;
		flex-direction: row;
		align-items: center;
		gap: 8px;
	}
	.sidebar-logout {
		padding: 8px 10px;
	}
	.two-col {
		grid-template-columns: 1fr;
	}
	.position-data {
		grid-template-columns: 1fr 1fr;
	}
	.form-grid {
		grid-template-columns: 1fr 1fr;
	}
	.topbar {
		padding: 16px 20px;
		flex-wrap: wrap;
	}
	.workspace-main {
		padding: 20px 20px 32px;
	}
}

@media (max-width: 560px) {
	.metric-grid {
		grid-template-columns: 1fr;
	}
	.position-data,
	.form-grid {
		grid-template-columns: 1fr;
	}
	.cycles-list li {
		grid-template-columns: 1fr;
		gap: 4px;
	}
	.topbar-right {
		width: 100%;
		justify-content: space-between;
	}
}
