 /* ── BASE & THEME VARIABLES ── */
 :root {
     --bg-primary: #f8f9fa;
     --bg-secondary: #f1f3f5;
     --bg-card: #ffffff;
     --text-primary: #212529;
     --text-secondary: #495057;
     --text-muted: #868e96;
     --accent: #FF6B35;
     --border-color: #e9ecef;
     --border-card: #dee2e6;
     --radius-sm: 8px;
     --radius-md: 12px;
     --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
     --ease: cubic-bezier(0.25, 0.8, 0.25, 1);
 }

 [data-theme="dark"] {
     --bg-primary: #121212;
     --bg-secondary: #000000;
     --bg-card: #1e1e1e;
     --text-primary: #f8f9fa;
     --text-secondary: #ced4da;
     --text-muted: #999999;
     --border-color: #2c2c2c;
     --border-card: #333333;
     --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.2);
 }

 * {
     margin: 0;
     padding: 0;
     box-sizing: border-box;
     -webkit-tap-highlight-color: transparent;
 }

 html,
 body {
     font-family: 'Tajawal', 'Noto Sans Arabic', system-ui, -apple-system, sans-serif;
     background-color: var(--bg-primary);
     color: var(--text-primary);
     line-height: 1.5;
     overflow-x: hidden;
     transition: background-color 0.2s var(--ease);
     height: 100%;
     overflow-y: hidden;
 }

 button {
     cursor: pointer;
     border: none;
     font-family: inherit;
     background: transparent;
     outline: none;
 }

 a {
     text-decoration: none;
     color: inherit;
 }

 #app {
     display: flex;
     flex-direction: column;
     height: 100%;
     width: 100%;
 }

 /* ── MAIN HEADER & FILTERS ── */
 .header {
     position: sticky;
     top: 0;
     z-index: 50;
     background: var(--bg-card);
     border-bottom: 1px solid var(--border-color);
     padding: calc(16px + env(safe-area-inset-top)) 16px 12px 16px;
     display: flex;
     flex-direction: column;
     gap: 12px;
     max-width: 800px;
     width: 100%;
     margin: 0 auto;
 }

 .header-top {
     display: flex;
     justify-content: space-between;
     align-items: center;
     padding: 0 4px;
 }

 .logo-btn {
     display: flex;
     align-items: center;
     gap: 8px;
     cursor: pointer;
 }

 .logo-icon {
     width: 36px;
     height: 36px;
     background: var(--accent);
     border-radius: 8px;
     display: flex;
     align-items: center;
     justify-content: center;
     color: white;
     font-size: 22px;
     font-weight: 800;
 }

 .logo-text {
     display: flex;
     flex-direction: column;
     align-items: flex-start;
     line-height: 1.1;
 }

 .logo-ar {
     font-size: 16px;
     font-weight: 800;
     color: var(--text-primary);
 }

 .logo-en {
     font-size: 10px;
     font-weight: 700;
     color: var(--accent);
     text-transform: none;
     margin-top: 2px;
 }



 .header-actions {
     display: flex;
     align-items: center;
     gap: 10px;
 }

 .search-wrap {
     max-width: 0;
     overflow: hidden;
     transition: max-width 0.25s var(--ease);
 }

 .search-wrap.open {
     max-width: 160px;
 }

 .search-input {
     width: 150px;
     background: var(--bg-secondary);
     border: 1px solid var(--border-color);
     border-radius: 20px;
     padding: 6px 12px;
     font-size: 13px;
     font-family: inherit;
     color: var(--text-primary);
     outline: none;
 }

 .icon-btn {
     width: 36px;
     height: 36px;
     border-radius: 50%;
     background: var(--bg-secondary);
     color: var(--text-secondary);
     display: flex;
     align-items: center;
     justify-content: center;
 }

 .filters-row {
     display: flex;
     gap: 8px;
     overflow-x: auto;
     padding-bottom: 4px;
     scrollbar-width: none;
 }

 .filters-row::-webkit-scrollbar {
     display: none;
 }

 .filter-select {
     background: var(--bg-secondary);
     color: var(--text-secondary);
     border: 1px solid var(--border-color);
     border-radius: 20px;
     padding: 6px 12px 6px 30px;
     font-size: 13px;
     font-weight: 700;
     appearance: none;
     font-family: inherit;
     cursor: pointer;
     outline: none;
     background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" stroke="%23868e96" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>');
     background-repeat: no-repeat;
     background-position: left 8px center;
     background-size: 14px;
 }

 .filter-select.active {
     background-color: var(--accent);
     color: white;
     border-color: var(--accent);
     background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 24 24" fill="none" stroke="%23ffffff" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg>');
 }

 /* ── TABS ── */
 .nav-tabs {
     display: flex;
     background: var(--bg-primary);
     border-bottom: 1px solid var(--border-color);
     position: sticky;
     top: 105px;
     z-index: 40;
     max-width: 800px;
     width: 100%;
     margin: 0 auto;
 }

 .nav-tab {
     flex: 1;
     padding: 12px 0;
     text-align: center;
     color: var(--text-muted);
     font-weight: 700;
     font-size: 15px;
     border-bottom: 3px solid transparent;
     transition: all 0.2s;
 }

 .nav-tab.active {
     color: var(--accent);
     border-bottom-color: var(--accent);
 }

 /* ── VIEWS ── */
 .view-section {
     display: none;
     padding: 0 24px;
     max-width: 800px;
     margin: 0 auto;
     min-height: 50vh;
 }

 .view-section.active {
     display: flex;
     flex-direction: column;
     flex: 1;
     width: 100%;
     overflow-y: auto;
     -webkit-overflow-scrolling: touch;
     padding-top: 40px;
     padding-bottom: 60px;
     animation: fadeIn 0.2s var(--ease);
 }

 @keyframes fadeIn {
     from {
         opacity: 0;
     }

     to {
         opacity: 1;
     }
 }

 /* ── STORES GRID ── */
 .stores-grid {
     display: grid;
     gap: 16px;
     grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
 }

 .store-card {
     background: var(--bg-card);
     border-radius: var(--radius-md);
     box-shadow: var(--shadow-sm);
     border: 1px solid var(--border-card);
     overflow: hidden;
     position: relative;
     display: flex;
     flex-direction: column;
     align-items: center;
     padding: 20px 12px;
     cursor: pointer;
     transition: transform 0.2s;
     text-align: center;
 }

 .store-card:hover {
     transform: translateY(-2px);
 }

 .fav-btn {
     position: absolute;
     top: 8px;
     right: 8px;
     padding: 4px;
     border-radius: 50%;
     color: var(--border-card);
     z-index: 2;
     display: flex;
     align-items: center;
     justify-content: center;
 }

 .fav-btn.is-fav {
     color: #ff3b30;
 }

 .fav-btn svg {
     width: 22px;
     height: 22px;
     fill: currentColor;
 }

 .store-logo-area {
     width: 72px;
     height: 72px;
     background: white;
     border-radius: 50%;
     border: 1px solid var(--border-color);
     display: flex;
     align-items: center;
     justify-content: center;
     overflow: hidden;
     margin-bottom: 12px;
 }


 .store-logo-wrap {
     position: relative;
     width: 72px;
     margin-bottom: 12px;
 }

 .store-logo-wrap .store-logo-area {
     margin-bottom: 0;
 }

 .store-status-dot {
     position: absolute;
     bottom: 6px;
     right: 2px;
     width: 14px;
     height: 14px;
     border-radius: 50%;
     background: #adb5bd;
     z-index: 2;
     border: 2px solid var(--bg-card);
 }

 .store-status-dot.online {
     background: #2ecc71;
 }

 .store-logo {
     width: 100%;
     height: 100%;
     object-fit: contain;
 }



 .store-fallback {
     font-size: 28px;
     font-weight: 800;
     color: var(--accent);
 }

 .store-name {
     font-size: 14px;
     font-weight: 800;
     color: var(--text-primary);
     margin-bottom: 4px;
     width: 100%;
     white-space: nowrap;
     overflow: hidden;
     text-overflow: ellipsis;
 }

 .store-meta {
     font-size: 12px;
     font-weight: 500;
     color: var(--text-muted);
 }


 .store-neighborhood {
     font-size: 11px;
     font-weight: 500;
     color: var(--text-muted);
     opacity: 0.75;
     margin-top: 2px;
 }

 /* ── FOOTER ── */
 .site-footer {
     text-align: center;
     padding: 40px 16px;
     background: var(--bg-card);
     border-top: 1px solid var(--border-color);
     color: var(--text-muted);
     font-size: 13px;
     line-height: 1.8;
     width: calc(100% + 48px);
     margin: 32px -24px 0 -24px;
 }

 .site-footer span {
     display: block;
     font-weight: 700;
     color: var(--text-primary);
     margin-bottom: 6px;
 }

 /* ── NEWSPAPER VIEWER (FLYER MODAL) ── */
 #viewer-modal {
     position: fixed;
     inset: 0;
     background: var(--bg-primary);
     z-index: 100;
     display: none;
     flex-direction: column;
     overflow: hidden;
 }

 #viewer-modal.open {
     display: flex;
 }

 .v-header {
     background: var(--bg-card);
     padding: calc(16px + env(safe-area-inset-top)) 16px 16px 16px;
     border-bottom: 1px solid var(--border-color);
     display: flex;
     justify-content: space-between;
     align-items: flex-start;
     max-width: 800px;
     margin: 0 auto;
     width: 100%;
     flex-shrink: 0;
 }

 .v-header-info {
     display: flex;
     flex-direction: column;
     gap: 4px;
 }

 .v-discount {
     font-size: 14px;
     font-weight: 800;
     color: #ff3b30;
 }

 .v-dates {
     font-size: 13px;
     font-weight: 600;
     color: var(--text-secondary);
 }

 .v-counter {
     font-size: 12px;
     font-weight: 700;
     color: var(--text-muted);
 }

 .v-share-btn {
     color: var(--accent);
     padding: 8px;
     border-radius: 50%;
     background: var(--bg-secondary);
     display: flex;
     align-items: center;
     justify-content: center;
 }

 .v-share-btn svg {
     width: 22px;
     height: 22px;
 }

 .v-content-wrap {
     max-width: 800px;
     margin: 0 auto;
     padding: 16px 16px 120px;
     width: 100%;
     flex: 1;
     overflow-y: auto;
     -webkit-overflow-scrolling: touch;
 }

 .stand-alone-img {
     width: 100%;
     display: flex;
     justify-content: center;
     margin-bottom: 16px;
 }

 .stand-alone-img img {
     width: 100%;
     height: auto;
     max-width: 800px;
     object-fit: contain;
     border-radius: var(--radius-sm);
 }

 .flyer-grid {
     display: grid;
     grid-template-columns: 1fr;
     gap: 16px;
     margin-bottom: 16px;
 }

 @media (min-width: 768px) {
     .flyer-grid {
         grid-template-columns: 1fr 1fr;
         gap: 16px 5px;
     }
 }

 .img-badge {
     position: absolute;
     top: 12px;
     left: 12px;
     background: rgba(0, 0, 0, 0.75);
     color: white;
     font-weight: 800;
     font-size: 12px;
     padding: 4px 10px;
     border-radius: 12px;
     z-index: 10;
     pointer-events: none;
 }

 .img-wrapper {
     position: relative;
     width: 100%;
 }

 .img-wrapper img {
     width: 100%;
     height: auto;
     display: block;
     object-fit: contain;
     border-radius: var(--radius-sm);
     border: 1px solid var(--border-color);
     opacity: 0;
     transition: opacity 220ms ease-out;
 }


 .img-wrapper:not(.loaded) {
     background: var(--border-color);
     border-radius: var(--radius-sm);
     min-height: 180px;
     animation: skeletonPulse 1.2s ease-in-out infinite;
 }

 .img-wrapper.loaded img {
     opacity: 1;
 }

 .frozen-back-btn {
     position: fixed;
     bottom: 24px;
     left: 50%;
     transform: translateX(-50%);
     z-index: 2000;
     background: var(--accent);
     color: white;
     font-weight: 800;
     font-size: 16px;
     padding: 14px 36px;
     border-radius: 50px;
     display: flex;
     align-items: center;
     gap: 8px;
     box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
 }

 .state-msg {
     text-align: center;
     padding: 40px 20px;
     font-size: 15px;
     font-weight: 700;
     color: var(--text-muted);
     grid-column: 1 / -1;
 }


 .skeleton-card {
     pointer-events: none;
 }

 .skeleton-box {
     background: var(--border-color);
     animation: skeletonPulse 1.2s ease-in-out infinite;
 }

 .skeleton-line {
     height: 12px;
     border-radius: 4px;
     background: var(--border-color);
     margin-top: 8px;
     animation: skeletonPulse 1.2s ease-in-out infinite;
 }

 @keyframes skeletonPulse {

     0%,
     100% {
         opacity: 1;
     }

     50% {
         opacity: 0.4;
     }
 }