/* ===================================================================
   GIFTLY — STYLESHEET
   Design System: Deep Plum, Soft Blush, Warm Ivory, Muted Gold
   =================================================================== */

:root {
  /* Core Brand Colors */
  --color-primary: #542B50;
  --color-primary-hover: #432240;
  --color-primary-light: #703B6B;
  --color-primary-subtle: rgba(84, 43, 80, 0.08);

  --color-secondary: #F5E7EC;
  --color-secondary-hover: #ECD4DC;
  --color-secondary-text: #542B50;

  --color-bg: #FAF8F5;
  --color-bg-alt: #F4EFEA;
  --color-card: #FFFFFF;

  --color-accent: #C5A46D;
  --color-accent-hover: #B5925A;
  --color-accent-light: #F7F1E5;

  /* Typography Colors */
  --color-text: #29252B;
  --color-text-muted: #817B82;
  --color-text-light: #A5A0A6;

  /* Status & Feedback Colors */
  --color-success: #2E7D32;
  --color-success-bg: #EAF5EA;
  --color-success-border: #C8E6C9;

  --color-warning: #B45309;
  --color-warning-bg: #FEF3C7;
  --color-warning-border: #FDE68A;

  --color-error: #C53030;
  --color-error-bg: #FDE8E8;
  --color-error-border: #F8B4B4;

  /* Neutral Borders & Dividers */
  --color-border: #E8E2D9;
  --color-border-subtle: #F1ECE5;
  --color-border-focus: #542B50;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(41, 37, 43, 0.05);
  --shadow-md: 0 4px 14px rgba(84, 43, 80, 0.07);
  --shadow-lg: 0 10px 30px rgba(84, 43, 80, 0.12);
  --shadow-modal: 0 20px 45px rgba(41, 37, 43, 0.22);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Layout sizing */
  --sidebar-width: 270px;
  --header-height: 64px;
  --transition-fast: 0.18s ease;
  --transition-normal: 0.25s ease;
}

/* Base Reset & Box Sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Typography Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-text);
  font-weight: 600;
  line-height: 1.3;
}

p {
  color: var(--color-text);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

/* Accessibility hidden class */
.hidden {
  display: none !important;
}

/* ===================================================================
   LAYOUT ARCHITECTURE
   =================================================================== */

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Mobile Header (Hidden on Desktop) */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1.25rem;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.mobile-header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-toggle-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.mobile-toggle-btn:hover {
  background-color: var(--color-secondary);
}

/* Mobile backdrop overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(41, 37, 43, 0.45);
  backdrop-filter: blur(2px);
  z-index: 45;
}

/* ===================================================================
   SIDEBAR NAVIGATION
   =================================================================== */

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-card);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.75rem 1.25rem 1.25rem 1.25rem;
  z-index: 50;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  margin-bottom: 1.5rem;
}

.brand-group {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(84, 43, 80, 0.25);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}

.brand-tagline {
  font-size: 0.73rem;
  color: var(--color-text-muted);
  line-height: 1.25;
  margin-top: 0.25rem;
}

.sidebar-quick-action {
  margin-bottom: 1.5rem;
}

.sidebar-quick-action .quick-btn {
  box-shadow: var(--shadow-sm);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-link {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-md);
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background-color: var(--color-secondary);
  color: var(--color-primary);
}

.nav-link.active {
  background-color: var(--color-primary);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(84, 43, 80, 0.2);
}

.nav-link .nav-icon {
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.nav-link:hover .nav-icon {
  transform: scale(1.05);
}

.nav-badge {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  background-color: var(--color-secondary);
  color: var(--color-primary);
  font-weight: 600;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-link.active .nav-badge {
  background-color: rgba(255, 255, 255, 0.25);
  color: #FFFFFF;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-subtle);
}

.sidebar-quote {
  padding: 0.85rem;
  background-color: var(--color-bg);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-accent);
}

.quote-text {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-style: italic;
  line-height: 1.4;
}

/* ===================================================================
   MAIN CONTENT AREA & VIEWS
   =================================================================== */

.main-content {
  flex: 1;
  padding: 2.25rem 2.5rem 3.5rem 2.5rem;
  max-width: 1240px;
  min-width: 0;
  margin: 0 auto;
}

.view-section {
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Section Header Bar */
.section-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -0.02em;
}

.section-desc {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* ===================================================================
   BUTTONS & CONTROLS
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  line-height: 1.2;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #FFFFFF;
  border: 1px solid var(--color-primary);
  box-shadow: 0 4px 14px rgba(84, 43, 80, 0.22);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  box-shadow: 0 6px 18px rgba(84, 43, 80, 0.3);
}

.btn-secondary {
  background-color: #FFFFFF;
  color: var(--color-primary);
  border: 1px solid rgba(84, 43, 80, 0.28);
  box-shadow: 0 1px 3px rgba(41, 37, 43, 0.04);
}

.btn-secondary:hover {
  background-color: rgba(84, 43, 80, 0.04);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-secondary:active {
  background-color: rgba(84, 43, 80, 0.08);
}

.btn-danger {
  background-color: var(--color-error);
  color: #FFFFFF;
}

.btn-danger:hover {
  background-color: #A82525;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn-text {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.btn-text:hover {
  background-color: var(--color-secondary);
  text-decoration: none;
}

.btn-icon {
  background: none;
  border: none;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--color-secondary);
  color: var(--color-primary);
}

.btn-icon-danger:hover {
  background-color: var(--color-error-bg);
  color: var(--color-error);
}

/* ===================================================================
   SEARCH & FILTER TOOLBAR SYSTEM
   =================================================================== */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  width: 100%;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

.search-input {
  width: 100%;
  height: 42px;
  line-height: 40px;
  padding: 0 2.25rem 0 2.45rem !important;
  background-color: #FFFFFF;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  color: var(--color-text);
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.btn-clear-search {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: var(--radius-full);
}

.btn-clear-search:hover {
  color: var(--color-text);
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.filter-select {
  height: 42px;
  line-height: normal;
  padding: 0 2.2rem 0 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: #FFFFFF;
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 500;
  box-sizing: border-box;
  cursor: pointer;
  transition: all var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23817B82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px 14px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.filter-select:hover {
  border-color: rgba(84, 43, 80, 0.35);
}

/* Section Specific Filter Widths on Desktop */
#filter-people-relationship {
  width: 200px;
}

#filter-notes-recipient {
  width: 175px;
}

#filter-notes-category {
  width: 185px;
}

#sort-notes {
  width: 145px;
}

#filter-gifts-status {
  width: 140px;
}

#filter-gifts-occasion {
  width: 160px;
}

#filter-gifts-recipient {
  width: 160px;
}

#sort-gifts {
  width: 155px;
}

#filter-occasions-type {
  width: 180px;
}

#filter-occasions-recipient {
  width: 180px;
}

/* ===================================================================
   OVERVIEW DASHBOARD WIDGETS
   =================================================================== */

/* Welcome Card */
.welcome-card {
  background: linear-gradient(135deg, #FFFFFF 0%, var(--color-secondary) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.welcome-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -30px;
  width: 140px;
  height: 140px;
  background-color: rgba(197, 164, 109, 0.12);
  border-radius: var(--radius-full);
  pointer-events: none;
}

.welcome-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: 0.4rem;
}

.welcome-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.35rem;
}

.welcome-subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  max-width: 580px;
}

.welcome-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* 4 Summary Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-focus);
}

.metric-icon-wrap {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-plum {
  background-color: var(--color-secondary);
  color: var(--color-primary);
}

.metric-gold {
  background-color: var(--color-accent-light);
  color: var(--color-accent-hover);
}

.metric-amber {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

.metric-green {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.metric-content {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.15;
  margin: 0.15rem 0;
}

.metric-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Dashboard Budget Card */
.dashboard-budget-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.budget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.budget-title {
  font-size: 1.25rem;
  color: var(--color-primary);
  font-weight: 700;
}

.budget-subtitle {
  font-size: 0.86rem;
  color: var(--color-text-muted);
}

.currency-tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background-color: var(--color-bg-alt);
  color: var(--color-text);
}

.budget-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
  border-top: 1px solid var(--color-border-subtle);
  border-bottom: 1px solid var(--color-border-subtle);
  margin-bottom: 1.25rem;
}

.budget-item {
  flex: 1;
  text-align: center;
}

.budget-item:first-child {
  text-align: left;
}

.budget-item:last-child {
  text-align: right;
}

.budget-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.budget-amount {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.budget-note {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.text-success {
  color: var(--color-success) !important;
}

.text-muted {
  color: var(--color-text-muted) !important;
}

.budget-divider {
  width: 1px;
  height: 48px;
  background-color: var(--color-border);
}

.budget-progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.budget-progress-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--color-bg-alt);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent) 0%, var(--color-primary) 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* ===================================================================
   OVERVIEW GETTING STARTED GUIDANCE
   =================================================================== */

.getting-started-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.getting-started-header {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.getting-started-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.getting-started-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-secondary) 0%, #FFFFFF 100%);
  color: var(--color-primary);
  border: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.getting-started-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.getting-started-desc {
  font-size: 0.86rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.getting-started-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.15rem;
}

.getting-started-step {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.getting-started-step:hover {
  background-color: #FFFFFF;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.step-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.step-desc {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-bottom: 0.75rem;
  flex: 1;
}

.getting-started-step .btn {
  align-self: flex-start;
  margin-top: auto;
}

/* Dashboard Dual Grid */
.dashboard-dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.dash-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.dash-card-title-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--color-primary);
}

.dash-card-title-group h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1;
}

/* Mini Occasion Item in Dashboard */
.mini-occasion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  transition: all var(--transition-fast);
}

.mini-occasion-item:hover {
  background-color: var(--color-secondary);
  border-color: var(--color-border);
}

.mini-occasion-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mini-occasion-meta h4 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.mini-occasion-meta p {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

/* Mini Note Item in Dashboard */
.mini-note-item {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  transition: all var(--transition-fast);
}

.mini-note-item:hover {
  background-color: var(--color-secondary);
  border-color: var(--color-border);
}

.mini-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  gap: 0.5rem;
}

.mini-note-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text);
}

.mini-note-body {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.mini-note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.mini-note-author {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
}

/* ===================================================================
   CARDS GRID (PEOPLE, NOTES, GIFTS, OCCASIONS)
   =================================================================== */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.35rem;
}

/* Standard Base Card */
.content-card {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.content-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-focus);
}

/* 1. Recipient Card */
.person-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.person-primary-info {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}

.person-name-group h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.25;
}

.person-relationship {
  display: inline-block;
  margin-top: 0.2rem;
}

.person-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.person-info-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.person-info-row svg {
  flex-shrink: 0;
  color: var(--color-accent);
}

.person-interests-tag {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text);
  line-height: 1.35;
}

.person-stats-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-subtle);
}

.person-stat-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background-color: var(--color-bg-alt);
  color: var(--color-text);
}

.person-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--color-border-subtle);
}

/* 2. Thought Note Card */
.note-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.note-category-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

.note-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
  margin-bottom: 0.65rem;
}

.note-quote-body {
  font-size: 0.88rem;
  color: var(--color-text);
  background-color: var(--color-bg);
  border-left: 3px solid var(--color-accent);
  padding: 0.75rem 0.95rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  line-height: 1.45;
  margin-bottom: 1rem;
  flex: 1;
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-subtle);
}

.note-recipient-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.note-recipient-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}

.note-date-tag {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.note-action-btns {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* 3. Gift Card */
.gift-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.gift-status-select {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 1.6rem 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  background-position: right 0.4rem center;
}

.gift-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.gift-name {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.gift-link-icon {
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.gift-link-icon:hover {
  background-color: var(--color-secondary);
  color: var(--color-primary);
}

.gift-recipient-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.gift-budget-box {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.gift-budget-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.gift-budget-amount {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.gift-description-text {
  font-size: 0.84rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-bottom: 0.85rem;
  flex: 1;
}

.gift-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-subtle);
}

/* 4. Occasion Card */
.occasion-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.occasion-date-box {
  display: flex;
  flex-direction: column;
}

.occasion-day-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.occasion-date-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
}

.occasion-name {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.4rem;
}

.occasion-person {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.occasion-notes-box {
  font-size: 0.84rem;
  color: var(--color-text-muted);
  background-color: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.85rem;
  line-height: 1.4;
  flex: 1;
}

.occasion-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border-subtle);
}

/* ===================================================================
   AVATARS & BADGES
   =================================================================== */

.avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #FFFFFF;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.72rem;
}

.avatar-large {
  width: 60px;
  height: 60px;
  font-size: 1.35rem;
}

/* Dynamic Palette Backgrounds for Avatars */
.avatar-bg-0 {
  background-color: #542B50;
}

.avatar-bg-1 {
  background-color: #7D4E78;
}

.avatar-bg-2 {
  background-color: #9C6C52;
}

.avatar-bg-3 {
  background-color: #386641;
}

.avatar-bg-4 {
  background-color: #5C677D;
}

.avatar-bg-5 {
  background-color: #A3485E;
}

.avatar-bg-6 {
  background-color: #A5844E;
}

.avatar-bg-7 {
  background-color: #4059AD;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.2;
}

.badge-subtle {
  background-color: var(--color-secondary);
  color: var(--color-primary);
}

/* Status Badges for Gifts */
.badge-status-planned {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

.badge-status-purchased {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-status-gifted {
  background-color: var(--color-secondary);
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

/* Countdown Badges for Occasions */
.badge-countdown-today {
  background-color: var(--color-accent);
  color: #FFFFFF;
  font-weight: 700;
  animation: pulse 2s infinite;
}

.badge-countdown-soon {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

.badge-countdown-normal {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

/* Category Badges for Notes */
.badge-category-wants {
  background-color: var(--color-accent-light);
  color: var(--color-accent-hover);
}

.badge-category-favourites {
  background-color: var(--color-secondary);
  color: var(--color-primary);
}

.badge-category-interests {
  background-color: #E6F0FA;
  color: #2563EB;
}

.badge-category-experiences {
  background-color: #F3E8FF;
  color: #7E22CE;
}

.badge-category-avoid {
  background-color: var(--color-error-bg);
  color: var(--color-error);
}

.badge-category-other {
  background-color: var(--color-bg-alt);
  color: var(--color-text-muted);
}

/* ===================================================================
   EMPTY STATES
   =================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1.5rem;
  background-color: var(--color-card);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  grid-column: 1 / -1;
}

.empty-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background-color: var(--color-secondary);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.empty-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.45rem;
}

.empty-desc {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  max-width: 440px;
  margin-bottom: 1.5rem;
  line-height: 1.45;
}

/* ===================================================================
   FORMS & INPUTS
   =================================================================== */

.form-body {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.col-6 {
  flex: 1;
}

.form-label {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--color-text);
}

.form-label.required::after {
  content: " *";
  color: var(--color-error);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: #FFFFFF;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.form-input.input-error,
.form-select.input-error,
.form-textarea.input-error {
  border-color: var(--color-error);
  background-color: #FFFDFD;
}

.form-input.input-error:focus,
.form-select.input-error:focus,
.form-textarea.input-error:focus {
  box-shadow: 0 0 0 3px rgba(197, 48, 48, 0.15);
}

.form-error {
  font-size: 0.76rem;
  color: var(--color-error);
  min-height: 1.1rem;
  display: block;
}

.form-textarea {
  resize: vertical;
}

.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 600;
  pointer-events: none;
}

.input-with-prefix {
  padding-left: 2rem !important;
}

/* ===================================================================
   MODALS & DIALOGS
   =================================================================== */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(41, 37, 43, 0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.modal-dialog {
  background-color: var(--color-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.modal-backdrop.active .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-dialog-large {
  max-width: 760px;
}

.modal-dialog-sm {
  max-width: 440px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary);
}

.modal-close-btn {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-form {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.modal-form .form-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 135px);
}

.modal-footer {
  padding: 1.15rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--color-bg);
}

/* Profile Detail Modal Specifics */
.profile-header-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-meta-card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.profile-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.profile-meta-item:nth-child(3),
.profile-meta-item:nth-child(4),
.profile-meta-item:nth-child(5) {
  grid-column: 1 / -1;
}

.meta-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.meta-text {
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.4;
}

.profile-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-section-block {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.block-header {
  padding: 0.85rem 1.15rem;
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.block-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-primary);
}

.block-title-wrap h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-primary);
}

.profile-sublist {
  padding: 0.85rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 220px;
  overflow-y: auto;
}

.profile-subitem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  font-size: 0.86rem;
}

/* Confirmation Modal Specifics */
.confirm-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background-color: var(--color-error-bg);
  color: var(--color-error);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.confirm-message-text {
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.45;
  margin-bottom: 0.85rem;
}

.confirm-alert-box {
  background-color: var(--color-error-bg);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  font-size: 0.84rem;
  color: var(--color-error);
  line-height: 1.4;
}

/* ===================================================================
   TOAST NOTIFICATIONS
   =================================================================== */

.toast-container {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 120;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background-color: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease-out forwards;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.toast-hiding {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast-icon {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.toast-success .toast-icon {
  color: var(--color-success);
}

.toast-error .toast-icon {
  color: var(--color-error);
}

.toast-info .toast-icon {
  color: var(--color-primary);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}

.toast-msg {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.35;
}

/* ===================================================================
   RESPONSIVE MEDIA QUERIES
   =================================================================== */

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

  /* Wrap filters cleanly in Gift Vault when 4 filters cannot fit with search */
  #view-gifts .filter-bar {
    flex-wrap: wrap;
  }

  #view-gifts .search-input-wrap {
    flex: 1 1 100%;
    width: 100%;
  }

  #view-gifts .filter-controls {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  #view-gifts .filter-select {
    flex: 1 1 auto;
    width: auto !important;
    min-width: 130px;
  }
}

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

  .dashboard-dual-grid {
    grid-template-columns: 1fr;
  }

  /* Wrap filters in Thought Notes if needed */
  #view-notes .filter-bar {
    flex-wrap: wrap;
  }

  #view-notes .search-input-wrap {
    flex: 1 1 100%;
    width: 100%;
  }

  #view-notes .filter-controls {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  #view-notes .filter-select {
    flex: 1 1 auto;
    width: auto !important;
    min-width: 140px;
  }
}

@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-modal);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-overlay.active {
    display: block;
  }

  .main-content {
    padding: calc(var(--header-height) + 1.25rem) 1.25rem 2.5rem 1.25rem;
  }

  .welcome-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem;
  }

  .welcome-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .welcome-actions .btn {
    flex: 1;
  }

  .getting-started-grid {
    grid-template-columns: 1fr;
  }

  .budget-stats-row {
    flex-direction: column;
    gap: 1rem;
    text-align: left !important;
  }

  .budget-item {
    text-align: left !important;
    width: 100%;
  }

  .budget-divider {
    display: none;
  }

  /* Mobile Search & Filter Toolbar Layout */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .search-input-wrap {
    width: 100% !important;
    flex: none !important;
    min-width: 0 !important;
  }

  .filter-controls {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .filter-select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .form-row {
    flex-direction: column;
    gap: 1.15rem;
  }

  .profile-meta-card {
    grid-template-columns: 1fr;
  }
}


/* Mobile modal sizing and actions */
@media (max-width: 600px) {
  .modal-backdrop {
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    overflow-y: auto;
  }

  .modal-dialog,
  .modal-dialog-sm,
  .modal-dialog-large {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    min-width: 0;
  }

  .modal-form {
    min-height: 0;
  }

  .modal-form .form-body,
  .modal-body {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 1rem;
    flex-shrink: 0;
  }

  .modal-footer .btn {
    width: 100%;
    max-width: none;
    white-space: normal;
    min-height: 48px;
  }

  #modal-confirm .modal-header {
    padding: 1rem 1.1rem;
  }

  #modal-confirm .modal-body {
    padding: 1.1rem;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .section-top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .section-top-bar .btn {
    width: 100%;
  }

  /* Single column filter layout on narrow mobile */
  .filter-controls {
    grid-template-columns: 1fr !important;
  }

  .modal-dialog {
    max-height: 95vh;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: none;
  }
}

/* ===================================================================
   GIFTLY MOBILE QA CORRECTIONS
   Targeted overrides; desktop styling and existing app behaviour kept.
   =================================================================== */

@media (max-width: 768px) {
  /* Keep the closed drawer completely off-canvas on iOS Safari.
     The border was remaining visible as a vertical line. */
  .sidebar {
    left: 0;
    width: min(var(--sidebar-width), 84vw);
    max-width: 320px;
    transform: translate3d(-105%, 0, 0);
    border-right: 0;
    visibility: hidden;
    transition: transform var(--transition-normal), visibility var(--transition-normal);
    will-change: transform;
  }

  .sidebar.mobile-open {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    border-right: 1px solid var(--color-border);
  }

  .mobile-overlay {
    left: 0;
    right: 0;
    width: 100%;
  }

  /* Prevent children of a view from forcing the document wider. */
  .app-container,
  .main-content,
  .view-section,
  #view-people,
  #view-notes,
  #view-gifts,
  #view-occasions,
  .cards-grid,
  .content-card {
    min-width: 0;
    max-width: 100%;
  }

  .main-content {
    width: 100%;
  }

  #view-gifts .filter-bar,
  #view-gifts .filter-controls {
    min-width: 0;
    max-width: 100%;
  }

  #view-gifts .filter-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The quick status control should size to its label, not fill the card. */
  .gift-card-header {
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
  }

  .gift-card-header > .badge {
    flex: 0 0 auto;
  }

  .gift-status-select {
    display: inline-block;
    width: auto !important;
    min-width: 112px;
    max-width: 145px;
    flex: 0 1 auto;
    min-height: 40px;
    padding: 0.35rem 1.75rem 0.35rem 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  /* Make native date controls occupy the same width as other form fields. */
  .modal-form .form-group,
  .modal-form .form-input[type="date"],
  .modal-form input[type="date"] {
    width: 100%;
    min-width: 0;
  }

  .modal-form input[type="date"] {
    display: block;
    min-height: 48px;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
  }
}

/* Mobile modal geometry and independent scrolling.
   Use dynamic viewport units so Safari's browser chrome is accounted for. */
@media (max-width: 600px) {
  .modal-backdrop {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    padding:
      max(16px, env(safe-area-inset-top))
      16px
      max(16px, env(safe-area-inset-bottom));
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
  }

  .modal-dialog,
  .modal-dialog-sm,
  .modal-dialog-large {
    width: 100%;
    max-width: 480px;
    min-width: 0;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px);
    height: auto;
    margin: auto;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #modal-recipient-profile .modal-dialog,
  #modal-recipient-profile .modal-dialog-large {
    max-width: 560px;
  }

  #modal-confirm .modal-dialog,
  #modal-confirm .modal-dialog-sm {
    max-width: 420px;
    max-height: min(560px, calc(100dvh - 40px));
  }

  .modal-header {
    flex: 0 0 auto;
    padding: 1rem 1.1rem;
  }

  .modal-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .modal-form .form-body,
  .modal-body,
  #modal-recipient-profile .profile-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1.1rem;
  }

  .modal-footer {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
    background-color: var(--color-bg);
    border-top: 1px solid var(--color-border);
  }

  .modal-footer .btn {
    width: 100%;
    max-width: none;
    min-height: 48px;
    white-space: normal;
  }

  #modal-confirm .modal-header {
    padding: 1rem 1.1rem;
  }

  #modal-confirm .modal-body {
    padding: 1.1rem;
  }

  #modal-recipient-profile .modal-header {
    gap: 0.6rem;
    padding: 0.85rem 1rem;
  }

  #modal-recipient-profile .profile-header-info {
    min-width: 0;
    gap: 0.65rem;
  }

  #modal-recipient-profile .profile-header-actions {
    flex-shrink: 0;
    gap: 0.25rem;
  }

  #modal-recipient-profile .avatar-large {
    width: 48px;
    height: 48px;
    font-size: 1rem;
  }

  #modal-recipient-profile .modal-title {
    font-size: 1.05rem;
  }

  #modal-recipient-profile .profile-header-actions .btn {
    padding: 0.4rem 0.55rem;
    font-size: 0.75rem;
  }

  /* Form controls share a consistent tap height on mobile. */
  .modal-form .form-input,
  .modal-form .form-select,
  .modal-form select,
  .filter-select {
    min-height: 48px;
    height: 48px;
    line-height: normal;
    box-sizing: border-box;
  }

  .modal-form .form-input,
  .modal-form .form-select,
  .modal-form input[type="date"],
  .modal-form select {
    width: 100%;
    max-width: 100%;
  }

  .modal-form .input-prefix-wrap {
    width: 100%;
    min-width: 0;
  }

  .modal-form .input-prefix-wrap .form-input {
    width: 100%;
  }

  .modal-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .modal-form .form-row > .form-group,
  .modal-form .form-row > .col-6 {
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .modal-backdrop {
    padding-left: 14px;
    padding-right: 14px;
  }

  .modal-dialog,
  .modal-dialog-sm,
  .modal-dialog-large {
    max-width: 100%;
  }

  .gift-card-header {
    gap: 0.5rem;
  }

  .gift-status-select {
    min-width: 104px;
    max-width: 132px;
  }
}

@media (max-width: 768px) {
  html,
  body {
    overscroll-behavior-x: none;
  }
}

/* Form field consistency: match every single-line dropdown to text inputs. */
@media (min-width: 601px) {
  .modal-form .form-input:not(textarea),
  .modal-form .form-select,
  .modal-form select:not(.gift-status-select),
  .modal-form input[type="date"],
  .modal-form input[type="number"] {
    height: 58px;
    min-height: 58px;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
    line-height: normal;
    vertical-align: middle;
  }
}

@media (max-width: 600px) {
  .modal-form .form-input:not(textarea),
  .modal-form .form-select,
  .modal-form select:not(.gift-status-select),
  .modal-form input[type="date"],
  .modal-form input[type="number"] {
    height: 48px;
    min-height: 48px;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
    line-height: normal;
  }
}


/* ===================================================================
   GIFTLY MOBILE QA — V3 OVERRIDES
   These rules intentionally come last to override earlier mobile rules.
   Desktop styles are not changed.
   =================================================================== */
@media screen and (max-width: 768px) {
  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .app-container, .main-content, .view-section, #view-gifts, #gifts-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Keep the closed drawer fully outside the viewport; remove its edge line. */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: min(270px, 84vw) !important;
    height: 100vh !important;
    height: 100dvh !important;
    border: 0 !important;
    outline: 0 !important;
    transform: translate3d(-110%, 0, 0) !important;
    visibility: hidden !important;
    box-shadow: none !important;
    will-change: transform;
  }

  .sidebar.mobile-open {
    transform: translate3d(0, 0, 0) !important;
    visibility: visible !important;
    box-shadow: var(--shadow-modal) !important;
  }

  /* Section filter controls: one consistent, comfortable mobile tap height. */
  .filter-bar, .filter-controls {
    min-width: 0;
    max-width: 100%;
  }

  .filter-select, .filter-controls select {
    height: 48px !important;
    min-height: 48px !important;
    line-height: normal !important;
    box-sizing: border-box !important;
  }

  /* Gift status control inside each Gift Vault card remains compact. */
  .gift-card-header {
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    align-items: center;
  }

  .gift-status-select {
    width: auto !important;
    min-width: 104px !important;
    max-width: 132px !important;
    min-height: 40px !important;
    height: 40px !important;
    flex: 0 1 auto !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
  }

  #gifts-grid > *, #gifts-grid .gift-card, #gifts-grid .card {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}

/* iOS Safari modal geometry. Use viewport-relative width rather than 100%
   so the dialog cannot expand to the phone edges if an ancestor is oversized. */
@media screen and (max-width: 600px) {
  .modal-backdrop {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    box-sizing: border-box !important;
    padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)) !important;
    display: none;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  .modal-backdrop.active {
    display: flex !important;
  }

  .modal-backdrop > .modal-dialog,
  .modal-backdrop > .modal-dialog-sm,
  .modal-backdrop > .modal-dialog-large {
    position: relative !important;
    display: flex !important;
    flex: 0 1 auto !important;
    flex-direction: column !important;
    width: calc(100vw - 32px) !important;
    max-width: 480px !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: calc(100vh - 32px) !important;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px) !important;
    margin: auto !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  #modal-recipient-profile > .modal-dialog {
    max-width: 520px !important;
  }

  #modal-confirm > .modal-dialog {
    max-width: 420px !important;
    max-height: min(560px, calc(100dvh - 40px)) !important;
  }

  .modal-backdrop > .modal-dialog > .modal-header {
    flex: 0 0 auto !important;
    min-width: 0;
  }

  .modal-backdrop > .modal-dialog > .modal-form {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .modal-form > .form-body,
  .modal-backdrop > .modal-dialog > .modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch !important;
  }

  .modal-backdrop > .modal-dialog > .modal-footer,
  .modal-form > .modal-footer {
    position: relative !important;
    z-index: 2 !important;
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom)) !important;
    background: var(--color-bg) !important;
  }

  .modal-footer .btn {
    width: 100% !important;
    max-width: none !important;
    min-height: 48px !important;
    white-space: normal;
  }

  /* Native date controls should align with the other full-width controls. */
  .modal-form input[type="date"],
  .modal-form input[type="datetime-local"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 48px !important;
    min-height: 48px !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
    appearance: none;
  }

  .modal-form .form-group,
  .modal-form .form-row > .form-group,
  .modal-form .form-row > .col-6 {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .modal-form .form-row {
    min-width: 0 !important;
  }
}

@media screen and (max-width: 480px) {
  .modal-backdrop {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .modal-backdrop > .modal-dialog,
  .modal-backdrop > .modal-dialog-sm,
  .modal-backdrop > .modal-dialog-large {
    width: calc(100vw - 32px) !important;
    max-width: calc(100vw - 32px) !important;
  }
}


/* V4: iPhone date controls and Safari visible-viewport footer fit. */
@media screen and (max-width: 600px) {
  .modal-form input[type="date"],
  .modal-form input[type="datetime-local"] {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    font: inherit !important;
    line-height: 48px !important;
    text-align: left !important;
    vertical-align: middle !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  /* Use the actual visible Safari viewport, not the larger layout viewport. */
  .modal-backdrop {
    top: var(--giftly-visual-top, 0px) !important;
    height: var(--giftly-visual-height, 100dvh) !important;
    max-height: var(--giftly-visual-height, 100dvh) !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    align-items: center !important;
  }

  .modal-backdrop > .modal-dialog,
  .modal-backdrop > .modal-dialog-sm,
  .modal-backdrop > .modal-dialog-large {
    max-height: calc(var(--giftly-visual-height, 100dvh) - 24px) !important;
  }

  .modal-backdrop > .modal-dialog > .modal-footer,
  .modal-form > .modal-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
    flex-shrink: 0 !important;
  }
}
