:root {
  --bg: #f0f7fa;
  --bg-grad: linear-gradient(180deg, #e6f3f7 0%, #f0f7fa 240px);
  --surface: #ffffff;
  --ink: #0f2733;
  --ink-soft: #4a6572;
  --subtle: #7c93a0;
  --line: #dbe7ec;
  --primary: #0c7ca3;
  --primary-deep: #0c4a6e;
  --primary-soft: #e0f2fc;
  --yes: #16a34a;
  --maybe: #f59e0b;
  --no: #cbd5e1;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(12,74,110,.06), 0 8px 24px rgba(12,74,110,.06);
  --shadow-lg: 0 12px 40px rgba(12,74,110,.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem 1.25rem;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.2rem; color: var(--primary-deep); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.4rem; }
.nav { display: flex; gap: .25rem; margin-left: .5rem; }
.nav a { color: var(--ink-soft); padding: .4rem .75rem; border-radius: 999px; font-weight: 500; font-size: .95rem; }
.nav a:hover { background: var(--primary-soft); text-decoration: none; color: var(--primary-deep); }
.nav a.active { background: var(--primary); color: #fff; }
.me { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.me-name { font-weight: 500; font-size: .95rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .85rem; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: .72rem; }

.container { width: min(1080px, 100%); margin: 0 auto; padding: 1.5rem 1.25rem 3rem; flex: 1; }

/* ---------- buttons ---------- */
.btn { font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 10px; padding: .55rem 1rem; cursor: pointer; transition: .15s; display: inline-flex; align-items: center; gap: .4rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: #fff; color: var(--ink); text-decoration: none; }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; justify-content: center; }
.link-btn { background: none; border: none; color: var(--primary); font: inherit; cursor: pointer; padding: 0; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--subtle); font-size: 1.3rem; line-height: 1; padding: 0 .25rem; }
.icon-btn:hover { color: var(--danger); }

/* ---------- cards / layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.subtle { color: var(--subtle); font-size: .9rem; margin: .25rem 0 0; }
.section-title { font-size: 1.15rem; margin: 1.75rem 0 .75rem; color: var(--primary-deep); }
.breadcrumb { margin-bottom: .5rem; font-size: .9rem; }
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.empty-state { text-align: center; padding: 2.5rem; display: grid; gap: 1rem; place-items: center; }
.empty-note { color: var(--subtle); font-size: .9rem; }

/* ---------- forms ---------- */
.stack { display: grid; gap: .85rem; }
label { font-weight: 500; font-size: .9rem; display: grid; gap: .35rem; color: var(--ink-soft); }
input, textarea, select { font: inherit; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.check-row { flex-direction: row; align-items: center; gap: .5rem; }
.check-row input { width: auto; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { position: relative; overflow: hidden; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: flex-end; min-height: 100vh; text-shadow: 0 1px 12px rgba(8,30,45,.6); }
.auth-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-orientation: from-image; z-index: 0; }
.auth-hero-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(11,49,73,.45) 0%, rgba(11,49,73,.82) 100%); z-index: 1; }
.auth-hero-content { position: relative; z-index: 2; }
.auth-mark { font-size: 3rem; }
.auth-hero h1 { color: #fff; font-size: 2.6rem; margin: .5rem 0; }
.auth-hero p { color: #cdeafe; max-width: 30ch; font-size: 1.05rem; }
.auth-card { display: flex; flex-direction: column; justify-content: center; padding: 3rem; max-width: 440px; width: 100%; margin: 0 auto; }
.auth-card h2 { margin-bottom: 1.25rem; }
.auth-alt { margin-top: 1.25rem; font-size: .92rem; color: var(--subtle); }
.auth-help { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid var(--line); font-size: .92rem; font-weight: 500; }

/* ---------- calendar ---------- */
.legend { display: flex; gap: 1rem; font-size: .85rem; color: var(--ink-soft); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.cal-layout { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.cal-nav h2 { font-size: 1.25rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { margin-bottom: 6px; }
.cal-dow { text-align: center; font-size: .72rem; font-weight: 600; color: var(--subtle); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 2px; }
.cal-grid + .cal-grid { margin-top: 6px; }
.cal-cell { aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 10px; padding: 4px 5px; cursor: pointer; position: relative; transition: .12s; display: flex; flex-direction: column; background: #fff; user-select: none; }
.cal-cell.empty { border: none; background: transparent; cursor: default; }
.cal-cell:not(.empty):hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.cal-cell.today { border-color: var(--primary); }
.cal-cell.today .cal-date { color: var(--primary); font-weight: 700; }
.cal-date { font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.cal-cell.mine-yes { background: #f0fdf4; border-color: #bbf7d0; }
.cal-cell.mine-maybe { background: #fffbeb; border-color: #fde68a; }
.cal-cell.mine-no { background: #f8fafc; }
.cal-dots { display: flex; flex-wrap: wrap; gap: 2px; margin-top: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.s-yes { background: var(--c, var(--yes)); }
.dot.s-maybe { background: var(--maybe); }
.dot.s-no { background: var(--no); }

.cal-side { display: grid; gap: 1.25rem; }
.suggest h2, .crew h2 { font-size: 1.1rem; margin-bottom: .15rem; }
.suggest-list { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .65rem; }
.suggest-item { display: flex; gap: .7rem; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; }
.suggest-item.top { background: var(--primary-soft); border-color: #bae6fd; }
.suggest-rank { font-family: 'Fraunces', serif; font-weight: 600; color: var(--primary); font-size: 1.05rem; }
.suggest-body { flex: 1; min-width: 0; }
.suggest-meta { display: flex; gap: .35rem; margin: .35rem 0; flex-wrap: wrap; }
.pill { font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; }
.pill-yes { background: #dcfce7; color: #166534; }
.pill-maybe { background: #fef3c7; color: #92400e; }
.suggest-people { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .4rem; }
.chip { font-size: .72rem; padding: .1rem .45rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--c, var(--primary)); }
.crew-list { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .5rem; }
.crew-list li { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }

/* ---------- weekends ---------- */
.weekend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.weekend-card { display: flex; flex-direction: column; gap: .4rem; transition: .15s; }
.weekend-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #bae6fd; }
.weekend-card.past { opacity: .72; }
.weekend-dates { font-size: .8rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; }
.weekend-card h3 { font-size: 1.15rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.weekend-foot { margin-top: auto; padding-top: .5rem; display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: .8rem; background: var(--primary-soft); color: var(--primary-deep); padding: .15rem .55rem; border-radius: 999px; font-weight: 600; }
.notes { margin-top: .5rem; color: var(--ink-soft); }
.head-actions { display: flex; gap: .5rem; flex: none; }

/* ---------- shopping list ---------- */
.shopping-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.shopping-head h2 { font-size: 1.25rem; }
.shopping-head-right { display: flex; align-items: center; gap: .6rem; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.counter { font-size: .85rem; color: var(--ink-soft); background: var(--primary-soft); padding: .25rem .7rem; border-radius: 999px; font-weight: 600; }
.add-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.add-row input[name=name] { flex: 1; }
.qty-input { width: 90px; flex: none; }
.item-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.item { display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.item.done { opacity: .6; background: #f8fafc; }
.item.done .item-name { text-decoration: line-through; }
.check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); background: #fff; cursor: pointer; flex: none; display: grid; place-items: center; padding: 0; }
.check .tick { color: #fff; font-size: .8rem; line-height: 1; opacity: 0; }
.item.done .check { background: var(--yes); border-color: var(--yes); }
.item.done .check .tick { opacity: 1; }
.item-main { flex: 1; display: flex; align-items: baseline; gap: .5rem; min-width: 0; }
.item-name { font-weight: 500; }
.item-qty { font-size: .8rem; color: var(--subtle); background: #f1f5f9; padding: .05rem .4rem; border-radius: 6px; }
.claim-btn { font: inherit; font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.claim-btn:hover { border-color: var(--primary); color: var(--primary); }
.claim-btn.claimed { background: var(--c, var(--primary)); border-color: transparent; color: #fff; }

/* meal planner */
.general-block { margin-bottom: 1.25rem; }
.block-title { font-size: 1.05rem; margin-bottom: .5rem; }
.block-title .subtle { font-weight: 400; font-size: .82rem; }
.day-group { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.day-title { font-size: 1.05rem; color: var(--primary-deep); margin-bottom: .75rem; }
.meals-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.meal-col { display: flex; flex-direction: column; }
.meal-head { font-weight: 600; font-size: .9rem; color: var(--ink-soft); margin-bottom: .5rem; display: flex; align-items: center; gap: .4rem; }
.meal-icon { font-size: 1.05rem; }
.meal-name-input { margin-bottom: .5rem; padding: .35rem .5rem; font-size: .85rem; font-weight: 500; border: 1px dashed var(--line); border-radius: 8px; background: transparent; color: var(--primary-deep); }
.meal-name-input::placeholder { font-weight: 400; color: var(--subtle); }
.meal-name-input:hover { border-color: var(--primary); }
.meal-name-input:focus { border-style: solid; background: #fff; }
.meal-block { background: #fafdff; border: 1px solid var(--line); border-radius: 12px; padding: .6rem; display: flex; flex-direction: column; gap: .5rem; height: 100%; }
.general-block .meal-block { background: var(--primary-soft); border-color: #cdeafe; }
.meal-block .item-list { gap: .4rem; }
.meal-block .item { padding: .4rem .5rem; gap: .4rem; }
.meal-block .item-main { min-width: 0; }
.meal-block .item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-block .check { flex: none; }
.meal-block .claim-btn { flex: none; font-size: .72rem; padding: .2rem .5rem; }
.meal-block .icon-btn { flex: none; }
.empty-meal { color: var(--subtle); font-size: .82rem; margin: 0; padding: .15rem .2rem; }
.meal-add { display: flex; gap: .35rem; margin-top: auto; }
.meal-add input[name=name] { flex: 1; padding: .4rem .55rem; font-size: .88rem; }
.meal-add .qty-input { width: 56px; padding: .4rem .4rem; font-size: .88rem; }
.icon-add { flex: none; width: 34px; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.icon-add:hover { background: var(--primary-deep); }

@media (max-width: 720px) {
  .meals-row { grid-template-columns: 1fr; gap: .75rem; }
}

/* ---------- pantry ---------- */
.pantry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.pantry-item { display: flex; flex-direction: column; gap: .5rem; }
.pantry-item.low { border-color: #fcd34d; background: #fffdf5; }
.pantry-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.low-toggle { font: inherit; font-size: .75rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; border: 1px solid var(--line); background: #f1f5f9; color: var(--subtle); cursor: pointer; white-space: nowrap; }
.low-toggle.on { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.low-text { color: #b45309; }
.pantry-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding-top: .25rem; border-top: 1px solid var(--line); }
.pantry-actions { display: flex; gap: .75rem; }
.pantry-group + .pantry-group { margin-top: 1.5rem; }
.lot-count { font-family: 'Inter', sans-serif; font-size: .8rem; font-weight: 600; color: var(--subtle); background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .05rem .5rem; vertical-align: middle; margin-left: .35rem; }
.cat-tag { font-size: .72rem; color: var(--ink-soft); background: #eef4f7; border-radius: 6px; padding: .05rem .4rem; margin-left: .35rem; vertical-align: middle; }

/* ---------- modal ---------- */
.modal { border: none; border-radius: var(--radius); padding: 1.5rem; width: min(460px, 92vw); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(12,39,51,.45); backdrop-filter: blur(2px); }
.modal h2 { margin-bottom: .5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }

/* ---------- admin ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat { text-align: center; padding: 1.1rem; }
.stat-num { font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 600; color: var(--primary-deep); line-height: 1; }
.stat-label { font-size: .82rem; color: var(--subtle); margin-top: .35rem; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.admin-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--subtle); font-weight: 600; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.admin-table th.num, .admin-table td.num { text-align: center; }
.admin-table td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table td:first-child { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.admin-table tr:last-child td { border-bottom: none; }
.role-pill { font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: #f1f5f9; color: var(--ink-soft); white-space: nowrap; }
.role-pill.admin { background: var(--primary-soft); color: var(--primary-deep); }
.row-actions { display: flex; gap: .9rem; white-space: nowrap; }

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- help page ---------- */
.help-page { max-width: 720px; margin: 0 auto; }
.help-hero { text-align: center; margin-bottom: 1.5rem; }
.help-hero h1 { font-size: 1.9rem; }
.help-step { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.help-num { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.1rem; }
.help-step h2 { font-size: 1.2rem; margin-bottom: .4rem; color: var(--primary-deep); }
.help-step p { margin: .4rem 0; }
.help-list { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .35rem; }
.help-list li { display: flex; align-items: center; gap: .5rem; }
.help-list .dot { width: 11px; height: 11px; }
.help-tip { background: var(--primary-soft); border-radius: 8px; padding: .5rem .75rem; font-size: .9rem; color: var(--primary-deep); }
.help-foot { text-align: center; margin-top: 1.5rem; padding: 1.5rem; display: grid; gap: .5rem; place-items: center; }

/* ---------- footer ---------- */
.site-footer { text-align: center; padding: 1.5rem; color: var(--subtle); font-size: .85rem; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .cal-layout { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 2.5rem 2rem; min-height: 42vh; }
  .auth-card { padding: 2rem; }
}
@media (max-width: 560px) {
  .nav a { padding: .4rem .55rem; font-size: .85rem; }
  .brand-name { display: none; }
  .me-name { display: none; }
  .cal-cell { border-radius: 8px; padding: 3px; }
  .cal-date { font-size: .72rem; }
  .dot { width: 7px; height: 7px; }
  .container { padding: 1rem .85rem 2.5rem; }
  .row { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}
