/* SMPW carts — styled per the SMPW Carts Design System (Claude Design handoff).
   Fresh minty-white + emerald palette, Nunito, friendly rounded geometry.
   Coverage semantics: green = covered/you · amber = gap/due · red = alone · blue = info. */

@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

:root {
  /* neutrals */
  --bg: #f2f6f3;
  --surface: #ffffff;
  --surface-sunk: #eef3ef;
  --text: #16201b;
  --muted: #5d6b63;
  --faint: #93a099;
  --border: #e0e8e2;
  --border-strong: #cdd8d0;

  /* primary green — covered / you / positive */
  --green: #0fa572;
  --green-bright: #16b97f;
  --green-press: #0c855c;
  --green-soft: #d7f4e7;
  --green-soft-bd: #9be4c4;
  --green-text: #0a6e4d;

  /* amber — gap / needs cover / due */
  --amber: #f5a623;
  --amber-soft: #fdeecf;
  --amber-soft-bd: #f6cd83;
  --amber-text: #8a560a;

  /* red — someone is alone (gentle, never alarming) */
  --red: #e5575b;
  --red-soft: #fce5e6;
  --red-soft-bd: #f3b6b8;
  --red-text: #b22d31;

  /* blue — info / selection */
  --blue: #2f6fe0;
  --blue-soft: #e4eefc;
  --blue-soft-bd: #aecbf5;
  --blue-text: #1d54b0;

  /* lilac — cart poster panel */
  --lilac-soft: #ecebfe;
  --lilac-text: #4b43a8;

  --font-sans: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(22, 32, 27, 0.05);
  --shadow-md: 0 2px 8px rgba(22, 32, 27, 0.07);
  --shadow-lg: 0 8px 24px rgba(22, 32, 27, 0.10);
  --shadow-pop: 0 12px 32px rgba(22, 32, 27, 0.16);
  --ring: 0 0 0 3px rgba(15, 165, 114, 0.30);

  /* back-compat aliases used across app.js markup */
  --accent: var(--green);
  --accent-soft: var(--green-soft);
  --accent-text: var(--green-text);
  --info: var(--blue-text);
  --info-soft: var(--blue-soft);
  --warn-soft: var(--amber-soft);
  --warn-text: var(--amber-text);
  --danger: var(--red-text);
  --danger-soft: var(--red-soft);
  --purple-soft: var(--lilac-soft);
  --purple-text: var(--lilac-text);
  --radius: var(--r-md);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  font-family: var(--font-sans);
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  min-height: 40px;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.97); }
button.primary { background: var(--green); border-color: var(--green); color: #fff; }
button.primary:hover { background: var(--green-bright); border-color: var(--green-bright); }
button.primary:active { background: var(--green-press); }
button.ghost { border-color: transparent; background: none; color: var(--muted); padding: 6px 10px; min-height: 0; font-weight: 600; }
button.danger { color: var(--red-text); border-color: var(--red-soft-bd); }

input, select, textarea {
  font: inherit;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--green);
}
label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-sunk);
  color: #4a544d;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px 11px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.me { background: var(--green-soft); color: var(--green-text); border-color: var(--green-soft-bd); font-weight: 700; }
.chip.need { background: var(--amber-soft); color: var(--amber-text); border-color: var(--amber-soft-bd); font-weight: 700; }
.chip .x { cursor: pointer; font-weight: 700; opacity: 0.6; margin-right: -2px; }
.chip .x:hover { opacity: 1; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  background: var(--surface-sunk);
  color: #5a645c;
}
.badge.open { background: var(--blue-soft); color: var(--blue-text); }
.badge.claimed { background: var(--surface-sunk); color: #5a645c; }
.badge.in-progress { background: var(--amber-soft); color: var(--amber-text); }
.badge.done { background: var(--green-soft); color: var(--green-text); font-weight: 700; }
.badge.high { background: var(--red-soft); color: var(--red-text); }
.badge.needs { background: var(--amber-soft); color: var(--amber-text); font-weight: 700; }

.muted { color: var(--muted); font-size: 13px; }
.faint { color: var(--faint); font-size: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.loading { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ----------------------------------------------- member app (mobile-first) */

.member-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 84px;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.app-header img { width: 30px; height: 30px; border-radius: var(--r-xs); object-fit: cover; }
.app-header h1 { margin: 0; font-size: 17px; font-weight: 800; flex: 1; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  background: var(--green-soft);
  color: var(--green-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: none;
  padding: 0;
  min-height: 0;
  flex: none;
}

.day-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 16px 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.day-strip::-webkit-scrollbar { display: none; }
.day-pill {
  flex: 0 0 48px;
  text-align: center;
  padding: 7px 0;
  border-radius: var(--r-sm);
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  min-height: 0;
}
.day-pill strong { display: block; font-size: 15px; color: var(--text); font-weight: 600; }
.day-pill.sel { background: var(--blue-soft); color: var(--blue-text); }
.day-pill.sel strong { color: var(--blue-text); font-weight: 700; }

.stack { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 16px; }

.slot-card .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.slot-card .win { font-weight: 700; font-size: 15px; white-space: nowrap; }
.slot-card.mine { background: var(--green-soft); border-color: var(--green-soft-bd); }
.slot-card.mine .win { color: var(--green-text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.join-btn {
  width: 100%;
  margin-top: 10px;
  font-weight: 700;
  font-size: 14px;
  min-height: 44px;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.join-btn:hover { background: var(--green-bright); border-color: var(--green-bright); }

.task-card .title { font-weight: 700; font-size: 15px; margin: 0 0 2px; }
.task-card .meta { margin: 0 0 8px; font-size: 14px; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.task-actions button { font-size: 13px; padding: 7px 13px; min-height: 34px; }

.section-h {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 16px 16px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  z-index: 20;
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: none;
  border-radius: 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  min-height: 0;
}
.bottom-nav button:active { transform: none; }
.bottom-nav button .ico { display: block; font-size: 20px; margin-bottom: 2px; }
.bottom-nav button.sel { color: var(--green); font-weight: 700; }

/* schedule view toggle + week/month views */
.seg {
  display: flex;
  gap: 3px;
  margin: 2px 16px 12px;
  background: var(--surface-sunk);
  padding: 3px;
  border-radius: var(--r-sm);
}
.seg button {
  flex: 1;
  border: none;
  background: none;
  border-radius: var(--r-xs);
  padding: 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  min-height: 0;
}
.seg button.sel { background: var(--surface); color: var(--text); font-weight: 700; box-shadow: var(--shadow-sm); }

.view-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 16px 10px;
}
.view-nav strong { flex: 1; text-align: center; font-size: 14px; font-weight: 700; }
.view-nav button { font-size: 13px; }

.wk-day {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  border: none;
  background: none;
  padding: 0;
  text-align: left;
  gap: 8px;
  min-height: 0;
}
.wk-day:active { transform: none; }
.wk-day strong { font-size: 14px; font-weight: 700; }
.wk-line { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.wk-when { flex: 0 0 86px; font-size: 12px; color: var(--faint); padding-top: 3px; }
.today-card { border-color: var(--blue-soft-bd); }

.month-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 16px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--faint);
  text-align: center;
}
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 0 16px;
}
.month-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  min-height: 54px;
  padding: 4px 5px;
  cursor: pointer;
}
.month-cell .d { font-size: 11px; color: var(--muted); }
.month-cell.other { opacity: 0.4; }
.month-cell.today { border: 2px solid var(--blue); padding: 3px 4px; }
.month-cell.today .d { color: var(--blue); font-weight: 700; }
.mc {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--r-xs);
  padding: 0 6px;
  margin: 2px 2px 0 0;
}
.mc-people { background: var(--green-soft); color: var(--green-text); }
.mc-short { background: var(--red-soft); color: var(--red-text); }
.mc-task { background: var(--amber-soft); color: var(--amber-text); }

/* sign-in */
.picker {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 28px;
  text-align: center;
  background: var(--surface);
}
.picker img.logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  object-fit: cover;
  margin: 0 auto 18px;
  box-shadow: var(--shadow-md);
}
.picker h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; }
.picker .sub { margin: 0 0 26px; color: var(--muted); font-size: 15px; }
.picker label { text-align: left; margin-bottom: 6px; }
.picker select { font-size: 16px; padding: 13px 14px; border-radius: var(--r-md); margin-bottom: 18px; }
.picker .go { width: 100%; font-size: 16px; padding: 14px 18px; min-height: 52px; }
.picker .note { margin: 20px 0 0; font-size: 12px; color: var(--faint); }

/* cart diagram */
.carts { display: flex; gap: 12px; flex-wrap: wrap; }
.cart-wrap { flex: 1 1 160px; min-width: 160px; }
.cart {
  border: 2px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
}
.cart-label { text-align: center; font-size: 13px; font-weight: 700; margin: 0 0 6px; }
.cart .poster {
  background: var(--lilac-soft);
  color: var(--lilac-text);
  border-radius: var(--r-xs);
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 6px;
}
.cart .poster small { font-weight: 400; opacity: 0.7; font-size: 11px; }
.cart .row { display: flex; gap: 6px; }
.cart .pub {
  flex: 1;
  background: var(--surface-sunk);
  color: #4a544d;
  border-radius: var(--r-xs);
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px;
}
.cart input { font-size: 12px; padding: 6px; text-align: center; border-radius: var(--r-xs); }
.cart .poster input { background: rgba(255, 255, 255, 0.7); margin-top: 4px; }

/* --------------------------------------------------------- admin (desktop) */

.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; }
.brand b { font-size: 16px; font-weight: 800; display: block; }
.brand span { display: block; font-size: 11px; color: var(--faint); font-weight: 600; }
.navitem {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  text-align: left;
  margin-bottom: 2px;
  min-height: 0;
}
.navitem.sel { background: var(--green-soft); color: var(--green-text); font-weight: 700; }
.navitem .ic { font-size: 17px; width: 20px; text-align: center; }
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
  font-size: 13px;
}
.side-user b { font-weight: 700; display: block; }
.side-user span { display: block; color: var(--faint); font-size: 12px; }

.admin-main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; flex: 1; }
.admin-content { padding: 24px 28px 40px; max-width: 1100px; }

@media (max-width: 820px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px; padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; }
  .navitem { width: auto; }
  .side-user { display: none; }
  .admin-content { padding: 16px; }
}

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.metric .n { font-size: 26px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.metric.alert .n { color: var(--amber-text); }
.metric .l { font-size: 13px; color: var(--muted); margin-top: 2px; }

.panel { margin-top: 18px; }
.panel h2 { font-size: 15px; font-weight: 700; margin: 0 0 10px; }

.grid-wrap { overflow-x: auto; }
.sched-grid {
  display: grid;
  grid-template-columns: 96px repeat(7, minmax(110px, 1fr));
  gap: 5px;
  min-width: 880px;
}
.sched-grid .h {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 7px 0;
  background: var(--surface-sunk);
  border-radius: var(--r-xs);
}
.sched-grid .h strong { display: block; font-size: 15px; font-weight: 700; color: var(--text); }
.sched-grid .h.today { background: var(--blue-soft); color: var(--blue-text); }
.sched-grid .h.today strong { color: var(--blue-text); }
.sched-grid .w {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-sunk);
  border-radius: var(--r-xs);
  padding: 8px 8px 0;
}
.sched-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  min-height: 64px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sched-cell.cov { background: var(--green-soft); border-color: var(--green-soft-bd); }
.sched-cell.alone { background: var(--red-soft); border-color: var(--red-soft-bd); }
.sched-cell.some { background: var(--amber-soft); border-color: var(--amber-soft-bd); }
.sched-cell select {
  font-size: 12px;
  padding: 3px 4px;
  border: 1px dashed var(--border-strong);
  color: var(--faint);
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--r-xs);
}
.gridname {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #4a544d;
  background: rgba(255, 255, 255, 0.65);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  white-space: nowrap;
}
.gridname.me { color: var(--green-text); font-weight: 700; }
.gridname .x { cursor: pointer; opacity: 0.6; font-weight: 700; }
.gridname .x:hover { opacity: 1; }
.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 4px;
  margin-right: 5px;
  vertical-align: -1px;
}

.row-line {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.row-line:last-child { border-bottom: none; }
.row-line .grow { flex: 1 1 200px; min-width: 160px; }
.row-line select, .row-line input { width: auto; font-size: 14px; padding: 7px 10px; }

.form-grid { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.form-grid > div { flex: 1 1 140px; }
.form-grid > div.wide { flex: 2 1 240px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

.stat-cell { flex: 0 0 110px; font-size: 14px; color: var(--muted); }

.locked {
  max-width: 380px;
  margin: 80px auto;
  text-align: center;
}
.locked .card { padding: 28px 24px; box-shadow: var(--shadow-md); }
.locked img.logo {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  object-fit: cover;
  margin: 0 auto 14px;
  box-shadow: var(--shadow-md);
}
.locked h1 { font-size: 19px; font-weight: 800; margin: 0 0 4px; }
