/* LWMissions.org — base stylesheet
 * Tailwind via CDN handles utilities. This sheet provides the design tokens,
 * component primitives, and overrides that should not be inlined as classes.
 */

:root {
  --primary: #1e40af;            /* overridden inline from org_settings */
  --primary-700: #1e3a8a;
  --primary-50: #eff6ff;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, .1), 0 4px 6px -2px rgba(15, 23, 42, .05);
  --sidebar-width: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- App shell ------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  flex-shrink: 0;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: nowrap;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.topbar > * { min-width: 0; }
.content { padding: 24px; flex: 1; }
.footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  font-size: .85rem; color: var(--text-muted);
  background: var(--surface);
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(-100%); transition: transform .2s ease;
    z-index: 50; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 49; display: none;
  }
  .sidebar-backdrop.active { display: block; }
}

/* --- Sidebar nav ----------------------------------------------------------- */
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 18px; border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sidebar .brand img, .sidebar .brand .brand-mark {
  width: 36px; height: 36px; border-radius: 8px; object-fit: cover;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
}
.sidebar .brand-name {
  font-weight: 700; font-size: .98rem; color: var(--text);
}
.sidebar .brand-tag {
  font-size: .75rem; color: var(--text-muted); display: block;
}
.nav-section {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-soft); padding: 14px 12px 6px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  color: var(--text); font-size: .92rem; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active {
  background: var(--primary-50); color: var(--primary); font-weight: 600;
}
.nav-link i { width: 18px; height: 18px; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 10px 0; }

/* --- Topbar / user menu ---------------------------------------------------- */
.user-menu { position: relative; }
.user-menu-btn {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; font-size: .9rem; color: var(--text);
}
.user-menu-btn:hover { background: var(--surface-2); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #e2e8f0; color: #475569;
  font-weight: 600; font-size: .8rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar.avatar-primary { background: var(--primary); color: #fff; }
.user-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px;
  display: none; z-index: 60;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 6px; color: var(--text); font-size: .9rem;
}
.user-menu-dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-dropdown a i { width: 16px; height: 16px; }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

.hamburger {
  display: none; background: transparent; border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; cursor: pointer;
}
@media (max-width: 900px) { .hamburger { display: inline-flex; } }

/* --- Cards / stats --------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px;
}
.stat-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600;
}
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; color: var(--text); }
.stat-meta  { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; font-size: .9rem; font-weight: 600;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn i { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-700); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 12px; font-size: .82rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }

/* --- Forms ----------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .85rem; font-weight: 600; color: var(--text);
  margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  display: block; width: 100%;
  padding: 9px 12px; font-size: .92rem;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: #fff; color: var(--text);
  font-family: inherit;
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 64, 175, .15);
}
.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; }

/* --- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); }
table.data {
  width: 100%; border-collapse: collapse; font-size: .9rem;
}
table.data th, table.data td {
  padding: 12px 14px; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
table.data thead th {
  background: var(--surface-2); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted);
  font-weight: 600;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.highlight { background: var(--primary-50); }

/* --- Badges / status ------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; font-size: .72rem; font-weight: 600;
  border-radius: 999px; text-transform: capitalize;
}
.badge-success { background: var(--success-bg); color: #166534; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-info    { background: var(--info-bg);    color: #1e40af; }
.badge-neutral { background: var(--surface-2);  color: var(--text-muted); }

/* --- Alerts / flash -------------------------------------------------------- */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  border: 1px solid transparent; margin-bottom: 12px;
  display: flex; gap: 10px; align-items: flex-start; font-size: .9rem;
}
.alert i { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.alert-error   { background: var(--danger-bg);  color: #991b1b; border-color: #fecaca; }
.alert-info    { background: var(--info-bg);    color: #1e40af; border-color: #bfdbfe; }

/* --- Progress bar ---------------------------------------------------------- */
.progress {
  background: var(--surface-2); border-radius: 999px; overflow: hidden;
  height: 8px; width: 100%;
}
.progress-bar {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width .3s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }

/* --- Layout helpers -------------------------------------------------------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }
.section { margin-bottom: 28px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* --- Empty state ----------------------------------------------------------- */
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty i { width: 48px; height: 48px; margin: 0 auto 12px; display: block; opacity: .6; }
.empty h3 { color: var(--text); font-size: 1.05rem; margin: 0 0 6px; }

/* --- Trip tiles ------------------------------------------------------------ */
.tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.trip-tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s ease, transform .2s ease;
}
.trip-tile:hover {
  box-shadow: var(--shadow-lg); transform: translateY(-2px);
}
.trip-tile .cover {
  /* v1.23.1: bumped from 140px → 240px so square/logo-style covers
     like a circular church seal show the full art instead of just
     the middle band. Aspect ratio also added so on narrow tiles
     the image scales rather than getting cropped to a thin strip. */
  height: 240px; min-height: 200px; max-height: 320px;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  background-size: cover; background-position: center;
  position: relative; overflow: hidden;
}
@media (max-width: 600px) {
  .trip-tile .cover { height: 220px; min-height: 180px; aspect-ratio: auto; }
}
.trip-tile .cover > img {
  /* v1.24.1: object-fit was 'cover', which crops square/logo art
     (e.g. circular Garden Mission seal) to fit a 4:3 wrapper. Switch
     to 'contain' so the full image is always visible — the gradient
     background fills any letterboxing. */
  width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  display: block;
}
.trip-tile .cover .year-badge {
  position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.5);
  color: #fff; padding: 4px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.trip-tile .body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.trip-tile h3 { margin: 0 0 4px; font-size: 1.05rem; }
.trip-tile .meta { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; }
.trip-tile .progress-wrap { margin-top: auto; }

/* --- Auth pages ------------------------------------------------------------ */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--bg);
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow);
}
.auth-card .brand {
  text-align: center; margin-bottom: 24px;
}
.auth-card .brand img { max-height: 48px; }
.auth-card .brand-mark {
  width: 56px; height: 56px; border-radius: 12px; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700;
}
.auth-card h1 { font-size: 1.3rem; margin: 16px 0 4px; text-align: center; }
.auth-card .subtitle { color: var(--text-muted); font-size: .9rem; text-align: center; margin-bottom: 24px; }
.auth-card .full-btn { width: 100%; justify-content: center; }
.auth-links { margin-top: 16px; text-align: center; font-size: .85rem; color: var(--text-muted); }

/* --- Toast notifications (JS-driven) -------------------------------------- */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow-lg); min-width: 240px; max-width: 360px;
  font-size: .9rem;
  animation: slideIn .25s ease;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Modal ----------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 28px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--text-muted); margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* --- Announcements bar ----------------------------------------------------- */
.announcement-bar {
  background: var(--info-bg); border-bottom: 1px solid #bfdbfe;
  padding: 10px 24px; display: flex; align-items: center; gap: 12px;
  font-size: .88rem;
}
.announcement-bar.urgent  { background: var(--danger-bg); border-color: #fecaca; color: #991b1b; }
.announcement-bar.high    { background: var(--warning-bg); border-color: #fde68a; color: #92400e; }
.announcement-bar .title  { font-weight: 600; }
.announcement-bar .dismiss { margin-left: auto; cursor: pointer; background: transparent; border: 0; color: inherit; }

/* --- Utility classes ------------------------------------------------------- */
.text-muted { color: var(--text-muted); }
.text-soft  { color: var(--text-soft); }
.text-sm    { font-size: .85rem; }
.text-xs    { font-size: .75rem; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.w-full { width: 100%; }
.hidden { display: none; }

/* --- Personal status card (dashboard hero) -------------------------------- */
.status-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--primary-50) 100%);
  border: 1px solid var(--border);
}
.status-card-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.status-avatar {
  width: 64px; height: 64px; flex-shrink: 0;
  border-radius: 50%; overflow: hidden; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.5rem; font-weight: 700;
}
.status-avatar img { width: 100%; height: 100%; object-fit: cover; }
.status-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.status-item {
  background: var(--surface); border-radius: var(--radius);
  padding: 12px 14px; border: 1px solid var(--border);
}
.status-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600;
}
.status-value {
  font-size: 1.1rem; font-weight: 700; margin-top: 4px;
  display: flex; align-items: center; gap: 6px;
}
.status-value i { width: 18px; height: 18px; }
.status-value.ok      { color: var(--success); }
.status-value.warn    { color: var(--warning); }
.status-value.bad     { color: var(--danger); }
.status-value.pending { color: #ca8a04; }
.status-meta {
  font-size: .82rem; color: var(--text-muted); margin-top: 4px;
}

/* --- Quick-link cards (profile/passport entry points) -------------------- */
.quick-links { display: grid; gap: 12px;
               grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.quick-link-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.quick-link-card:hover {
  text-decoration: none; border-color: var(--primary);
  box-shadow: var(--shadow); transform: translateY(-1px);
}

/* --- Topbar: name → chevron → avatar → message icon (all flush) -------- */
.topbar-account {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  flex-wrap: nowrap !important;
  gap: 0;
  flex-shrink: 0;
}
.topbar-account > * { flex-shrink: 0; }
.topbar-account .user-menu { display: inline-flex; }

/* User-menu button: name first, chevron, then avatar at the right edge */
.topbar-account .user-menu-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 0; padding: 4px;
  cursor: pointer; color: var(--text);
  border-radius: 999px 0 0 999px;
  transition: background .15s ease;
}
.topbar-account .user-menu-btn:hover { background: var(--surface-2); }
.topbar-account .user-menu-btn .avatar {
  width: 38px; height: 38px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.topbar-account .user-menu-name {
  display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1.1; padding-left: 6px;
}

/* Message icon: immediately to the right of the avatar, same diameter,
   matching ring so the two read as paired circles */
.topbar-msg {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.topbar-msg:hover {
  background: var(--primary-50); color: var(--primary);
  border-color: var(--primary); text-decoration: none;
}
.topbar-msg i { width: 18px; height: 18px; }
.topbar-msg-badge {
  position: absolute; top: -3px; right: -3px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 1px 5px; min-width: 18px; height: 18px;
  border-radius: 999px; line-height: 16px; text-align: center;
  border: 2px solid var(--bg);
}

@media (max-width: 640px) {
  .topbar-account .user-menu-name { display: none; }
  .topbar-account .user-menu-btn  { padding: 2px; gap: 4px; }
  .topbar-account .user-menu-btn i[data-lucide="chevron-down"] { display: none; }
  .topbar-msg { margin-left: 6px; }
}

/* --- Mobile-friendly user-menu (hide name on small screens) ------------- */
.user-menu-name {
  display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1;
}
@media (max-width: 640px) {
  .user-menu-name { display: none; }
}

/* --- Mobile responsive overhaul ------------------------------------------ */
@media (max-width: 768px) {
  body { font-size: 14px; }
  .content { padding: 16px 12px; }
  .topbar  { padding: 10px 12px; }
  .footer  { padding: 12px 16px; font-size: .8rem; }

  .page-title { font-size: 1.3rem; }
  .page-header { gap: 8px; align-items: flex-start; }

  .card { padding: 14px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.35rem; }

  .btn      { padding: 9px 14px; }
  .btn-lg   { padding: 12px 18px; font-size: .95rem; }
  .btn-sm   { padding: 6px 10px; font-size: .78rem; }

  /* Tables: force horizontal scroll so they don't squash */
  .table-wrap { -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
  table.data { min-width: 540px; }
  table.data th, table.data td { padding: 10px 12px; font-size: .85rem; }

  /* Form rows always stack on phones */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 8px; }
  .form-input, .form-select, .form-textarea {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }

  /* Page header stacks on mobile */
  .page-header {
    flex-direction: column; align-items: stretch;
  }
  .page-header > div:last-child { width: 100%; }
  .page-header > div:last-child .btn { flex: 1; justify-content: center; }

  /* Status card: avatar + name on first row, items below */
  .status-card-head h2 { font-size: 1rem; }
  .status-avatar { width: 52px; height: 52px; font-size: 1.1rem; }

  /* Trip tile heading shrinks slightly */
  .trip-tile h3 { font-size: 1rem; }

  /* Login / register card padding */
  .auth-card { padding: 22px 18px; }

  /* Modal full width with margin */
  .modal { padding: 22px 18px; max-width: calc(100vw - 24px); }

  /* Sidebar (mobile-drawer) — header brand condensed */
  .sidebar { padding: 16px 12px; width: 80vw; max-width: 280px; }
  .sidebar .brand-tag { display: none; }
}

@media (max-width: 480px) {
  /* Stack stat cards 1-column on very small screens */
  .stat-grid { grid-template-columns: 1fr; }
  .tile-grid { grid-template-columns: 1fr; }

  /* Topbar shows only hamburger + avatar */
  .topbar > div:nth-child(2) { display: none; }

  /* Smaller alerts */
  .alert { padding: 10px 12px; font-size: .85rem; }

  .quick-links { grid-template-columns: 1fr; }
  .status-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Photo gallery --------------------------------------------------------- */
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.photo-tile {
  position: relative; aspect-ratio: 1; overflow: hidden;
  border-radius: var(--radius); background: var(--surface-2);
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.photo-tile:hover img { transform: scale(1.05); }
.photo-tile .delete-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,.6); color: #fff; border: 0;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.photo-tile:hover .delete-btn { display: flex; }

/* ============================================================
   Help drawer (v1.4.0)
   ============================================================ */

.topbar-help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff; color: var(--text, #1f2937);
  cursor: pointer; text-decoration: none;
  margin-right: 6px;
  transition: background .15s, transform .15s;
}
.topbar-help:hover { background: var(--surface-2, #f3f4f6); transform: translateY(-1px); }
.topbar-help svg { width: 18px; height: 18px; }

.help-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
  z-index: 998;
}
.help-backdrop.is-open { opacity: 1; pointer-events: auto; }

.help-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 100vw;
  background: #fff;
  box-shadow: -8px 0 30px rgba(15,23,42,.18);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 999;
  display: flex; flex-direction: column;
}
.help-drawer.is-open { transform: translateX(0); }
@media (max-width: 600px) {
  .help-drawer { width: 100vw; box-shadow: none; }
}

.help-drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--primary, #1e40af); color: #fff;
}
.help-drawer-head .text-muted { color: rgba(255,255,255,.85); }
.help-close {
  background: rgba(255,255,255,.18); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.help-close:hover { background: rgba(255,255,255,.28); }
.help-close svg { width: 18px; height: 18px; }

.help-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border, #e5e7eb);
  background: #fafafa;
}
.help-tab {
  flex: 1; padding: 12px 8px; background: transparent; border: 0;
  border-bottom: 3px solid transparent;
  font-weight: 600; color: var(--text-muted, #6b7280);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; font-size: .92rem;
}
.help-tab svg { width: 16px; height: 16px; }
.help-tab.is-active {
  color: var(--primary, #1e40af);
  border-bottom-color: var(--primary, #1e40af);
  background: #fff;
}
.help-tab-count {
  background: var(--primary, #1e40af); color: #fff;
  border-radius: 999px; padding: 1px 8px; font-size: .72rem; font-weight: 700;
}
.help-tab.is-active .help-tab-count { background: #fff; color: var(--primary, #1e40af); }

.help-pane { display: none; flex: 1; overflow: auto; padding: 16px; }
.help-pane.is-active { display: block; }

/* AI pane: declare flex-column layout on the BASE selector (not just
   .is-active) so the layout is computed correctly the moment it becomes
   visible. v1.23.1 fix: previously the AI pane swapped from display:none
   directly to display:flex on tab switch, and on mobile some browsers
   didn't reflow the inner .help-chat-form to sit at the bottom — the
   message box would scroll off-screen below the viewport. Setting the
   flex props always (just toggling visibility via :not(.is-active)) makes
   the layout deterministic. The min-height:0 lets the inner scrollable
   .help-chat shrink properly inside its flex parent on iOS Safari. */
.help-pane[data-help-pane="ai"] {
  display: flex; flex-direction: column; padding: 0;
  overflow: hidden;
  min-height: 0;
}
.help-pane[data-help-pane="ai"]:not(.is-active) { display: none; }
.help-pane[data-help-pane="ai"] .help-chat { min-height: 0; }

.help-progress {
  background: var(--surface-2, #f3f4f6);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 14px;
}
.help-progress-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem; color: var(--text-muted, #6b7280); margin-bottom: 6px;
}
.help-progress-label strong { color: var(--primary, #1e40af); }
.help-progress-bar {
  height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden;
}
.help-progress-fill {
  height: 100%; background: var(--primary, #1e40af);
  transition: width .4s ease;
}

.help-section-title {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted, #6b7280); margin: 6px 0 8px;
  font-weight: 700;
}
.help-list { list-style: none; padding: 0; margin: 0 0 12px; }
.help-item { margin-bottom: 6px; }
.help-item-link {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: inherit;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  transition: background .12s, border-color .12s;
}
.help-item-link:hover {
  background: var(--surface-2, #f3f4f6);
  border-color: var(--primary, #1e40af);
}
.help-item.is-urgent .help-item-link {
  border-left: 4px solid var(--warning, #f59e0b);
  background: #fffbeb;
}
.help-item.is-complete .help-item-link {
  background: #f0fdf4; border-color: #d1fae5; opacity: .8;
}
.help-item-icon {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-50, #eff6ff); color: var(--primary, #1e40af);
}
.help-item.is-complete .help-item-icon {
  background: #d1fae5; color: #166534;
}
.help-item-icon svg { width: 16px; height: 16px; }
.help-item-body { flex: 1; min-width: 0; }
.help-item-title { display: block; font-weight: 600; font-size: .92rem; }
.help-item-hint  { display: block; color: var(--text-muted, #6b7280); font-size: .82rem; margin-top: 2px; }
.help-item-chevron {
  width: 16px; height: 16px; color: var(--text-muted, #6b7280); flex-shrink: 0; align-self: center;
}

.help-done {
  margin-top: 8px; border-top: 1px solid var(--border, #e5e7eb); padding-top: 10px;
}
.help-done summary {
  cursor: pointer; font-weight: 600; color: var(--text-muted, #6b7280);
  font-size: .85rem; padding: 4px 0;
}

/* ---------- AI chat ---------- */
.help-chat {
  flex: 1; overflow-y: auto; padding: 16px; background: var(--surface-2, #f3f4f6);
}
.help-chat-msg {
  display: flex; margin-bottom: 10px;
}
.help-chat-msg.is-bot  { justify-content: flex-start; }
.help-chat-msg.is-user { justify-content: flex-end; }
.help-chat-bubble {
  max-width: 86%;
  padding: 10px 14px; border-radius: 14px;
  font-size: .92rem; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.help-chat-msg.is-bot .help-chat-bubble {
  background: #fff; color: var(--text, #1f2937);
  border: 1px solid var(--border, #e5e7eb);
  border-bottom-left-radius: 4px;
}
.help-chat-msg.is-user .help-chat-bubble {
  background: var(--primary, #1e40af); color: #fff;
  border-bottom-right-radius: 4px;
}
.help-chat-bubble a { color: inherit; text-decoration: underline; }
.help-chat-msg.is-user .help-chat-bubble a { color: #fff; }
.help-chat-bubble code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px;
  font-size: .85em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.help-typing { display: inline-flex; gap: 4px; align-items: center; }
.help-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted, #6b7280);
  animation: helpBlink 1.2s infinite ease-in-out;
}
.help-typing span:nth-child(2) { animation-delay: .15s; }
.help-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes helpBlink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-2px); }
}

.help-chat-form {
  display: flex; gap: 8px; padding: 10px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: #fff;
}
.help-chat-form textarea {
  flex: 1; resize: none;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border, #e5e7eb);
  font: inherit; font-size: 16px; /* iOS no-zoom */
  background: #fff;
}
.help-chat-form textarea:focus {
  outline: none; border-color: var(--primary, #1e40af);
  box-shadow: 0 0 0 3px var(--primary-50, #eff6ff);
}
.help-chat-send {
  width: 44px; flex-shrink: 0;
  background: var(--primary, #1e40af); color: #fff;
  border: 0; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.help-chat-send:hover { background: var(--primary-700, #1e3a8a); }
.help-chat-send svg { width: 18px; height: 18px; }

body.help-drawer-open { overflow: hidden; }


.help-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.help-chat-clear {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-muted, #6b7280); font-size: .82rem;
  padding: 4px 8px; border-radius: 6px;
}
.help-chat-clear:hover { background: var(--surface-2, #f3f4f6); color: var(--danger, #dc2626); }
.help-chat-clear svg { width: 14px; height: 14px; }


/* Universal "message this person" icon button (v1.7.0) */
.msg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-muted, #6b7280);
  background: transparent;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}
.msg-btn:hover {
  background: var(--primary-50, #eff6ff);
  color: var(--primary, #1e40af);
  border-color: var(--primary, #1e40af);
}
.msg-btn svg { width: 14px; height: 14px; }
.msg-btn-md { width: 32px; height: 32px; }
.msg-btn-md svg { width: 16px; height: 16px; }


/* Notifications bell + dropdown (v1.14.0) */
.topbar-bell {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border, #e5e7eb);
  background: #fff; color: var(--text, #1f2937);
  cursor: pointer; text-decoration: none;
  margin-right: 6px;
  transition: background .15s, transform .15s;
}
.topbar-bell:hover { background: var(--surface-2, #f3f4f6); transform: translateY(-1px); }
.topbar-bell svg { width: 18px; height: 18px; }
.topbar-bell-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px;
  background: var(--danger, #dc2626); color: #fff;
  border-radius: 999px; padding: 0 5px;
  font-size: .65rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

.notif-dropdown {
  position: absolute; top: 56px; right: 78px; z-index: 900;
  width: 360px; max-width: calc(100vw - 20px);
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15,23,42,.15);
  overflow: hidden;
}
.notif-dropdown-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: var(--surface-2, #f9fafb);
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.notif-mark-all {
  background: transparent; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; color: var(--text-muted, #6b7280);
  padding: 4px 8px; border-radius: 6px;
}
.notif-mark-all:hover { background: #fff; color: var(--primary, #1e40af); }

.notif-list { max-height: 480px; overflow-y: auto; }
.notif-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  text-decoration: none; color: inherit;
  transition: background .12s;
}
.notif-row:hover { background: var(--surface-2, #f9fafb); }
.notif-row.is-unread { background: rgba(30,64,175,.03); }
.notif-row:last-child { border-bottom: 0; }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary, #1e40af);
  flex-shrink: 0; margin-top: 6px;
}

@media (max-width: 600px) {
  .notif-dropdown { right: 10px; left: 10px; width: auto; }
}


/* Pending pills that click through to review (v1.14.0) */
.review-pill {
  text-decoration: none !important;
  display: inline-flex; align-items: center; gap: 4px;
  transition: filter .12s, transform .12s, box-shadow .12s;
}
.review-pill:hover {
  filter: brightness(.92);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(217,119,6,.25);
}


/* Image lightbox (v1.14.1) — any <img data-lightbox> becomes click-to-zoom */
.img-clickable {
  cursor: zoom-in;
  transition: transform .12s ease;
}
.img-clickable:hover { transform: scale(1.01); }
.lightbox-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .92);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.lightbox-overlay.is-open { opacity: 1; pointer-events: auto; }
.lightbox-overlay img {
  max-width: 100%; max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 25px 60px rgba(0,0,0,.5);
  background: #fff;
}
.lightbox-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,.15); color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255,255,255,.28); }
.lightbox-hint {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.7); font-size: .8rem;
  background: rgba(0,0,0,.4); padding: 6px 12px; border-radius: 99px;
  pointer-events: none;
}


/* Notification mute toggle (v1.15.0) */
.notif-mute {
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-muted, #6b7280);
  padding: 4px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.notif-mute:hover { background: #fff; color: var(--primary, #1e40af); }

