:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --ink: #1f2430;
    --muted: #6b7280;
    --line: #e5e7eb;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --yes: #16a34a;
    --yes-bg: #dcfce7;
    --maybe: #d97706;
    --maybe-bg: #fef3c7;
    --no: #dc2626;
    --no-bg: #fee2e2;
    --winner-bg: #eef2ff;
    --declared: #16a34a;
    --declared-bg: #dcfce7;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 8px 24px rgba(0, 0, 0, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

.site-header { text-align: center; padding: 2rem 1rem .5rem; }
.brand { font-size: 1.8rem; font-weight: 800; text-decoration: none; color: var(--ink); letter-spacing: -.02em; }
.brand span { color: var(--brand); }
.tagline { color: var(--muted); margin: .25rem 0 0; }
.admin-nav { margin-top: .5rem; font-size: .85rem; }
.admin-nav a { color: var(--brand); text-decoration: none; }
.admin-nav a:hover { text-decoration: underline; }

.container { max-width: 860px; margin: 0 auto; padding: 1rem; }
.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 0; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.center { text-align: center; }

h1 { margin-top: 0; font-size: 1.5rem; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.meta { color: var(--muted); margin: .25rem 0; }
.description { white-space: pre-line; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
label > span { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
label.checkbox { display: flex; flex-direction: row; align-items: center; gap: .5rem; margin-top: .6rem; }
label.checkbox input { width: auto; }
label.checkbox span { display: inline; margin: 0; font-weight: 400; font-size: .9rem; }
label em { color: var(--brand); font-style: normal; }

input[type="text"], input[type="date"], input[type="time"], textarea {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}
input:focus, textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

fieldset.dates { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; }
legend { font-weight: 600; padding: 0 .4rem; }
.date-row { display: flex; gap: .5rem; margin-bottom: .5rem; align-items: center; }
.date-row input[type="date"] { flex: 2; }
.date-row input[type="time"] { flex: 1; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .6rem 1rem; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; border-style: dashed; color: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.icon { padding: .4rem .6rem; line-height: 1; }
.btn:disabled { opacity: .6; cursor: default; }

.alert { background: var(--no-bg); color: var(--no); padding: .7rem .9rem; border-radius: 8px; }

/* Share banner */
.share-banner { background: var(--winner-bg); border-color: #c7d2fe; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { font-family: ui-monospace, monospace; }

/* --- Voting grid --- */
.grid-wrap { overflow-x: auto; margin: 1rem 0; }
table.grid { border-collapse: collapse; width: 100%; min-width: 100%; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: .55rem .6rem; text-align: center; }
table.grid th.corner, table.grid th.who { text-align: left; white-space: nowrap; background: #fafafa; font-weight: 600; }
table.grid th.date { vertical-align: bottom; min-width: 90px; }
.date-label { font-size: .82rem; line-height: 1.2; display: inline-block; }
th.date.winner, td.tally.winner { background: var(--winner-bg); }
th.date.declared, td.tally.declared { background: var(--declared-bg); box-shadow: inset 0 0 0 2px var(--declared); }
.date-pin { display: block; margin-top: .2rem; }

/* The confirmed final date, shown to everyone above the grid. */
.declared-banner {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    margin-bottom: 1rem; padding: .8rem 1rem; border-radius: 8px;
    background: var(--declared-bg); border: 1px solid var(--declared);
}
.declared-badge { font-weight: 700; color: var(--declared); }
.declared-date { font-weight: 700; font-size: 1.05rem; }

.cell { font-weight: 700; }
.cell.yes { background: var(--yes-bg); color: var(--yes); }
.cell.maybe { background: var(--maybe-bg); color: var(--maybe); }
.cell.no { background: var(--no-bg); color: var(--no); }
.cell.empty { color: var(--line); }
.cell.editable { cursor: pointer; }
.cell.editable:hover { outline: 2px solid var(--brand); outline-offset: -2px; }
.cell.editable.empty { color: var(--muted); }
.cell.editable.empty::after { content: '·'; }
.cell.saving { opacity: .5; }
tr.you-existing th.who { color: var(--brand); }

/* Organiser's per-voter remove button, sat next to the name */
th.who { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.voter-remove {
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
    font-size: .9rem; line-height: 1; padding: .15rem .35rem; border-radius: 6px;
}
.voter-remove:hover { background: var(--no-bg); color: var(--no); }

tr.totals th, tr.totals td { background: #fafafa; font-weight: 700; }
.tally-yes { color: var(--yes); }
.tally-maybe { color: var(--maybe); margin-left: .3rem; font-weight: 600; }
.tally-no { color: var(--no); margin-left: .3rem; font-weight: 600; }

/* --- Editor panel --- */
.editor { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 2px dashed var(--line); }
.editor h3 { margin: 0 0 .75rem; }
.name-input { max-width: 320px; margin-bottom: 1rem; }
.editor-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; }
.choice {
    display: flex; flex-direction: column; gap: .2rem; padding: .6rem; cursor: pointer;
    border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; text-align: left;
}
.choice:hover { border-color: var(--brand); }
.choice-date { font-size: .8rem; color: var(--muted); }
.choice-state { font-weight: 700; }
.choice.yes { background: var(--yes-bg); border-color: var(--yes); }
.choice.yes .choice-state { color: var(--yes); }
.choice.maybe { background: var(--maybe-bg); border-color: var(--maybe); }
.choice.maybe .choice-state { color: var(--maybe); }
.choice.no { background: var(--no-bg); border-color: var(--no); }
.choice.no .choice-state { color: var(--no); }
.choice.empty .choice-state { color: var(--muted); font-weight: 600; }

.editor-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.save-msg { font-weight: 600; }
.save-msg.ok { color: var(--yes); }
.save-msg.error { color: var(--no); }

/* Shown in place of the editor once voting is closed */
.closed-notice {
    display: flex; align-items: center; gap: .6rem;
    margin-top: 1.5rem; padding: .9rem 1rem; border-radius: 8px;
    background: #fafafa; border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.closed-icon { font-size: 1.1rem; }

/* Organiser's declare-the-final-date panel */
.declare-panel { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 2px dashed var(--line); }
.declare-panel h3 { margin: 0 0 .35rem; }
.declare-panel p { margin: 0 0 .75rem; }
.declare-select { font: inherit; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

.admin-share { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.admin-share .copy-row { margin-top: .35rem; }
.admin-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.admin-actions { display: flex; align-items: center; gap: .5rem; }

/* Admin event index */
.index-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.event-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.event-item { padding: .85rem 0; border-top: 1px solid var(--line); }
.event-item:first-child { border-top: none; }
.event-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.event-title:hover { color: var(--brand); text-decoration: underline; }
.event-meta { margin-top: .2rem; }
