/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
	--bg: #0f172a; /* slate-900 */
	--bg-2: #1e293b; /* slate-800 */
	--text: #f1f5f9; /* slate-100 */
	--muted: #94a3b8; /* slate-400 */
	--primary: #3b82f6; /* blue-500 */
	--primary-strong: #2563eb; /* blue-600 */
	--success: #10b981; /* emerald-500 */
	--warning: #f59e0b; /* amber-500 */
	--danger: #ef4444; /* red-500 */
	--surface: rgba(30, 41, 59, 0.7); /* More opaque for better contrast */
	--surface-2: rgba(51, 65, 85, 0.8);
	--border: rgba(255,255,255,0.1);
	--shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
	--radius: 16px;
	--radius-sm: 12px;
	--radius-xs: 8px;
	--blur: 16px;
	--ring: rgba(59,130,246,0.5);
}

html { direction: rtl; scroll-behavior: smooth; }
* { box-sizing: border-box; }
/* Ensure all elements inherit the base font (especially form controls) */
*, *::before, *::after { font-family: inherit; }

body {
	font-family: 'Vazirmatn', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	margin: 0;
	padding: 0;
	color: var(--text);
	text-align: right;
	line-height: 1.6;
	background: radial-gradient(circle at top left, #1e1b4b, transparent 40%),
				radial-gradient(circle at bottom right, #312e81, transparent 40%),
				var(--bg);
	min-height: 100vh;
	position: relative;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
}

body::before {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
	z-index: 0;
	opacity: 0.4;
}

.container { max-width: 1000px; margin: auto; padding: 24px 20px; position: relative; z-index: 1; width: 100%; animation: fadeIn .6s ease; }

/* =========================================
   2. TYPOGRAPHY
   ========================================= */
h1, h2, h3, h4 { margin: 0 0 16px; letter-spacing: -0.3px; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; color: var(--muted); }
/* Center main titles and section headers */
.container h1, .container h2, .card h3, .card h4 { text-align: center; }

a { color: var(--primary); text-decoration: none; position: relative; }
a:hover { color: var(--primary-strong); }
a::after { content: ""; position: absolute; right: 0; bottom: -2px; width: 0; height: 2px; background: currentColor; transition: width .25s ease; }
a:hover::after { width: 100%; }

/* =========================================
   3. LAYOUT & COMPONENTS
   ========================================= */

/* --- App Header --- */
.app-header {
	position: sticky;
	top: 0;
	z-index: 1000;
	backdrop-filter: blur(16px);
	-webkit-backdrop-filter: blur(16px);
	background: rgba(15, 23, 42, 0.65);
	border-bottom: 1px solid rgba(255,255,255,0.08);
	border-radius: 16px;
	margin: 10px;
	box-shadow: 0 10px 30px -18px rgba(0,0,0,0.55);
	transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.app-header-inner {
	width: 100%;
	max-width: 1000px;
	margin: 0 auto;
	padding: 12px 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-direction: row-reverse; /* Logo on left (RTL), profile on right */
}
.brand-link { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.1rem; }
.brand-emoji { font-size: 1.4rem; }

/* --- Profile Menu --- */
.profile { display: flex; align-items: center; gap: 10px; position: relative; }
.profile-btn {
	display: inline-flex; align-items: center; gap: 10px;
	padding: 6px 12px 6px 8px;
	border-radius: 99px;
	border: 1px solid rgba(255,255,255,0.08);
	background: rgba(255,255,255,0.03);
	color: var(--text);
	cursor: pointer;
	margin: 0;
	transition: background .2s ease, border-color .2s ease, transform .15s ease, box-shadow .2s ease;
	box-shadow: 0 0 0 0 rgba(0,0,0,0) !important;
}
.profile-btn:hover {
	background: rgba(255,255,255,0.07);
	border-color: rgba(255,255,255,0.16);
	transform: translateY(-1px);
}
.profile-btn:active { transform: translateY(0); }
.profile-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 4px var(--ring) !important;
	border-color: color-mix(in srgb, var(--primary), transparent 35%);
}
.profile-btn .avatar { width: 32px; height: 32px; border-radius: 50%; background: #1e293b; }
.profile-name { display: none; font-weight: 600; font-size: 0.9rem; }
.chev { opacity: .6; font-size: .8em; }

@media (max-width: 520px) {
	.app-header { margin: 8px; }
	.app-header-inner { padding: 10px 14px; gap: 12px; }
}

.profile .menu {
	position: absolute;
	top: calc(100% + 12px);
	left: auto;
	right: 0;
	min-width: 200px;
	background: #1e293b;
	border: 1px solid rgba(255,255,255,0.1);
	border-radius: 16px;
	box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
	display: none;
	flex-direction: column;
	overflow: hidden;
	padding: 6px;
	z-index: 1001;
}
.profile .menu.open { display: flex; animation: menuFade .2s ease forwards; }
@keyframes menuFade { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.profile .menu a, .profile .menu button {
	text-align: right;
	width: 100%;
	background: transparent;
	border: none;
	color: var(--text);
	padding: 10px 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	border-radius: 8px;
	font-size: 0.9rem;
	margin: 0;
}
.profile .menu a:hover, .profile .menu button:hover { background: rgba(255,255,255,0.08); }
.profile .menu button.danger { color: #f87171; }
.profile .menu button.danger:hover { background: rgba(248,113,113,0.1); }
.menu-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 4px 0; }

@media (min-width: 768px) {
	.profile-name { display: inline; }
}

/* --- Page Header --- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 18px; flex-direction: column; }
.page-header .page-title { display: inline-flex; align-items: center; gap: 10px; margin: 0; text-align: right; }
.page-header .page-title .emoji { font-size: 1.2em; line-height: 1; }
.page-header.center { justify-content: center; }
.page-header.center .page-title { text-align: center; }
.back-link { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.18); background: rgba(148,163,184,0.12); color: var(--text); text-decoration: none; transition: transform .15s ease, background .2s ease, box-shadow .2s ease; }
.back-link .icon { font-size: 1.1em; line-height: 1; }
.back-link:hover { background: rgba(148,163,184,0.22); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.back-link:active { transform: translateY(0); }

/* --- Cards --- */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 18px;
	margin: 18px 0;
	box-shadow: var(--shadow);
	backdrop-filter: blur(var(--blur));
	-webkit-backdrop-filter: blur(var(--blur));
	transition: transform .25s ease, background .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.card:hover { transform: translateY(-2px); background: var(--surface-2); box-shadow: 0 16px 40px rgba(0,0,0,0.45); }

/* --- Forms --- */
label { display: block; margin: 12px 0 8px; font-weight: 600; color: var(--muted); text-align: right; }
input, select, textarea {
	width: 100%;
	padding: 12px 14px;
	color: var(--text);
	background: rgba(255,255,255,0.06);
	border: 1px solid rgba(255,255,255,0.16);
	border-radius: 12px;
	outline: none;
	transition: border-color .2s ease, box-shadow .2s ease, background .2s ease, transform .1s ease;
	backdrop-filter: blur(6px);
	text-align: center;
}
input, select, textarea, button { font: inherit; }
input::placeholder, textarea::placeholder { color: #94a3b885; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); background: rgba(255,255,255,0.1); }
input:hover, textarea:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.25); }
input:active { transform: translateY(0.5px); }

input[type="number"], input[type="email"], input[type="url"], input[type="tel"] { direction: ltr; text-align: center; }

/* --- Buttons --- */
button {
	margin-top: 24px;
	background: linear-gradient(135deg, var(--primary), var(--primary-strong));
	color: white;
	border: 1px solid rgba(255,255,255,0.2);
	padding: 12px 24px;
	border-radius: 12px;
	cursor: pointer;
	font-weight: 600;
	letter-spacing: .5px;
	/* ---box-shadow: 0 4px 12px rgba(59,130,246,0.3);--- */
	transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	overflow: hidden;
	width: 100%;
	display: block;
}
button::before {
	content: "";
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
	opacity: 0;
	transition: opacity .2s;
}
button:active { transform: translateY(0); }
button:disabled { opacity: .6; cursor: not-allowed; filter: grayscale(.2); }

.secondary {
	background: linear-gradient(135deg, rgba(148,163,184,0.25), rgba(100,116,139,0.2));
	color: #e2e8f0;
	box-shadow: 0 6px 18px rgba(15,23,42,0.45) inset, 0 2px 10px rgba(0,0,0,0.3);
}
.secondary:hover { background: linear-gradient(135deg, rgba(148,163,184,0.35), rgba(100,116,139,0.28)); }

.icon-btn { 
	margin-right: 0;
	font-size: 18px; 
	line-height: 1; 
	padding: 8px 12px; 
	border-radius: 10px; 
	border: 1px solid rgba(255,255,255,0.18); 
	background: rgba(148,163,184,0.15); 
	cursor: pointer; 
	color: var(--text); 
	transition: background .2s ease, transform .2s ease, box-shadow .2s ease; 
	width: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 0;
	box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.icon-btn:hover { background: rgba(148,163,184,0.35); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

.actions-row { display: inline-flex; align-items: stretch; gap: 0; white-space: nowrap; border-radius: 12px; overflow: hidden; border: 1px solid rgba(255,255,255,0.18); background: rgba(30,41,59,0.3); box-shadow: 0 2px 8px rgba(0,0,0,0.2); margin: 0 auto; }
.actions-row .icon-btn.same { padding: 10px 16px; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; border-radius: 0; border: none; border-left: 1px solid rgba(255,255,255,0.12); margin: 0; box-shadow: none; }
.actions-row .icon-btn.same:first-child { border-left: none; }
.actions-row .icon-btn.same:hover { background: rgba(148,163,184,0.25); transform: none; box-shadow: none; }
.actions-row button { margin-top: 0; width: auto; }
.actions-row form { margin: 0; display: inline-flex; }
td .actions-row { justify-content: center; }

/* --- Flash Messages --- */
.flashes { list-style: none; padding: 0; margin: 0 0 16px 0; width: 100%; }
.flashes li {
	padding: 14px 16px;
	margin: 10px 0;
	border-radius: 12px;
	border: 1px solid rgba(255,255,255,0.1);
	background: rgba(30, 41, 59, 0.8);
	box-shadow: 0 4px 12px rgba(0,0,0,0.2);
	backdrop-filter: blur(12px);
	word-break: break-word;
	overflow-wrap: anywhere;
	text-align: center;
	font-weight: 500;
	display: flex;
	align-items: center;
	justify-content: center;
}
.container > .flashes, .modal-content > .flashes { width: 100%; max-width: 100%; }
.flashes li.success { background: rgba(6, 78, 59, 0.8); color: #d1fae5; border-color: rgba(52, 211, 153, 0.3); }
.flashes li.info { background: rgba(30, 58, 138, 0.8); color: #dbeafe; border-color: rgba(96, 165, 250, 0.3); }
.flashes li.warning { background: rgba(120, 53, 15, 0.8); color: #fef3c7; border-color: rgba(251, 191, 36, 0.3); }
.flashes li.danger { background: rgba(127, 29, 29, 0.8); color: #fee2e2; border-color: rgba(248, 113, 113, 0.3); }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid rgba(255,255,255,0.08); padding: 10px 8px; }
th { font-weight: 700; color: #cbd5e1; }
.table-wrapper { width: 100%; overflow-x: auto; border-radius: var(--radius-xs); }
.responsive-table { width: 100%; }
.responsive-table td:nth-child(5) { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }

@media (min-width: 641px) {
	.responsive-table { table-layout: auto; }
	.responsive-table th, .responsive-table td { text-align: center; vertical-align: middle; white-space: nowrap; }
	.responsive-table td:nth-child(5), .responsive-table th:nth-child(4) { white-space: normal; }
	.responsive-table:not(.api-keys-table) td:nth-child(5) {
		line-clamp: 3;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
		line-height: 1.7;
		max-height: calc(1.7em * 3);
		min-width: 250px;
	}
	.responsive-table th + th, .responsive-table td + td { border-right: 1px solid rgba(255,255,255,0.06); }
	.responsive-table tr { transition: background .25s ease; }
	.responsive-table tbody tr:hover { background: rgba(255,255,255,0.04); }

	.responsive-table.kv-compact { border-collapse: separate; border-spacing: 0 10px; }
	.responsive-table.kv-compact th, .responsive-table.kv-compact td { border: none; white-space: normal; }
	.responsive-table.kv-compact th + th, .responsive-table.kv-compact td + td { border-right: none; }
	.responsive-table.kv-compact tbody td { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); padding: 12px 16px; }
	.responsive-table.kv-compact tbody td + td { border-right: 0; }
	.responsive-table.kv-compact tbody td:first-child { border-radius: 0 12px 12px 0; }
	.responsive-table.kv-compact tbody td:last-child { border-radius: 12px 0 0 12px; }
	.responsive-table.kv-compact tbody tr:hover td { background: rgba(255,255,255,0.08); }
	.responsive-table.kv-compact thead th { color: var(--muted); padding: 8px 10px; }
	.responsive-table.kv-compact tbody td:first-child { font-weight: 600; color: var(--muted); text-align: center; width: 40%; }
}

@media (max-width: 640px) {
    .table-wrapper { margin: 0; }
	.page-header { flex-direction: column; align-items: center; gap: 8px; }
	.container .page-header h1 { text-align: center; }
	.responsive-table thead { display: none; }
	.responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
	.responsive-table tr { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.16); border-radius: 12px; margin-bottom: 8px; padding: 6px 0; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
	.responsive-table td { border: none; border-bottom: 1px solid rgba(255,255,255,0.08); padding: 10px; min-height: 36px; text-align: center; white-space: normal; overflow-wrap: anywhere; word-break: break-word; overflow: hidden; }
	.responsive-table td:last-child { border-bottom: none; }
	.responsive-table td::before { content: attr(data-label); display: block; position: static; margin-bottom: 4px; font-weight: 600; color: var(--muted); text-align: center; white-space: normal; }
	.responsive-table td:nth-child(8) { display: flex; flex-direction: column; align-items: center; }

	.responsive-table.kv-compact td:first-child { display: block; }
	.responsive-table.kv-compact tbody { background: transparent; border: none; border-radius: 0; box-shadow: none; padding: 0; }
	.responsive-table.kv-compact tr { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.16); border-radius: 12px; margin-bottom: 12px; padding: 6px 0; box-shadow: var(--shadow); }
	.responsive-table.kv-compact td + td { border-top: none; }
	.responsive-table.kv-compact td:first-child::before { content: ""; display: none; }
	.responsive-table.kv-compact td:last-child::before { content: ""; display: none; }

	h1 { font-size: 1.35rem; }
	h2 { font-size: 1.1rem; }
	button { padding: 10px 14px; border-radius: 10px; }
	.container { margin: auto; padding: 24px 14px; }
	.card { padding: 14px; }
	.flashes { padding: 0 4px; }
	.flashes li { margin: 8px 0; }
}

.responsive-table td.ltr, .responsive-table th.ltr { direction: ltr; text-align: center; }
.api-key-value code { display: inline-block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; word-break: break-word; color: #e2e8f0; }

/* --- Modals --- */
.modal { position: fixed; inset: 0; background: rgba(2,6,23,.55); display: none; align-items: center; justify-content: center; padding: 18px; overflow: auto; backdrop-filter: blur(3px); z-index: 10000; }
.modal.open { display: flex; animation: fadeIn .25s ease; }
.modal-content {
	background: var(--surface);
	width: 100%;
	max-width: 640px;
	max-height: 90vh;
	overflow: auto;
	border-radius: var(--radius);
	border: 1px solid var(--border);
	padding: 40px 24px;
	box-shadow: var(--shadow);
	backdrop-filter: blur(var(--blur));
	z-index: 10001;
	margin-top: 80px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 12px; }
.modal-header h3 { margin: 0; font-size: 1.4rem; }
.close-modal-btn { background: transparent; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 4px; margin: 0; width: auto; box-shadow: none; }
.close-modal-btn:hover { color: var(--text); transform: none; box-shadow: none; }

.settings-section { background: rgba(255,255,255,0.03); border-radius: 12px; padding: 24px 16px; margin: 24px 0; border: 1px solid rgba(255,255,255,0.05); }
.settings-section h4 { margin-top: 0; color: var(--text); font-size: 1.1rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.settings-icon { width: 18px; height: 18px; color: var(--muted); flex: 0 0 auto; }

/* In the admin settings modal, keep all settings categories the same width.
   The API-keys block is a direct child of .modal-content (not inside a form),
   so it needs the same max-width constraint as .modal-content > form. */
.modal-content > .settings-section {
	width: 100%;
	max-width: 560px;
	margin-left: auto;
	margin-right: auto;
}
.inline-form { display: flex; align-items: stretch; justify-content: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 150px; }
.inline-form input:only-of-type { width: 100%; }
.small-btn { padding: 12px 14px; font-size: 0.9rem; margin-top: 0; width: auto; white-space: nowrap; flex-shrink: 0; }

@media (max-width: 480px) {
	.inline-form { flex-direction: column; }
	.inline-form input { width: 100%; min-width: auto; }
	.small-btn { width: 100%; }
}
.empty-state { color: var(--muted); text-align: center; padding: 12px; }
.hint { font-size: 0.85rem; color: var(--muted); }
.hint code { background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-family: monospace; }

/* --- Switch (Passkey toggle) --- */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.switch-label { color: var(--text); font-weight: 700; }
.switch { display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.switch .track {
	width: 46px;
	height: 26px;
	border-radius: 999px;
	background: rgba(255,255,255,0.12);
	border: 1px solid rgba(255,255,255,0.16);
	position: relative;
	transition: background .2s ease, border-color .2s ease;
	display: inline-block;
}
.switch .thumb {
	position: absolute;
	top: 2px;
	right: 2px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: rgba(255,255,255,0.92);
	transition: transform .2s ease;
}
.switch input:focus + .track { box-shadow: 0 0 0 4px var(--ring); border-color: var(--primary); }
.switch input:checked + .track {
	background: color-mix(in srgb, var(--primary), transparent 70%);
	border-color: color-mix(in srgb, var(--primary), transparent 40%);
}
.switch input:checked + .track .thumb { transform: translateX(-20px); }

.settings-form .form-group { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 16px; margin-top: 32px; justify-content: center; }
.modal-actions button { margin-top: 0; width: 100%; flex: 1; padding: 14px; font-size: 1rem; }

/* --- Status Badge --- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; background: rgba(99,102,241,0.25); color: #c7d2fe; font-size: 12px; border: 1px solid rgba(99,102,241,0.35); }

/* --- API Key Badge (colored) --- */
.badge.badge-key {
	--badge-color: var(--primary);
	background: color-mix(in srgb, var(--badge-color), transparent 78%);
	border-color: color-mix(in srgb, var(--badge-color), transparent 55%);
	color: color-mix(in srgb, var(--badge-color), white 70%);
	font-weight: 700;
}

/* --- Payment Status Badge (colored) --- */
.badge.badge-success {
	--badge-color: var(--success);
	background: color-mix(in srgb, var(--badge-color), transparent 78%);
	border-color: color-mix(in srgb, var(--badge-color), transparent 55%);
	color: color-mix(in srgb, var(--badge-color), white 70%);
	font-weight: 700;
}
.badge.badge-warning {
	--badge-color: var(--warning);
	background: color-mix(in srgb, var(--badge-color), transparent 78%);
	border-color: color-mix(in srgb, var(--badge-color), transparent 55%);
	color: color-mix(in srgb, var(--badge-color), white 70%);
	font-weight: 700;
}
.badge.badge-danger {
	--badge-color: var(--danger);
	background: color-mix(in srgb, var(--badge-color), transparent 78%);
	border-color: color-mix(in srgb, var(--badge-color), transparent 55%);
	color: color-mix(in srgb, var(--badge-color), white 70%);
	font-weight: 700;
}

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.card { animation: slideUp .5s ease backwards; }
.card:nth-child(1) { animation-delay: .1s; }
.card:nth-child(2) { animation-delay: .2s; }

/* --- Dashboard Stats & Charts --- */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 20px;
	display: flex;
	align-items: center;
	gap: 16px;
	box-shadow: var(--shadow);
	backdrop-filter: blur(var(--blur));
	transition: transform .2s ease, background .2s ease;
	animation: slideUp .4s ease backwards;
}
.stat-card:nth-child(1) { animation-delay: .05s; }
.stat-card:nth-child(2) { animation-delay: .1s; }
.stat-card:nth-child(3) { animation-delay: .15s; }
.stat-card:hover { transform: translateY(-3px); background: var(--surface-2); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.stat-info { display: flex; flex-direction: column; }
.stat-label { font-size: 0.9rem; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.stat-value small { font-size: 0.8rem; font-weight: 400; opacity: 0.7; }

.charts-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 32px; }
.chart-card { min-height: 350px; display: flex; flex-direction: column; animation: slideUp .5s ease backwards; animation-delay: .2s; }
.chart-wrapper { flex: 1; position: relative; width: 100%; min-height: 250px; }

@media (max-width: 768px) {
	.dashboard-grid { grid-template-columns: 1fr; }
	.charts-container { grid-template-columns: 1fr; }
	.stat-card { padding: 16px; }
}


/* --- Scrollbar --- */
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-track { background: rgba(148,163,184,0.12); }
*::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.38); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.55); }

/* --- Centered Forms --- */
.container > form, .container form.card, .modal-content > form { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; display: flex; flex-direction: column; gap: 10px; }
.container > form:not(.card) { align-items: center; }
form.card { padding: 20px; }

/* --- Toolbar & Search --- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.search-form { width: 100%; }
.search-group { display: flex; align-items: center; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; padding: 4px 8px; transition: all .2s; width: 100%; }
.search-group:focus-within { background: rgba(255,255,255,0.08); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.search-btn { background: transparent; border: none; color: var(--muted); font-size: 1.1rem; padding: 8px; cursor: pointer; margin: 0; box-shadow: none; width: auto; display: flex; align-items: center; justify-content: center; }
.search-btn:hover { color: var(--text); transform: none; box-shadow: none; }
.search-group input { border: none; background: transparent; box-shadow: none; padding: 10px 4px; text-align: right; width: 100%; }
.search-group input:focus { box-shadow: none; background: transparent; }
.search-clear { color: var(--muted); font-size: 1.1rem; padding: 8px; cursor: pointer; transition: color .2s; line-height: 1; display: flex; align-items: center; }
.search-clear:hover { color: var(--danger); }

/* --- Auth Pages --- */
.auth-wrap { width: 100%; max-width: 560px; margin: 0 auto; }
.auth-card { max-width: 560px; margin: 0 auto; padding: 32px 24px; }
.auth-subtitle { margin: 6px 0 18px; text-align: center; color: var(--muted); }
.auth-footer { margin-top: 24px; text-align: center; font-size: 0.95rem; color: var(--muted); border-top: 1px solid rgba(255,255,255,0.1); padding-top: 16px; }
.auth-footer a { font-weight: 600; }

/* --- Pagination --- */
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.page-info { color: var(--muted); font-size: .95rem; }
.page-controls { display: flex; align-items: center; gap: 6px; }
.page-btn, .page-num { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.16); background: rgba(148,163,184,0.12); color: var(--text); text-decoration: none; transition: transform .15s ease, background .2s ease, box-shadow .2s ease; }
.page-btn:hover, .page-num:hover { background: rgba(148,163,184,0.24); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.page-num.active { background: linear-gradient(135deg, var(--primary-strong), #7c3aed); border-color: rgba(255,255,255,0.18); box-shadow: 0 8px 24px rgba(59,130,246,0.35); font-weight: 700; }
.page-controls [data-disabled] { pointer-events: none; opacity: .5; filter: grayscale(.3); }
.page-numbers { display: inline-flex; align-items: center; gap: 6px; }
.ellipsis { color: var(--muted); padding: 0 4px; }

/* --- Global Loader --- */
#global-loader { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(2, 6, 23, 0.85); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 2147483000; transition: opacity .35s ease, visibility .35s ease; }
#global-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-wrapper { position: relative; display: flex; align-items: center; justify-content: center; width: 180px; height: 180px; font-family: "Inter", sans-serif; font-size: 1.2em; font-weight: 300; color: white; user-select: none; z-index: 1; direction: ltr; }
.loader-wrapper::before { content: ""; position: absolute; inset: -20px; border-radius: 25px; background: rgba(255, 255, 255, 0.1); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.2); z-index: -1; }
.loader { position: absolute; top: 0; left: 0; width: 100%; aspect-ratio: 1 / 1; border-radius: 50%; background-color: transparent; animation: loader-rotate 2s linear infinite; z-index: 0; }
@keyframes loader-rotate {
	0% { transform: rotate(90deg); box-shadow: 0 10px 20px 0 #fff inset, 0 20px 30px 0 #ad5fff inset, 0 60px 60px 0 #471eec inset; }
	50% { transform: rotate(270deg); box-shadow: 0 10px 20px 0 #fff inset, 0 20px 10px 0 #d60a47 inset, 0 40px 60px 0 #311e80 inset; }
	100% { transform: rotate(450deg); box-shadow: 0 10px 20px 0 #fff inset, 0 20px 30px 0 #ad5fff inset, 0 60px 60px 0 #471eec inset; }
}
.loader-letter { display: inline-block; opacity: 0.4; transform: translateY(0); animation: loader-letter-anim 2s infinite; z-index: 1; border-radius: 50ch; border: none; }
.loader-letter:nth-child(1) { animation-delay: 0s; }
.loader-letter:nth-child(2) { animation-delay: 0.1s; }
.loader-letter:nth-child(3) { animation-delay: 0.2s; }
.loader-letter:nth-child(4) { animation-delay: 0.3s; }
.loader-letter:nth-child(5) { animation-delay: 0.4s; }
.loader-letter:nth-child(6) { animation-delay: 0.5s; }
.loader-letter:nth-child(7) { animation-delay: 0.6s; }
.loader-letter:nth-child(8) { animation-delay: 0.7s; }
.loader-letter:nth-child(9) { animation-delay: 0.8s; }
.loader-letter:nth-child(10) { animation-delay: 0.9s; }
@keyframes loader-letter-anim { 0%, 100% { opacity: 0.4; transform: translateY(0); } 20% { opacity: 1; transform: scale(1.15); } 40% { opacity: 0.7; transform: translateY(0); } }

/* --- Status Animations --- */
.status-image { display: flex; margin-left: auto; margin-right: auto; flex-shrink: 0; justify-content: center; align-items: center; width: 8rem; height: 8rem; border-radius: 9999px; animation: status-pulse .6s linear alternate-reverse infinite; transition: .6s ease; margin-bottom: 1rem; }
.status-image svg { width: 4.5rem; height: 4.5rem; }
@keyframes status-pulse { from { transform: scale(1); } to { transform: scale(1.1); } }
.status-image.success { background-color: rgba(16, 185, 129, 0.2); }
.status-image.success svg { color: #10b981; }
.status-image.failed { background-color: rgba(239, 68, 68, 0.2); }
.status-image.failed svg { color: #ef4444; }
.status-image.duplicate { background-color: rgba(59, 130, 246, 0.2); }
.status-image.duplicate svg { color: #3b82f6; }
.status-image.invalid { background-color: rgba(245, 158, 11, 0.2); }
.status-image.invalid svg { color: #f59e0b; }
.status-image.unknown { background-color: rgba(148, 163, 184, 0.2); }
.status-image.unknown svg { color: #94a3b8; }

/* =========================================
   4. PAGE SPECIFIC STYLES
   ========================================= */

/* --- Docs Page --- */
.app-header .header-content { max-width: 900px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; }
.app-header .header-title h1 { margin: 0; font-size: 1.5rem; background: linear-gradient(to right, #fff, #94a3b8); background-clip: text; -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.app-header .header-actions { display: flex; gap: 10px; }
.docs-container { max-width: 900px; margin: 0 auto; padding: 20px 0; }
.docs-container .endpoint-card { margin-bottom: 20px; border-right: 5px solid rgba(255,255,255,0.25); }
.docs-container .endpoint-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; background: rgba(255, 255, 255, 0.05); padding: 10px; border-radius: 5px; }
.docs-container .method { font-weight: bold; padding: 4px 8px; border-radius: 4px; color: white; font-size: 0.9em; }
.docs-container .method.get { background-color: #3b82f6; }
.docs-container .method.post { background-color: #10b981; }
.docs-container .url { font-family: monospace; font-size: 1.1em; direction: ltr; }
.docs-container .test-section { background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.1); padding: 15px; border-radius: 5px; margin-top: 15px; }
.docs-container .code-block { background: #1e293b; color: #e2e8f0; padding: 15px; border-radius: 5px; overflow-x: auto; direction: ltr; text-align: left; margin-top: 10px; font-size: 0.9em; border: 1px solid rgba(255, 255, 255, 0.1); }
.docs-container .api-key-section { background: rgba(59, 130, 246, 0.1); padding: 15px; border-radius: 5px; margin-top: 15px; border: 1px solid rgba(59, 130, 246, 0.2); }

.docs-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: 8px; text-decoration: none; cursor: pointer; font-size: 0.9rem; border: 1px solid rgba(255,255,255,0.1); transition: all 0.2s; font-weight: 500; width: auto; margin-top: 0; box-shadow: none; }
.docs-btn-primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: white; }
.docs-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(59,130,246,0.3); }
.docs-btn-secondary { background: rgba(148, 163, 184, 0.2); color: #e2e8f0; }
.docs-btn-secondary:hover { background: rgba(148, 163, 184, 0.3); }
.docs-btn-danger { background: rgba(239, 68, 68, 0.2); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }
.docs-btn-danger:hover { background: rgba(239, 68, 68, 0.3); }

.docs-container .form-group { margin-bottom: 15px; }
.docs-container .form-control { width: 100%; padding: 10px; margin-top: 5px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(0, 0, 0, 0.2); color: white; }
.docs-container .form-control:focus { border-color: #3b82f6; outline: none; }
.docs-container .preview-section { margin: 15px 0; background: rgba(0,0,0,0.3); padding: 10px; border-radius: 8px; border: 1px dashed rgba(255,255,255,0.1); }
.docs-container .preview-section h5 { margin: 0 0 5px 0; color: #94a3b8; font-size: 0.85rem; }

/* --- Invoice Page (Animated Button) --- */
.pay-btn {
	display: flex;
	justify-content: center;
	align-items: center;
	width: 13rem;
	overflow: hidden;
	height: 3rem;
	background-size: 300% 300%;
	cursor: pointer;
	backdrop-filter: blur(1rem);
	border-radius: 5rem;
	transition: 0.5s;
	animation: gradient_301 5s ease infinite;
	border: double 4px transparent;
	background-image: linear-gradient(#212121, #212121), linear-gradient(137.48deg, #ffdb3b 10%, #fe53bb 45%, #8f51ea 67%, #0044ff 87%);
	background-origin: border-box;
	background-clip: content-box, border-box;
	margin: 0 auto; /* Center it */
}
.pay-btn strong { z-index: 2; font-family: inherit; font-size: 21px; letter-spacing: 5px; color: #ffffff; text-shadow: 0 0 4px white; }
.pay-btn:hover { transform: scale(1.1); }
.pay-btn:hover #container-stars { z-index: 1; background-color: #212121; }
.pay-btn:active { border: double 4px #fe53bb; background-origin: border-box; background-clip: content-box, border-box; animation: none; }
.pay-btn:active .circle { background: #fe53bb; }

#container-stars { position: absolute; z-index: -1; width: 100%; height: 100%; overflow: hidden; transition: 0.5s; backdrop-filter: blur(1rem); border-radius: 5rem; }
#glow { position: absolute; display: flex; width: 12rem; }
.circle { width: 100%; height: 30px; filter: blur(2rem); animation: pulse_3011 4s infinite; z-index: -1; }
.circle:nth-of-type(1) { background: rgba(254, 83, 186, 0.636); }
.circle:nth-of-type(2) { background: rgba(142, 81, 234, 0.704); }
#stars { position: relative; background: transparent; width: 200rem; height: 200rem; }
#stars::after { content: ""; position: absolute; top: -10rem; left: -100rem; width: 100%; height: 100%; animation: animStarRotate 90s linear infinite; background-image: radial-gradient(#ffffff 1px, transparent 1%); background-size: 50px 50px; }
#stars::before { content: ""; position: absolute; top: 0; left: -50%; width: 170%; height: 500%; animation: animStar 60s linear infinite; background-image: radial-gradient(#ffffff 1px, transparent 1%); background-size: 50px 50px; opacity: 0.5; }

@keyframes animStar { from { transform: translateY(0); } to { transform: translateY(-135rem); } }
@keyframes animStarRotate { from { transform: rotate(360deg); } to { transform: rotate(0); } }
@keyframes gradient_301 { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes pulse_3011 { 0% { transform: scale(0.75); box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); } 100% { transform: scale(0.75); box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }

/* =========================================
   5. UTILITIES & HELPERS
   ========================================= */
.text-center { text-align: center; }
.justify-center { justify-content: center; }
.ltr { direction: ltr; }
.hidden { display: none; }

/* Admin Page Helpers */
.final-dest-wrapper { max-width: 280px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.badge-waiting { background: rgba(148,163,184,.25); color: #e2e8f0; }
.badge-revoked { background: #bbb; }
.form-inline { display: inline; margin: 0; }

/* Callback Page Helpers */
.callback-card { text-align: center; padding: 40px 20px; margin-bottom: 20px; }
.status-icon-wrapper { margin: 0 auto 20px; }
.status-title { margin: 0 0 10px; font-size: 1.5rem; }
.status-desc { margin: 0; color: var(--muted); }
.redirect-box { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.redirect-msg { margin: 0; color: var(--muted); font-size: .95rem; }

/* Error Page Helpers */
.error-text { font-size: 1.2rem; margin-bottom: 20px; }
.error-title { margin: 0 0 10px; }

/* Invoice Page Helpers */
.currency-unit { color: var(--muted); font-size: .9em; }

/* Loading Page Helpers */
.loading-msg { margin: 10px 0; color: var(--muted); }
.loading-sub { margin: 0; font-size: .95rem; color: var(--muted); }
.error-msg-detail { margin: 0 0 14px; color: var(--muted); }

/* Passkey Delete Button */
.passkey-action-cell {
	text-align: center !important;
}

.delete-passkey-btn {
	background: transparent;
	border: 1px solid rgba(239, 68, 68, 0.3);
	color: var(--danger);
	padding: 6px 8px;
	border-radius: var(--radius-xs);
	cursor: pointer;
	transition: all 0.2s ease;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto;
}

.delete-passkey-btn:hover {
	background: rgba(239, 68, 68, 0.1);
	border-color: var(--danger);
}

.delete-passkey-btn:active {
	transform: scale(0.95);
}

.delete-passkey-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.delete-passkey-btn svg {
	width: 16px;
	height: 16px;
	display: block;
}
