:root {
    --primary: #F97316;
    --primary-hover: #EA580C;
    --primary-light: #FFF7ED;
    --primary-soft: #FFEDD5;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --success: #10B981;
    --success-light: #D1FAE5;
    --error: #EF4444;
    --error-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --info: #3B82F6;
    --info-light: #DBEAFE;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --topbar-h: 52px;
    --tabbar-h: 44px;
    --font-heading: 'Rubik', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-body: 'Nunito Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-top: calc(var(--topbar-h) + var(--tabbar-h) + 4px);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ============== TOP BAR ============== */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 200;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.topbar-title svg {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.topbar-search-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.topbar-search-btn:hover {
    background: var(--border-light);
    color: var(--text);
}

/* Search overlay */
.search-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--surface);
    z-index: 300;
    padding: 0.75rem 1rem;
    display: none;
    flex-direction: column;
    gap: 0.75rem;
}

.search-overlay.active {
    display: flex;
}

.search-overlay-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-overlay input {
    flex: 1;
    height: 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0 1rem 0 2.5rem;
    font-size: 0.9rem;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition-fast);
}

.search-overlay input:focus {
    border-color: var(--primary);
}

.search-overlay .cancel-btn {
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-body);
    white-space: nowrap;
}

/* ============== CATEGORY TABS ============== */
.category-tabs-wrapper {
    position: fixed;
    top: var(--topbar-h);
    left: 0; right: 0;
    height: var(--tabbar-h);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 199;
    display: flex;
    align-items: center;
}

.category-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 1rem;
    white-space: nowrap;
    height: 100%;
    align-items: center;
}

.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.9rem;
    border-radius: 40px;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition-fast);
    scroll-snap-align: start;
    border: 1.5px solid transparent;
    background: var(--bg);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.category-tab:hover {
    background: var(--border-light);
    color: var(--text);
}

.category-tab.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(249,115,22,0.25);
}

.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============== MAIN CONTENT ============== */
.main-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 1rem;
}

/* ============== COUPON CARD - Horizontal Layout ============== */
.coupon-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.coupon-card {
    display: flex;
    flex-direction: row;
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition-normal);
    border: 1px solid var(--border);
    position: relative;
    height: auto;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.75rem;
    width: 100%;
    box-sizing: border-box;
}

.coupon-card:hover {
    box-shadow: var(--shadow-md);
}

.coupon-card.expired {
    opacity: 0.55;
    filter: grayscale(0.6);
}

.coupon-card.expired::after {
    content: '已过期';
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

.coupon-card-img {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    overflow: hidden;
    position: relative;
    border-radius: var(--radius-sm);
    align-self: center;
}

.coupon-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.coupon-card-img .no-img {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    padding: 0.5rem;
}

/* Color accent strip on left edge */
.coupon-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    z-index: 1;
}

.coupon-card-body {
    flex: 1;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.coupon-card-category {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.68rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.coupon-card-category .cat-color-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.coupon-card h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.2rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.coupon-card .card-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.coupon-card .card-expire {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.card-expire svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ============== BUTTONS ============== */
.coupon-card .btn-group {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.2rem;
    width: 100%;
}

.coupon-card .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    background: var(--primary);
    color: #fff;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    line-height: 1.2;
}

.coupon-card .btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249,115,22,0.2);
}

.coupon-card .btn:active {
    transform: translateY(0);
}

.coupon-card .btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.coupon-card .btn-outline:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(249,115,22,0.2);
}

.coupon-card .btn svg {
    width: 13px;
    height: 13px;
}

/* ============== INFINITE SCROLL ============== */
.scroll-sentinel {
    width: 100%;
    height: 1px;
}

.load-more-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.load-more-indicator.hidden { display: none; }

.load-more-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============== EMPTY STATE ============== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    opacity: 0.4;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 500;
}

/* ============== MODAL ============== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem 1.75rem;
    text-align: center;
    max-width: 320px;
    width: 85%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--success-light);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.modal-icon svg { width: 28px; height: 28px; }

.modal-content h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.modal-content p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.modal-content .btn {
    background: var(--primary);
    color: #fff;
    padding: 0.55rem 2rem;
    border-radius: 40px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all var(--transition-fast);
}

.modal-content .btn:hover {
    filter: brightness(1.1);
}

/* ============== FOOTER ============== */
.site-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ============== COUPON DETAIL PAGE ============== */
.coupon-detail {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
}

.coupon-detail .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    margin-bottom: 1rem;
    font-weight: 500;
}

.coupon-detail .back-link:hover {
    color: var(--primary);
}

.coupon-detail .back-link svg {
    width: 16px;
    height: 16px;
}

.coupon-detail-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.coupon-detail-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.coupon-detail-card .no-img {
    width: 100%;
    height: 220px;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.coupon-detail-body {
    padding: 1.25rem 1.5rem;
}

.coupon-detail-body .cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    margin-bottom: 0.6rem;
}

.coupon-detail-body h1 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.coupon-detail-body .desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.coupon-detail-body .expire-info {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.coupon-detail-body .expire-info svg {
    width: 14px;
    height: 14px;
}

.coupon-detail-body .btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.coupon-detail-body .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--primary);
    color: #fff;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 700;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
}

.coupon-detail-body .btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.coupon-detail-body .btn svg {
    width: 16px;
    height: 16px;
}

.detail-footer-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 480px) {
    .coupon-card {
        padding: 0.6rem;
        gap: 0.6rem;
    }
    .coupon-card-img {
        width: 80px;
        height: 80px;
    }
    .coupon-card h3 { font-size: 0.85rem; }
    .coupon-card .card-desc { font-size: 0.72rem; }
    .coupon-card .btn { font-size: 0.72rem; padding: 0.35rem 0.6rem; }
    .coupon-detail-card img { height: 180px; }
}

@media (min-width: 481px) and (max-width: 767px) {
    .coupon-card {
        max-width: 100%;
        padding: 0.85rem;
        gap: 0.85rem;
    }
    .coupon-card-img {
        width: 90px;
        height: 90px;
    }
}

@media (min-width: 768px) {
    .coupon-card {
        max-width: 720px;
        margin: 0 auto;
        padding: 1rem;
        gap: 1rem;
    }
    .coupon-card-img {
        width: 100px;
        height: 100px;
    }
}

/* ============== LEGACY SUPPORT for login/category pages ============== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.login-box {
    max-width: 440px;
    margin: 4rem auto;
    background: var(--surface);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-box h2 {
    font-family: var(--font-heading);
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-box form div { margin-bottom: 1rem; }

.login-box label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.login-box input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition-fast);
    outline: none;
}

.login-box input:focus {
    border-color: var(--primary);
}

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash-msg {
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.flash-msg.success { background: var(--success-light); color: #065F46; }
.flash-msg.danger { background: var(--error-light); color: #991B1B; }
.flash-msg.info { background: var(--info-light); color: #1E40AF; }
.flash-msg.warning { background: var(--warning-light); color: #92400E; }

/* Admin panel shared styles */
.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.25rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.25rem;
    text-align: center;
}

.stat-card .stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Table styles */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

table th, table td {
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table th {
    background: var(--border-light);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

table tr:hover td { background: var(--border-light); }

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition-fast);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

.form-group .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
    text-decoration: none;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249,115,22,0.2);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
    text-decoration: none;
    font-family: var(--font-body);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

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

.btn-danger:hover {
    background: #DC2626;
}

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.85rem; }
.alert-info { background: var(--info-light); color: #1E40AF; }
.alert-success { background: var(--success-light); color: #065F46; }
.alert-warning { background: var(--warning-light); color: #92400E; }
.alert-danger { background: var(--error-light); color: #991B1B; }

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition-fast);
    background: var(--surface);
}

.upload-zone:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
