/* BuckBro — Dark Fintech Dashboard */

:root {
	--bb-bg: #0b0f19;
	--bb-card: #151b2b;
	--bb-card-border: rgba(255, 255, 255, 0.06);
	--bb-primary: #3b82f6;
	--bb-emerald: #10b981;
	--bb-rose: #f43f5e;
	--bb-orange: #f59e0b;
	--bb-text: #f8fafc;
	--bb-muted: #94a3b8;
	--bb-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
	--bb-radius-card: 16px;
	--bb-radius-btn: 12px;
	--bb-font: "Inter", system-ui, sans-serif;
	--bb-mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	padding: 0;
	min-height: 100%;
	background: radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, 0.12), transparent 55%),
		radial-gradient(900px 500px at 100% 0%, rgba(16, 185, 129, 0.08), transparent 50%),
		var(--bb-bg);
	color: var(--bb-text);
	font-family: var(--bb-font);
	-webkit-font-smoothing: antialiased;
}

body {
	padding: 16px;
}

#bb-app {
	max-width: 1200px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.mono {
	font-family: var(--bb-mono);
}

.rose {
	color: var(--bb-rose);
}

.emerald {
	color: var(--bb-emerald);
}

/* Header */
.bb-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 4px 4px;
}

.bb-logo {
	font-weight: 700;
	font-size: 24px;
	letter-spacing: -0.02em;
	color: #fff;
}

.bb-status {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--bb-muted);
	font-size: 13px;
	font-weight: 500;
}

.bb-pulse {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--bb-emerald);
	box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
	animation: bb-pulse 1.8s ease infinite;
}

@keyframes bb-pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
	}
	70% {
		box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
	}
}

/* Cards */
.bb-card {
	background: rgba(21, 27, 43, 0.85);
	border: 1px solid var(--bb-card-border);
	border-radius: var(--bb-radius-card);
	box-shadow: var(--bb-shadow);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	padding: 20px;
}

.bb-section-title {
	margin: 0 0 16px;
	font-size: 16px;
	font-weight: 600;
	color: var(--bb-text);
}

/* Metrics */
.bb-metrics {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.bb-metric-label {
	font-size: 12px;
	font-weight: 500;
	color: var(--bb-muted);
	margin-bottom: 8px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.bb-metric-value {
	font-size: 22px;
	font-weight: 500;
	line-height: 1.2;
}

.bb-metric-chart {
	display: flex;
	flex-direction: column;
}

.bb-mini-chart-wrap {
	position: relative;
	width: 88px;
	height: 88px;
	margin-top: 4px;
}

.bb-mini-chart-center {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 13px;
	font-weight: 500;
	pointer-events: none;
}

/* Upload */
.bb-upload {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.bb-build {
	margin-left: 8px;
	font-size: 11px;
	font-weight: 500;
	color: var(--bb-muted);
	letter-spacing: 0.02em;
}

.bb-dropzone {
	position: relative;
	border: 2px dashed rgba(255, 255, 255, 0.15);
	border-radius: 20px;
	padding: 0;
	text-align: center;
	transition: border-color 0.2s ease, background 0.2s ease;
	min-height: 160px;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	justify-content: center;
	overflow: hidden;
}

.bb-dropzone:hover,
.bb-dropzone.dragover {
	border-color: var(--bb-primary);
	background: rgba(59, 130, 246, 0.06);
}

/* Direct overlay: user taps the <input type=file> itself (best for Chrome/Brave/Vivo). */
.bb-file-hit {
	position: relative;
	display: block;
	width: 100%;
	min-height: 160px;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}

.bb-file-hit-btn {
	min-height: 48px;
	border-radius: var(--bb-radius-btn);
}

.bb-file-overlay {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
	font-size: 64px; /* enlarges hit target on WebKit/Blink mobile */
	z-index: 3;
}

.bb-drop-visual {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 40px 20px;
	min-height: 160px;
	pointer-events: none;
}

.bb-file-btn-face {
	pointer-events: none;
	width: 100%;
}

.bb-camera-icon {
	color: var(--bb-muted);
}

.bb-pick-hint {
	margin: 0;
	font-size: 12px;
	line-height: 1.4;
	color: var(--bb-muted);
}

.bb-pick-hint strong {
	color: #cbd5e1;
	font-weight: 600;
}

.bb-btn-secondary {
	flex: 1;
	min-height: 48px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 12px 16px;
	border-radius: var(--bb-radius-btn);
	border: 1px solid rgba(59, 130, 246, 0.45);
	background: rgba(59, 130, 246, 0.12);
	color: #93c5fd;
	font-family: var(--bb-font);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	text-align: center;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}

.bb-btn-secondary:active {
	transform: scale(0.98);
}

.bb-drop-title {
	margin: 0;
	font-size: 15px;
	font-weight: 500;
}

.bb-drop-sub {
	margin: 0;
	font-size: 13px;
	color: var(--bb-muted);
}

.bb-preview {
	max-width: 160px;
	max-height: 120px;
	border-radius: 10px;
	margin-top: 8px;
	object-fit: cover;
	border: 1px solid var(--bb-card-border);
}

.bb-input {
	width: 100%;
	min-height: 44px;
	padding: 12px 14px;
	border-radius: var(--bb-radius-btn);
	border: 1px solid rgba(255, 255, 255, 0.1);
	background: rgba(0, 0, 0, 0.25);
	color: var(--bb-text);
	font-family: var(--bb-font);
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s ease;
}

.bb-input:focus {
	border-color: var(--bb-primary);
}

.bb-btn {
	min-height: 48px;
	border: none;
	border-radius: var(--bb-radius-btn);
	padding: 12px 18px;
	font-family: var(--bb-font);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
	width: 100%;
}

.bb-btn:active {
	transform: scale(0.98);
}

.bb-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.bb-btn-primary {
	background: var(--bb-primary);
	color: #fff;
}

.bb-btn-primary:hover:not(:disabled) {
	background: #2563eb;
}

.bb-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: bb-spin 0.7s linear infinite;
}

@keyframes bb-spin {
	to {
		transform: rotate(360deg);
	}
}

.bb-sheet-hint {
	margin: 0;
	font-size: 12px;
	color: var(--bb-muted);
	min-height: 1em;
	word-break: break-word;
}

.bb-sheet-hint.bb-sheet-ok {
	color: #34d399;
}

.bb-sheet-hint.bb-sheet-fail {
	color: #fbbf24;
}

/* Manual */
.bb-manual-toggle {
	width: 100%;
	min-height: 44px;
	background: transparent;
	border: none;
	color: var(--bb-text);
	font-family: var(--bb-font);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0;
}

.bb-manual-form {
	margin-top: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.bb-form-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

.bb-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 12px;
	color: var(--bb-muted);
	font-weight: 500;
}

.bb-seg-row {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.bb-seg {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	background: rgba(0, 0, 0, 0.25);
	padding: 4px;
	border-radius: 14px;
	border: 1px solid rgba(255, 255, 255, 0.06);
}

.bb-seg-btn {
	min-height: 44px;
	border: none;
	border-radius: 10px;
	background: transparent;
	color: var(--bb-muted);
	font-family: var(--bb-font);
	font-weight: 600;
	font-size: 13px;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.bb-seg-btn.active {
	background: rgba(59, 130, 246, 0.2);
	color: #fff;
}

/* Charts */
.bb-charts {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.bb-chart-box {
	position: relative;
	height: 260px;
	width: 100%;
}

/* Table */
.bb-table-wrap {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.bb-table {
	width: 100%;
	border-collapse: collapse;
	min-width: 720px;
}

.bb-table th,
.bb-table td {
	padding: 12px 10px;
	text-align: left;
	font-size: 13px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.04);
	vertical-align: middle;
}

.bb-table th {
	color: var(--bb-muted);
	font-weight: 600;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}

.bb-table th:last-child,
.bb-table td:last-child {
	cursor: default;
	width: 48px;
}

.bb-table tbody tr:nth-child(even) {
	background: rgba(255, 255, 255, 0.02);
}

.bb-table tbody tr:hover {
	background: rgba(59, 130, 246, 0.06);
}

.bb-empty-row td {
	text-align: center;
	color: var(--bb-muted);
	padding: 28px 12px;
}

.bb-badge {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.2;
}

.bb-badge-paid {
	background: rgba(244, 63, 94, 0.15);
	color: #fb7185;
}

.bb-badge-received {
	background: rgba(16, 185, 129, 0.15);
	color: #34d399;
}

.bb-badge-productive {
	background: rgba(59, 130, 246, 0.15);
	color: #60a5fa;
}

.bb-badge-nonsense {
	background: rgba(245, 158, 11, 0.15);
	color: #fbbf24;
}

.bb-status-cell {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.bb-status-ok {
	color: var(--bb-emerald);
}

.bb-status-warn {
	color: var(--bb-orange);
	cursor: help;
}

.bb-amount {
	font-family: var(--bb-mono);
	font-weight: 500;
	white-space: nowrap;
}

.bb-delete {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 10px;
	background: transparent;
	color: var(--bb-muted);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: color 0.2s ease, background 0.2s ease;
}

.bb-delete:hover {
	color: var(--bb-rose);
	background: rgba(244, 63, 94, 0.1);
}

/* Activity log */
.bb-logs-section {
	padding: 16px;
}

.bb-logs-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.bb-logs-actions {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.bb-logs-sub {
	margin: 4px 0 12px;
	font-size: 12px;
	color: var(--bb-muted);
}

.bb-btn-ghost {
	min-height: 36px;
	padding: 8px 12px;
	border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.1);
	background: rgba(255, 255, 255, 0.03);
	color: var(--bb-muted);
	font-family: var(--bb-font);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
}

.bb-btn-ghost:active {
	transform: scale(0.98);
}

.bb-logs {
	max-height: 320px;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid rgba(255, 255, 255, 0.06);
	border-radius: 12px;
	background: rgba(0, 0, 0, 0.25);
	padding: 8px;
	font-family: var(--bb-mono);
	font-size: 11px;
	line-height: 1.45;
}

.bb-log-empty {
	padding: 16px 8px;
	color: var(--bb-muted);
	font-family: var(--bb-font);
	font-size: 13px;
	text-align: center;
}

.bb-log-row {
	display: grid;
	grid-template-columns: 64px 52px 1fr;
	gap: 8px;
	padding: 8px;
	border-bottom: 1px solid rgba(255, 255, 255, 0.04);
	word-break: break-word;
}

.bb-log-row:last-child {
	border-bottom: none;
}

.bb-log-time {
	color: var(--bb-muted);
	white-space: nowrap;
}

.bb-log-level {
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.bb-log-level.info {
	color: #60a5fa;
}

.bb-log-level.warn {
	color: #fbbf24;
}

.bb-log-level.error {
	color: #fb7185;
}

.bb-log-msg {
	color: #e2e8f0;
}

.bb-log-ctx {
	display: block;
	margin-top: 4px;
	color: #64748b;
	white-space: pre-wrap;
}

/* Toasts */
.bb-toasts {
	position: fixed;
	top: 16px;
	right: 16px;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: min(360px, calc(100vw - 32px));
	pointer-events: none;
}

.bb-toast {
	pointer-events: auto;
	padding: 14px 16px;
	border-radius: 12px;
	background: #1e293b;
	border: 1px solid rgba(255, 255, 255, 0.08);
	box-shadow: var(--bb-shadow);
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	animation: bb-slide-in 0.25s ease;
}

.bb-toast.success {
	border-left: 3px solid var(--bb-emerald);
}

.bb-toast.warning {
	border-left: 3px solid var(--bb-orange);
}

.bb-toast.error {
	border-left: 3px solid var(--bb-rose);
}

@keyframes bb-slide-in {
	from {
		opacity: 0;
		transform: translateX(24px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

/* Desktop */
@media (min-width: 768px) {
	body {
		padding: 28px;
	}

	#bb-app {
		gap: 20px;
	}

	.bb-metrics {
		grid-template-columns: repeat(4, 1fr);
		gap: 16px;
	}

	.bb-metric-value {
		font-size: 26px;
	}

	.bb-form-grid {
		grid-template-columns: 1fr 1fr;
	}

	.bb-seg-row {
		flex-direction: row;
	}

	.bb-seg {
		flex: 1;
	}

	.bb-charts {
		flex-direction: row;
		align-items: stretch;
	}

	.bb-chart-bar {
		flex: 0 0 60%;
		max-width: 60%;
	}

	.bb-chart-doughnut {
		flex: 0 0 calc(40% - 12px);
		max-width: calc(40% - 12px);
	}

	.bb-btn {
		width: auto;
		align-self: flex-start;
		min-width: 200px;
	}

	.bb-manual-form .bb-btn {
		align-self: flex-start;
	}
}
