/* assets/styles.css */
* {
	box-sizing: border-box;
}

[data-welcome] {
	opacity: 1;
	transition: opacity 0.2s ease-in-out;
}

[data-welcome].invisible {
	opacity: 0;
}

html,
body {
	height: 100%;
}

.flex-col {
	flex-direction: column;
}

/* Tailwind's `h-full` */
.h-full {
	height: 100%;
}

.whitespace-nowrap {
	white-space: nowrap;
}

body {
	margin: 0;
	font-family: var(--font-sans);
	font-size: 16px;
	line-height: 1.5;
	color: #e5e7eb;
	background: var(--dark-bcg);
	transition: background-color 0.3s ease, color 0.3s ease;
	overflow-x: hidden;
}

html.light body {
	color: #1f2937;
	background: #ffffff;
}

html.light .text-body {
	color: #1f2937;
}

.text-body {
	color: #e5e7eb;
}

h1 {
	font-size: 35px;
	font-weight: 600;
	line-height: 1;
}

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

.text-left {
	text-align: left;
}

:root {
	--sidebar-w: 18rem;
}

:root {
	--font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
		Arial, "Apple Color Emoji", "Segoe UI Emoji";
	--dark-bcg: #000f1e;
	--dark-sidebar-bcg: #061321;
	--light-bcg: #ffffff;
	--light-sidebar-bcg: #f9fafb;
}

html.light {
	--dark-bcg: var(--light-bcg);
	--dark-sidebar-bcg: var(--light-sidebar-bcg);
}

.app-grid {
	display: grid;
	grid-template-columns: var(--sidebar-w) 1fr;
	min-height: 100vh;
}

/* Mobile layout - single column, full width content */
@media (max-width: 1050px) {
	.app-grid {
		grid-template-columns: 1fr !important;
		min-height: auto;
	}

	/* Ensure main content stretches */
	main.content {
		width: 100%;
		max-width: 100%;
		padding-left: 1rem;
		padding-right: 1rem;
	}

	/* Sidebar completely hidden */
	#sidebar {
		display: none !important;
	}

	/* Topbar always on top, fixed */
	.topbar-mobile {
		position: relative;
		top: 0;
		left: 0;
		right: 0;
		z-index: 50;
		width: 100%;
		max-height: 54px;
	}
}

.app-grid > main.content {
	padding: 1.75rem 2.25rem;
}

@media (max-width: 1050px) {
	
	.app-grid>main.content {
			padding: 1.2rem;
		}

}


a {
	color: #a5d8ff;
	text-decoration: none;
}

.app {
	min-height: 100vh;
	display: flex;
}

.brand-title {
	color: #fff;
	font-size: 19px;
}

#runTitle {
	min-height: 43px;
}

#runHeader {
	min-height: 32.8px;
}

#runMeta {
	min-height: 1rem;
}

#sidebar {
	padding: 24px;
	background: var(--dark-sidebar-bcg);
	border-right: 1px solid #1c2232;
	padding: 0.5rem;
	transition: background-color 0.3s ease, border-color 0.3s ease;
}

html.light #sidebar {
	background: var(--light-sidebar-bcg);
	border-right-color: #e5e7eb;
}

.brand {
	display: flex;
	align-items: center;
	gap: 12px;
}

.logo {
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.1);
	display: flex;
	align-items: center;
	justify-content: center;
}

.brand-text {
	display: flex;
	flex-direction: column;
}

.brand-name {
	font-weight: 700;
}

.brand-sub {
	font-size: 12px;
	opacity: 0.6;
}

.nav-link span {
	margin-left: 4px;
}

.nav-link .lucide,
.nav-link i,
.nav-link svg {
	display: inline-block;
	flex-shrink: 0;
	width: 1rem;
	/* 16px */
	height: 1rem;
}

.nav {
	margin-top: 20px;
	display: grid;
	gap: 10px;
}

.nav-link {
	margin-bottom: 7px;
}

.nav-link {
	display: flex;
	padding: 9px 14px;
	border-radius: 12px;
	border: 1px solid;
	border-color: transparent;
	color: rgba(255, 255, 255, 0.9);
	font-weight: 500;
	border-radius: 13px !important;
	transition: 0.4s;
	align-items: center;
}

.nav-link:hover {
	background: rgba(255, 255, 255, 0.08);
}

.nav-link.active,
.nav-link.active:hover {
	background: #24203c;
	border: 1px solid transparent;
}

.space-y-1 > :not([hidden]) ~ :not([hidden]) {
	margin-top: 0;
}

.account-card {
	margin-top: auto;
	padding: 16px;
	border-radius: 12px;
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(255, 255, 255, 0.04);
}

.user-row {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
}

.user-label {
	opacity: 0.85;
	font-size: 14px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.btn-ghost {
	background: #374151;
	color: #fff;
	border: 0;
	border-radius: 10px;
	padding: 8px 12px;
	cursor: pointer;
}

.btn-ghost:hover {
	background: #4b5563;
}

.main-col {
	flex: 1;
	min-width: 0;
}

.topbar {
	position: sticky;
	top: 0;
	z-index: 10;
	height: 56px;
	display: flex;
	align-items: center;
	padding: 0 16px;
	background: rgba(0, 0, 0, 0.35);
	backdrop-filter: blur(6px);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-title {
	font-weight: 600;
}

.main {
	max-width: 1100px;
	margin: 0 auto;
	padding: 24px;
}

.main h1 {
	margin: 0 0 18px;
	font-size: 28px;
}

/* Never flash content before auth */
[data-cloak] {
	visibility: hidden;
}

/* Header row next to the page title */
.page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	flex-wrap: wrap;
	/* stacks on small screens */
}

.page-header h1 {
	margin: 0;
}

/* Generic buttons (opt-in) */
.btn {
	--btn-bg: transparent;
	--btn-border: rgba(255, 255, 255, 0.12);
	--btn-fg: #fff;

	display: inline-flex;
	align-items: center;
	gap: 0.6rem;
	padding: 0.7rem 1rem;
	border-radius: 14px;
	border: 1px solid var(--btn-border);
	background: var(--btn-bg);
	color: var(--btn-fg);
	text-decoration: none;
	font-weight: 500;
	line-height: 1;
	transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
	white-space: nowrap;
}

.btn i {
	display: block;
}

/* keeps Lucide icon aligned */

/* Size variants */
.btn-lg {
	padding: 0.9rem 1.2rem;
	font-size: 16px;
	background: #121721;
	border-color: #121721;
}

/* Accent (gradient) variant */
.btn-accent {
		--gradient-primary: linear-gradient(135deg, hsl(263 70% 50%), hsl(340 75% 55%));
	background: var(--gradient-primary);
	transition: 0.4s;
	border: 0;
}

.btn-accent-secondary {
	background: linear-gradient(150deg, #8c3e91, #581299)
}

.btn-accent-disabled {
		background: linear-gradient(150deg, #8c3e91, #581299);
			opacity: .5;
}

.bcg-primary {
		background: linear-gradient(135deg, hsl(263 70% 50%), hsl(340 75% 55%));
}

.btn-accent:hover {
	filter: brightness(1.06);
}

.btn-accent:active {
	transform: translateY(0);
	filter: brightness(1);
}

/* ---- Uniform dark inputs ---- */
.ui-field {
	width: 100%;
	height: 44px;
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.08);
	color: #e5e7eb;
	/* slate-200 */
	padding: 0 0.875rem;
	/* side padding */
	transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.ui-field:hover {
	background: rgba(255, 255, 255, 0.06);
	border-color: rgba(255, 255, 255, 0.18);
}

.ui-field:focus {
	outline: none;
	border-color: #8b5cf6;
	/* violet-500 */
	box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.35);
}

/* ---- Pretty select (hides native arrow, adds our chevron) ---- */
.ui-select {
	position: relative;
}

.ui-select > select {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	/* hide default arrow */
	padding-right: 2.25rem;
	/* room for chevron */
	background-color: transparent;
	/* keep same bg as .ui-field */
}

.ui-select .chev {
	position: absolute;
	right: 0.65rem;
	top: 50%;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	color: #cbd5e1;
	/* slate-300 */
	pointer-events: none;
	opacity: 0.8;
}

.ui-select:focus-within .chev {
	opacity: 1;
	color: #e5e7eb;
}

/* ===== Custom Select ===== */
.tsl-select {
	position: relative;
}

.tsl-select__trigger {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border-radius: 12px;
	background-color: #292f355c;
	border: 1px solid;
	border-color: transparent;
	color: #e5e7eb;
}

.tsl-select__trigger:hover {
	background-color: rgb(35 37 42 / 85%);
}

.tsl-select__trigger:focus-visible {
	outline: none;
	border-color: #a78bfa;
	/* purple ring */
	box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.25);
}

.tsl-select__chevron {
	opacity: 0.8;
	transition: transform 0.18s ease;
}

/* menu */
.tsl-select__menu {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 8px);
	background: rgba(18, 19, 25, 0.98);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 12px;
	padding: 6px;
	margin: 0;
	list-style: none;
	box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45), 0 8px 20px rgba(0, 0, 0, 0.35);
	max-height: 320px;
	overflow: auto;
	transform: translateY(-6px);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.12s ease, transform 0.12s ease;
	z-index: 40;
}

#strategyForm,
#tab-overview,
#tab-trades,
#tab-overview,
#tab-analysis,
#tab-pnl-calendar,
#runDetail,
.page {
	max-width: 1300px;
}

/* Responsive tabs grid */
#runTabs {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1170px) {
	#runTabs {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 860px) {
	#runTabs {
		grid-template-columns: 1fr;
	}
}

#cardsGrid,
#search-box {
	max-width: 1400px;
}

.tsl-option {
	padding: 10px 12px;
	border-radius: 10px;
	cursor: pointer;
	color: #e5e7eb;
	white-space: nowrap;
}

.focus\:ring-purple-500:focus {
	--tw-ring-opacity: 1;
	--tw-ring-color: rgb(59 50 69);
}

.tsl-option:hover {
	background: rgba(255, 255, 255, 0.06);
}

.tsl-option[aria-selected="true"] {
	background: linear-gradient(180deg, rgba(168, 85, 247, 0.16), rgba(168, 85, 247, 0.04));
	border: 1px solid rgba(168, 85, 247, 0.25);
}

/* open state */
.tsl-select--open .tsl-select__menu {
	opacity: 1;
	transform: translateY(0);
	pointer-events: auto;
}

.tsl-select--open .tsl-select__chevron {
	transform: rotate(180deg);
}

.bg-gray-700 {
	background-color: #191e2c54

}

/*Backtesting*/
.space-between {
	justify-content: space-between;
}

.space-around {
	justify-content: space-around;
}

.justify-between {
	justify-content: space-between;
	/* = justify-between */

}

.self-end {
	align-self: flex-end;
	/* overrides container's align-items for this item */
}

/* Tailwind generates this */
.leading-none {
	line-height: 1;
}

.align-bottom {
	align-items: flex-end;
}

.button-processing {
	color: #cbccce;
	border-color: #424a58 !important;
}

.sbtfr {
	font-size: 0.77rem;
	border-radius: 22px;
	padding: 5px 15px;
	color: rgb(255 255 255 / 78%);
}

.bckstatus {
	font-size: 0.77rem;
	border-radius: 22px;
	padding: 5px 15px;
	line-height: 1.25rem;
	border-color: transparent;
	border: 1px solid;
}

.inline-flex {
	display: inline-flex;
}

.flex-start {
	align-items: flex-start;
}

.border-green-900 {
	border-color: rgb(52 188 139);
}

/* Fallback in case Tailwind's sr-only isn't active */
.visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.text-disabled {
	color: #424a58;
	border-color: #252d37;
}

/* visual “disabled” look without losing the native time icon */
.is-disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.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;
}

/* Hide the native checkbox while keeping it accessible and focusable */
.tsl-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.basis-12 {
	width: 100%;
}

.text-424a58 {
	color: #424a58;
}

.justify-center {
	justify-content: center;
}

h2#runTitle {
	font-size: 32px;
}



.text-blue-300 {
	color: #3674cd;
}




.text-orange-300 {
	color: #e39f25;
}

.align-right,
.text-right {
	text-align: right;
}

.float-right {
	float: right;
}

.rounded-sq {
	border-radius: 0.5rem;
}

.rounded-sq-main {
	border-radius: 0.5rem;
}

.min-w-full {
	width: 100%;
}

/* Equity Curve

/* --- Backtest Equity chart --- */
#equityChart {
	position: relative;
}

#equityChart > svg {
	display: block;
	/* remove inline SVG baseline gap */
}

#equityChart .tsl-tip {
	position: absolute;
	/* keep tooltip out of doc flow */
	pointer-events: none;
	/* don't catch mouse */
	will-change: transform;
	/* smoother moves */
}

#equityChart .tsl-tip.hidden {
	left: -9999px;
	/* hide without affecting layout */
	top: -9999px;
}

.ml-auto {
	margin-left: auto;
}

#runPills span {
	min-height: 25.19px;
	line-height: 1.1;
}



/* KPIs*/
.card-title {
  font-size: 14px;
      font-weight: 500;
}

#runKpis .bg-gray-800 {
    backdrop-filter: blur(4px);
        transition-property: all;
        transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);

        transition-duration: 0.6s;
}

#runKpis .bg-gray-800:hover {
  box-shadow: 0 0 13px #6b26d94d;
}

th {
	font-weight: normal;
}

/* ============================================
   Light Mode Theme Overrides
   ============================================ */

html.light .brand-title {
	color: #1f2937;
}

html.light .nav-link {
	color: rgba(31, 41, 55, 0.9);
}

html.light .nav-link:hover {
	background: rgba(0, 0, 0, 0.05);
}

html.light .nav-link.active,
html.light .nav-link.active:hover {
	background: #e5e7eb;
	color: #1f2937;
}

html.light .logo {
	background: rgba(0, 0, 0, 0.05);
}

html.light .account-card {
	border-color: rgba(0, 0, 0, 0.1);
	background: rgba(0, 0, 0, 0.02);
}

html.light .user-label {
	color: #1f2937;
}

html.light .topbar {
	background: rgba(255, 255, 255, 0.9);
	border-bottom-color: rgba(0, 0, 0, 0.1);
}

html.light .topbar-title {
	color: #1f2937;
}

html.light h1 {
	color: #1f2937;
}

html.light a {
	color: #2563eb;
}

/* Text color overrides for light mode */
html.light .text-gray-100,
html.light .text-gray-200,
html.light .text-gray-300,
html.light .text-gray-400,
html.light .text-gray-500,
html.light .text-gray-600 {
	color: #4b5563 !important;
}

html.light .text-white {
	color: #1f2937 !important;
}

/* Background color overrides for light mode */
html.light .bg-gray-800,
html.light .bg-gray-900 {
	background-color: #f9fafb !important;
}

html.light .bg-gray-700 {
	background-color: #e5e7eb !important;
}

html.light .bg-gray-600 {
	background-color: #d1d5db !important;
}

html.light .border-gray-700,
html.light .border-gray-800 {
	border-color: #d1d5db !important;
}

html.light .border-gray-600 {
	border-color: #e5e7eb !important;
}

/* Buttons */
html.light .btn {
	--btn-border: rgba(0, 0, 0, 0.15);
	--btn-fg: #1f2937;
}

html.light .btn-accent {
	background: linear-gradient(135deg, hsl(263 70% 50%), hsl(340 75% 55%));
}

html.light button.bg-gray-700,
html.light .bg-gray-700 {
	background-color: #e5e7eb !important;
	color: #1f2937 !important;
}

html.light button.bg-gray-700:hover,
html.light .bg-gray-700:hover {
	background-color: #d1d5db !important;
}

/* Form inputs */
html.light .ui-field {
	background: rgba(0, 0, 0, 0.03);
	border-color: rgba(0, 0, 0, 0.1);
	color: #1f2937;
}

html.light .ui-field:hover {
	background: rgba(0, 0, 0, 0.05);
	border-color: rgba(0, 0, 0, 0.15);
}

html.light .ui-field:focus {
	border-color: #8b5cf6;
	box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Select dropdowns */
html.light .tsl-select__trigger {
	background-color: #f9fafb;
	border-color: #d1d5db;
	color: #1f2937;
}

html.light .tsl-select__menu {
	background-color: #ffffff;
	border-color: #d1d5db;
}

html.light .tsl-option {
	color: #1f2937;
}

html.light .tsl-option:hover {
	background-color: #f3f4f6;
}

html.light .tsl-option[aria-selected="true"] {
	background-color: #e5e7eb;
	color: #1f2937;
}

/* Calendar specific light mode styles */
html.light .pnl-calendar-container {
	background-color: #ffffff !important;
	border-color: #d1d5db !important;
}

html.light .bg-gray-800\/50 {
	background-color: rgba(249, 250, 251, 0.5) !important;
}

html.light .bg-green-950\/40 {
	background-color: rgba(220, 252, 231, 0.8) !important;
}

html.light .bg-red-950\/40 {
	background-color: rgba(254, 226, 226, 0.8) !important;
}

html.light .border-green-800\/60 {
	border-color: rgba(34, 197, 94, 0.6) !important;
}

html.light .border-red-800\/60 {
	border-color: rgba(239, 68, 68, 0.6) !important;
}

html.light .border-gray-800 {
	border-color: #e5e7eb !important;
}

/* Account page light mode */
html.light .text-gray-300 {
	color: #4b5563 !important;
}

html.light label.text-gray-300 {
	color: #374151 !important;
}

/* P&L Calendar - Weekly column spacing (only when scrolling is enabled) */
.pnl-calendar-container .scrollable.scroll-enabled .grid.grid-cols-8 .weekly-column-header,
.pnl-calendar-container .scrollable.scroll-enabled .grid.grid-cols-8 .weekly-column {
	margin-left: 1rem; /* 16px - creates larger gap between Saturday and weekly column */
}

/* P&L Calendar - Center month/arrows in entire header */
.pnl-calendar-container .relative {
	position: relative;
}

.pnl-calendar-container .absolute {
	position: absolute;
}

.pnl-calendar-container .left-1\/2 {
	left: 50%;
}

.pnl-calendar-container .transform {
	transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.pnl-calendar-container .-translate-x-1\/2 {
	--tw-translate-x: -50%;
}

/* P&L Calendar Header - Responsive layout for monthly stats */
.pnl-calendar-container .calendar-header {
	flex-wrap: wrap;
}

/* When content width <= 990px, show monthly stats below month/arrows */
.pnl-calendar-container .calendar-header.stats-below {
	flex-direction: column;
	gap: 1rem;
}

.pnl-calendar-container .calendar-header.stats-below .calendar-month-nav {
	position: static;
	transform: none;
	left: auto;
	justify-content: center;
	width: 100%;
}

.pnl-calendar-container .calendar-header.stats-below .calendar-monthly-stats {
	margin-left: 0;
	justify-content: center;
	width: 100%;
}

/* Tab styling */
.tab {
	font-weight: 500;
	min-height: 46px;
}

.tab.active {
	background-color: #712081;
}

/* Border gray-600 color */
.border-gray-600 {
	border-color: #191a26;
}

/* Strategy Analysis Table - Horizontal scroll pattern (similar to P&L calendar) */
.analysis-table-scrollable {
	overflow-x: hidden;
	overflow-y: hidden;
	width: 100%;
	max-width: 100%;
	position: relative;
}

.analysis-table-scrollable.scroll-enabled {
	overflow-x: auto !important;
}

.analysis-table-scrollable.scroll-enabled > div {
	width: auto;
	min-width: 100%;
}

.analysis-table-scrollable.scroll-enabled > div::-webkit-scrollbar {
	height: 12px;
}

.analysis-table-scrollable.scroll-enabled > div::-webkit-scrollbar-track {
	background: rgba(31, 41, 55, 0.5);
	box-shadow: 0 0 2px rgba(0, 0, 0, 0.15) inset;
}

.analysis-table-scrollable.scroll-enabled > div::-webkit-scrollbar-thumb {
	background: rgba(156, 163, 175, 0.5);
	border-radius: 6px;
}

.analysis-table-scrollable.scroll-enabled > div::-webkit-scrollbar-thumb:hover {
	background: rgba(156, 163, 175, 0.7);
}

/* Trades Table - Horizontal scroll pattern (similar to P&L calendar) */
.trades-table-scrollable {
	overflow-x: hidden;
	overflow-y: hidden;
	width: 100%;
	max-width: 100%;
	position: relative;
}

.trades-table-scrollable.scroll-enabled {
	overflow-x: auto !important;
}

.trades-table-scrollable.scroll-enabled > div {
	width: auto;
	min-width: 100%;
}

.trades-table-scrollable.scroll-enabled > div::-webkit-scrollbar {
	height: 12px;
}

.trades-table-scrollable.scroll-enabled > div::-webkit-scrollbar-track {
	background: rgba(31, 41, 55, 0.5);
	box-shadow: 0 0 2px rgba(0, 0, 0, 0.15) inset;
}

.trades-table-scrollable.scroll-enabled > div::-webkit-scrollbar-thumb {
	background: rgba(156, 163, 175, 0.5);
	border-radius: 6px;
}

.trades-table-scrollable.scroll-enabled > div::-webkit-scrollbar-thumb:hover {
	background: rgba(156, 163, 175, 0.7);
}


/* Prevent page-level horizontal scrolling */
html {
	overflow-x: hidden;
}

/* Ensure tab panel doesn't overflow */
#tab-pnl-calendar {
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

/* Ensure pnl-calendar-panel doesn't overflow */
#pnl-calendar-panel {
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

/* P&L Calendar - Horizontal scroll pattern (from CodePen) */
.pnl-calendar-container {
	width: 100%;
	max-width: 100%;
	overflow: visible;
}

.pnl-calendar-container .scrollable {
	overflow: hidden;
	position: relative;
	width: 100%;
	max-width: 100%;
}


/* Calendar container can expand for scrolling */
.pnl-calendar-container #calendarContainer {
	width: fit-content;
	min-width: 100%;
}

/* Prevent page-level horizontal scrolling */
html {
	overflow-x: hidden;
}

/* Ensure tab panel doesn't overflow */
#tab-pnl-calendar {
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

/* Ensure pnl-calendar-panel doesn't overflow */
#pnl-calendar-panel {
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

/* P&L Calendar - Horizontal scroll pattern (from CodePen) */
.pnl-calendar-container {
	width: 100%;
	max-width: 100%;
	overflow: visible;
}

.pnl-calendar-container .scrollable {
	overflow-x: auto;
	overflow-y: hidden;
	width: 100%;
	max-width: 100%;
}

/* Prevent page-level horizontal scrolling - CRITICAL */
html {
	overflow-x: hidden;
	max-width: 100vw;
}

body {
	overflow-x: hidden;
	max-width: 100vw;
	width: 100%;
}

/* Ensure main container stays within bounds */
main {
	width: 100%;
	max-width: 100vw;
	overflow-x: hidden;
}

/* Ensure page container stays within bounds */
.page {
	max-width: 1300px;
	width: 100%;
	overflow-x: hidden;
}

/* Ensure wrapper div around tabs stays within bounds */
.page > div {
	max-width: 100%;
	overflow-x: hidden;
}

/* Ensure tabs container stays within bounds */
#runTabs {
	width: 100%;
	max-width: 100%;
	overflow-x: hidden;
}

/* Ensure tab panel doesn't overflow - only for P&L calendar */
#tab-pnl-calendar {
	width: 100%;
	max-width: 100%;
	overflow-x: visible; /* Allow calendar to expand when not scrolling */
	overflow-y: hidden;
}

/* Ensure pnl-calendar-panel doesn't overflow */
#pnl-calendar-panel {
	width: 100%;
	max-width: 100%;
	overflow-x: visible; /* Allow calendar to expand when not scrolling */
	overflow-y: hidden;
}

/* P&L Calendar - Horizontal scroll pattern (from CodePen) */
.pnl-calendar-container {
	width: 100%;
	max-width: 100%;
	overflow: visible;
}

.pnl-calendar-container .scrollable {
	overflow-x: hidden !important; /* Default: no scrolling */
	overflow-y: hidden;
	width: 100%;
	max-width: 100%;
	position: relative;
}

/* Scrolling enabled via JavaScript when content width <= 1233px */
.pnl-calendar-container .scrollable.scroll-enabled {
	overflow-x: auto !important;
}

.pnl-calendar-container .scrollable.scroll-enabled > div {
	width: auto;
	min-width: 100%;
}

/* When scrolling is disabled, allow inner div to expand naturally */
.pnl-calendar-container .scrollable:not(.scroll-enabled) > div {
	width: auto !important;
	max-width: none !important;
	min-width: 0 !important;
}

.pnl-calendar-container .scrollable.scroll-enabled > div::-webkit-scrollbar {
	height: 12px;
}

.pnl-calendar-container .scrollable.scroll-enabled > div::-webkit-scrollbar-track {
	background: rgba(31, 41, 55, 0.5);
	box-shadow: 0 0 2px rgba(0, 0, 0, 0.15) inset;
}

.pnl-calendar-container .scrollable.scroll-enabled > div::-webkit-scrollbar-thumb {
	background: rgba(156, 163, 175, 0.5);
	border-radius: 6px;
}

.pnl-calendar-container .scrollable.scroll-enabled > div::-webkit-scrollbar-thumb:hover {
	background: rgba(156, 163, 175, 0.7);
}

/* Calendar container - allow natural expansion */
.pnl-calendar-container #calendarContainer {
	width: auto;
	min-width: 100%;
}

/* Calendar grid - allow natural expansion */
.pnl-calendar-container #calendarGrid {
	width: auto;
	min-width: 100%;
}

/* Ensure grid columns have minimum width of 127px (only when scrolling is enabled) */
.pnl-calendar-container .scrollable.scroll-enabled #calendarGrid > .grid {
	grid-template-columns: repeat(8, minmax(127px, 1fr)) !important;
}

/* When scrolling is disabled, allow columns to shrink proportionally */
.pnl-calendar-container .scrollable:not(.scroll-enabled) #calendarGrid > .grid {
	grid-template-columns: repeat(8, 1fr) !important;
}

/* Mobile: Ensure calendar day cells don't become too large on initial load */
@media (max-width: 768px) {
	.pnl-calendar-container .calendar-day-cell {
		max-width: 100%;
		min-width: 0;
		max-height: 150px; /* Prevent squares from becoming too tall */
	}
	
	/* Ensure grid columns are properly sized on mobile */
	.pnl-calendar-container #calendarGrid > .grid {
		grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
	}
	
	/* Override aspect-square on mobile to prevent huge squares */
	.pnl-calendar-container .calendar-day-cell.aspect-square {
		aspect-ratio: auto;
		height: auto;
		min-height: 80px;
		max-height: 150px;
	}
}

/* Ensure weekly column also has minimum width (only when scrolling is enabled) */
.pnl-calendar-container .scrollable.scroll-enabled .weekly-column {
	min-width: 127px;
	width: 100%;
}

/* When scrolling is disabled, allow weekly column to shrink */
.pnl-calendar-container .scrollable:not(.scroll-enabled) .weekly-column {
	min-width: 0;
	width: 100%;
}

/* Ensure header cells also respect minimum width (only when scrolling is enabled) */
.pnl-calendar-container .scrollable.scroll-enabled #calendarGrid > div:first-child > div {
	min-width: 127px;
}

/* When scrolling is disabled, allow header cells to shrink */
.pnl-calendar-container .scrollable:not(.scroll-enabled) #calendarGrid > div:first-child > div {
	min-width: 0;
}