/*
 * App shell for every page on the cgindansstocks layout: a menu hidden until ☰ slides it over
 * the page, one top bar that carries the page's name and its own controls, and a quiet footer.
 * Teal accent of the admin theme; shared tokens also used by the screener card.
 */
:root {
	--scr-bg: #f3f6f6;
	--scr-surface: #fff;
	--scr-surface-2: #f7f9f9;
	--scr-line: #e2e8e8;
	--scr-line-strong: #cfd8d8;
	--scr-fg: #1d2a2a;
	--scr-muted: #64748b;
	--scr-accent: #1a9e82;
	--scr-accent-soft: #e3f4f0;
	--scr-up: #0f8a4a;
	--scr-down: #c2362f;
	--scr-warn: #a8620a;
	--scr-warn-soft: #fdf0dc;
	--scr-shadow: 0 1px 2px rgba(20, 40, 40, .06), 0 4px 16px rgba(20, 40, 40, .05);
	--app-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	--app-font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
	--app-topbar-height: 60px;
}

body.app-shell {
	margin: 0;
	background: var(--scr-bg);
	color: var(--scr-fg);
	font-family: var(--app-font);
}
body.app-shell.app-menu-open { overflow: hidden; }
.app-shell :focus-visible { outline: 2px solid var(--scr-accent); outline-offset: 2px; }

.app-skip-link { position: absolute; left: -9999px; top: 8px; z-index: 2000; background: var(--scr-surface); padding: 8px 12px; border-radius: 6px; }
.app-skip-link:focus { left: 8px; }

/* Main area: the full width of the window; the menu never takes space from it. */
.app-main { min-height: 100vh; display: flex; flex-direction: column; }
.app-gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* Top bar: ☰, the page name with its details, the page's controls, the account menu. */
.app-topbar {
	position: sticky;
	top: 0;
	z-index: 1030;
	min-height: var(--app-topbar-height);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 14px;
	padding-block: 10px;
	background: var(--scr-surface);
	border-bottom: 1px solid var(--scr-line);
}
.app-icon-btn {
	width: 38px;
	height: 38px;
	flex: none;
	display: inline-grid;
	place-items: center;
	border: 1px solid transparent;
	border-radius: 8px;
	background: none;
	color: var(--scr-muted);
	cursor: pointer;
	font-size: 18px;
	padding: 0;
}
.app-icon-btn:hover { background: var(--scr-surface-2); color: var(--scr-fg); }
.app-page-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; min-width: 0; margin-right: auto; }
.app-page-title h1 { margin: 0; font-family: var(--app-font-head); font-size: 19px; font-weight: 600; letter-spacing: -.01em; color: var(--scr-fg); line-height: 1.3; }
.app-page-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--scr-muted); white-space: nowrap; }
.app-page-meta .app-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--scr-up); display: inline-block; }
.app-page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.app-page-actions:empty { display: none; }

.app-user { position: relative; }
.app-user-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 3px; border-radius: 50%; cursor: pointer; }
.app-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--scr-accent-soft); color: var(--scr-accent); display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; text-transform: uppercase; }
.app-user-btn:hover .app-avatar { box-shadow: 0 0 0 3px var(--scr-line); }
.app-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 8px); width: 220px; background: var(--scr-surface); border: 1px solid var(--scr-line-strong); border-radius: 8px; box-shadow: var(--scr-shadow); padding: 6px; z-index: 1050; }
.app-dropdown.open { display: block; }
.app-dropdown-who { padding: 6px 10px; line-height: 1.35; }
.app-dropdown-who b { display: block; color: var(--scr-fg); }
.app-dropdown-who span { color: var(--scr-muted); font-size: 12px; }
.app-dropdown hr { border: 0; border-top: 1px solid var(--scr-line); margin: 4px 0; }
.app-dropdown a { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px; color: var(--scr-fg); text-decoration: none; }
.app-dropdown a:hover { background: var(--scr-surface-2); color: var(--scr-fg); text-decoration: none; }
.app-login { color: var(--scr-accent); font-weight: 600; }

/* Content and footer. */
.app-content { flex: 1; padding-block: 14px; min-width: 0; }
.app-content > .row { margin-left: -8px; margin-right: -8px; }
.app-footer {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	justify-content: space-between;
	align-items: center;
	padding-block: 14px;
	border-top: 1px solid var(--scr-line);
	background: var(--scr-surface);
	color: var(--scr-muted);
	font-size: 12px;
}

/* Menu: hidden off the left edge until ☰ opens it over the page. */
.app-side {
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
	z-index: 1060;
	width: 284px;
	max-width: 86vw;
	display: flex;
	flex-direction: column;
	background: var(--scr-surface);
	border-right: 1px solid var(--scr-line);
	box-shadow: 6px 0 28px rgba(10, 30, 30, .18);
	transform: translateX(-105%);
	visibility: hidden;
	transition: transform .2s ease, visibility .2s;
	padding-top: env(safe-area-inset-top, 0px);
	padding-bottom: env(safe-area-inset-bottom, 0px);
}
.app-menu-open .app-side { transform: none; visibility: visible; }
.app-scrim { position: fixed; inset: 0; z-index: 1055; background: rgba(10, 20, 20, .35); }
.app-brand { display: flex; align-items: center; gap: 10px; min-height: var(--app-topbar-height); padding: 0 10px 0 18px; border-bottom: 1px solid var(--scr-line); }
.app-brand a { display: flex; align-items: center; gap: 10px; color: var(--scr-fg); text-decoration: none; min-width: 0; }
.app-brand a:hover { text-decoration: none; color: var(--scr-fg); }
.app-brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--scr-accent); color: #fff; display: grid; place-items: center; flex: none; font-size: 15px; }
.app-brand-name { font-family: var(--app-font-head); font-weight: 600; font-size: 16px; line-height: 1.2; white-space: nowrap; }
.app-brand-name small { display: block; font-family: var(--app-font); font-weight: 400; font-size: 11px; color: var(--scr-muted); }
.app-brand .app-icon-btn { margin-left: auto; }

.app-nav { flex: 1; overflow-y: auto; padding: 10px; }
.app-nav ul { list-style: none; margin: 0; padding: 0; }
/* The theme styles .nav.side-menu for its old dark sidebar (and Bootstrap makes .nav a flex row): reset both. */
.app-nav .nav.side-menu, .app-nav .nav.child_menu { display: block; flex-wrap: nowrap; position: static; width: auto; background: none; left: auto; z-index: auto; }
.app-nav .nav.side-menu > li, .app-nav .nav.child_menu > li { display: block; float: none; position: relative; margin: 1px 0; padding: 0; border: 0 !important; background: none !important; cursor: default; }
.app-nav .nav.child_menu > li::before, .app-nav .nav.child_menu > li::after { content: none; display: none; }
.app-nav .nav.side-menu a, .app-nav .nav.child_menu a { position: relative; display: flex; align-items: center; gap: 11px; min-height: 38px; margin: 0; padding: 0 10px; border-radius: 7px; color: var(--scr-fg) !important; font-size: 13px; font-weight: 500; text-align: left !important; text-decoration: none; text-shadow: none !important; background: none !important; box-shadow: none !important; }
.app-nav .nav.side-menu a:hover, .app-nav .nav.side-menu a:focus { background: var(--scr-surface-2) !important; color: var(--scr-fg) !important; text-decoration: none; }
.app-nav .nav.side-menu a > i:not(.app-chevron) { width: 18px !important; margin: 0 !important; font-size: 15px !important; text-align: center; color: var(--scr-muted); flex: none; }
.app-nav .nav.side-menu > li.active > a, .app-nav .nav.child_menu > li.active > a { background: var(--scr-accent-soft) !important; color: var(--scr-accent) !important; font-weight: 600; }
.app-nav .nav.side-menu li.active > a > i:not(.app-chevron) { color: var(--scr-accent); }
.app-nav .nav.side-menu li.active > a::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--scr-accent); }
.app-nav .nav.side-menu .label { margin-left: auto !important; background: var(--scr-warn-soft); color: var(--scr-warn); border-radius: 10px; font-size: 11px; padding: 2px 7px; }
.app-nav .app-chevron { margin-left: auto; font-size: 11px !important; width: auto !important; color: var(--scr-muted); transition: transform .15s; }
.app-nav li.app-open > a .app-chevron { transform: rotate(90deg); }
.app-nav .nav.child_menu { display: none !important; padding: 2px 0 6px 29px; }
.app-nav li.app-open > .nav.child_menu { display: block !important; }
.app-nav .nav.child_menu a { min-height: 34px; font-weight: 400; color: var(--scr-muted) !important; font-size: 13px; }
.app-nav .nav.child_menu a:hover { color: var(--scr-fg) !important; }
.app-nav .nav.child_menu li.active > a::before { left: -39px; }
.app-nav .fa-chevron-down { display: none !important; }

.app-side-user { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--scr-line); }
.app-side-user .app-who { min-width: 0; line-height: 1.3; }
.app-side-user .app-who b { display: block; font-size: 13px; color: var(--scr-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-side-user .app-who span { font-size: 11px; color: var(--scr-muted); }
.app-side-user .app-icon-btn { margin-left: auto; }
.app-side-user .app-icon-btn:hover { color: var(--scr-down); }

@media (max-width: 720px) {
	/* Phones: the top bar holds three rows here, so it scrolls away instead of covering the list. */
	.app-topbar { position: static; }
	.app-page-title { flex: 1 1 0; flex-direction: column; align-items: flex-start; gap: 0; }
	.app-page-title h1 { font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.app-page-actions { order: 5; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
	.app-side { transition: none; }
}

/* Request progress bar (NProgress) — accent while loading, red when a request failed. */
#nprogress .bar { background: var(--scr-accent); height: 3px; z-index: 2100; transition: background-color .15s; }
#nprogress .peg { box-shadow: 0 0 10px var(--scr-accent), 0 0 5px var(--scr-accent); }
.app-progress-error #nprogress .bar { background: var(--scr-down); }
.app-progress-error #nprogress .peg { box-shadow: 0 0 10px var(--scr-down), 0 0 5px var(--scr-down); }

/* Inside the CG Stocks app (?app=1): the app has its own navigation, so the page is only its content. */
.app-embedded .app-skip-link, .app-embedded .app-side, .app-embedded .app-scrim, .app-embedded .app-topbar, .app-embedded .app-footer { display: none !important; }
.app-embedded .app-content { padding: 0; }
.app-embedded .app-gutter { padding-left: 0; padding-right: 0; }
