:root {
	color-scheme: light dark;
	--bg: #f5f6f8;
	--surface: #ffffff;
	--surface-alt: #f1f3f6;
	--border: #e2e5ea;
	--text: #1c2128;
	--text-muted: #6b7280;
	--brand: #4f46e5;
	--brand-hover: #4338ca;
	--brand-contrast: #ffffff;
	--positive: #0f9d58;
	--negative: #e0393e;
	--radius: 10px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #14161a;
		--surface: #1c1f26;
		--surface-alt: #23262e;
		--border: #2d313b;
		--text: #e6e8eb;
		--text-muted: #9aa1ab;
		--brand: #6366f1;
		--brand-hover: #818cf8;
		--brand-contrast: #ffffff;
		--positive: #34d399;
		--negative: #f87171;
		--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .4);
	}
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; }

.page {
	max-width: none;
	margin: 0;
	padding: 0 1.5rem 3rem;
}

.page-narrow { max-width: 460px; margin: 0 auto; }

/* Navbar */
.app-nav {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	margin-bottom: 2rem;
}

.app-nav-inner {
	max-width: none;
	margin: 0;
	padding: 0.85rem 1.5rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
}

.app-nav-brand {
	font-weight: 700;
	font-size: 1.05rem;
	color: var(--text);
}
.app-nav-brand:hover { color: var(--text); text-decoration: none; }

.app-nav-links {
	display: flex;
	align-items: center;
	gap: 1.25rem;
	flex-wrap: wrap;
}

.app-nav-links a { color: var(--text-muted); font-weight: 500; }
.app-nav-links a:hover { color: var(--text); text-decoration: none; }
.app-nav-links a.active { color: var(--brand); }

.app-nav-user {
	color: var(--text-muted);
	font-size: 0.9rem;
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	padding: 0.55rem 1.1rem;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.btn-primary { background: var(--brand); color: var(--brand-contrast); }
.btn-primary:hover { background: var(--brand-hover); color: var(--brand-contrast); text-decoration: none; }

.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* Cards */
.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 1.5rem;
	margin-bottom: 1.5rem;
}

/* Forms */
.form-group { margin-bottom: 1.1rem; }

label {
	display: block;
	font-weight: 600;
	font-size: 0.85rem;
	margin-bottom: 0.35rem;
	color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
	width: 100%;
	padding: 0.55rem 0.75rem;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--surface);
	color: var(--text);
	font-size: 0.9rem;
	font-family: inherit;
}

input:focus, select:focus, textarea:focus {
	outline: none;
	border-color: var(--brand);
	box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}

.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; color: var(--text); }

/* Alerts */
.alert {
	padding: 0.85rem 1rem;
	border-radius: var(--radius);
	margin-bottom: 1.25rem;
	font-size: 0.9rem;
	border: 1px solid transparent;
}
.alert-error { background: rgba(224, 57, 62, .1); border-color: rgba(224, 57, 62, .3); color: var(--negative); }
.alert-success { background: rgba(15, 157, 88, .1); border-color: rgba(15, 157, 88, .3); color: var(--positive); }
.alert-info { background: var(--surface-alt); border-color: var(--border); color: var(--text-muted); }

/* Tables */
table.table {
	width: 100%;
	border-collapse: collapse;
	background: var(--surface);
	font-size: 0.85rem;
}

table.table th, table.table td {
	padding: 0.6rem 0.75rem;
	border-bottom: 1px solid var(--border);
	text-align: left;
	vertical-align: middle;
}

table.table thead th {
	color: var(--text-muted);
	font-weight: 600;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	background: var(--surface-alt);
}

table.table tbody tr:hover { background: var(--surface-alt); }

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }

.card > table.table { margin: -1.5rem; width: calc(100% + 3rem); }

/* Auth pages */
.auth-card { margin-top: 3rem; }
.auth-card .helper-text { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--text-muted); }

/* Overview page: quick actions + filter row */
.overview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.overview-toolbar > div:first-child { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.filter-row { background: var(--surface-alt); }
.filter-row th { padding: 0.4rem !important; vertical-align: top; border-bottom: 1px solid var(--border); }

.filter-input, .numeric-filter input {
	width: 100%;
	padding: 0.3rem 0.4rem;
	font-size: 0.75rem;
	border: 1px solid var(--border);
	border-radius: 5px;
	background: var(--surface);
	color: var(--text);
	box-sizing: border-box;
}

.numeric-filter { display: flex; flex-direction: column; gap: 2px; }

.filter-clear-btn {
	background: var(--negative);
	color: #fff;
	border: none;
	padding: 2px 6px;
	font-size: 0.65rem;
	border-radius: 4px;
	cursor: pointer;
	margin-top: 2px;
	width: 100%;
}

.updateMarket { cursor: pointer; font-weight: 600; }
.updateMarket[data-newvalue="0"], .updateMarket.new[data-newvalue="1"] { color: var(--positive); }
.updateMarket[data-newvalue="1"], .updateMarket.new[data-newvalue="0"] { color: var(--negative); }
.updateMarket-locked { color: var(--text-muted); font-size: 0.8rem; }

#companiesTable { width: 100% !important; table-layout: auto; }

/* DataTables default chrome, restyled to match the app instead of its stock theme */
.dataTables_wrapper { width: 100%; color: var(--text); font-size: 0.85rem; }
.dataTables_scrollHead table, .dataTables_scrollBody table { width: 100% !important; }
.dataTables_length select {
	border: 1px solid var(--border);
	border-radius: 6px;
	background: var(--surface);
	color: var(--text);
	padding: 0.15rem 1.5rem 0.15rem 0.4rem;
	font-size: 0.8rem;
}
.dataTables_info, .dataTables_length { color: var(--text-muted); padding: 0.35rem 0; font-size: 0.8rem; }
.dataTables_paginate .paginate_button {
	padding: 0.3rem 0.65rem;
	margin-left: 0.25rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	cursor: pointer;
}
.dataTables_paginate .paginate_button.current { background: var(--brand); color: var(--brand-contrast) !important; border-color: var(--brand); }
.dataTables_paginate .paginate_button.disabled { color: var(--text-muted) !important; cursor: default; }
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after { opacity: .5; }
