@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Inter:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:      #0f1a10;
  --ink2:     #4a5e50;
  --bg:       #f0f4f0;
  --surface:  #ffffff;
  --accent:   #16a34a;
  --accent-h: #15803d;
  --blue:     #2355c0;
  --yes:      #22c55e;
  --maybe:    #b45309;
  --no:       #dc2626;
  --border:   #cfdacf;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.07);
  --shadow-sm:0 1px 3px rgba(0,0,0,.08);
}

html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Nav ──────────────────────────────────────────────────────────────────── */
nav {
  background: var(--ink);
  padding: .8rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.brand {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand-icon { width: 28px; height: 28px; flex-shrink: 0; }
.brand span { color: #4ade80; }
.nav-divider { color: rgba(255,255,255,.2); }
.nav-user    { color: rgba(255,255,255,.6); font-size: .83rem; }
.nav-link    { color: rgba(255,255,255,.55); font-size: .83rem; text-decoration: none; transition: color .15s; }
.nav-link:hover { color: #fff; }
.nav-logout  { margin-left: auto; }
.nav-eco {
  margin-left: auto;
  font-size: .7rem;
  color: #4ade80;
  opacity: .75;
  white-space: nowrap;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.page-wrap { max-width: 820px; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }

/* ── Type ─────────────────────────────────────────────────────────────────── */
h1 { font-family: 'Syne', sans-serif; font-size: 2rem; font-weight: 800; letter-spacing: -.5px; line-height: 1.15; }
h2 { font-family: 'Syne', sans-serif; font-size: 1.25rem; font-weight: 700; margin-bottom: .6rem; }
h3 { font-size: .95rem; font-weight: 600; }
p  { color: var(--ink2); font-size: .92rem; }
a  { color: var(--blue); }
.muted { color: var(--ink2); font-weight: 400; }

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

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .55rem 1.1rem;
  border: 1.5px solid transparent;
  border-radius: 7px;
  font-family: 'Inter', sans-serif; font-size: .88rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .1s, filter .1s;
  white-space: nowrap;
}
.btn:hover   { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active  { transform: none; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--ink); color: #fff; }
.btn-ghost     { background: transparent; border-color: var(--border); color: var(--ink2); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-sm        { padding: .35rem .8rem; font-size: .8rem; }
.btn-block     { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
label  { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .3rem; color: var(--ink); letter-spacing: .02em; }
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=url],
textarea, select {
  width: 100%; padding: .55rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: 'Inter', sans-serif; font-size: .9rem;
  background: #fafaf8; color: var(--ink);
  transition: border-color .12s, background .12s;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); background: #fff; }
textarea { resize: vertical; min-height: 72px; }
.hint  { font-size: .78rem; color: var(--ink2); margin-top: .2rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 540px) { .row-2 { grid-template-columns: 1fr; } }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: 8px;
  font-size: .88rem; margin-bottom: 1.25rem;
  border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */
body.auth-page { display: flex; flex-direction: column; min-height: 100vh; }
.auth-wrap  { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card  { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: .25rem; }
.auth-sub   { margin-bottom: 1.25rem; }
.auth-form  { margin-top: 1rem; }
.auth-switch { font-size: .83rem; color: var(--ink2); margin-top: 1rem; text-align: center; }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.dashboard-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem;
}
.dashboard-header h1 { margin-bottom: .15rem; }
.header-actions { display: flex; gap: .5rem; flex-shrink: 0; }

.poll-list { display: flex; flex-direction: column; gap: .75rem; }
.poll-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 1.5rem;
}
.poll-card-body { flex: 1; min-width: 0; }
.poll-meta { margin-bottom: .3rem; }
.poll-title { font-size: 1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poll-stats { font-size: .8rem; color: var(--ink2); margin-top: .2rem; }
.poll-card-actions { display: flex; gap: .4rem; flex-shrink: 0; }

.badge {
  display: inline-block; padding: .15rem .6rem; border-radius: 20px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.badge-open      { background: #dcfce7; color: #15803d; }
.badge-finalized { background: #dbeafe; color: #1e40af; }
.badge-expired   { background: #f3f4f6; color: #6b7280; }

.empty-state { text-align: center; padding: 3rem 2rem; }
.empty-icon  { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h2 { font-size: 1.2rem; margin-bottom: .4rem; }

/* ── Create poll ──────────────────────────────────────────────────────────── */
.slots-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.slots-header h2 { margin: 0; }

.suggest-panel {
  background: #f8f7f3; border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem; margin-bottom: 1rem;
}

.add-slot-row {
  display: flex; gap: .5rem; align-items: flex-end;
  margin-bottom: .75rem; flex-wrap: wrap;
}
.add-slot-row input { width: auto; flex: 1; min-width: 130px; }

.slot-chip-list { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 1rem; }
.slot-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .7rem;
  background: #f0eee8; border: 1px solid var(--border);
  border-radius: 20px; font-size: .82rem;
}
.chip-remove {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; line-height: 1; color: var(--ink2); padding: 0;
}
.chip-remove:hover { color: var(--no); }

.suggest-chip {
  cursor: pointer; background: #fff; border: 1.5px solid var(--blue);
  color: var(--blue); border-radius: 20px;
  padding: .28rem .75rem; font-size: .82rem; font-weight: 500;
  transition: background .12s;
}
.suggest-chip:hover:not(:disabled) { background: #eff6ff; }
.suggest-chip.added { background: #dcfce7; border-color: #86efac; color: #166534; }
.suggest-chip:disabled { cursor: default; }

/* ── Vote page ────────────────────────────────────────────────────────────── */
.vote-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem;
}
.vote-header h1 { margin-bottom: .2rem; }
.deadline-badge {
  flex-shrink: 0; padding: .3rem .75rem; border-radius: 6px;
  background: #fefce8; border: 1px solid #fde68a;
  color: #92400e; font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.deadline-badge.expired { background: #f3f4f6; border-color: #d1d5db; color: #6b7280; }

.vote-grid-wrap { overflow-x: auto; margin-bottom: .5rem; }
.vote-grid { display: flex; gap: 1.25rem; min-width: min-content; }
.vote-day { min-width: 160px; }
.vote-day-header {
  font-family: 'Syne', sans-serif; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--ink2);
  padding-bottom: .4rem; border-bottom: 1.5px solid var(--border);
  margin-bottom: .5rem;
}
.vote-slot-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; margin-bottom: .4rem;
}
.slot-time { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.vote-btns { display: flex; gap: .2rem; }
.vote-opt { cursor: pointer; }
.vote-opt input { display: none; }
.vote-opt span,
.vote-opt {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  font-size: .85rem; font-weight: 700;
  border: 1.5px solid var(--border);
  color: var(--ink2); background: #fafaf8;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}
.vote-opt.yes:has(input:checked)   { background: #dcfce7; border-color: #86efac; color: var(--yes); }
.vote-opt.maybe:has(input:checked) { background: #fef9c3; border-color: #fde68a; color: var(--maybe); }
.vote-opt.no:has(input:checked)    { background: #fee2e2; border-color: #fca5a5; color: var(--no); }

.vote-legend { display: flex; gap: 1rem; font-size: .78rem; font-weight: 600; margin-top: .5rem; }
.legend-yes   { color: var(--yes); }
.legend-maybe { color: var(--maybe); }
.legend-no    { color: var(--no); }

/* ── Vote / Results table ─────────────────────────────────────────────────── */
.vote-table-wrap { overflow-x: auto; margin-top: .5rem; }
.vote-table { border-collapse: collapse; width: 100%; font-size: .83rem; }
.vote-table th {
  background: var(--ink); color: rgba(255,255,255,.9);
  padding: .45rem .6rem; font-weight: 500;
}
.name-th { text-align: left; min-width: 120px; padding-left: .75rem; }
.slot-th { text-align: center; min-width: 64px; }
.th-date { font-size: .72rem; color: rgba(255,255,255,.6); }
.th-time { font-size: .82rem; font-weight: 600; }
.vote-table tr:nth-child(even) td { background: #fafaf8; }
.name-td { padding: .4rem .75rem; font-weight: 500; white-space: nowrap; }
.vote-cell { text-align: center; padding: .4rem .3rem; font-weight: 700; font-size: .85rem; }
.status-yes   { color: var(--yes); }
.status-maybe { color: var(--maybe); }
.status-no    { color: #ccc; }
tfoot td { border-top: 2px solid var(--border); }
.tfoot-label  { font-size: .75rem; font-weight: 700; color: var(--ink2); padding: .4rem .75rem; }
.tfoot-count  { text-align: center; font-weight: 700; font-size: .85rem; }

/* ── Results page ─────────────────────────────────────────────────────────── */
.finalized-banner { font-size: .9rem; }

.share-card { padding: 1rem 1.25rem; }
.share-row  { display: flex; gap: .5rem; margin-top: .4rem; }
.share-row input { flex: 1; background: #f8f7f3; color: var(--ink2); font-size: .82rem; }

.ranked-slots { display: flex; flex-direction: column; gap: .6rem; }
.ranked-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .9rem; border-radius: 8px;
  border: 1.5px solid var(--border); background: #fafaf8;
  transition: border-color .12s;
}
.ranked-row:hover { border-color: #c5c2ba; }
.ranked-row.is-final { border-color: #93c5fd; background: #eff6ff; }
.rank-num { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800; color: var(--ink2); width: 1.5rem; flex-shrink: 0; }
.rank-info { flex: 1; min-width: 0; }
.rank-label { font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.rank-bar-wrap { height: 6px; background: #ede8e0; border-radius: 3px; margin-bottom: .3rem; overflow: hidden; display: flex; }
.rank-bar { height: 100%; border-radius: 3px; }
.yes-bar   { background: var(--yes); }
.maybe-bar { background: var(--maybe); opacity: .7; }
.rank-counts { font-size: .75rem; display: flex; gap: .75rem; }
.yes-text   { color: var(--yes); font-weight: 600; }
.maybe-text { color: var(--maybe); font-weight: 600; }
.no-text    { color: #ccc; font-weight: 600; }

/* ── Calendar page ────────────────────────────────────────────────────────── */
.cal-row {
  display: flex; align-items: center; gap: .9rem;
  padding: .65rem 0; border-bottom: 1px solid var(--border);
}
.cal-row:last-child { border-bottom: none; }
.cal-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem; flex-shrink: 0;
}
.cal-google    { background: #fee2e2; color: #991b1b; }
.cal-microsoft { background: #dbeafe; color: #1e40af; }
.cal-caldav    { background: #f0fdf4; color: #166534; }
.cal-info { flex: 1; }
.cal-info strong { display: block; font-size: .9rem; }
.cal-info .hint  { margin: 0; }

.provider-card { margin-bottom: .75rem; }
.provider-header { display: flex; align-items: center; gap: .9rem; margin-bottom: .9rem; }
.provider-logo {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.1rem; flex-shrink: 0;
}
.google-logo { background: #fee2e2; color: #991b1b; }
.ms-logo     { background: #dbeafe; color: #1e40af; }
.caldav-logo { background: #f0fdf4; font-size: 1.3rem; }
.provider-header h3 { margin: 0 0 .15rem; font-size: .95rem; }
.provider-header p  { margin: 0; font-size: .82rem; }
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }

/* ── Slot grid (create.php) ───────────────────────────────────────────────── */
.grid-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: .65rem; margin-bottom: .6rem; flex-wrap: wrap;
}
.grid-controls { display: flex; gap: .65rem; align-items: flex-end; flex-wrap: wrap; }
.ctrl-label { display: block; font-size: .72rem; font-weight: 600; margin-bottom: .2rem; }
.ctrl-input  { width: auto !important; padding: .32rem .6rem !important; font-size: .82rem !important; }
.ctrl-select { width: auto !important; padding: .32rem .6rem !important; font-size: .82rem !important; }
.toggle-check {
  display: flex; align-items: center; gap: .3rem;
  font-size: .81rem; font-weight: 500; cursor: pointer;
}
.toggle-check input { width: auto !important; }
.grid-quick { display: flex; gap: .3rem; align-items: center; flex-shrink: 0; }

.slot-grid-scroll { overflow-x: auto; padding-bottom: .25rem; }
.slot-grid { border-collapse: separate; border-spacing: 2px; table-layout: fixed; user-select: none; }
.time-label-th { width: 40px; }
.time-label {
  font-size: .7rem; color: var(--ink2); font-weight: 600;
  white-space: nowrap; padding-right: .4rem; text-align: right;
  vertical-align: middle;
}
.grid-head-cell {
  font-size: .68rem; font-weight: 700; text-align: center;
  padding: 0 1px 4px; min-width: 38px;
}
.grid-head-cell.wknd .gh-day,
.grid-head-cell.wknd .gh-date { color: var(--ink2); opacity: .55; }
.gh-day  { display: block; font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink2); }
.gh-date { display: block; font-size: .75rem; font-weight: 700; }

.grid-cell {
  width: 38px; height: 24px;
  background: #f2f0eb; border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer; display: block;
  transition: background .08s, border-color .08s;
}
.grid-cell:hover  { background: #e4e0d8; border-color: #bbb8b0; }
.grid-cell.sel    { background: var(--accent); border-color: var(--accent-h); }
.grid-cell.sel:hover { filter: brightness(1.1); }
.grid-cell.wknd   { background: #edece8; }
.grid-cell.busy   { background: #b0bdb0; border-color: #8fa08f; }
.grid-cell.busy:hover { background: #a0b0a0; }

/* ── Vote matrix grid ─────────────────────────────────────────────────────── */
.vf-identity { display: flex; gap: .5rem; margin-bottom: .75rem; }
.vf-identity input { flex: 1; width: auto !important; min-width: 0; }

.vgrid-scroll { overflow-x: auto; margin: 0 -1px; }
.vgrid { border-collapse: collapse; font-size: .82rem; white-space: nowrap; user-select: none; }

.vg-corner { min-width: 72px; }
.vg-date-h {
  text-align: center; padding: .3rem .4rem .2rem;
  background: var(--ink); color: #fff;
  border-left: 1px solid rgba(255,255,255,.12);
}
.vg-dow { font-size: .6rem; text-transform: uppercase; letter-spacing: .05em; opacity: .65; }
.vg-dm  { font-size: .78rem; font-weight: 700; }

.vg-time-h {
  text-align: center; font-size: .7rem; font-weight: 600; color: var(--ink2);
  padding: .2rem .3rem; min-width: 44px;
  border-left: 1px solid var(--border); border-bottom: 1.5px solid var(--border);
  background: #f8f7f3;
}

.vg-name {
  font-size: .8rem; font-weight: 500; padding: .25rem .6rem .25rem 0;
  max-width: 100px; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
}
.vg-rc {
  text-align: center; min-width: 44px; font-size: .82rem; font-weight: 700;
  border: 1px solid var(--border); padding: .25rem .2rem;
}
.rc-yes   { background: #dcfce7; color: var(--yes); }
.rc-maybe { background: #fef9c3; color: var(--maybe); }
.rc-no    { color: #ddd; background: #fafaf8; }

.vg-sep td { height: 5px; background: var(--bg); padding: 0; border: none; }

.vg-your-label {
  font-size: .76rem; font-weight: 700; color: var(--ink);
  padding-right: .6rem; white-space: nowrap;
}
.vg-vcell { text-align: center; padding: 2px; border: 1px solid var(--border); }
.vg-btn {
  width: 40px; height: 30px;
  border: 1.5px solid var(--border); border-radius: 5px;
  background: #f5f4f0; cursor: pointer;
  font-size: .82rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; transition: background .1s, border-color .1s;
  gap: 1px;
}
.vg-btn:hover    { background: #e8e5de; }
.vg-btn.vg-yes   { background: #dcfce7; border-color: #86efac; color: var(--yes); }
.vg-btn.vg-maybe { background: #fef9c3; border-color: #fde68a; color: var(--maybe); }
.vg-n {
  position: absolute; top: 1px; right: 2px;
  font-size: .58rem; color: var(--ink2); font-weight: 700; line-height: 1;
}

.vg-legend { display: flex; gap: .75rem; font-size: .75rem; font-weight: 600; align-items: center; margin-top: .5rem; }
.vg-l-yes   { color: var(--yes); }
.vg-l-maybe { color: var(--maybe); }
.vg-l-no    { color: var(--ink2); }
.vg-l-hint  { color: var(--ink2); font-weight: 400; margin-left: auto; font-style: italic; }

/* ── Mode toggle ──────────────────────────────────────────────────────────── */
.mode-toggle { display: flex; gap: .3rem; }
.mode-btn {
  padding: .3rem .8rem; border-radius: 6px; font-size: .82rem; font-weight: 600;
  border: 1.5px solid var(--border); background: transparent; color: var(--ink2); cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Full-day date grid ────────────────────────────────────────────────────── */
.date-grid { display: flex; flex-wrap: wrap; gap: .4rem; padding: .25rem 0; }
.date-cell {
  display: flex; flex-direction: column; align-items: center;
  width: 54px; padding: .4rem .2rem; border-radius: 8px;
  border: 1.5px solid var(--border); background: #f5f4f0;
  cursor: pointer; transition: background .1s, border-color .1s;
  user-select: none;
}
.date-cell:hover    { background: #e8e5de; }
.date-cell.sel      { background: var(--accent); border-color: var(--accent-h); }
.date-cell.wknd     { background: #edece8; }
.date-cell.sel .dc-day,
.date-cell.sel .dc-num,
.date-cell.sel .dc-mon { color: #fff; }
.dc-day { font-size: .6rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink2); }
.dc-num { font-size: 1.1rem; font-weight: 800; font-family: 'Syne', sans-serif; line-height: 1.1; color: var(--ink); }
.dc-mon { font-size: .6rem; color: var(--ink2); }

/* ── Row-3 layout ─────────────────────────────────────────────────────────── */
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .row-3 { grid-template-columns: 1fr 1fr; } }

/* ── Form footer ──────────────────────────────────────────────────────────── */
.form-footer-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.template-tools  { display: flex; gap: .4rem; align-items: center; margin-left: auto; }

/* ── Rank people chips ────────────────────────────────────────────────────── */
.rank-people { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .4rem; }
.rp {
  font-size: .68rem; font-weight: 500;
  padding: .1rem .45rem; border-radius: 20px;
}
.rp-yes   { background: #dcfce7; color: #15803d; }
.rp-maybe { background: #fef9c3; color: #92400e; }
.rp-no    { background: #f3f4f6; color: #6b7280; }

/* ── Eco nav badge ────────────────────────────────────────────────────────── */
.eco-strip {
  background: #f0fdf4; border-bottom: 1px solid #bbf7d0;
  padding: .45rem 1.5rem;
  display: flex; gap: 1.5rem; justify-content: center; flex-wrap: wrap;
  font-size: .78rem; color: #15803d; font-weight: 500;
}
.eco-strip span::before { content: '✦ '; opacity: .6; }
