:root {
	--bg: #f5f6f8;
	--card: #fff;
	--line: #e2e5ea;
	--ink: #1f2733;
	--muted: #6b7280;
	--accent: #1877f2; /* FB blue */
	--accent-dark: #145fc4;
	--ok: #1a7f37;
	--err: #b42318;
}

* { box-sizing: border-box; }

body {
	margin: 0;
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	color: var(--ink);
	background: var(--bg);
}

/* Gate */
.gate { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.gate-card {
	background: var(--card); border: 1px solid var(--line); border-radius: 12px;
	padding: 2rem; width: 100%; max-width: 360px; box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.gate-card h1 { margin: 0 0 .25rem; font-size: 1.3rem; }
.gate-card p { margin: 0 0 1rem; color: var(--muted); }
.gate-card input, .gate-card button { width: 100%; padding: .65rem .8rem; border-radius: 8px; font-size: 1rem; }
.gate-card input { border: 1px solid var(--line); margin-bottom: .75rem; }
.gate-card button { border: 0; background: var(--accent); color: #fff; cursor: pointer; }
.gate-card button:hover { background: var(--accent-dark); }
.error { color: var(--err); }

/* Topbar */
.topbar {
	display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
	padding: .9rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
	position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
#search { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px; min-width: 240px; }
.logout { color: var(--muted); text-decoration: none; font-size: .9rem; }
.logout:hover { text-decoration: underline; }

main { padding: 1.25rem; }
.status { color: var(--muted); }
.status.error { color: var(--err); }

/* Table */
/* NOTE: do NOT put overflow:hidden/auto on the table or any ancestor of the
   sticky <thead> — it traps the sticky header inside that scroll box and breaks
   pinning. Rounded corners are dropped for that reason. */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th {
	background: #f1f3f6; cursor: pointer; user-select: none;
	position: sticky; top: var(--topbar-h, 62px); z-index: 10;
	/* draw the divider as an inset shadow so it stays visible while stuck */
	box-shadow: inset 0 -1px 0 var(--line), 0 1px 0 var(--line);
}
th[data-key]::after { content: ''; opacity: .4; margin-left: .35rem; }
th.asc::after { content: '▲'; opacity: .8; }
th.desc::after { content: '▼'; opacity: .8; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: #f8fafc; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

.fb-btn {
	border: 0; background: var(--accent); color: #fff; padding: .4rem .7rem;
	border-radius: 6px; cursor: pointer; font-size: .85rem;
}
.fb-btn:hover { background: var(--accent-dark); }
.fb-btn:disabled { background: #9bbcf0; cursor: default; }

/* Toast */
.toast {
	position: fixed; right: 1rem; bottom: 1rem; max-width: 360px;
	padding: .8rem 1rem; border-radius: 8px; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
