/* Page /market (module/market/index.php). Loaded via var_custom_css in Market::index. */
/* main.php forces a, h1-h4 to the brand color with !important, hence the !important on text colors below. */

:root {
	--mk-brand: #066a6d;
	--mk-brand-dark: #044d4f;
	--mk-brand-soft: #e7f3f3;
	--mk-ink: #1f2a2e;
	--mk-muted: #6b7680;
	--mk-line: #e5e9ec;
	--mk-radius: 12px;
}

/* ---------- Header ---------- */
.mk-hero {
	color: #fff; border-radius: 16px; padding: 28px 32px 30px; margin: 24px 0;
	background:
		linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 40px 40px,
		linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px) 0 0 / 40px 40px,
		linear-gradient(135deg, #03393b 0%, #066a6d 60%, #0b8a85 100%);
}
.mk-crumb { font-size: 13px; color: #9cc7c6; margin-bottom: 12px; }
.mk-crumb a { color: #d5ecec !important; }
.mk-hero h1 { color: #fff !important; font-size: 30px; font-weight: 700; margin: 0 0 8px; }
.mk-lead { color: #cfe6e5; font-size: 15px; max-width: 680px; margin-bottom: 18px; }
.mk-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 20px; padding: 0; color: #cfe6e5; }
.mk-stats b { color: #fff; font-size: 18px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.mk-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.mk-search { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 10px; padding: 0 12px; margin: 0; flex: 0 1 340px; }
.mk-search i { color: var(--mk-muted); font-size: 16px; }
.mk-search input { border: 0; outline: 0; height: 42px; width: 100%; font-size: 14px; color: var(--mk-ink); background: none; }
.mk-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-filter button, .mk-filter a { border: 1px solid rgba(255,255,255,.3); background: transparent; color: #e3f2f1 !important; border-radius: 18px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .2s, border-color .2s; }
.mk-filter button span, .mk-filter a span { opacity: .7; font-weight: 400; margin-left: 2px; }
.mk-filter button:hover, .mk-filter a:hover { border-color: #fff; }
.mk-filter button.active, .mk-filter a.active { background: #fff; border-color: #fff; color: var(--mk-brand) !important; }
.mk-stats a { color: #cfe6e5 !important; text-decoration: none; }
.mk-stats a:hover b { text-decoration: underline; }

/* ---------- List ---------- */
.mk-body { padding-bottom: 24px; }
.mk-group { margin-bottom: 28px; }
.mk-group h2 { font-size: 20px; font-weight: 700; color: var(--mk-ink) !important; margin: 0 0 12px; }
.mk-group h2 small { font-size: 13px; font-weight: 400; color: var(--mk-muted); margin-left: 6px; }
.mk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.mk-card {
	display: flex; flex-direction: column; gap: 12px; background: #fff; border: 1px solid var(--mk-line); border-radius: var(--mk-radius);
	padding: 16px; color: var(--mk-ink) !important; text-decoration: none; transition: border-color .2s, box-shadow .2s, transform .2s;
}
.mk-card:hover { border-color: var(--mk-brand); box-shadow: 0 8px 22px rgba(6,106,109,.1); transform: translateY(-2px); }
.mk-card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mk-card-head img { width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--mk-line); object-fit: cover; background: #f4f6f7; }
.mk-card-title { display: flex; flex-direction: column; min-width: 0; }
.mk-card-title b { font-size: 16px; line-height: 1.3; }
.mk-card:hover .mk-card-title b { color: var(--mk-brand); }
.mk-card-title small { font-size: 13px; color: var(--mk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-code { margin-left: auto; align-self: flex-start; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--mk-brand); background: var(--mk-brand-soft); border-radius: 6px; padding: 3px 8px; }
.mk-figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: auto 0 0; padding: 12px 0 0; border-top: 1px solid #f0f2f4; }
.mk-figures dt { font-size: 11px; font-weight: 600; color: var(--mk-muted); text-transform: uppercase; letter-spacing: .3px; }
.mk-figures dd { margin: 0; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mk-card[hidden], .mk-group[hidden], .mk-empty[hidden] { display: none !important; }
.mk-empty { background: #fff; border: 1px dashed var(--mk-line); border-radius: var(--mk-radius); padding: 24px; text-align: center; color: var(--mk-muted); }

.mk-box { background: #fff; border: 1px solid var(--mk-line); border-radius: var(--mk-radius); padding: 22px; margin-bottom: 16px; }
.mk-box h2 { font-size: 17px; font-weight: 700; color: var(--mk-ink) !important; margin: 0 0 10px; }
.mk-about { margin-top: 8px; color: #3b4650; line-height: 1.7; }
.mk-about p + h2 { margin-top: 22px; }
.mk-faq { border-top: 1px solid #f0f2f4; padding: 10px 0; }
.mk-faq summary { cursor: pointer; font-weight: 600; color: var(--mk-ink); }
.mk-faq p { margin: 8px 0 0; }

/* ---------- Sidebar ---------- */
.mk-side { position: sticky; top: 140px; }
.mk-side .mk-box { padding: 18px; }
.mk-side .mk-box h2 { font-size: 15px; }
.mk-rank { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.mk-rank li { counter-increment: rank; }
.mk-rank a { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 4px 8px; padding: 8px 2px; border-bottom: 1px solid #f0f2f4; color: var(--mk-ink) !important; text-decoration: none; font-size: 13px; }
.mk-rank li:last-child a { border-bottom: 0; }
.mk-rank a::before { content: counter(rank); color: var(--mk-muted); font-size: 12px; }
.mk-rank span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-rank a:hover span { color: var(--mk-brand); }
.mk-rank b { font-variant-numeric: tabular-nums; }
.mk-rank svg { grid-column: 2 / -1; width: 100%; height: 4px; border-radius: 2px; overflow: hidden; }
.mk-bar-bg { fill: #eef1f3; }
.mk-bar { fill: var(--mk-brand); }
.mk-cta { background: var(--mk-brand-soft); border-color: #cfe5e5; }
.mk-cta p { color: #46585a; font-size: 13px; }
.mk-btn { display: inline-block; background: var(--mk-brand); color: #fff !important; border-radius: 10px; font-weight: 600; font-size: 14px; padding: 8px 16px; text-decoration: none; }
.mk-btn:hover { background: var(--mk-brand-dark); }
.mk-btn i { margin-right: 4px; }

/* ---------- All stocks of an exchange (all_stocks.php) ---------- */
.mk-list { padding: 0; overflow: hidden; }
.mk-list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--mk-line); }
.mk-count { margin: 0; color: var(--mk-muted); font-size: 13px; }
.mk-count b { color: var(--mk-ink); font-variant-numeric: tabular-nums; }
.mk-sort { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--mk-muted); }
.mk-sort label { margin: 0; }
.mk-sort select { height: 36px; border: 1px solid var(--mk-line); border-radius: 8px; padding: 0 10px; font-size: 13px; color: var(--mk-ink); background: #fff; }

.mk-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.mk-table thead th { background: #f8fafa; font-size: 11px; font-weight: 600; color: var(--mk-muted); text-transform: uppercase; letter-spacing: .3px; padding: 10px 12px; border-bottom: 1px solid var(--mk-line); text-align: right; white-space: nowrap; }
.mk-table thead th:nth-child(-n+2), .mk-table thead th:last-child { text-align: left; }
.mk-table tbody th, .mk-table td { padding: 10px 12px; border-bottom: 1px solid #f0f2f4; vertical-align: middle; }
.mk-table tbody tr:last-child th, .mk-table tbody tr:last-child td { border-bottom: 0; }
.mk-table tbody tr:hover { background: #fafcfc; }
.mk-table tbody th { font-weight: 400; text-align: left; }
.mk-table td { text-align: right; white-space: nowrap; color: #3b4650; }
.mk-table td small { color: var(--mk-muted); font-size: 11px; }
.mk-table .mk-no { text-align: left; color: var(--mk-muted); font-size: 12px; width: 40px; }
.mk-table .mk-sector { text-align: left; color: var(--mk-muted); font-size: 13px; }
.mk-table .up { color: #12805c; font-weight: 600; }
.mk-table .dn { color: #c8372d; font-weight: 600; }
.mk-stock { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--mk-ink) !important; text-decoration: none; }
.mk-stock:hover b { color: var(--mk-brand); }
.mk-stock > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.mk-stock b { font-weight: 600; max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-stock small { color: var(--mk-muted); font-size: 12px; }
.mk-logo { position: relative; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px; border: 1px solid var(--mk-line); background: var(--mk-brand-soft); color: var(--mk-brand); font-size: 11px; font-weight: 700; overflow: hidden; }
.mk-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; }
.mk-rating { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 13px; border-radius: 6px; padding: 2px 7px; }
.mk-rating i { font-size: 12px; }
.mk-rating.r0, .mk-rating.r1 { color: #b4372c; background: #fdecea; }
.mk-rating.r2 { color: #a15c00; background: #fdf3e1; }
.mk-rating.r3 { color: #6b6b00; background: #f6f6dc; }
.mk-rating.r4, .mk-rating.r5 { color: #12805c; background: #e3f5ee; }

.mk-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 16px; border-top: 1px solid var(--mk-line); }
.mk-pages a, .mk-pages span { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 8px; border-radius: 8px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-pages a { border: 1px solid var(--mk-line); color: var(--mk-ink) !important; text-decoration: none; }
.mk-pages a:hover { border-color: var(--mk-brand); color: var(--mk-brand) !important; }
.mk-pages .active { background: var(--mk-brand); color: #fff; }
.mk-pages .mk-gap { color: var(--mk-muted); min-width: 20px; padding: 0; }
.mk-list .mk-empty { border: 0; border-radius: 0; margin: 0; }
.mk-note { font-size: 12px; color: var(--mk-muted); margin: -4px 0 24px; }

/* ---------- Exchange overview (detail.php) ---------- */
.mk-ex-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.mk-ex-head h1 { margin: 0 0 4px; }
.mk-ex-head .mk-lead { margin: 0; }
.mk-ex-flag { width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); object-fit: cover; background: #fff; }
.mk-ex-code { display: inline-block; vertical-align: middle; font-size: 13px; font-weight: 700; letter-spacing: .3px; color: #03393b; background: #fff; border-radius: 6px; padding: 2px 8px; margin-left: 6px; }
.mk-ex-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mk-btn-light, .mk-btn-ghost { display: inline-flex; align-items: center; gap: 6px; border-radius: 10px; font-weight: 600; font-size: 14px; padding: 9px 16px; text-decoration: none; }
.mk-btn-light { background: #fff; color: var(--mk-brand) !important; }
.mk-btn-light:hover { background: var(--mk-brand-soft); }
.mk-btn-ghost { border: 1px solid rgba(255,255,255,.35); color: #e3f2f1 !important; }
.mk-btn-ghost:hover { border-color: #fff; color: #fff !important; }

.mk-list-head h2 { font-size: 17px; font-weight: 700; color: var(--mk-ink) !important; margin: 0; }
.mk-more, .mk-box-head a { font-size: 13px; font-weight: 600; text-decoration: none; }
.mk-box-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mk-chg { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--mk-muted); }
.mk-chg.up { color: #12805c; }
.mk-chg.dn { color: #c8372d; }
.mk-section-title { font-size: 20px; font-weight: 700; color: var(--mk-ink) !important; margin: 28px 0 12px; }

.mk-sectors { list-style: none; margin: 0; padding: 0; }
.mk-sectors li { display: grid; grid-template-columns: minmax(150px, 1.2fr) 80px minmax(80px, 2fr) 56px 64px; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid #f0f2f4; font-size: 14px; }
.mk-sectors li:last-child { border-bottom: 0; }
.mk-sectors a { font-weight: 600; color: var(--mk-ink) !important; text-decoration: none; }
.mk-sectors a:hover { color: var(--mk-brand) !important; }
.mk-sectors small { color: var(--mk-muted); font-size: 12px; }
.mk-sectors b { text-align: right; font-variant-numeric: tabular-nums; }
.mk-sectors .mk-chg { text-align: right; font-size: 13px; }
.mk-sec-bar { height: 8px; border-radius: 4px; background: #eef1f3; overflow: hidden; }
.mk-sec-bar i { display: block; height: 100%; border-radius: 4px; background: var(--mk-brand); }

.mk-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mk-card-head .mk-logo { width: 40px; height: 40px; }
.mk-figures .mk-rating { font-size: 12px; }
.mk-grid-ideas { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 24px; }
.mk-idea { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--mk-line); border-radius: var(--mk-radius); padding: 14px 16px; color: var(--mk-ink) !important; text-decoration: none; transition: border-color .2s, box-shadow .2s; }
.mk-idea:hover { border-color: var(--mk-brand); box-shadow: 0 6px 18px rgba(6,106,109,.08); }
.mk-idea img { width: 44px; height: 44px; flex-shrink: 0; object-fit: contain; }
.mk-idea span { display: flex; flex-direction: column; min-width: 0; }
.mk-idea b { font-size: 15px; }
.mk-idea:hover b { color: var(--mk-brand); }
.mk-idea small { color: var(--mk-muted); font-size: 13px; line-height: 1.4; }
.mk-about-box { margin-top: 8px; }

.mk-breadth { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #eef1f3; margin: 4px 0 10px; }
.mk-breadth i.up { background: #12805c; }
.mk-breadth i.dn { background: #c8372d; }
.mk-breadth i.flat { background: #c5ccd2; }
.mk-breadth-legend { list-style: none; display: flex; justify-content: space-between; margin: 0; padding: 0; font-size: 13px; color: var(--mk-muted); }
.mk-breadth-legend .up b { color: #12805c; }
.mk-breadth-legend .dn b { color: #c8372d; }
.mk-movers { list-style: none; margin: 0; padding: 0; }
.mk-movers li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f2f4; }
.mk-movers li:last-child { border-bottom: 0; }
.mk-movers .mk-stock > span { display: flex; flex-direction: column; min-width: 0; }
.mk-movers .mk-stock b { font-size: 14px; }
.mk-movers .mk-stock small { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-mover-num { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; font-size: 13px; }
.mk-mover-num small { color: var(--mk-muted); font-size: 12px; }

/* ---------- Investing idea on an exchange (discover/exchange.php) ---------- */
.dv-icon { width: 56px; height: 56px; flex-shrink: 0; object-fit: contain; background: #fff; border-radius: 14px; padding: 6px; }
.mk-ex-head h1 small { font-size: 18px; font-weight: 400; color: #cfe6e5; }
.dv-search { max-width: 380px; margin-top: 4px; }
.dv-ideas, .dv-markets { list-style: none; margin: 0; padding: 0; }
.dv-ideas a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--mk-ink) !important; text-decoration: none; }
.dv-ideas a:hover b { color: var(--mk-brand); }
.dv-ideas li.me a { background: var(--mk-brand-soft); }
.dv-ideas img { width: 32px; height: 32px; flex-shrink: 0; object-fit: contain; }
.dv-ideas span { display: flex; flex-direction: column; min-width: 0; }
.dv-ideas b { font-size: 14px; }
.dv-ideas small { font-size: 12px; color: var(--mk-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dv-markets { display: flex; flex-wrap: wrap; gap: 6px; }
.dv-markets a { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--mk-line); border-radius: 16px; padding: 4px 10px 4px 5px; font-size: 13px; font-weight: 600; color: var(--mk-ink) !important; text-decoration: none; }
.dv-markets a:hover { border-color: var(--mk-brand); color: var(--mk-brand) !important; }
.dv-markets img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.mk-list + .mk-note { margin: 10px 0 24px; }

/* ---------- Investing ideas (discover/index.php, discover/detail.php) ---------- */
.dv-idea-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dv-idea-card { gap: 10px; }
.dv-idea-card:hover { transform: none; }
.dv-idea-head { display: flex; align-items: center; gap: 12px; color: var(--mk-ink) !important; text-decoration: none; }
.dv-idea-head img { width: 52px; height: 52px; flex-shrink: 0; object-fit: contain; }
.dv-idea-head span { display: flex; flex-direction: column; min-width: 0; }
.dv-idea-head b { font-size: 17px; line-height: 1.3; }
.dv-idea-head:hover b { color: var(--mk-brand); }
.dv-idea-head small { font-size: 13px; color: var(--mk-muted); }
.dv-idea-card > p { flex: 1; font-size: 13.5px; line-height: 1.6; color: #3b4650; margin: 0; }
.dv-quick { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; border-top: 1px solid #f0f2f4; }
.dv-quick a { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--mk-line); border-radius: 14px; padding: 3px 9px 3px 4px; font-size: 12px; font-weight: 600; color: var(--mk-ink) !important; text-decoration: none; }
.dv-quick a:hover { border-color: var(--mk-brand); color: var(--mk-brand) !important; }
.dv-quick img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }
.dv-quick a.dv-quick-all { border-color: transparent; padding-left: 6px; color: var(--mk-brand) !important; }
.dv-how { margin-top: 28px; }
.dv-first { margin-top: 0; }
.dv-card-foot { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid #f0f2f4; font-size: 13px; font-weight: 600; color: var(--mk-muted); }
.mk-card:hover .dv-card-foot { color: var(--mk-brand); }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
	.mk-side { position: static; }
	.mk-grid-3, .dv-idea-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
	.mk-sectors li { grid-template-columns: minmax(0, 1fr) 56px 64px; gap: 4px 10px; }
	.mk-sectors small { display: none; }
	.mk-sec-bar { grid-column: 1 / -1; grid-row: 2; }
	.mk-grid-3, .mk-grid-ideas, .dv-idea-grid { grid-template-columns: 1fr; }
	.mk-ex-head h1 { font-size: 22px; }
	.mk-ex-flag { width: 40px; height: 40px; }
}
@media (max-width: 767px) {
	.mk-hero { padding: 22px 18px; margin: 16px 0; }
	.mk-hero h1 { font-size: 24px; }
	.mk-search { flex-basis: 100%; }
	.mk-filter { flex-wrap: nowrap; overflow-x: auto; margin: 0 -18px; padding: 0 18px 2px; scrollbar-width: none; }
	.mk-filter button { flex-shrink: 0; }
	.mk-grid { grid-template-columns: 1fr; }
	/* stock table becomes one card per stock */
	.mk-table thead { display: none; }
	.mk-table, .mk-table tbody { display: block; }
	.mk-table tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; padding: 12px 16px; border-bottom: 1px solid #f0f2f4; }
	.mk-table tbody th { grid-column: 1 / -1; padding: 0; border: 0; }
	.mk-table td { padding: 0; border: 0; text-align: left; font-size: 13px; }
	.mk-table td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--mk-muted); }
	.mk-table .mk-no { display: none; }
	.mk-table .mk-sector { grid-column: span 2; }
	.mk-stock b { max-width: none; white-space: normal; }
	.mk-list-head { padding: 12px 16px; }
}
@media (min-width: 768px) and (max-width: 1199px) {
	.mk-table .mk-sector, .mk-table thead th:last-child { display: none; }
	/* The exchange overview table ends with Rating, not Sector */
	.mk-table.mk-table-ex thead th:last-child { display: table-cell; }
}
