:root {
  --bg: #FAF6F0;
  --surface: #FFFFFF;
  --surface-soft: #F3EDE2;
  --primary: #1B5E57;
  --primary-dark: #134640;
  --primary-light: #E6F2F0;
  --accent: #C86D51;
  --accent-light: #FBECE7;
  --gold: #D49B35;
  --gold-light: #FDF6E4;
  --text: #1E2423;
  --text-muted: #5C6664;
  --border: #E4DDD0;
  --success: #23784B;
  --success-bg: #E7F5EE;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 18px rgba(27, 94, 87, 0.07);
  --font-en: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-fa: "Vazirmatn", "IRANSans", "Segoe UI", Tahoma, "Geeza Pro", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 0 0 92px;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-en);
  line-height: 1.5;
}

body[dir="rtl"] { font-family: var(--font-fa); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 240, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.header-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.brand-title { font-weight: 800; font-size: 1.05rem; color: var(--primary-dark); line-height: 1.2; margin: 0; }
.brand-sub { font-size: 0.75rem; color: var(--text-muted); margin: 0; display: flex; align-items: center; gap: 6px; }

.sync-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--gold); }
.sync-dot.live { background: var(--success); box-shadow: 0 0 0 3px rgba(35, 120, 75, 0.18); }

.header-controls { display: flex; align-items: center; gap: 8px; }

.profile-pill {
  display: inline-flex;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}

.profile-btn {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.profile-btn.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.lang-toggle-btn {
  border: 1.5px solid var(--primary);
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-fa);
}

.card-lang-btn {
  border: 1px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 4px 11px;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-fa);
  white-space: nowrap;
}

.card-lang-btn:hover, .card-lang-btn.active-fa { background: var(--primary); color: #FFFFFF; }

.container { max-width: 780px; margin: 0 auto; padding: 14px 16px 32px; }

.install-bar {
  background: linear-gradient(135deg, #1B5E57 0%, #24756C 100%);
  color: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.install-bar-text { font-size: 0.84rem; line-height: 1.35; }
.install-bar-text strong { display: block; font-size: 0.92rem; margin-bottom: 2px; }
.install-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-light {
  background: #FFFFFF;
  color: var(--primary-dark);
  border: none;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-outline-light {
  background: rgba(255,255,255,0.14);
  color: #FFFFFF;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-title { font-size: 1.02rem; font-weight: 800; margin: 0; color: var(--primary-dark); }
.drop-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: 100%; max-width: 100%; min-width: 0; }

.input-textarea {
  width: 100%;
  min-height: 74px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  resize: vertical;
}

.row-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; width: 100%; max-width: 100%; min-width: 0; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }

.input-select, .input-text {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: inherit;
  font-size: 0.86rem;
  color: var(--text);
}

.camera-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.photo-preview-wrap {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.photo-preview-wrap.visible { display: flex; }
.photo-preview-img { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }

.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; max-width: 100%; min-width: 0; padding-bottom: 4px; }
.preset-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: normal;
  text-align: start;
  max-width: 100%;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.cards-list { display: grid; grid-template-columns: 1fr; gap: 14px; }

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.item-card[dir="rtl"] { font-family: var(--font-fa); text-align: right; }
.item-card[dir="ltr"] { font-family: var(--font-en); text-align: left; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge { font-size: 0.72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center; }
.badge-cat { background: var(--primary-light); color: var(--primary-dark); }
.badge-status-accent { background: var(--accent-light); color: #9E472D; }
.badge-status-success { background: var(--success-bg); color: var(--success); }
.badge-status-warning { background: var(--gold-light); color: #8F6210; }
.badge-status-neutral { background: var(--surface-soft); color: var(--text-muted); }

.card-title { font-size: 1.06rem; font-weight: 800; margin: 4px 0; color: var(--text); }
.card-subtitle { font-size: 0.85rem; font-weight: 600; color: var(--primary); margin: 0 0 8px; }
.card-details {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 12px;
  line-height: 1.55;
  background: var(--bg);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border-inline-start: 3px solid var(--primary);
}

.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.swatch-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
}
.swatch-dot { width: 20px; height: 20px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.15); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--surface-soft);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.action-link, .action-btn {
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--primary-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.action-btn.share-sanaz { background: var(--accent-light); color: #9E472D; border-color: #F0CABB; }

.drive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.drive-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.86rem;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav-inner { max-width: 780px; margin: 0 auto; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }

.nav-tab {
  border: none;
  background: transparent;
  padding: 6px 4px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.nav-tab .nav-icon { font-size: 1.15rem; line-height: 1; }
.nav-tab.active { color: var(--primary-dark); background: var(--primary-light); }

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1E2423;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 120;
}

.modal-backdrop.open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  padding: 20px;
}

/* In-App Update Notification Banner */
.update-banner {
  display: none;
  background: linear-gradient(135deg, #FFF8EB 0%, #FCEBD2 100%);
  border: 2px solid #E5A93C;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(183, 121, 31, 0.16);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  animation: slideDownUpdate 0.25s ease-out;
}
.update-banner.visible {
  display: flex;
}
@keyframes slideDownUpdate {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.update-banner-content {
  flex: 1;
  min-width: 210px;
}
.update-banner-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: #6B420F;
  margin: 0 0 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.update-banner-notes {
  font-size: 0.8rem;
  color: #825418;
  margin: 0;
  line-height: 1.45;
}
.update-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-update-now {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(27, 94, 87, 0.25);
  white-space: nowrap;
}
.btn-update-now:hover {
  background: var(--primary-dark);
}
.btn-update-dismiss {
  background: rgba(107, 66, 15, 0.1);
  color: #6B420F;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.version-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid rgba(27, 94, 87, 0.2);
}

.item-card.shared-highlight {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(27, 94, 87, 0.14), var(--shadow-md);
}
.share-shortcut-box {
  background: var(--primary-light);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.code-pill {
  display: block;
  background: #1E2423;
  color: #E8F5F3;
  padding: 8px 10px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.75rem;
  word-break: break-all;
  margin: 6px 0;
  direction: ltr;
  text-align: left;
}

/* WhatsApp-Style First-Time Login Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: linear-gradient(155deg, #12423D 0%, #1B5E57 50%, #244B47 100%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.auth-overlay.open {
  display: flex;
}
.auth-card {
  background: var(--surface);
  color: var(--text);
  width: 100%;
  max-width: 440px;
  border-radius: 22px;
  padding: 22px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.auth-member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.auth-member-card {
  border: 2px solid var(--border);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.auth-member-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(27, 94, 87, 0.15);
}
.auth-member-emoji {
  font-size: 1.55rem;
  line-height: 1.1;
}
.auth-member-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text);
}
.auth-member-fa {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-fa);
}
.family-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.family-member-row.active-member {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Monogram Initial Badges & 3-Level Permission Styles */
.monogram-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1B5E57 0%, #12423D 100%);
  color: #FAF6F0;
  font-weight: 800;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #E5A93C;
  flex-shrink: 0;
  overflow: hidden;
}
.monogram-badge.sm {
  width: 22px;
  height: 22px;
  font-size: 0.68rem;
  border-width: 1.5px;
}
.monogram-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}
.role-pill.admin {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #F59E0B;
}
.role-pill.full {
  background: #E3F2EF;
  color: #12423D;
  border: 1px solid #1B5E57;
}
.role-pill.guest {
  background: #FCEBD2;
  color: #9E472D;
  border: 1px solid #D97757;
}
.guest-checklist-box {
  background: #FFFDF9;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
}
.guest-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.guest-check-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
}
.guest-check-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}
.avatar-choice-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.avatar-choice-pill {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.avatar-choice-pill.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* v1.6.1 Mobile Viewport & Grid/Flex Overflow Fix (iOS Safari LTR + RTL) */
html, body {
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
}

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

.app-header,
.header-inner,
.container,
.tab-section,
.panel,
.drop-grid,
.cards-list,
.item-card,
.install-bar,
.update-banner,
.share-shortcut-box {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.panel {
  overflow: hidden;
}

.panel-header {
  flex-wrap: wrap;
  min-width: 0;
}

.brand {
  min-width: 0;
  max-width: 100%;
}

.brand-sub {
  flex-wrap: wrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}

.profile-pill {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}

.drop-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.drop-grid > * {
  min-width: 0;
  max-width: 100%;
}

.row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.row-2 > * {
  min-width: 0;
  max-width: 100%;
}

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

.input-textarea,
.input-select,
.input-text,
.camera-upload-label,
.btn-primary {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.camera-upload-label {
  text-align: center;
  flex-wrap: wrap;
  word-break: break-word;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: visible;
  padding-bottom: 2px;
}

.preset-chip {
  max-width: 100%;
  white-space: normal;
  text-align: start;
  line-height: 1.3;
  word-break: break-word;
}

.share-shortcut-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.share-shortcut-box > * {
  min-width: 0;
  max-width: 100%;
}

.share-shortcut-box .action-btn {
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.3;
}

.bottom-nav-inner {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
  max-width: 780px;
}

.nav-tab {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
