/* ==========================================================================
   KEEPSAKES VAULT - ULTRA-POLISHED IMPECCABLE DESIGN SYSTEM
   Linear / Apple Notes / Stripe Aesthetic
   Architected for Desktop & Samsung Galaxy S24 Ultra (FHD+ 3-Button Nav)
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Samsung Galaxy S24 Ultra & Android System Metrics */
  --android-nav-height: 48px;
  --bottom-nav-height: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --s24-bottom-clearance: calc(var(--bottom-nav-height) + max(var(--safe-bottom), 14px) + var(--android-nav-height) + 16px);
  --touch-min: 48px;

  /* Spring Physics */
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 240ms;
}

/* ----------------- Obsidian Dark Theme (Default) ----------------- */

:root, [data-theme="dark"] {
  --bg-ground: #080b11;
  --bg-surface: #0f1420;
  --bg-elevated: #151c2d;
  --bg-overlay: #1a2338;
  --bg-subtle: rgba(255, 255, 255, 0.04);
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-active: rgba(255, 255, 255, 0.10);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-inverse: #080b11;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-tint: rgba(59, 130, 246, 0.14);
  --accent-text: #60a5fa;

  --gold: #eab308;
  --gold-tint: rgba(234, 179, 8, 0.14);
  --gold-text: #facc15;

  --rose: #f43f5e;
  --rose-tint: rgba(244, 63, 94, 0.14);
  --rose-text: #fb7185;

  --emerald: #10b981;
  --emerald-tint: rgba(16, 185, 129, 0.14);
  --emerald-text: #34d399;

  --amber: #f59e0b;
  --amber-tint: rgba(245, 158, 11, 0.14);
  --amber-text: #fbbf24;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.5), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.7), 0 6px 16px -2px rgba(0, 0, 0, 0.5);

  --card-bg: #0f1420;
  --card-hover-bg: #131a2b;
  --card-border: rgba(255, 255, 255, 0.07);
  --card-border-hover: rgba(255, 255, 255, 0.15);

  --backdrop-scrim: rgba(4, 6, 11, 0.82);
}

/* ----------------- Warm Tactile Paper Light Theme ----------------- */

[data-theme="light"] {
  --bg-ground: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-overlay: #ffffff;
  --bg-subtle: rgba(0, 0, 0, 0.03);
  --bg-hover: rgba(0, 0, 0, 0.06);
  --bg-active: rgba(0, 0, 0, 0.09);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);
  --border-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-inverse: #ffffff;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-tint: rgba(37, 99, 235, 0.09);
  --accent-text: #1d4ed8;

  --gold: #ca8a04;
  --gold-tint: rgba(202, 138, 4, 0.12);
  --gold-text: #a16207;

  --rose: #e11d48;
  --rose-tint: rgba(225, 29, 72, 0.10);
  --rose-text: #be123c;

  --emerald: #059669;
  --emerald-tint: rgba(5, 150, 105, 0.10);
  --emerald-text: #047857;

  --amber: #d97706;
  --amber-tint: rgba(217, 119, 6, 0.11);
  --amber-text: #b45309;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 40px -6px rgba(0, 0, 0, 0.14), 0 6px 16px -2px rgba(0, 0, 0, 0.06);

  --card-bg: #ffffff;
  --card-hover-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
  --card-border-hover: rgba(0, 0, 0, 0.16);

  --backdrop-scrim: rgba(15, 23, 42, 0.50);
}

/* ----------------- Universal Resets ----------------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  background-color: var(--bg-ground);
  color: var(--text-primary);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-ground);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* Reset buttons cleanly so OS defaults never bleed through */
button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  outline: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-wrap: balance;
}

/* ----------------- App Shell Grid ----------------- */

#appShell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ----------------- Sleek Frameless Sidebar Rail (Desktop) ----------------- */

#sidebarRail {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 12px;
  overflow-y: auto;
  z-index: 20;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 14px 8px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--accent-tint);
  flex-shrink: 0;
}

.brand-icon-box svg {
  width: 20px;
  height: 20px;
}

.brand-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.2;
}

.vault-switcher-pill {
  margin-top: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.vault-switcher-pill:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.vault-switcher-pill select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.82rem;
  width: 100%;
  cursor: pointer;
}

/* Sidebar Nav Links */
.sidebar-nav-group {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 8px 10px 4px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none !important;
  background: transparent !important;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
  user-select: none;
  min-height: 38px;
  text-decoration: none;
  position: relative;
}

.nav-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary);
}

.nav-link:hover svg {
  opacity: 1;
}

.nav-link.active {
  background: var(--accent-tint) !important;
  color: var(--accent-text) !important;
  font-weight: 600;
}

.nav-link.active svg {
  stroke: var(--accent-text);
  opacity: 1;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.nav-badge {
  margin-left: auto;
  background: var(--rose);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-smooth);
}

.user-profile-row:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ----------------- Main Viewport & Header ----------------- */

#mainViewport {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  position: relative;
  background: var(--bg-ground);
}

/* Desktop Top Header */
.viewport-top-header {
  position: sticky;
  top: 0;
  background: var(--bg-ground);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 10;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Hide mobile search bar on desktop */
@media (min-width: 961px) {
  .mobile-search-bar {
    display: none !important;
  }
}

.search-field-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 7px 14px;
  max-width: 440px;
  width: 100%;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.search-field-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-tint);
  background: var(--bg-elevated);
}

.search-field-wrapper svg {
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-input-bare {
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.search-input-bare::placeholder {
  color: var(--text-tertiary);
}

.search-kbd-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  pointer-events: none;
  user-select: none;
}

.header-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Clean Buttons */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-spring);
  border: 1px solid transparent;
  text-decoration: none;
  min-height: 38px;
  white-space: nowrap;
  user-select: none;
}

.btn-action svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

.btn-action:active {
  transform: scale(0.97);
}

.btn-primary-action {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-tint);
}

.btn-primary-action:hover {
  background: var(--accent-hover);
}

.btn-secondary-action {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary-action:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-danger-action {
  background: var(--rose-tint);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--rose-text);
}

.btn-danger-action:hover {
  background: var(--rose);
  color: #ffffff;
}

.btn-icon-square {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-icon-square:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.btn-icon-square svg {
  width: 16px;
  height: 16px;
}

/* ----------------- Filter Chips Rail ----------------- */

.filter-chips-rail {
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-ground);
}

.filter-chips-rail::-webkit-scrollbar {
  display: none;
}

.chip-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 9999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
  user-select: none;
  min-height: 32px;
}

.chip-pill svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
}

.chip-pill:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.chip-pill.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  font-weight: 600;
}

.chip-pill.active svg {
  stroke: #ffffff;
}

/* ----------------- Main View Container ----------------- */

.view-panel {
  display: none;
  padding: 24px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.view-panel.active {
  display: block;
  animation: viewFadeIn var(--duration-normal) var(--ease-spring);
}

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------- Document Gallery & Precision Cards ----------------- */

.gallery-timeline-group {
  margin-bottom: 28px;
}

.gallery-timeline-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.gallery-timeline-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
}

.gallery-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

/* Precision Document Card */
.doc-card-neo {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring), box-shadow var(--duration-fast) var(--ease-spring), border-color var(--duration-fast);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.doc-card-neo:hover {
  transform: translateY(-2px);
  background: var(--card-hover-bg);
  border-color: var(--card-border-hover);
  box-shadow: var(--shadow-md);
}

.doc-card-neo.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.card-media-wrapper {
  height: 148px;
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-media-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-normal) var(--ease-smooth);
}

.doc-card-neo:hover .card-media-wrapper img {
  transform: scale(1.02);
}

/* Beautiful Illustrated Document Folio (for PDFs / text contracts) */
.doc-folio-preview {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-surface));
  position: relative;
}

.doc-folio-nanny {
  background: linear-gradient(145deg, rgba(244, 63, 94, 0.12), var(--bg-surface));
  border-bottom: 2px solid var(--rose);
}

.doc-folio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-folio-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-overlay);
  color: var(--text-secondary);
}

.doc-folio-nanny .doc-folio-badge {
  background: var(--rose-tint);
  color: var(--rose-text);
}

.doc-folio-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-top: 8px;
}

.doc-folio-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.doc-folio-line {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  width: 85%;
}

.doc-folio-line:nth-child(2) {
  width: 65%;
}

.doc-folio-footer {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
}

.card-star-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
  z-index: 2;
}

.card-star-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
}

.card-star-btn.active {
  color: var(--gold-text);
  background: rgba(0, 0, 0, 0.65);
}

.card-star-btn svg {
  width: 15px;
  height: 15px;
}

.card-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-smooth);
  z-index: 2;
}

.doc-card-neo:hover .card-checkbox,
.doc-card-neo.selected .card-checkbox,
body.select-mode .card-checkbox {
  opacity: 1;
}

.card-body-neo {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.card-title-neo {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.card-pill-tag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.card-amount-neo {
  font-weight: 700;
  color: var(--emerald-text);
  font-size: 0.84rem;
}

/* ----------------- Expiries & Warranties View ----------------- */

.expiry-timeline-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.expiry-row-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.expiry-row-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.expiry-row-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.expiry-row-title {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expiry-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pill.expired {
  background: var(--rose-tint);
  color: var(--rose-text);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.status-pill.urgent {
  background: var(--amber-tint);
  color: var(--amber-text);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-pill.valid {
  background: var(--emerald-tint);
  color: var(--emerald-text);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ----------------- Sammy's Nanny Hub View ----------------- */

.nanny-hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 14px;
}

@media (max-width: 900px) {
  .nanny-hub-grid {
    grid-template-columns: 1fr;
  }
}

.glass-panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group-neo {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label-neo {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input-neo, .form-select-neo, .form-textarea-neo {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--duration-fast) var(--ease-smooth);
  min-height: 40px;
}

.form-textarea-neo {
  min-height: 75px;
  resize: vertical;
}

.form-input-neo:focus, .form-select-neo:focus, .form-textarea-neo:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

/* ----------------- Spending & Tax Analytics ----------------- */

.analytics-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-tile-neo {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.stat-tile-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-tile-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* ----------------- Bottom Sheet Drawers ----------------- */

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: var(--backdrop-scrim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-smooth);
}

.drawer-scrim.active {
  display: flex;
  opacity: 1;
}

.drawer-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
  width: 100%;
}

@media (min-width: 768px) {
  .drawer-sheet {
    max-width: 620px;
    border-radius: 16px;
    animation: modalPop var(--duration-normal) var(--ease-spring);
  }
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-header-title svg {
  width: 18px;
  height: 18px;
  stroke: var(--accent);
}

.drawer-content {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-grab-bar {
  display: none;
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 10px auto 4px auto;
  flex-shrink: 0;
}

/* ----------------- Floating Toast Notifications ----------------- */

#toastContainer {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast-pill {
  pointer-events: auto;
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  animation: toastSlideDown var(--duration-normal) var(--ease-spring);
}

.toast-pill svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------- Floating Multi-Select Bulk Bar ----------------- */

.floating-bulk-bar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 24px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: transform var(--duration-normal) var(--ease-spring), opacity var(--duration-fast);
  opacity: 0;
  pointer-events: none;
}

.floating-bulk-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   SAMSUNG GALAXY S24 ULTRA (MOBILE BREAKPOINT <= 960px)
   ========================================================================== */

#mobileTopBar {
  display: none;
}

#mobileBottomNav {
  display: none;
}

@media (max-width: 960px) {
  #appShell {
    display: block;
    height: auto;
    overflow: visible;
  }

  #sidebarRail {
    display: none;
  }

  .viewport-top-header {
    display: none;
  }

  #mobileTopBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--bg-ground);
    border-bottom: 1px solid var(--border-subtle);
    padding: 10px 16px;
    z-index: 50;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-brand-box {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mobile-search-bar {
    display: block;
    padding: 8px 16px;
    background: var(--bg-ground);
  }

  #mainViewport {
    padding-bottom: var(--s24-bottom-clearance);
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .view-panel {
    padding: 14px;
  }

  .gallery-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .card-media-wrapper {
    height: 124px;
  }

  .filter-chips-rail {
    padding: 8px 14px;
  }

  /* Fixed Mobile Bottom Navigation Bar */
  #mobileBottomNav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding-bottom: max(var(--safe-bottom), var(--android-nav-height));
    height: calc(var(--bottom-nav-height) + max(var(--safe-bottom), var(--android-nav-height)));
    z-index: 80;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .bottom-nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: var(--bottom-nav-height);
    color: var(--text-tertiary);
    cursor: pointer;
    user-select: none;
    transition: color var(--duration-fast) var(--ease-smooth);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    position: relative;
  }

  .bottom-nav-tab svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
  }

  .bottom-nav-tab span {
    font-size: 0.68rem;
    font-weight: 600;
  }

  .bottom-nav-tab.active {
    color: var(--accent-text);
  }

  .bottom-nav-tab.active svg {
    stroke: var(--accent-text);
  }

  /* Center Scan FAB */
  .bottom-fab-scan {
    position: relative;
    top: -12px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #1d4ed8);
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
    border: 3px solid var(--bg-surface);
    flex: none;
    transition: transform var(--duration-fast) var(--ease-spring);
  }

  .bottom-fab-scan svg {
    width: 22px;
    height: 22px;
    stroke: #ffffff;
  }

  .drawer-scrim {
    align-items: flex-end;
    padding: 0;
  }

  .drawer-sheet {
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    border-bottom: none;
    padding-bottom: max(var(--safe-bottom), 16px);
    animation: drawerSlideUp var(--duration-normal) var(--ease-spring);
  }

  .drawer-grab-bar {
    display: block;
  }

  @keyframes drawerSlideUp {
    from {
      transform: translateY(100%);
    }
    to {
      transform: translateY(0);
    }
  }

  .floating-bulk-bar {
    bottom: calc(var(--bottom-nav-height) + var(--android-nav-height) + 16px);
    width: calc(100% - 32px);
    justify-content: space-between;
  }
}
