:root {
	--bg: #f8fafc;
	--surface: #ffffff;
	--surface-2: #f1f5f9;
	--surface-3: #e2e8f0;
	--border: #e2e8f0;
	--border-strong: #cbd5e1;
	--hover: #f1f5f9;

	--accent: #00a651;
	--accent-hover: #008944;
	--accent-2: #3b82f6;
	--accent-2-hover: #2563eb;
	--accent-glow: rgba(0, 166, 81, 0.14);
	--accent-bg: rgba(0, 166, 81, 0.1);

	--text: #1e293b;
	--text-2: #64748b;
	--text-3: #94a3b8;
	--text-inverse: #ffffff;

	--success: #16a34a;
	--warning: #fd7e14;
	--error: #dc2626;
	--info: #2563eb;

	--font-display:
		"Poppins", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
		sans-serif;
	--font-body:
		"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

	--radius: 6px;
	--radius-lg: 8px;
	--radius-xl: 12px;
	--radius-full: 9999px;

	--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
	--shadow-panel: 0 12px 32px rgba(15, 23, 42, 0.12);
}

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

html {
	font-size: 16px;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

body {
	font-family: var(--font-body);
	background: var(--bg);
	color: var(--text);
	line-height: 1.5;
	min-height: 100vh;
}

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

a:hover {
	text-decoration: underline;
}

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

.app-sidebar {
	width: 250px;
	background: var(--surface);
	border-right: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	z-index: 10;
}

.app-sidebar__brand {
	padding: 20px 24px;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	gap: 12px;
}

.app-sidebar__brand h1 {
	font-family: var(--font-display);
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--accent);
	line-height: 1.2;
}

.app-sidebar__brand small {
	font-size: 0.7rem;
	color: var(--text-2);
	display: block;
}

.app-sidebar__nav {
	flex: 1;
	padding: 12px 8px;
	overflow-y: auto;
}

.app-sidebar__nav a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 16px;
	border-radius: var(--radius);
	color: var(--text);
	font-weight: 600;
	font-size: 0.875rem;
	transition:
		background 0.15s,
		color 0.15s;
}

.app-sidebar__nav a:hover {
	background: var(--hover);
	text-decoration: none;
}

.app-sidebar__nav a.active {
	background: var(--accent-glow);
	color: var(--accent);
}

.app-sidebar__nav .nav-icon {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
}

.app-sidebar__footer {
	padding: 16px 24px;
	border-top: 1px solid var(--border);
	font-size: 0.8rem;
	color: var(--text-2);
}

.app-main {
	margin-left: 250px;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.app-header {
	padding: 16px 32px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 5;
}

.app-header__title {
	font-family: var(--font-display);
	font-size: 1.25rem;
	font-weight: 700;
}

.app-header__user {
	display: flex;
	align-items: center;
	gap: 12px;
	font-size: 0.85rem;
}

.app-content {
	padding: 32px;
	flex: 1;
}

/* Login page */
.login-page {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
}

.login-card {
	width: 420px;
	max-width: 90vw;
	background: var(--surface);
	border-radius: var(--radius-xl);
	box-shadow: var(--shadow-panel);
	padding: 40px;
}

.login-card__brand {
	text-align: center;
	margin-bottom: 32px;
}

.login-card__brand h1 {
	font-family: var(--font-display);
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--accent);
}

.login-card__brand p {
	color: var(--text-2);
	font-size: 0.9rem;
	margin-top: 4px;
}

/* Cards */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-card);
	padding: 24px;
}

.card--sm {
	padding: 16px;
}

.card__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

.card__title {
	font-family: var(--font-display);
	font-size: 1.1rem;
	font-weight: 700;
}

/* Stats grid */
.stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 20px;
	box-shadow: var(--shadow-card);
}

.stat-card__label {
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-2);
	margin-bottom: 8px;
}

.stat-card__value {
	font-family: var(--font-display);
	font-size: 1.8rem;
	font-weight: 700;
	color: var(--text);
}

.stat-card__meta {
	font-size: 0.78rem;
	color: var(--text-2);
	margin-top: 4px;
}

.stat-card--success {
	border-left: 3px solid var(--success);
}
.stat-card--warning {
	border-left: 3px solid var(--warning);
}
.stat-card--error {
	border-left: 3px solid var(--error);
}
.stat-card--info {
	border-left: 3px solid var(--info);
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 40px;
	padding: 8px 16px;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: transparent;
	color: var(--text);
	font-family: var(--font-body);
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition:
		background 0.15s,
		border-color 0.15s,
		color 0.15s,
		transform 0.15s;
	white-space: nowrap;
	text-decoration: none;
}

.btn:hover:not(:disabled) {
	transform: translateY(-1px);
}
.btn:disabled {
	cursor: not-allowed;
	opacity: 0.6;
}
.btn:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.btn--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--text-inverse);
}

.btn--primary:hover:not(:disabled) {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
}

.btn--ghost {
	border-color: var(--border);
	color: var(--text);
	background: var(--surface);
}

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

.btn--danger {
	background: var(--error);
	border-color: var(--error);
	color: var(--text-inverse);
}

.btn--danger:hover:not(:disabled) {
	filter: brightness(0.93);
}

.btn--sm {
	min-height: 34px;
	padding: 6px 12px;
	font-size: 0.8rem;
}

/* Inputs */
.input {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font-family: var(--font-body);
	font-size: 0.9rem;
	line-height: 1.4;
	transition:
		border-color 0.15s,
		box-shadow 0.15s;
}

.input::placeholder {
	color: var(--text-3);
}
.input:hover:not(:disabled) {
	border-color: var(--accent);
}

.input:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-glow);
}

.input:disabled {
	background: var(--surface-2);
	color: var(--text-3);
	cursor: not-allowed;
}

/* Form */
.form-field {
	display: grid;
	gap: 6px;
}

.form-label {
	font-size: 0.78rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--text-2);
}

.form-error {
	font-size: 0.78rem;
	color: var(--error);
}

.form-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 16px;
}

.form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--border);
	margin-top: 8px;
}

/* Tables */
.data-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.875rem;
}

.data-table thead {
	background: var(--surface-2);
}

.data-table th {
	padding: 12px 16px;
	text-align: left;
	font-weight: 700;
	color: var(--text);
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}

.data-table td {
	padding: 12px 16px;
	color: var(--text);
	border-bottom: 1px solid var(--border);
	vertical-align: middle;
}

.data-table tbody tr:last-child td {
	border-bottom: none;
}
.data-table tbody tr:hover {
	background: var(--hover);
}

/* Badges */
.badge {
	display: inline-flex;
	align-items: center;
	width: fit-content;
	min-height: 24px;
	padding: 3px 10px;
	border-radius: var(--radius-full);
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.badge--success {
	background: rgba(22, 163, 74, 0.12);
	color: var(--success);
}

.badge--error {
	background: rgba(220, 38, 38, 0.12);
	color: var(--error);
}

.badge--warning {
	background: rgba(253, 126, 20, 0.12);
	color: var(--warning);
}

.badge--muted {
	background: var(--surface-3);
	color: var(--text-2);
}

.badge--info {
	background: rgba(37, 99, 235, 0.12);
	color: var(--info);
}

/* Alerts */
.alert {
	padding: 14px 18px;
	border-radius: var(--radius);
	font-size: 0.875rem;
	margin-bottom: 16px;
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.alert--error {
	background: rgba(220, 38, 38, 0.08);
	border: 1px solid rgba(220, 38, 38, 0.2);
	color: var(--error);
}

.alert--success {
	background: rgba(22, 163, 74, 0.08);
	border: 1px solid rgba(22, 163, 74, 0.2);
	color: var(--success);
}

.alert--info {
	background: rgba(37, 99, 235, 0.08);
	border: 1px solid rgba(37, 99, 235, 0.2);
	color: var(--info);
}

/* Skeleton loader */
.skeleton {
	background: linear-gradient(
		90deg,
		var(--surface-3) 25%,
		var(--surface-2) 50%,
		var(--surface-3) 75%
	);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s ease-in-out infinite;
	border-radius: var(--radius);
}

@keyframes skeleton-loading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* Spinner */
.spinner {
	width: 20px;
	height: 20px;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.6s linear infinite;
	display: inline-block;
}

@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* Modal */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
}

.modal {
	background: var(--surface);
	border-radius: var(--radius-xl);
	box-shadow: var(--shadow-panel);
	padding: 32px;
	width: 520px;
	max-width: 90vw;
	max-height: 85vh;
	overflow-y: auto;
}

.modal__title {
	font-family: var(--font-display);
	font-size: 1.2rem;
	font-weight: 700;
	margin-bottom: 20px;
}

/* Monospace */
.mono {
	font-family: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", monospace;
	font-size: 0.82rem;
}

/* Copy text */
.copy-text {
	display: flex;
	align-items: center;
	gap: 8px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 8px 12px;
}

.copy-text code {
	flex: 1;
	font-size: 0.82rem;
	word-break: break-all;
}

/* Tabs */
.tabs {
	display: flex;
	gap: 4px;
	border-bottom: 1px solid var(--border);
	margin-bottom: 20px;
}

.tab {
	padding: 10px 18px;
	border: none;
	background: none;
	color: var(--text-2);
	font-family: var(--font-body);
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	border-bottom: 2px solid transparent;
	transition:
		color 0.15s,
		border-color 0.15s;
}

.tab:hover {
	color: var(--text);
}
.tab--active {
	color: var(--accent);
	border-bottom-color: var(--accent);
}

/* Utility */
.flex-between {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.flex-gap {
	gap: 8px;
}
.mb-16 {
	margin-bottom: 16px;
}
.mb-24 {
	margin-bottom: 24px;
}
.text-2 {
	color: var(--text-2);
}
.text-error {
	color: var(--error);
}
.text-success {
	color: var(--success);
}
.text-center {
	text-align: center;
}
.text-sm {
	font-size: 0.85rem;
}
.truncate {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hidden {
	display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
	width: 6px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: var(--border-strong);
	border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
	background: var(--text-3);
}
