/* Updated for accessible contrast on negative ticker values */
:root {
	color-scheme: dark;
	--bg-primary: #09090b;
	--bg-secondary: #18181b;
	--bg-tertiary: #27272a;
	--accent: #00d4aa;
	--accent-hover: #00f5c4;
	--red: #ff6b6b;
	--green: #0ecb81;
	--text-primary: #fafafa;
	--text-secondary: #a1a1aa;
	--border: #27272a;
	font-family: 'Inter', system-ui, sans-serif;
	--radius: 2px;
}

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

html, body {
	height: 100%;
	overflow: hidden;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

body {
	background: var(--bg-primary);
	color: var(--text-primary);
}

.dashboard {
	display: grid;
	grid-template-columns: 240px 1fr 320px;
	height: 100vh;
	overflow: hidden;
}

/* Sidebar */
.sidebar {
	background: var(--bg-secondary);
	border-right: 1px solid var(--border);
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}

.sidebar__logo {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	font-size: 1.5rem;
	font-weight: 700;
	margin-bottom: 2rem;
	color: var(--accent);
}

.sidebar__logo i {
	width: 28px;
	height: 28px;
}

.sidebar__nav {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	flex: 1;
}

.sidebar__link {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.875rem 1rem;
	border-radius: 2px;
	color: var(--text-secondary);
	text-decoration: none;
	transition: all 0.2s;
}

.sidebar__link:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

.sidebar__link--active {
	background: var(--accent);
	color: var(--bg-primary);
	font-weight: 600;
}

.sidebar__link i {
	width: 20px;
	height: 20px;
}

.sidebar__link span {
	white-space: nowrap;
}

.sidebar__user {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 1rem;
	background: var(--bg-tertiary);
	border-radius: 3px;
}

.sidebar__user img {
	width: 36px;
	height: 36px;
	border-radius: 2px;
	object-fit: cover;
	flex-shrink: 0;
}

.sidebar__username {
	display: block;
	font-weight: 600;
	font-size: 0.875rem;
}

.sidebar__status {
	font-size: 0.75rem;
	color: var(--accent);
}

/* Main */
.main {
	padding: 1.5rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
	overflow: hidden;
}

/* Header */
.header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-shrink: 0;
	gap: 1rem;
	flex-wrap: wrap;
}

.header__search {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 0.75rem 1rem;
	width: 320px;
	max-width: 100%;
	flex: 1;
	min-width: 200px;
}

.header__search i {
	width: 18px;
	height: 18px;
	color: var(--text-secondary);
	flex-shrink: 0;
}

.header__search input {
	background: none;
	border: none;
	outline: none;
	color: var(--text-primary);
	font-size: 0.875rem;
	width: 100%;
}

.header__actions {
	display: flex;
	gap: 0.75rem;
	flex-shrink: 0;
}

.header__btn {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 0.75rem 1rem;
	color: var(--text-primary);
	cursor: pointer;
	transition: all 0.2s;
	white-space: nowrap;
}

.header__btn:hover {
	background: var(--bg-tertiary);
}

.header__btn--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--bg-primary);
	font-weight: 500;
	letter-spacing: -0.01em;
}

.header__btn--primary:hover {
	background: var(--accent-hover);
}

.header__btn i {
	width: 18px;
	height: 18px;
}

/* Stats */
.stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 1rem;
	flex-shrink: 0;
}

.stat-card {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 3px;
	padding: 1rem;
}

.stat-card__label {
	display: block;
	color: var(--text-secondary);
	font-size: 0.8rem;
	margin-bottom: 0.375rem;
}

.stat-card__value {
	display: block;
	font-size: 1.375rem;
	font-weight: 600;
	margin-bottom: 0.25rem;
	letter-spacing: -0.025em;
}

.stat-card__change {
	font-size: 0.8rem;
	color: var(--text-secondary);
}

.stat-card__change--up {
	color: var(--green);
}

.stat-card__change--down {
	color: var(--red);
}

/* Trading View */
.trading-view {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 3px;
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.trading-view__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--border);
	flex-shrink: 0;
	gap: 1rem;
	flex-wrap: wrap;
}

.trading-view__pair {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
}

.trading-view__symbol {
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.trading-view__price {
	font-size: 1.125rem;
	font-weight: 600;
}

.trading-view__change {
	padding: 0.25rem 0.5rem;
	border-radius: 4px;
	font-size: 0.75rem;
	font-weight: 600;
}

.trading-view__change--up {
	background: rgba(14, 203, 129, 0.15);
	color: var(--green);
}

.trading-view__change--down {
	background: rgba(255, 107, 107, 0.15);
	color: var(--red);
}

.trading-view__timeframes {
	display: flex;
	gap: 0.25rem;
	flex-wrap: wrap;
}

.timeframe {
	background: none;
	border: none;
	padding: 0.5rem 0.75rem;
	border-radius: 4px;
	color: var(--text-secondary);
	cursor: pointer;
	font-size: 0.8125rem;
	transition: all 0.2s;
}

.timeframe:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

.timeframe--active {
	background: var(--accent);
	color: var(--bg-primary);
}

.trading-view__tools {
	display: flex;
	gap: 0.5rem;
}

.trading-view__tools button {
	background: none;
	border: none;
	padding: 0.5rem;
	border-radius: 8px;
	color: var(--text-secondary);
	cursor: pointer;
	transition: all 0.2s;
}

.trading-view__tools button:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

.trading-view__tools i {
	width: 18px;
	height: 18px;
}

.chart {
	flex: 1;
	position: relative;
	overflow: hidden;
	background: #1e2329;
	min-height: 250px;
}

.chart iframe {
	border: none !important;
}

.trading-view__footer {
	display: flex;
	justify-content: space-between;
	padding: 0.75rem 1.25rem;
	border-top: 1px solid var(--border);
	font-size: 0.8125rem;
	color: var(--text-secondary);
	flex-shrink: 0;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.ohlc {
	display: flex;
	gap: 1.5rem;
	flex-wrap: wrap;
}

.ohlc strong {
	color: var(--text-primary);
}

/* Order Panel */
.order-panel {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 16px;
	padding: 1rem;
	flex-shrink: 0;
}

.order-panel__tabs {
	display: flex;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.order-tab {
	flex: 1;
	padding: 0.75rem;
	border: none;
	border-radius: 6px;
	font-weight: 600;
	cursor: pointer;
	background: var(--bg-tertiary);
	color: var(--text-secondary);
	transition: all 0.2s;
}

.order-tab--active.order-tab--buy {
	background: var(--green);
	color: var(--bg-primary);
}

.order-tab--active.order-tab--sell {
	background: var(--red);
	color: white;
}

.order-panel__form {
	display: flex;
	gap: 0.75rem;
	align-items: flex-end;
	flex-wrap: wrap;
}

.order-input {
	flex: 1;
	min-width: 120px;
}

.order-input label {
	display: block;
	font-size: 0.75rem;
	color: var(--text-secondary);
	margin-bottom: 0.375rem;
}

.order-input input {
	width: 100%;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 0.625rem 0.75rem;
	color: var(--text-primary);
	font-size: 0.875rem;
}

.order-input input:focus {
	outline: none;
	border-color: var(--accent);
}

.order-slider {
	display: flex;
	gap: 0.5rem;
	font-size: 0.75rem;
	color: var(--text-secondary);
}

.order-slider span {
	padding: 0.375rem 0.625rem;
	background: var(--bg-tertiary);
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.2s;
}

.order-slider span:hover {
	background: var(--accent);
	color: var(--bg-primary);
}

.order-btn {
	padding: 0.75rem 2rem;
	border: none;
	border-radius: 2px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.2s;
	white-space: nowrap;
}

.order-btn--buy {
	background: var(--green);
	color: var(--bg-primary);
}

.order-btn--buy:hover {
	filter: brightness(1.1);
}

.order-btn--sell {
	background: var(--red);
	color: white;
}

.order-btn--sell:hover {
	filter: brightness(1.1);
}

/* Ticker */
.ticker {
	background: var(--bg-secondary);
	border-left: 1px solid var(--border);
	padding: 1.5rem;
	overflow-y: auto;
}

.ticker__title {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 1rem;
	color: var(--text-secondary);
}

.ticker__list {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.ticker__item {
	display: grid;
	grid-template-columns: 1fr auto auto;
	gap: 0.75rem;
	padding: 0.75rem;
	border-radius: 10px;
	transition: background 0.2s;
	cursor: pointer;
}

.ticker__item:hover {
	background: var(--bg-tertiary);
}

.ticker__item--active {
	background: rgba(0, 212, 170, 0.1);
	border-left: 2px solid var(--accent);
}

.ticker__coin {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	min-width: 0;
}

.ticker__icon {
	width: 32px;
	height: 32px;
	border-radius: 4px;
	background: var(--bg-tertiary);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 600;
	font-size: 0.6875rem;
	flex-shrink: 0;
	letter-spacing: 0.025em;
}

.ticker__name {
	font-weight: 600;
	font-size: 0.875rem;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ticker__symbol {
	font-size: 0.75rem;
	color: var(--text-secondary);
}

.ticker__price {
	text-align: right;
	font-weight: 600;
	font-size: 0.875rem;
	transition: color 0.15s;
	white-space: nowrap;
}

.ticker__price--flash-up {
	color: var(--green);
}

.ticker__price--flash-down {
	color: var(--red);
}

.ticker__change {
	text-align: right;
	font-size: 0.8125rem;
	font-weight: 500;
	min-width: 60px;
	white-space: nowrap;
}

.ticker__change--up {
	color: var(--green);
}

.ticker__change--down {
	color: var(--red);
}

/* Mobile menu toggle */
.mobile-toggle {
	display: none;
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.75rem;
	color: var(--text-primary);
	cursor: pointer;
}

.mobile-toggle i {
	width: 24px;
	height: 24px;
}

/* Responsive Styles */
@media (max-width: 1200px) {
	.dashboard {
		grid-template-columns: 200px 1fr 280px;
	}

	.sidebar__link span {
		font-size: 0.875rem;
	}

	.ticker__item {
		grid-template-columns: 1fr auto;
	}

	.ticker__change {
		display: none;
	}
}

@media (max-width: 1024px) {
	.dashboard {
		grid-template-columns: 1fr;
		grid-template-rows: auto 1fr;
	}

	.sidebar {
		position: fixed;
		left: -280px;
		top: 0;
		bottom: 0;
		width: 280px;
		z-index: 1000;
		transition: left 0.3s ease;
	}

	.sidebar.open {
		left: 0;
	}

	.sidebar-overlay {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.5);
		z-index: 999;
		display: none;
	}

	.sidebar-overlay.open {
		display: block;
	}

	.ticker {
		position: fixed;
		right: -320px;
		top: 0;
		bottom: 0;
		width: 320px;
		z-index: 1000;
		transition: right 0.3s ease;
	}

	.ticker.open {
		right: 0;
	}

	.mobile-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.header {
		order: -1;
	}

	.main {
		padding: 1rem;
		overflow-y: auto;
	}

	html, body {
		overflow: auto;
	}

	.trading-view {
		min-height: 400px;
	}
}

@media (max-width: 768px) {
	.stats {
		grid-template-columns: 1fr;
	}

	.stat-card {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0.875rem 1rem;
	}

	.stat-card__value {
		font-size: 1.25rem;
		margin-bottom: 0;
	}

	.stat-card__label {
		margin-bottom: 0;
	}

	.stat-card__change {
		margin-left: auto;
		padding-left: 1rem;
	}

	.header__search {
		width: 100%;
		order: 1;
	}

	.header__actions {
		width: 100%;
		justify-content: space-between;
	}

	.trading-view__header {
		padding: 0.75rem 1rem;
	}

	.trading-view__tools {
		display: none;
	}

	.order-panel__form {
		flex-direction: column;
	}

	.order-input {
		width: 100%;
	}

	.order-slider {
		width: 100%;
		justify-content: space-between;
	}

	.order-btn {
		width: 100%;
	}

	.ohlc {
		gap: 0.75rem;
	}

	.ohlc span {
		font-size: 0.75rem;
	}
}

@media (max-width: 480px) {
	.main {
		padding: 0.75rem;
		gap: 0.75rem;
	}

	.header__btn span {
		display: none;
	}

	.trading-view__pair {
		gap: 0.5rem;
	}

	.trading-view__symbol {
		font-size: 1rem;
	}

	.trading-view__price {
		font-size: 1rem;
	}

	.timeframe {
		padding: 0.375rem 0.5rem;
		font-size: 0.75rem;
	}

	.trading-view__footer {
		padding: 0.5rem 0.75rem;
	}

	.volume {
		display: none;
	}
}

/* Modal Styles */
.modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.7);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2000;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
	padding: 1rem;
}

.modal.open {
	opacity: 1;
	visibility: visible;
}

.modal__content {
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 16px;
	width: 100%;
	max-width: 420px;
	max-height: 90vh;
	overflow-y: auto;
	transform: scale(0.9) translateY(20px);
	transition: transform 0.3s ease;
}

.modal.open .modal__content {
	transform: scale(1) translateY(0);
}

.modal__content--small {
	max-width: 340px;
}

.modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1.25rem 1.5rem;
	border-bottom: 1px solid var(--border);
}

.modal__header h3 {
	font-size: 1.125rem;
	font-weight: 600;
}

.modal__close {
	background: none;
	border: none;
	color: var(--text-secondary);
	cursor: pointer;
	padding: 0.5rem;
	border-radius: 8px;
	transition: all 0.2s;
}

.modal__close:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

.modal__close i {
	width: 20px;
	height: 20px;
}

.modal__body {
	padding: 1.5rem;
}

.modal__body--center {
	text-align: center;
}

.modal__body--center h3 {
	margin: 1rem 0 0.5rem;
	font-size: 1.25rem;
}

.modal__body--center p {
	color: var(--text-secondary);
	margin-bottom: 0.5rem;
}

.modal__field {
	margin-bottom: 1.25rem;
}

.modal__field label {
	display: block;
	font-size: 0.875rem;
	color: var(--text-secondary);
	margin-bottom: 0.5rem;
}

.modal__select,
.modal__input {
	width: 100%;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.875rem 1rem;
	color: var(--text-primary);
	font-size: 0.9375rem;
	outline: none;
	transition: border-color 0.2s;
}

.modal__select:focus,
.modal__input:focus {
	border-color: var(--accent);
}

.modal__address {
	display: flex;
	gap: 0.5rem;
}

.modal__address input {
	flex: 1;
	background: var(--bg-tertiary);
	border: 1px solid var(--border);
	border-radius: 10px;
	padding: 0.875rem 1rem;
	color: var(--text-primary);
	font-size: 0.875rem;
	font-family: monospace;
}

.modal__copy {
	background: var(--accent);
	border: none;
	border-radius: 10px;
	padding: 0 1rem;
	color: var(--bg-primary);
	cursor: pointer;
	transition: all 0.2s;
}

.modal__copy:hover {
	background: var(--accent-hover);
}

.modal__copy i {
	width: 18px;
	height: 18px;
}

.modal__qr {
	display: flex;
	justify-content: center;
	margin: 1.5rem 0;
}

.modal__qr-placeholder {
	width: 160px;
	height: 160px;
	background: white;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--bg-primary);
	font-weight: 600;
}

.modal__warning {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	background: rgba(255, 107, 107, 0.1);
	border: 1px solid rgba(255, 107, 107, 0.3);
	border-radius: 10px;
	padding: 1rem;
	font-size: 0.8125rem;
	color: var(--red);
}

.modal__warning i {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	margin-top: 2px;
}

.modal__actions {
	display: flex;
	gap: 0.75rem;
	margin-top: 1.5rem;
}

.modal__btn {
	flex: 1;
	padding: 0.875rem 1.5rem;
	border: none;
	border-radius: 10px;
	font-weight: 600;
	font-size: 0.9375rem;
	cursor: pointer;
	transition: all 0.2s;
}

.modal__btn--cancel {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}

.modal__btn--cancel:hover {
	background: var(--border);
}

.modal__btn--confirm {
	background: var(--accent);
	color: var(--bg-primary);
}

.modal__btn--confirm:hover {
	background: var(--accent-hover);
}

/* Order Summary */
.order-summary {
	background: var(--bg-tertiary);
	border-radius: 12px;
	padding: 1rem;
}

.order-summary__row {
	display: flex;
	justify-content: space-between;
	padding: 0.625rem 0;
	border-bottom: 1px solid var(--border);
	font-size: 0.9375rem;
}

.order-summary__row:last-child {
	border-bottom: none;
}

.order-summary__row--total {
	margin-top: 0.5rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border);
	font-weight: 600;
	font-size: 1rem;
}

.order-summary__value {
	font-weight: 500;
}

.order-summary__value--buy {
	color: var(--green);
}

.order-summary__value--sell {
	color: var(--red);
}

/* Success Icon */
.success-icon {
	width: 72px;
	height: 72px;
	background: rgba(14, 203, 129, 0.15);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto;
}

.success-icon i {
	width: 40px;
	height: 40px;
	color: var(--green);
}

.success-order-id {
	font-family: monospace;
	background: var(--bg-tertiary);
	padding: 0.5rem 1rem;
	border-radius: 8px;
	display: inline-block;
	margin: 1rem 0 1.5rem;
}

/* Toast Notification */
.toast {
	position: fixed;
	bottom: 2rem;
	left: 50%;
	transform: translateX(-50%) translateY(100px);
	background: var(--bg-secondary);
	border: 1px solid var(--border);
	border-radius: 12px;
	padding: 1rem 1.5rem;
	display: flex;
	align-items: center;
	gap: 0.75rem;
	z-index: 3000;
	opacity: 0;
	transition: all 0.3s ease;
}

.toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

.toast i {
	width: 20px;
	height: 20px;
	color: var(--green);
}