:root {
    --bg: #f4f4f1;
    --surface: #ffffff;
    --text: #1c1c1a;
    --muted: #6b6b66;
    --line: #dededa;
    --accent: #65b32e;
    --accent-text: #3f7a1a;
    --accent-dark: #4c8623;
    --bar: #111111;
    --bar-text: #e8e8e4;
    --danger: #b3261e;
    --ok-bg: #e6f3da;
    --error-bg: #f9e3e1;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161614;
        --surface: #1f1f1c;
        --text: #e6e6e1;
        --muted: #9a9a93;
        --line: #33332f;
        --accent-text: #8fd25a;
        --accent-dark: #76bf3d;
        --bar: #0a0a0a;
        --ok-bg: #243a16;
        --error-bg: #4a1f1c;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    }
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent-text); }
a:hover { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
.muted { color: var(--muted); }
img { max-width: 100%; height: auto; display: block; }

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 1.25rem;
    min-height: 60px;
    background: var(--bar);
    color: var(--bar-text);
    border-bottom: 3px solid var(--accent);
}
.topbar .logo { display: flex; align-items: center; color: #fff; padding: .4rem 0; }
.topbar .logo svg { height: 30px; width: auto; fill: currentColor; }
.topbar .logo:hover { color: var(--accent); }
.topnav, .account { display: flex; flex-wrap: wrap; gap: .25rem; }
.topnav { flex: 1; }
.account { margin-left: auto; align-items: center; }
.topbar a, .topbar button.link {
    color: var(--bar-text);
    text-decoration: none;
    padding: .45rem .7rem;
    border-radius: var(--radius);
    font-size: .95rem;
}
.topbar a:hover, .topbar button.link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.topbar a.active { color: var(--accent); }
button.link { background: none; border: 0; font: inherit; cursor: pointer; }

/* Shell: sidebar + main */
.shell {
    flex: 1;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem;
}
.sidebar section { margin-bottom: 1.5rem; }
.sidebar h2 {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 0 0 .35rem;
}
.sidebar a {
    display: block;
    padding: .3rem .5rem;
    margin-left: -.5rem;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.sidebar a:hover { background: var(--surface); }
.sidebar a.active { border-left-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* Home */
.hero {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem 2.25rem;
    margin-bottom: 2rem;
    border-top: 4px solid var(--accent);
}
.hero .kicker {
    margin: 0 0 .5rem;
    font-size: .8rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--accent-text);
    font-weight: 600;
}
.hero h1 { font-size: 2.2rem; }
.hero .lead { font-size: 1.1rem; max-width: 60ch; }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.25rem 0 0; }

.events { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.card img { width: 100%; background: #000; }
.card-body { padding: 1.25rem 1.5rem 1.5rem; }
.card h2 a { text-decoration: none; color: var(--text); }
.card h2 a:hover { color: var(--accent-text); }
.card .meta { color: var(--accent-text); font-weight: 600; font-size: .9rem; margin-top: -.25rem; }

/* Buttons and forms */
.button, button.small {
    display: inline-block;
    padding: .55rem 1.1rem;
    background: var(--accent);
    color: #0b1a04;
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--accent-dark); color: #fff; }
.button.secondary { background: transparent; color: var(--accent-text); box-shadow: inset 0 0 0 2px var(--accent); }
.button.secondary:hover { background: var(--accent); color: #0b1a04; }

.form { max-width: 28rem; display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.check { grid-template-columns: auto 1fr; align-items: center; font-weight: 400; }
.form input:not([type=checkbox]) {
    font: inherit;
    padding: .5rem .65rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
}
.form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form .button { justify-self: start; }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.flash.ok { background: var(--ok-bg); }
.flash.error { background: var(--error-bg); }
ul.flash { padding-left: 2rem; }

hr { border: 0; border-top: 1px solid var(--line); margin: 1.75rem 0 1.25rem; max-width: 28rem; }

/* Profile */
.profile { display: grid; grid-template-columns: 160px 1fr; gap: 2rem; margin-bottom: 2.5rem; }
.avatar img, .avatar .placeholder {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar .placeholder {
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #0b1a04;
    font-size: 4rem;
    font-weight: 700;
}
.avatar p { text-align: center; }

/* Admin table */
.members { width: 100%; border-collapse: collapse; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); font-size: .95rem; }
.members th, .members td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.members th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.members tr.status-pending td { background: var(--ok-bg); }
.members tr.status-disabled td { color: var(--muted); }
.members .actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.members .actions form { display: inline; }
button.small { padding: .3rem .6rem; font-size: .85rem; background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); font-weight: 500; }
button.small:hover { box-shadow: inset 0 0 0 1px var(--accent); }
button.small.primary { background: var(--accent); color: #0b1a04; box-shadow: none; }
button.small.danger { color: var(--danger); }

footer {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .9rem;
}
footer a { color: var(--muted); }

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; gap: 1.5rem; }
    .sidebar { order: 2; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
    .topbar { flex-wrap: wrap; padding: .5rem 1rem; gap: .5rem 1rem; }
    .hero { padding: 1.5rem; }
    .hero h1 { font-size: 1.7rem; }
    .profile { grid-template-columns: 1fr; }
    .members { display: block; overflow-x: auto; }
}
