:root {
  --green: oklch(0.32 0.07 152);
  --green-dark: oklch(0.24 0.06 152);
  --orange: oklch(0.68 0.16 48);
  --ink: oklch(0.22 0.02 150);
  --muted: oklch(0.5 0.02 120);
  --bg: oklch(0.93 0.01 85);
  --surface: oklch(0.97 0.012 85);
  --border: oklch(0.89 0.01 85);
  --border-soft: oklch(0.91 0.01 85);
  --border-faint: oklch(0.94 0.01 85);
  --green-tint-bg: oklch(0.94 0.025 152);
  --orange-tint-bg: oklch(0.94 0.06 55);
  --red: oklch(0.55 0.19 25);
  --red-tint-bg: oklch(0.94 0.06 25);
  --success: oklch(0.5 0.14 145);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  height: 100%;
}

body {
  font-family: 'PT Sans', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

input, textarea, button { font-family: inherit; }
input, textarea { outline: none; }
input:focus, textarea:focus { border-color: var(--green) !important; }
::placeholder { color: oklch(0.6 0.02 120); }
button { border: none; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

/* ---------- Login / Troop Select ---------- */

.auth-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: #ffffff;
}

.auth-header {
  background: var(--green);
  padding: 56px 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.auth-badge {
  width: 84px;
  height: 84px;
}

.auth-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 25px;
  color: #fff;
  margin-top: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.8);
}

.auth-body {
  flex: 1;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--ink); }

.input, textarea.input {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-size: 16px;
  font-family: 'PT Sans', sans-serif;
  color: var(--ink);
  width: 100%;
  background: #fff;
}

textarea.input { resize: none; font-size: 14px; }

.btn {
  padding: 16px;
  border-radius: 14px;
  text-align: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}

.btn-primary { background: var(--orange); color: #fff; }
.btn-primary[disabled], .btn-primary.disabled { opacity: 0.45; pointer-events: none; }
.btn-solid-green { background: var(--green); color: #fff; }
.btn-outline-green { background: #fff; border: 1.5px solid var(--green); color: var(--green); }
.btn-outline-red { background: #fff; border: 1.5px solid var(--red); color: var(--red); }
.btn-small { padding: 12px; border-radius: 12px; font-size: 14px; }

.error-banner {
  background: var(--red-tint-bg);
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 10px;
}

.link-center {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
  cursor: pointer;
}

.help-text {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------- Troop select ---------- */

.troop-select-screen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--surface); }
.troop-select-header { background: var(--green); padding: 52px 24px 22px; }
.troop-select-header .title { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 21px; color: #fff; }
.troop-select-header .subtitle { font-size: 13px; color: rgba(255,255,255,0.75); margin-top: 4px; }
.troop-list { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }

.troop-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.troop-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--green-tint-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--green);
  flex-shrink: 0;
}

.troop-info { flex: 1; }
.troop-name { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); }
.troop-loc { font-size: 13px; color: var(--muted); margin-top: 2px; }

.empty-state { text-align: center; color: var(--muted); font-size: 14px; padding: 40px 20px; }

/* ---------- Main app shell ---------- */

.main-screen { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--surface); }

.app-header {
  background: var(--green);
  padding: 46px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-header-row { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.app-header-title {
  flex: 1;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 21px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}

.app-header-subtitle { font-size: 12.5px; color: rgba(255,255,255,0.75); margin-left: 44px; }

.app-content { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }

/* Cards */

.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.shift-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: left; width: 100%; }
.shift-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.shift-name { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); }
.shift-meta { font-size: 13px; color: var(--muted); }

.badge { padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; flex-shrink: 0; }
.badge-progress { background: var(--green); color: #fff; }
.badge-scheduled { background: var(--border); color: var(--muted); }
.badge-completed { background: oklch(0.9 0.03 250); color: oklch(0.4 0.1 250); }
.badge-reconciled { background: oklch(0.9 0.05 300); color: oklch(0.4 0.12 300); }

/* Products */

.search-input { padding: 12px 16px; border-radius: 12px; border: 1.5px solid var(--border); background: #fff; font-size: 15px; width: 100%; }

.product-card { display: flex; flex-direction: column; gap: 10px; }
.product-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.product-name { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); }
.product-sku { font-size: 12px; color: var(--muted); margin-top: 2px; }
.category-pill { padding: 4px 10px; border-radius: 999px; background: var(--green-tint-bg); color: var(--green); font-size: 11.5px; font-weight: 700; flex-shrink: 0; white-space: nowrap; }
.price-row { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: 10px; padding: 10px 14px; }
.price-main { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 19px; color: var(--green); }
.price-sub { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.4; }

/* Earnings */

.balance-card { background: var(--green); border-radius: 18px; padding: 22px; }
.balance-label { font-size: 13px; color: rgba(255,255,255,0.8); font-weight: 700; }
.balance-value { font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 36px; color: #fff; margin-top: 6px; }
.balance-name { font-size: 13px; color: rgba(255,255,255,0.75); margin-top: 4px; }

.section-title { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); margin-bottom: 10px; }

.tx-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-faint); }
.tx-row:last-child { border-bottom: none; }
.tx-date { width: 44px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.tx-desc { flex: 1; font-size: 14px; color: var(--ink); }
.tx-amount { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.tx-credit { color: var(--success); }
.tx-debit { color: var(--red); }

.about-text { font-size: 13px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

/* Segmented control */

.segment { display: flex; background: #fff; border-radius: 12px; padding: 4px; gap: 4px; }
.segment.on-surface { background: #fff; }
.segment-btn { flex: 1; text-align: center; padding: 10px; border-radius: 9px; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 13px; cursor: pointer; color: var(--ink); }
.segment-btn.active { background: var(--green); color: #fff; }

/* Goals */

.goal-card { display: flex; flex-direction: column; gap: 10px; }
.goal-top { display: flex; align-items: center; gap: 10px; }
.goal-name { flex: 1; font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 16px; color: var(--ink); }
.goal-target { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 14px; color: var(--green); flex-shrink: 0; }
.progress-track { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.progress-fill { height: 8px; border-radius: 999px; background: var(--orange); }
.goal-bottom-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.goal-pct { font-weight: 700; color: var(--orange); }
.goal-message { font-size: 12.5px; font-style: italic; color: var(--green); }
.goal-achieved-badge { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 12px; color: oklch(0.55 0.15 75); }

/* Shift detail */

.stat-row { display: flex; gap: 10px; }
.stat-tile { flex: 1; border-radius: 12px; padding: 12px; text-align: center; }
.stat-tile.green { background: var(--green-tint-bg); }
.stat-tile.orange { background: var(--orange-tint-bg); }
.stat-value { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 18px; }
.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }
.stat-label { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.detail-line { font-size: 13px; color: var(--muted); }
.detail-line span { color: var(--ink); }

/* Record sale grid */

.sale-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sale-tile {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  border: 1.5px solid var(--border-soft);
  text-align: left;
  width: 100%;
}
.sale-tile-name { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 14px; color: var(--ink); }
.sale-tile-price { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 15px; color: var(--green); }
.qty-bubble { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 999px; background: var(--orange); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }

.cart-box { background: #fff; border-radius: 14px; padding: 6px 14px; }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-faint); }
.cart-line:last-child { border-bottom: none; }
.cart-line-name { flex: 1; font-size: 14px; color: var(--ink); }
.qty-btn { width: 26px; height: 26px; border-radius: 999px; background: var(--border-faint); display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 700; }
.qty-value { width: 18px; text-align: center; font-size: 14px; font-weight: 700; }
.line-total { width: 56px; text-align: right; font-weight: 700; font-size: 13px; color: var(--ink); }
.remove-btn { color: var(--red); font-size: 13px; cursor: pointer; padding-left: 4px; }

.footer-bar { padding: 14px 20px; background: #fff; border-top: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.footer-bar .btn { flex: 1; max-width: 210px; }
.footer-bar.single .btn { max-width: none; width: 100%; }
.footer-total-label { font-size: 11.5px; color: var(--muted); }
.footer-total-value { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 19px; color: var(--ink); }

/* Confirm screen */

.confirm-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.confirm-circle { width: 80px; height: 80px; border-radius: 999px; background: var(--success); display: flex; align-items: center; justify-content: center; }
.confirm-title { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 20px; color: var(--ink); }
.confirm-amount { font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 32px; color: var(--green); }
.confirm-actions { display: flex; gap: 10px; width: 100%; max-width: 280px; }
.confirm-actions .btn { flex: 1; padding: 15px; font-size: 14px; }

/* Donation quick amounts */

.quick-amounts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.quick-amt {
  text-align: center;
  padding: 12px 4px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.quick-amt.selected { background: var(--orange); color: #fff; border-color: var(--orange); }

.amount-input {
  padding: 16px;
  border-radius: 12px;
  border: 2px solid var(--green);
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  font-family: 'Poppins', sans-serif;
  color: var(--green);
  width: 100%;
}

/* Profile */

.profile-top { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 8px; }
.profile-avatar { width: 76px; height: 76px; border-radius: 999px; background: var(--green); display: flex; align-items: center; justify-content: center; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 24px; color: #fff; }
.profile-name { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); }
.profile-email { font-size: 13px; color: var(--muted); }
.role-pill { padding: 5px 12px; border-radius: 999px; background: var(--green-tint-bg); color: var(--green); font-size: 12px; font-weight: 700; }

.list-card { background: #fff; border-radius: 16px; overflow: hidden; margin-top: 8px; }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid var(--border-faint); font-size: 14px; color: var(--ink); }
.list-row:last-child { border-bottom: none; }

/* Tab bar */

.tab-bar { display: flex; background: var(--green-dark); padding: 10px 8px calc(20px + env(safe-area-inset-bottom, 0px)); justify-content: space-around; align-items: center; }
.tab-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; width: 25%; }
.tab-btn-label { font-size: 10.5px; font-weight: 700; }

/* Loading / misc */

.spinner-wrap { display: flex; justify-content: center; padding: 40px 0; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1000;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }

/* Participants (check-in/out) */

.participant-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border-faint); }
.participant-row:last-child { border-bottom: none; }
.participant-name { font-family: 'Poppins', sans-serif; font-weight: 600; font-size: 15px; color: var(--ink); }
.participant-status { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.participant-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Begin/Close Shift per-product counts */

.count-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border-radius: 12px; padding: 12px 14px; }
.count-row-name { font-size: 14px; color: var(--ink); flex: 1; }
.count-input { width: 76px; padding: 10px; border-radius: 10px; border: 1.5px solid var(--border); font-size: 15px; text-align: center; font-family: 'PT Sans', sans-serif; }

@media (min-width: 500px) {
  body { background: linear-gradient(180deg, oklch(0.9 0.02 85), oklch(0.95 0.01 85)); }
  #app { min-height: 92vh; margin: 4vh auto; border-radius: 28px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.18); }
}
