/* Stock detail page (module/stocks/detail.php). Loaded via var_custom_css in Stocks::detail. */
/* main.php forces a, h1-h4 to the brand color with !important, hence the !important on text colors below. */

:root {
	--sd-brand: #066a6d;
	--sd-brand-dark: #044d4f;
	--sd-brand-soft: #e7f3f3;
	--sd-ink: #1f2a2e;
	--sd-muted: #6b7680;
	--sd-line: #e5e9ec;
	--sd-up: #12805c;
	--sd-down: #c0392b;
	--sd-radius: 12px;
}

.sd-hero .up, .sd-body .up { color: var(--sd-up); }
.sd-hero .dn, .sd-body .dn { color: var(--sd-down); }

/* ---------- Header ---------- */
.sd-hero {
	color: #fff; border-radius: 16px; padding: 24px 28px; margin: 24px 0 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%);
}
.sd-crumb { font-size: 13px; color: #9cc7c6; margin-bottom: 16px; }
.sd-crumb a { color: #d5ecec !important; }

.sd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.sd-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.sd-logo { position: relative; flex-shrink: 0; width: 64px; height: 64px; border-radius: 14px; background: #fff; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.sd-logo b { font-size: 22px; font-weight: 700; color: var(--sd-brand); }
.sd-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 6px; background: #fff; }
.sd-id h1 { margin: 0; line-height: 1.2; color: #fff !important; font-size: 28px; font-weight: 700; }
.sd-id h1 .sd-name { display: block; font-size: 16px; font-weight: 400; color: #cfe6e5; margin-top: 2px; }
.sd-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sd-tags span, .sd-tags a { font-size: 12px; border: 1px solid rgba(255,255,255,.3); border-radius: 12px; padding: 2px 10px; color: #e3f2f1 !important; text-decoration: none; }
.sd-tags a:hover { border-color: #fff; }
.sd-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sd-watch { margin: 0; }
.sd-watch button, .sd-hold { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--sd-brand) !important; border: 0; border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.sd-watch button[aria-pressed=true], .sd-hold.on { background: rgba(255,255,255,.14); color: #fff !important; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.sd-hold.on i { color: #ffd166; }
/* Ask AI: the accent of the header, and the call to action at the end of the sidebar */
.sd-ask { display: inline-flex; align-items: center; gap: 6px; background: #ffd166; color: #3d2e00 !important; border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 700; text-decoration: none; }
.sd-ask:hover { background: #ffc53d; }
.sd-card.sd-ask-card { background: linear-gradient(135deg, #03393b, #066a6d 60%, #0b8a85); color: #cfe6e5; border: 0; }
.sd-card.sd-ask-card h2 { color: #fff !important; font-size: 17px; margin: 0 0 6px; }
.sd-card.sd-ask-card p { font-size: 13px; margin: 0 0 12px; }
.sd-ask-qs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sd-ask-qs a { font-size: 13px; color: #fff !important; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 7px 10px; text-decoration: none; }
.sd-ask-qs a:hover { background: rgba(255,255,255,.18); }
.sd-watch button[aria-pressed=true] i { color: #ffd166; }
.sd-watch button:disabled { opacity: .7; }

.sd-price { text-align: right; min-width: 220px; }
.sd-price .px { font-size: 32px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sd-price .px small { font-size: 14px; font-weight: 600; color: #cfe6e5; }
.sd-price > small { color: #9cc7c6; font-size: 12px; }
/* Light green/red that stay readable on the dark header */
.sd-price .chg { font-size: 15px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; color: #e3f2f1; }
.sd-price .chg.up { color: #7ee2b8; }
.sd-price .chg.dn { color: #ffaba1; }
.sd-range { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11px; color: #cfe6e5; font-variant-numeric: tabular-nums; }
.sd-range i { position: relative; flex: 1; min-width: 90px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); }
.sd-range i b { position: absolute; top: -4px; width: 4px; height: 12px; margin-left: -2px; border-radius: 2px; background: #fff; }

.sd-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin: 20px 0 0; border-radius: var(--sd-radius); overflow: hidden; background: rgba(255,255,255,.15); }
.sd-stats > div { padding: 10px 14px; background: rgba(3,57,59,.45); }
.sd-stats dt { font-size: 12px; font-weight: 400; color: #9cc7c6; }
.sd-stats dd { margin: 2px 0 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sd-stats dd small { font-size: 12px; font-weight: 400; color: #9cc7c6; }
.sd-star { color: #f5c04a; }
.sd-basis { font-size: 12px; color: #9cc7c6; margin: 10px 0 0; }

/* Light variant inside cards (dividends) */
.sd-card .sd-stats { background: var(--sd-line); border: 1px solid var(--sd-line); margin: 0 0 18px; }
.sd-card .sd-stats > div { background: #fff; }
.sd-card .sd-stats dt { color: var(--sd-muted); }
.sd-card .sd-stats dd { color: var(--sd-ink); }
.sd-stats-sm { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Tabs ---------- */
.sd-tabs { position: sticky; top: 70px; z-index: 20; background: #fff; border-bottom: 1px solid var(--sd-line); margin: 16px 0 20px; border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.sd-tabs [role=tablist] { display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 8px; }
.sd-tabs [role=tablist]::-webkit-scrollbar { display: none; }
.sd-tabs a { display: inline-flex; align-items: center; flex-shrink: 0; min-height: 50px; padding: 3px 16px 0; color: var(--sd-muted) !important; font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; text-decoration: none; }
.sd-tabs a:hover { color: var(--sd-ink) !important; }
.sd-tabs a.active { color: var(--sd-brand) !important; border-bottom-color: var(--sd-brand); }

/* ---------- Cards ---------- */
.sd-body { padding-bottom: 24px; }
.sd-card { background: #fff; border: 1px solid var(--sd-line); border-radius: var(--sd-radius); padding: 20px; margin-bottom: 20px; }
.sd-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sd-card-head h2 { font-size: 18px; font-weight: 700; color: var(--sd-ink) !important; margin: 0; }
.sd-card-head > small { color: var(--sd-muted); }
.sd-pill { background: var(--sd-brand-soft); color: var(--sd-brand); font-size: 12px; font-weight: 700; border-radius: 12px; padding: 3px 10px; }
.sd-note { font-size: 12px; color: var(--sd-muted); margin: 10px 0 0; }
.sd-sub { font-size: 15px; font-weight: 700; color: var(--sd-ink) !important; margin: 20px 0 8px; }
.sd-about { color: #374151; line-height: 1.7; margin: 0; }
.sd-more { display: inline-flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 14px; font-weight: 600; }

.sd-rating { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 13px; border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.sd-rating i { font-size: 12px; }
.sd-rating.r0, .sd-rating.r1 { color: #b4372c; background: #fdecea; }
.sd-rating.r2 { color: #a15c00; background: #fdf3e1; }
.sd-rating.r3 { color: #6b6b00; background: #f6f6dc; }
.sd-rating.r4, .sd-rating.r5 { color: #12805c; background: #e3f5ee; }

/* ---------- Graham number ---------- */
.sd-fair-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.sd-fair-nums small { display: block; font-size: 12px; color: var(--sd-muted); }
.sd-fair-nums b { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--sd-ink); }
.sd-fair-nums .up b { color: var(--sd-up); }
.sd-fair-nums .dn b { color: var(--sd-down); }
.sd-fair-bar { display: block; width: 100%; height: 12px; }
.sd-fair-bar .track { fill: #e9ecef; }
.sd-fair-bar .fill.up { fill: var(--sd-brand); }
.sd-fair-bar .fill.dn { fill: #e8875f; }
.sd-fair-bar .mark { fill: var(--sd-ink); }
.sd-fair-text { margin: 12px 0 0; }

/* ---------- Scorecard ---------- */
.sd-score { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sd-score-item { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--sd-line); border-radius: 10px; padding: 10px 12px; }
.sd-score-item > i { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff; margin-top: 2px; }
.sd-score-item.ok > i { background: var(--sd-up); }
.sd-score-item.part > i { background: #e0a100; }
.sd-score-item.no > i { background: #d9706a; }
.sd-score-item h3 { font-size: 14px; font-weight: 700; color: var(--sd-ink) !important; margin: 0 0 2px; }
.sd-score-item h3 small { font-weight: 600; color: var(--sd-muted); font-size: 11px; margin-left: 4px; }
.sd-score-item p { font-size: 12.5px; color: var(--sd-muted); margin: 0; line-height: 1.45; }

/* ---------- Technical & price chart ---------- */
.sd-tech { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sd-tech > div { border: 1px solid var(--sd-line); border-radius: 10px; padding: 12px; }
.sd-tech h3 { font-size: 14px; font-weight: 700; color: var(--sd-ink) !important; margin: 0 0 6px; }
.sd-signal { display: inline-block; font-weight: 700; font-size: 13px; border-radius: 8px; padding: 2px 10px; background: #f1f3f5; color: #4b5563; }
.sd-signal.up { background: #e3f5ee; }
.sd-signal.dn { background: #fdecea; }
.sd-chips button { border: 0; background: none; font-size: 12px; font-weight: 600; color: var(--sd-muted); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.sd-tv { height: 440px; border-radius: 10px; overflow: hidden; background: #f7f9fa; }

/* ---------- Bar charts (financials, dividends) ---------- */
.sd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.sd-chips button { border: 1px solid var(--sd-line); background: #fff; border-radius: 14px; }
.sd-chips button.active { background: var(--sd-brand); border-color: var(--sd-brand); color: #fff; }
.sd-bars { height: 220px; margin-bottom: 8px; }
.sd-bars svg { width: 100%; height: 100%; display: block; overflow: visible; }
.sd-bars .bar { fill: #7fb8b7; }
.sd-bars .bar.neg { fill: #e8875f; }
.sd-bars .bar.last { fill: var(--sd-brand); }
.sd-bars .bar.anlz { fill: url(#sd-hatch); stroke: var(--sd-brand); stroke-width: 1; stroke-dasharray: 3 2; }
.sd-bars .hatch-bg { fill: var(--sd-brand-soft); }
.sd-bars .hatch-line { stroke: #7fb8b7; stroke-width: 2.5; }
.sd-bars .zero { stroke: #cfd4d9; stroke-width: 1; }
.sd-bars text { font-size: 11px; fill: var(--sd-muted); font-family: inherit; }
.sd-bars text.val { fill: var(--sd-ink); font-weight: 600; }
.sd-bars text.val.anlz { fill: var(--sd-brand); font-style: italic; }
.sd-bars text.anlz-lbl { font-size: 10px; font-weight: 700; fill: var(--sd-brand); }
.sd-anlz-note { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--sd-muted); }
.sd-anlz-note b { color: var(--sd-ink); }
.sd-anlz-swatch { flex-shrink: 0; width: 14px; height: 14px; margin-top: 2px; border-radius: 3px; border: 1px dashed var(--sd-brand); background: repeating-linear-gradient(45deg, #7fb8b7 0 2px, var(--sd-brand-soft) 2px 5px); }

/* ---------- Tables ---------- */
.sd-table-wrap { overflow-x: auto; }
.sd-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.sd-table caption { caption-side: top; padding: 0 0 8px; font-size: 12px; color: var(--sd-muted); }
.sd-table th, .sd-table td { padding: 8px 10px; border-bottom: 1px solid #eef0f2; text-align: right; white-space: nowrap; }
.sd-table th:first-child, .sd-table td:first-child { text-align: left; }
.sd-table thead th { font-size: 12px; font-weight: 600; color: var(--sd-muted); background: #fafbfb; }
.sd-table tbody th { font-weight: 500; color: var(--sd-ink); white-space: normal; }
.sd-caption { font-size: 12px; color: var(--sd-muted); margin: 0 0 8px; }
/* The table scrolls to the latest year first: item names and group titles stay pinned on the left */
.sd-fin tbody th, .sd-fin thead th:first-child { position: sticky; left: 0; z-index: 1; background: #fff; min-width: 180px; box-shadow: 6px 0 6px -6px rgba(0,0,0,.12); }
.sd-fin thead th:first-child { background: #fafbfb; }
.sd-fin tr.grp th { background: var(--sd-brand-soft); color: var(--sd-brand); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; position: static; }
.sd-fin tr.grp th span { position: sticky; left: 10px; }
.sd-fin th.anlz, .sd-fin td.anlz { background: #f4f6f6; font-style: italic; color: #4b5563; }
.sd-fin thead th.anlz { cursor: help; }
.sd-fin thead th.anlz small { display: inline-block; margin-left: 2px; padding: 0 5px; border-radius: 4px; background: var(--sd-brand-soft); color: var(--sd-brand); font-style: normal; font-weight: 700; font-size: 10px; }
.sd-glossary { margin-top: 14px; }
.sd-glossary summary { cursor: pointer; font-weight: 600; color: var(--sd-brand); }
.sd-glossary dl { margin: 12px 0 0; }
.sd-glossary dt { font-weight: 700; color: var(--sd-ink); margin-top: 10px; }
.sd-glossary dd { margin: 2px 0 0; color: #4b5563; font-size: 14px; line-height: 1.6; }

/* ---------- Ownership ---------- */
.sd-holders { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.sd-donut { width: 170px; height: 170px; flex-shrink: 0; }
.sd-donut circle { fill: none; stroke-width: 6; }
.sd-donut .ring { stroke: #eef0f2; }
.sd-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 220px; }
.sd-legend li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f1f3f5; font-size: 14px; }
.sd-legend li.sub { color: var(--sd-muted); font-size: 13px; }
.sd-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.sd-legend .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.sd-donut .c0, .sd-legend .c0 { stroke: #044d4f; background: #044d4f; }
.sd-donut .c1, .sd-legend .c1 { stroke: #2fa6a0; background: #2fa6a0; }
.sd-donut .c2, .sd-legend .c2 { stroke: #b9dcdb; background: #b9dcdb; }

/* ---------- Company ---------- */
.sd-profile { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin: 0; }
.sd-profile dt, .sd-facts dt { font-size: 12px; font-weight: 400; color: var(--sd-muted); }
.sd-profile dd { margin: 2px 0 0; color: var(--sd-ink); word-break: break-word; }
.sd-board { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.sd-board li { padding: 8px 0; border-bottom: 1px solid #f1f3f5; }
.sd-board li b { display: block; font-weight: 600; color: var(--sd-ink); font-size: 14px; }
.sd-board li small { color: var(--sd-muted); }

/* ---------- Sidebar ---------- */
.sd-side { position: sticky; top: 140px; }
.sd-facts { margin: 0; }
.sd-facts > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f1f3f5; }
.sd-facts > div:last-child { border-bottom: 0; }
.sd-facts dd { margin: 0; font-weight: 600; color: var(--sd-ink); font-variant-numeric: tabular-nums; text-align: right; }
.sd-peers { list-style: none; margin: 0; padding: 0; }
.sd-peers li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid #f1f3f5; }
.sd-peers li.me { background: var(--sd-brand-soft); border-radius: 8px; }
.sd-peers li > div { min-width: 0; }
.sd-peers a, .sd-peers b { font-weight: 700; font-size: 14px; }
.sd-peers b { color: var(--sd-ink); }
.sd-peers small { display: block; font-size: 12px; color: var(--sd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

[hidden] { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1199px) {
	.sd-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.sd-stats-sm { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
	.sd-side { position: static; }
}
@media (max-width: 767px) {
	.sd-hero { padding: 20px 16px; }
	.sd-price { text-align: left; min-width: 0; width: 100%; }
	.sd-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.sd-score, .sd-tech, .sd-profile, .sd-board { grid-template-columns: 1fr; }
	.sd-fair-nums b { font-size: 18px; }
	.sd-tv { height: 360px; }
	.sd-id h1 { font-size: 24px; }
	.sd-tabs { top: 60px; }
	.sd-tabs a { min-height: 46px; padding: 3px 12px 0; }
}
