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

:root {
	/* Page backgrounds */
	--bg: #f1f3f8;
	--surface: #ffffff;
	--surface-2: #f6f8fc;
	--surface-3: #edf0f7;

	/* Borders */
	--border: #e4e8f0;
	--border-2: #d0d7e8;

	/* Text */
	--text: #1a1d2e;
	--text-muted: #8b95b0;
	--text-secondary: #5a6280;

	/* Primary */
	--primary: #004838;
	--primary-hover: #003629;
	--primary-light: rgba(0, 72, 56, 0.08);
	--primary-border: rgba(0, 72, 56, 0.2);

	/* Status */
	--success: #059669;
	--success-light: rgba(5, 150, 105, 0.08);
	--success-border: rgba(5, 150, 105, 0.2);
	--error: #dc2626;
	--error-light: rgba(220, 38, 38, 0.08);
	--warning: #d97706;
	--warning-light: rgba(217, 119, 6, 0.08);
	--warning-border: rgba(217, 119, 6, 0.2);

	/* Sidebar (always dark) */
	--sb-bg: #004838;
	--sb-surface: #005c47;
	--sb-border: #003629;
	--sb-text: #8fb3a8;
	--sb-text-hover: #c8dbd3;
	--sb-text-active: #e8f0ec;

	/* Misc */
	--radius: 8px;
	--radius-sm: 5px;
	--radius-lg: 12px;
	--shadow: 0 2px 12px rgba(26, 29, 46, 0.1);
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
	--mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
	--sidebar-w: 248px;
}

html,
body {
	height: 100%;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
}
a {
	color: var(--primary);
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
}
.hidden {
	display: none !important;
}

/* ── TOASTS ── */
#toasts {
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	gap: 8px;
	pointer-events: none;
}
.toast {
	padding: 11px 16px;
	border-radius: var(--radius);
	font-size: 13px;
	font-weight: 500;
	max-width: 340px;
	pointer-events: all;
	display: flex;
	align-items: center;
	gap: 8px;
	animation: toastIn 0.2s ease;
}
.toast-success {
	background: #fff;
	border: 1px solid var(--success-border);
	color: var(--success);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.toast-error {
	background: #fff;
	border: 1px solid rgba(220, 38, 38, 0.3);
	color: var(--error);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
.toast-info {
	background: #fff;
	border: 1px solid var(--border-2);
	color: var(--text-secondary);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}
@keyframes toastIn {
	from {
		transform: translateX(32px);
		opacity: 0;
	}
	to {
		transform: none;
		opacity: 1;
	}
}

/* ── FORMS ── */
.form-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
}
label {
	font-size: 13px;
	font-weight: 500;
	color: var(--text-secondary);
}
input[type="text"],
input[type="email"],
input[type="password"],
select {
	background: var(--surface-2);
	border: 1px solid var(--border-2);
	border-radius: var(--radius);
	color: var(--text);
	font-family: var(--font);
	font-size: 14px;
	padding: 10px 12px;
	width: 100%;
	outline: none;
	transition: border-color 0.15s;
}
input:focus,
select:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-light);
}
input::placeholder {
	color: var(--text-muted);
}
.form-hint {
	font-size: 12px;
	color: var(--text-muted);
}
.form-error {
	font-size: 12px;
	color: var(--error);
	padding: 8px 10px;
	background: var(--error-light);
	border-radius: var(--radius-sm);
	border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── BUTTONS ── */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 16px;
	border-radius: var(--radius);
	font-family: var(--font);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	border: none;
	transition:
		background 0.15s,
		opacity 0.15s;
	white-space: nowrap;
}
.btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.btn-primary {
	background: var(--primary);
	color: #e2fb63;
}
.btn-primary:hover:not(:disabled) {
	background: var(--primary-hover);
}
.btn-ghost {
	background: transparent;
	color: var(--text-secondary);
	border: 1px solid var(--border-2);
}
.btn-ghost:hover:not(:disabled) {
	background: var(--surface-3);
	color: var(--text);
}
.btn-danger {
	background: transparent;
	color: var(--error);
	border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) {
	background: var(--error-light);
}
.btn-sm {
	padding: 5px 10px;
	font-size: 12px;
}
.btn-block {
	width: 100%;
}

/* ── BADGES ── */
.badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: 100px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}
.badge-sandbox {
	background: var(--warning-light);
	color: var(--warning);
	border: 1px solid var(--warning-border);
}
.badge-production {
	background: var(--success-light);
	color: var(--success);
	border: 1px solid var(--success-border);
}
.badge-active {
	background: var(--success-light);
	color: var(--success);
	border: 1px solid var(--success-border);
}
.badge-revoked {
	background: var(--error-light);
	color: var(--error);
	border: 1px solid rgba(239, 68, 68, 0.2);
}
.scope-tag {
	background: var(--primary-light);
	color: var(--primary);
	border: 1px solid var(--primary-border);
	padding: 2px 7px;
	border-radius: 4px;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.04em;
	font-family: var(--mono);
}

/* ── SPINNER ── */
.spinner {
	display: inline-block;
	width: 13px;
	height: 13px;
	border: 2px solid var(--primary-border);
	border-top-color: var(--primary);
	border-radius: 50%;
	animation: spin 0.65s linear infinite;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ── AUTH VIEWS ── */
.auth-view {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}
.auth-card {
	width: 100%;
	max-width: 400px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 32px;
	display: flex;
	flex-direction: column;
	gap: 24px;
}
.auth-brand {
	display: flex;
	align-items: center;
	gap: 10px;
}
.brand-icon {
	width: 34px;
	height: 34px;
	flex-shrink: 0;
	object-fit: contain;
	display: block;
}
.brand-name {
	font-weight: 700;
	font-size: 15px;
}
.brand-sub {
	font-size: 10px;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.08em;
}
.auth-heading h2 {
	font-size: 20px;
	font-weight: 700;
}
.auth-heading p {
	font-size: 14px;
	color: var(--text-muted);
	margin-top: 4px;
}
.auth-form {
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.auth-footer {
	text-align: center;
	font-size: 13px;
	color: var(--text-muted);
}
.back-btn {
	background: none;
	border: none;
	color: var(--text-secondary);
	font-size: 13px;
	cursor: pointer;
	font-family: var(--font);
	padding: 0;
	display: inline-flex;
	align-items: center;
	gap: 5px;
}
.back-btn:hover {
	color: var(--text);
}

/* ── LANDING ── */
.landing {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}
.landing-nav {
	padding: 14px 40px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	border-bottom: 1px solid var(--border);
}
.landing-hero {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 72px 40px 48px;
	text-align: center;
}
.pill {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--primary);
	background: var(--primary-light);
	border: 1px solid var(--primary-border);
	padding: 3px 12px;
	border-radius: 100px;
	margin-bottom: 20px;
}
.landing-title {
	font-size: 52px;
	font-weight: 800;
	line-height: 1.1;
	max-width: 680px;
	margin-bottom: 16px;
	letter-spacing: -0.02em;
}
.landing-title span {
	color: var(--primary);
}
.landing-desc {
	font-size: 16px;
	color: var(--text-muted);
	max-width: 480px;
	margin-bottom: 32px;
	line-height: 1.7;
}
.landing-cta {
	display: flex;
	gap: 10px;
	justify-content: center;
	flex-wrap: wrap;
}
.landing-cta .btn {
	padding: 11px 22px;
	font-size: 14px;
}
.feature-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 14px;
	padding: 0 40px 60px;
	max-width: 960px;
	margin: 0 auto;
	width: 100%;
}
.feature-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 20px;
}
.feature-icon {
	font-size: 22px;
	margin-bottom: 10px;
}
.feature-title {
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 5px;
}
.feature-desc {
	font-size: 12px;
	color: var(--text-muted);
	line-height: 1.55;
}

/* ── APP SHELL ── */
.app-shell {
	display: flex;
	height: 100vh;
	overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
	width: var(--sidebar-w);
	min-width: var(--sidebar-w);
	background: var(--sb-bg);
	border-right: 1px solid var(--sb-border);
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}
.sidebar-top {
	padding: 16px;
	background: #ffffff;
	border-bottom: 1px solid var(--sb-border);
	display: flex;
	align-items: center;
	gap: 9px;
}
.sidebar-brand-text .name {
	font-weight: 700;
	font-size: 14px;
	line-height: 1.2;
	color: var(--text);
}
.sidebar-brand-text .sub {
	font-size: 10px;
	color: var(--text-secondary);
	text-transform: uppercase;
	letter-spacing: 0.07em;
}
.sidebar-nav {
	flex: 1;
	padding: 8px 0;
}
.nav-label {
	padding: 10px 16px 4px;
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	color: var(--sb-text);
}
.nav-item {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 8px 14px;
	font-size: 13px;
	color: var(--sb-text);
	cursor: pointer;
	border: none;
	background: none;
	width: 100%;
	font-family: var(--font);
	text-align: left;
	border-radius: 6px;
	margin: 0 4px;
	width: calc(100% - 8px);
	transition:
		background 0.1s,
		color 0.1s;
}
.nav-item:hover {
	background: rgba(255, 255, 255, 0.07);
	color: var(--sb-text-hover);
}
.nav-item.active {
	background: rgba(255, 255, 255, 0.12);
	color: var(--sb-text-active);
}
.nav-item svg {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}
.sidebar-footer {
	padding: 12px;
	border-top: 1px solid var(--sb-border);
}
.sidebar-footer .btn-ghost {
	color: var(--sb-text);
	border-color: var(--sb-border);
}
.sidebar-footer .btn-ghost:hover {
	background: rgba(255, 255, 255, 0.07);
	color: var(--sb-text-hover);
}
.account-row {
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 8px;
	border-radius: var(--radius);
	margin-bottom: 6px;
}
.avatar {
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: var(--primary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
	color: #fff;
	flex-shrink: 0;
}
.account-name {
	font-size: 13px;
	font-weight: 600;
	color: var(--sb-text-active);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.account-email {
	font-size: 11px;
	color: var(--sb-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ── MAIN ── */
.main {
	flex: 1;
	overflow-y: auto;
	background: var(--bg);
}
.page-header {
	padding: 28px 32px 0;
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
}
.page-title {
	font-size: 22px;
	font-weight: 700;
	letter-spacing: -0.01em;
}
.page-subtitle {
	font-size: 13px;
	color: var(--text-muted);
	margin-top: 3px;
}
.page-body {
	padding: 20px 32px 40px;
}

/* ── BANNER ── */
.banner {
	margin: 16px 32px 0;
	padding: 12px 16px;
	border-radius: var(--radius);
	font-size: 13px;
	display: flex;
	align-items: center;
	gap: 8px;
}
.banner-warning {
	background: var(--warning-light);
	border: 1px solid var(--warning-border);
	color: var(--warning);
}

/* ── EMPTY STATE ── */
.empty {
	text-align: center;
	padding: 72px 24px;
}
.empty-icon {
	font-size: 36px;
	margin-bottom: 12px;
}
.empty-title {
	font-size: 16px;
	font-weight: 600;
	color: var(--text-secondary);
	margin-bottom: 6px;
}
.empty-desc {
	font-size: 13px;
	color: var(--text-muted);
	margin-bottom: 20px;
}

/* ── KEY CARD ── */
.key-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 20px;
	margin-bottom: 10px;
	transition: border-color 0.15s;
}
.key-card:hover {
	border-color: var(--border-2);
}
.key-card.is-revoked {
	opacity: 0.55;
}
.kc-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}
.kc-label {
	font-size: 15px;
	font-weight: 600;
}
.kc-meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 5px;
}
.kc-date {
	font-size: 12px;
	color: var(--text-muted);
}
.kc-actions {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}
.key-row {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 8px 12px;
	margin-bottom: 12px;
}
.key-prefix {
	font-family: var(--mono);
	font-size: 12px;
	color: var(--text-secondary);
	flex: 1;
}
.copy-btn {
	background: none;
	border: none;
	cursor: pointer;
	color: var(--text-muted);
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 11px;
	font-family: var(--font);
	font-weight: 500;
	white-space: nowrap;
	transition: color 0.1s;
}
.copy-btn:hover {
	color: var(--text);
}
.copy-btn.copied {
	color: var(--success);
}
.scopes-wrap {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
}

/* ── MODAL ── */
.overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.65);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	padding: 20px;
	backdrop-filter: blur(4px);
}
.modal {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	width: 100%;
	max-width: 480px;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: var(--shadow);
}
.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 24px 16px;
	border-bottom: 1px solid var(--border);
}
.modal-head h3 {
	font-size: 16px;
	font-weight: 700;
}
.modal-close {
	background: none;
	border: none;
	color: var(--text-muted);
	cursor: pointer;
	font-size: 18px;
	line-height: 1;
	padding: 4px;
	border-radius: 4px;
}
.modal-close:hover {
	color: var(--text);
}
.modal-body {
	padding: 22px 24px;
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.modal-foot {
	padding: 14px 24px;
	border-top: 1px solid var(--border);
	display: flex;
	justify-content: flex-end;
	gap: 8px;
}

/* env selector */
.env-row {
	display: flex;
	gap: 8px;
}
.env-opt {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 9px;
	padding: 11px 12px;
	border-radius: var(--radius);
	border: 1px solid var(--border-2);
	cursor: pointer;
	transition:
		border-color 0.15s,
		background 0.15s;
	user-select: none;
}
.env-opt:hover {
	border-color: var(--primary);
}
.env-opt.selected {
	border-color: var(--primary);
	background: var(--primary-light);
}
.env-opt input[type="radio"] {
	accent-color: var(--primary);
	margin: 0;
}
.env-opt-label {
	font-size: 13px;
	font-weight: 600;
}
.env-opt-desc {
	font-size: 11px;
	color: var(--text-muted);
}

/* scope grid */
.scope-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 5px;
}
.scope-item {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 7px 10px;
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	cursor: pointer;
	user-select: none;
	transition:
		border-color 0.1s,
		background 0.1s;
}
.scope-item:hover {
	border-color: var(--primary);
	background: var(--primary-light);
}
.scope-item.on {
	border-color: var(--primary);
	background: var(--primary-light);
}
.scope-item input[type="checkbox"] {
	accent-color: var(--primary);
	margin: 0;
	width: auto;
	padding: 0;
	background: none;
	border: none;
}
.scope-item span {
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 500;
}

/* reveal box */
.reveal-box {
	background: var(--surface-2);
	border: 1px solid var(--border-2);
	border-radius: var(--radius);
	padding: 16px;
}
.reveal-warn {
	font-size: 12px;
	color: var(--warning);
	margin-bottom: 10px;
	display: flex;
	align-items: center;
	gap: 6px;
}
.reveal-key {
	font-family: var(--mono);
	font-size: 12px;
	word-break: break-all;
	background: var(--surface-3);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	padding: 10px 12px;
	margin-bottom: 8px;
	color: var(--text);
}

/* confirm dialog */
.confirm-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 24px;
	max-width: 360px;
	width: 100%;
	box-shadow: var(--shadow);
}
.confirm-title {
	font-size: 16px;
	font-weight: 700;
	margin-bottom: 8px;
}
.confirm-desc {
	font-size: 13px;
	color: var(--text-muted);
	margin-bottom: 20px;
	line-height: 1.6;
}
.confirm-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
}

/* docs sections */
.docs-body {
	max-width: 720px;
}
.docs-body p {
	color: var(--text-muted);
	line-height: 1.75;
	margin-bottom: 16px;
	font-size: 14px;
}
.docs-body h3 {
	font-size: 15px;
	font-weight: 600;
	margin: 24px 0 10px;
}
.code-block {
	font-family: var(--mono);
	font-size: 12px;
	background: #f8f9fc;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 14px 16px;
	line-height: 1.7;
	overflow-x: auto;
	margin-bottom: 16px;
	color: var(--text-secondary);
}
.code-block .dim {
	color: var(--text-muted);
}
.code-block .key {
	color: #2563eb;
}
.code-block .val {
	color: #059669;
}
.endpoint-list {
	display: flex;
	flex-direction: column;
	gap: 8px;
}
.endpoint-row {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 14px 18px;
	display: flex;
	align-items: flex-start;
	gap: 14px;
}
.method-badge {
	padding: 3px 8px;
	border-radius: 4px;
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 700;
	white-space: nowrap;
	margin-top: 1px;
}
.method-GET {
	background: rgba(5, 150, 105, 0.1);
	color: #059669;
}
.method-POST {
	background: rgba(0, 72, 56, 0.1);
	color: #004838;
}
.method-PATCH {
	background: rgba(217, 119, 6, 0.1);
	color: #d97706;
}
.method-PUT {
	background: rgba(37, 99, 235, 0.1);
	color: #2563eb;
}
.method-DELETE {
	background: rgba(220, 38, 38, 0.1);
	color: #dc2626;
}
.endpoint-path {
	font-family: var(--mono);
	font-size: 12px;
	color: var(--text);
	margin-bottom: 5px;
	word-break: break-all;
}
.endpoint-desc {
	font-size: 12px;
	color: var(--text-muted);
	margin-bottom: 6px;
}

/* responsive */
@media (max-width: 640px) {
	.feature-grid {
		grid-template-columns: 1fr;
		padding: 0 20px 40px;
	}
	.landing-title {
		font-size: 34px;
	}
	.sidebar {
		display: none;
	}
	.page-body {
		padding: 16px;
	}
	.page-header {
		padding: 20px 16px 0;
	}
}
