:root {
	--bg: #f5f6f8;
	--card: #ffffff;
	--ink: #1c2230;
	--muted: #7a8499;
	--line: #e6e9ef;
	--accent: #4f8cff;
	--accent-ink: #ffffff;
	--danger: #ff5d6c;
	--radius: 12px;
}

* { box-sizing: border-box; }

/* Author rules below set display on labels/etc., which would otherwise
   override the UA [hidden] behaviour — keep hidden meaning hidden. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: var(--bg);
	color: var(--ink);
	line-height: 1.45;
	font-size: 16px;
}

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

/* Top bar */
.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0.85rem 1.25rem;
	padding-left: max(1.25rem, env(safe-area-inset-left));
	padding-right: max(1.25rem, env(safe-area-inset-right));
	background: var(--card);
	border-bottom: 1px solid var(--line);
	position: sticky;
	top: 0;
	z-index: 20;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.brand:hover { text-decoration: none; }

main { max-width: 960px; margin: 1.5rem auto; padding: 0 1.25rem; }

/* Hamburger menu (native <details>) */
.menu { position: relative; }
.menu summary {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.35rem 0.6rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu .who { color: var(--ink); font-weight: 600; font-size: 0.9rem; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .burger { font-size: 1.2rem; line-height: 1; color: var(--muted); }
.menu[open] summary { border-color: var(--accent); }

.menu-panel {
	position: absolute;
	right: 0;
	top: calc(100% + 0.5rem);
	width: 240px;
	max-width: 80vw;
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: 0 12px 32px rgba(20, 30, 60, 0.16);
	padding: 0.5rem;
	z-index: 30;
}
.menu-nav { display: flex; flex-direction: column; }
.menu-nav a {
	padding: 0.6rem 0.7rem;
	border-radius: 8px;
	color: var(--ink);
	font-weight: 500;
}
.menu-nav a:hover { background: #f0f3f9; text-decoration: none; }

.menu-section { border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.5rem; }
.menu-label { margin: 0 0 0.35rem; padding: 0 0.7rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.profile {
	display: block;
	padding: 0.5rem 0.7rem;
	border-radius: 8px;
	color: var(--ink);
	font-weight: 500;
}
.profile:hover { background: #f0f3f9; text-decoration: none; }
.profile.active { background: var(--accent); color: var(--accent-ink); }

.addmember { display: flex; gap: 0.4rem; margin-top: 0.4rem; padding: 0 0.2rem; }
.addmember input { flex: 1; min-width: 0; margin: 0; }
.addmember button { flex: 0 0 auto; }

.logout { width: 100%; color: var(--danger); }
.logout:hover { background: #fff0f1; }

/* Cards */
.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 1.25rem 1.35rem;
	margin-bottom: 1.25rem;
}
.card h1 { margin-top: 0; }
.card h2 { margin: 0 0 1rem; font-size: 1.05rem; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

/* Forms */
label { display: block; margin-bottom: 0.9rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
input, select, button, textarea { font: inherit; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], select {
	width: 100%;
	margin-top: 0.3rem;
	padding: 0.6rem 0.7rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fff;
	color: var(--ink);
	font-size: 16px; /* keeps iOS from zooming on focus */
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

button {
	cursor: pointer;
	border: 1px solid var(--line);
	background: #fff;
	color: var(--ink);
	padding: 0.55rem 0.9rem;
	border-radius: 8px;
	font-weight: 600;
	min-height: 44px; /* comfortable tap target */
}
button:hover { background: #f0f3f9; }
button.primary, .auth button[type=submit] {
	background: var(--accent);
	color: var(--accent-ink);
	border-color: var(--accent);
	width: 100%;
	padding: 0.7rem;
	margin-top: 0.4rem;
}
button.primary:hover, .auth button[type=submit]:hover { filter: brightness(1.05); }

/* Auth */
.auth { max-width: 380px; margin: 3rem auto; }

/* Entries table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.entries { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.entries th {
	text-align: left;
	color: var(--muted);
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	padding: 0 0.5rem 0.5rem;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}
table.entries td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.entries tr:last-child td { border-bottom: none; }
.when { color: var(--muted); white-space: nowrap; font-size: 0.82rem; }
.badge {
	display: inline-block;
	padding: 0.15rem 0.55rem;
	background: #eef3ff;
	color: var(--accent);
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	white-space: nowrap;
}
.del {
	border: none;
	background: none;
	color: var(--muted);
	font-size: 1.3rem;
	line-height: 1;
	padding: 0 0.4rem;
	min-height: auto;
}
.del:hover { background: none; color: var(--danger); }

/* Charts */
canvas { width: 100% !important; height: 260px !important; }

/* Misc */
.muted { color: var(--muted); }
.error {
	background: #fff0f1;
	color: #b3263a;
	border: 1px solid #ffd5da;
	padding: 0.6rem 0.8rem;
	border-radius: 8px;
	font-size: 0.9rem;
}
.summary { margin: -0.3rem 0 1.1rem; }
.summary .hint { font-size: 0.85rem; }
small { font-size: 0.8rem; }

@media (max-width: 760px) {
	main { margin: 1rem auto; padding: 0 0.9rem; }
	.card { padding: 1.1rem; }
	.summary .hint { display: block; margin-top: 0.2rem; }
}
