/* ── Theme Variables ─────────────────────────────────── */

:root {
	--bg: #ffffff;
	--text: #000000;
	--text-secondary: #555555;
	--link: rgb(0, 0, 238);
	--divider: rgba(0, 0, 0, 0.15);
	--border: black;
	--border-light: lightgray;
	--border-subtle: #e0e0e0;
	--border-gray: gray;
	--row-even: #ffffff;
	--row-odd: #eeeeee;
	--row-hover: rgba(255, 165, 0, 0.10);
	--input-bg: #ffffff;
	--submit-bg: #eeeeee;
	--submit-hover: lightgray;
	--index-hover: #eeeeee;
	--btn-color: #666666;
	--btn-border: #cccccc;
	--btn-hover-bg: #f0f0f0;
	--btn-hover-border: #aaaaaa;
	--btn-hover-color: #333333;
	--spin-btn-bg: rgba(255, 255, 255, 0.85);
	--spin-btn-hover: rgba(240, 240, 255, 1);
	--footer-color: #999999;
	--footer-border: #e0e0e0;
	--muted: #888888;
	--placeholder: #a7a7a7;
	--selection-bg: yellow;
	--chart-shadow: rgba(0, 0, 0, 0.25);
	--chart-btn-bg: #52525b;
	--chart-btn-text: #f4f4f5;
	--chart-btn-border: #71717a;
	--chart-btn-active-bg: #4f46e5;
	--chart-btn-active-text: #ffffff;
	--star-color: #ffc107;
}

[data-theme="dark"] {
	--bg: #151a24;
	--text: #e5e7eb;
	--text-secondary: #9ca3af;
	--link: #60a5fa;
	--divider: rgba(255, 255, 255, 0.10);
	--border: #4b5563;
	--border-light: #374151;
	--border-subtle: #374151;
	--border-gray: #4b5563;
	--row-even: #1f2937;
	--row-odd: #1a2333;
	--row-hover: rgba(251, 191, 36, 0.12);
	--input-bg: #1f2937;
	--submit-bg: #1f2937;
	--submit-hover: #374151;
	--index-hover: #1f2937;

	--btn-color: #9ca3af;
	--btn-border: #4b5563;
	--btn-hover-bg: #1f2937;
	--btn-hover-border: #6b7280;
	--btn-hover-color: #d1d5db;
	--spin-btn-bg: rgba(17, 24, 39, 0.85);
	--spin-btn-hover: rgba(31, 41, 55, 1);
	--footer-color: #6b7280;
	--footer-border: #374151;
	--muted: #6b7280;
	--placeholder: #6b7280;
	--selection-bg: #78350f;
	--chart-shadow: rgba(0, 0, 0, 0.55);
	--star-color: #fbbf24;

}

/* ── Base ────────────────────────────────────────────── */

* {
	box-sizing: border-box;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

::selection {
	background: var(--selection-bg);
}

::-moz-selection {

	background: var(--selection-bg);
}

::placeholder {
	color: var(--placeholder);
	opacity: 1;
}

h1, h2, h3, h4, h5, h6 {
	font-family: 'Cormorant Garamond', serif;
}

hr {
	border: 0;
	border-top: 1px solid var(--divider);
}

body {
	min-width: 250px;
	max-width: 95vw;
	margin: auto;
	padding: 10px 20px;
	overflow-y: scroll;
	background-color: var(--bg);
	color: var(--text);
	font-size: 16px;
	line-height: 1.5;
	font-family: 'Open Sans', sans-serif;
}

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

a:hover {
	text-decoration: underline;
}

/* ── Layout ─────────────────────────────────────────── */

#top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 15px;
	margin-bottom: 20px;
	padding: 10px 0;
}

#navHome {
	font-size: 1.25rem;
}

#symbolQuote {
	display: flex;
	align-items: center;
	gap: 8px;
}

#symbolQuote form {
	display: flex;
	align-items: center;
}

#symbolQuote input[type="text"] {
	font-family: inherit;
	font-size: 0.9rem;
	height: 35px;
	padding: 0 10px;
	border: 1px solid var(--border);
	border-radius: 3px;
	background: var(--input-bg);
	color: var(--text);
}

#symbolQuote input[type="submit"] {
	height: 35px;
	padding: 0 15px;
	border: 1px solid var(--border);
	border-radius: 3px;
	background: var(--submit-bg);
	cursor: pointer;
	transition: background 0.5s;
	margin-left: 5px;
	color: var(--text);
}

#symbolQuote input[type="submit"]:hover {
	background: var(--submit-hover);
}

#theme-toggle {
	cursor: pointer;
	background: transparent;
	border: 1px solid var(--border-light);
	border-radius: 3px;
	font-size: 18px;
	padding: 0 8px;
	height: 35px;
	color: inherit;
	display: flex;
	align-items: center;
	justify-content: center;
}

#theme-toggle:hover {
	background: var(--index-hover);
}

/* ── Tables ─────────────────────────────────────────── */

.table-responsive {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 1rem;
	border: 1px solid var(--border-light);
	border-radius: 4px;
	/* Indicate scrollability */
	background: linear-gradient(to right, var(--bg) 30%, rgba(255, 255, 255, 0)),
		linear-gradient(to right, rgba(255, 255, 255, 0), var(--bg) 70%) 100% 0,
		radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)),
		radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .2), rgba(0, 0, 0, 0)) 100% 0;
	background-repeat: no-repeat;
	background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
	background-attachment: local, local, scroll, scroll;
}

/* Home page table height limit */
.home-table-container {
	width: 100%;
	max-height: 250px;
	overflow-y: auto;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

table.quote_detail {
	width: 100%;
	border-collapse: collapse;
	background: var(--bg);
	border: 1px solid var(--border);
}

table.quote_detail th,
table.quote_detail td {
	padding: 4px 8px;
	text-align: left;
}

table.quote_detail th {
	font-weight: bold;
	font-size: 1.05rem;
	white-space: nowrap;
	background: var(--row-odd);
	position: sticky;
	top: 0;
	z-index: 1;
}

table.quote_detail tbody tr:nth-child(even) {
	background: var(--row-even);
}

table.quote_detail tbody tr:nth-child(odd) {
	background: var(--row-odd);
}

table.quote_detail tbody tr {
	transition: background 0.5s;
}

table.quote_detail tbody tr:hover {
	background: var(--row-hover);
}

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

/* simpletable restoration */
table.simpletable {
	border-collapse: collapse;
	margin-bottom: 8px;
}

table.simpletable td,
table.simpletable th {
	border: 1px solid var(--border-subtle);
	padding: 2px 6px;
}

/* ── Components ─────────────────────────────────────── */

.see-more {
	font-weight: bold;
}

.positive {
	color: green;
}

.negative {
	color: red;
}

.stars {
	color: var(--star-color);
	white-space: nowrap;
	font-family: 'Segoe UI Symbol', 'DejaVu Sans', serif;
	letter-spacing: 1px;
}

.small {
	font-size: 0.8rem;
}

.big {
	font-size: 1.25rem;
}

.subText {
	color: var(--text-secondary);
	font-style: oblique;
}

.indexBlock {
	display: inline-block;
	border: 1px solid var(--border-light);
	border-radius: 4px;
	padding: 5px 10px;
	min-width: 140px;
	transition: background 0.5s;
	background: var(--bg);
}

.indexBlock:hover {
	background: var(--index-hover);
}

.indexLink {
	margin: 3px 7px;
	display: inline-block;
}

.index-pair {
	display: inline-flex;
	flex-wrap: nowrap;
}

@media (max-width: 480px) {
	#infoWrapper {
		display: flex;
		flex-wrap: wrap;
	}

	.index-pair {
		flex: 0 0 100%;
	}
}

/* ── Home Page Sections ─────────────────────────────── */

.home-section h2 {
	margin-bottom: 0;
}

.section-header {
	display: flex;
	align-items: baseline;
	gap: 12px;
	border-bottom: 1px solid var(--divider);
	padding-bottom: 4px;
	margin-bottom: 10px;
}

.section-header h2 {
	border-bottom: none;
	padding-bottom: 0;
}

.see-more {
	margin-left: auto;
	white-space: nowrap;
}

.home-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 20px;
}

/* ── Media Queries ──────────────────────────────────── */

@media (max-width: 768px) {
	body {
		padding: 5px 10px;
		font-size: 85%;
	}

	table.quote_detail th {
		font-size: 85%;
	}

	table.quote_detail td {
		padding: 2px 4px;
	}

	.col-name {
		display: none;
	}

	.trim {
		display: none;
	}

	.big {
		font-size: 85%;
	}


	#top {
		flex-direction: column;
		align-items: flex-start;
	}

	#symbolQuote {
		justify-content: flex-end;
	}

	#symbolQuote input[type="text"] {
		flex-grow: 1;
	}

	.home-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 480px) {
	.indexBlock {
		width: 100%;
		margin: 5px 0;
	}

	#navHome {
		width: 100%;
		text-align: center;
	}
}

/* ── Charts & Footer ───────────────────────────────── */

.highchart, .js-plotly-plot {
	width: 100% !important;
	max-width: 1200px;
	margin: 20px auto;
	box-shadow: 0px 1px 20px 0px var(--chart-shadow);
}

.chart-spinner {
	width: 100%;
	max-width: 1200px;
	height: 600px;
	margin: 20px auto;
	box-shadow: 0px 1px 20px 0px var(--chart-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
}

.chart-spinner::after {
	content: '';
	width: 36px;
	height: 36px;
	border: 3px solid var(--border-subtle);
	border-top-color: var(--muted);
	border-radius: 50%;
	animation: chart-spin 0.8s linear infinite;
}

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

.chart-unavailable {
	width: 100%;
	max-width: 1200px;
	height: 600px;
	margin: 20px auto;
	box-shadow: 0px 1px 20px 0px var(--chart-shadow);
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--muted);
	font-size: 0.85em;
}

/* dividend chart is shorter */
#div-chart-loading {
	height: 350px;
}

@media (max-width: 768px) {
	.chart-spinner, .chart-unavailable {
		height: 350px;
	}

	.js-plotly-plot .updatemenu-container {
		transform: scale(0.8);
	}
}

@media (max-width: 480px) {
	.chart-spinner, .chart-unavailable {
		height: 280px;
	}

	.js-plotly-plot .updatemenu-container {
		transform: scale(0.65);
	}
}

/* ── Pagination ──────────────────────────────────────── */

.pagination {
	display: flex;
	align-items: center;
	gap: 4px;
	margin-top: 20px;
	flex-wrap: wrap;
}

.pagination a,
.pagination .pg-current,
.pagination .pg-disabled,
.pagination .pg-ellipsis {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	height: 34px;
	padding: 0 10px;
	border-radius: 4px;
	font-size: 0.875em;
	line-height: 1;
	text-decoration: none;
	border: 1px solid var(--btn-border);
}

.pagination a {
	color: var(--btn-color);
	background: transparent;
	transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pagination a:hover {
	background: var(--btn-hover-bg);
	border-color: var(--btn-hover-border);
	color: var(--btn-hover-color);
}

.pagination .pg-current {
	background: var(--text);
	border-color: var(--text);
	color: var(--bg);
	font-weight: 600;
	cursor: default;
}

.pagination .pg-disabled {
	color: var(--muted);
	border-color: var(--border-subtle);
	cursor: default;
	opacity: 0.5;
}

.pagination .pg-ellipsis {
	border-color: transparent;
	color: var(--muted);
	cursor: default;
	min-width: 24px;
	padding: 0 4px;
}

/* ── Policy Pages ────────────────────────────────────── */

.policy-page {
	max-width: 900px;
	margin: 40px auto;
	padding: 0 20px;
}

.warning-box {
	font-weight: bold;
	background-color: rgba(239, 68, 68, 0.1);
	padding: 15px;
	border-left: 4px solid rgb(239, 68, 68);
	margin: 20px 0;
}

/* ── Footer ──────────────────────────────────────────– */

#site-footer {
	margin-top: 40px;
	padding: 16px 20px;
	border-top: 1px solid var(--footer-border);
	text-align: center;
	color: var(--footer-color);
	font-size: 0.78em;
	line-height: 1.6;
}