:root {
    --primary: #0ea5e9;
    --primary-deep: #0284c7;
    --primary-gradient: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
    --accent: #14b8a6;
    --bg-body: #f0f4f8;
    --bg-mesh: radial-gradient(ellipse 80% 60% at 10% -10%, rgba(14,165,233,.12), transparent 55%),
               radial-gradient(ellipse 60% 50% at 100% 0%, rgba(20,184,166,.10), transparent 50%),
               linear-gradient(180deg, #eef3f8 0%, #f7fafc 40%, #f0f4f8 100%);
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 280px;
    --radius-xl: 22px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.08);
    --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    --chat-pattern: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230ea5e9' fill-opacity='0.035'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

body.app-body {
    font-family: var(--font);
    background: var(--bg-mesh);
    color: var(--text-main);
    letter-spacing: -0.01em;
    min-height: 100vh;
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem 2.25rem;
    min-height: 100vh;
}

.page-title {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
}

.page-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
}

.surface-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.notice-banner {
    background: linear-gradient(90deg, #fffbeb, #ffffff);
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.35rem;
    margin-bottom: 1.75rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.balance-pill {
    background: #fff;
    padding: 10px 12px 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.btn-app {
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    font-weight: 700;
    border-radius: 14px;
    padding: 0.75rem 1.35rem;
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.28);
    transition: transform .2s ease, box-shadow .2s ease;
}
.btn-app:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(14, 165, 233, 0.35);
}

/* Sidebar overrides to match new palette */
.sidebar {
    background: rgba(255,255,255,.92) !important;
    backdrop-filter: blur(14px);
    border-right: 1px solid rgba(15,23,42,.06) !important;
}
.sidebar .nav-link.active {
    background: var(--primary-gradient) !important;
    box-shadow: 0 8px 22px rgba(14, 165, 233, 0.28) !important;
}

/* Mobile sidebar toggle */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-md);
    color: var(--text-main);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.35);
    z-index: 999;
}

@media (max-width: 992px) {
    .mobile-nav-toggle { display: none !important; }
    .sidebar,
    .sidebar-backdrop { display: none !important; }
    .main-content {
        margin-left: 0 !important;
        padding: 1rem 1rem calc(88px + env(safe-area-inset-bottom, 0px)) !important;
    }
    body.app-body { padding-bottom: 0; }
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.06);
    justify-content: space-around;
    align-items: stretch;
}
.mobile-bottom-nav .mb-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    border-radius: 14px;
    position: relative;
    transition: color .15s ease, background .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.mobile-bottom-nav .mb-item i {
    font-size: 1.15rem;
    line-height: 1;
}
.mobile-bottom-nav .mb-item.active {
    color: #0284c7;
    background: rgba(14, 165, 233, 0.1);
}
.mobile-bottom-nav .mb-dot {
    position: absolute;
    top: 6px;
    right: calc(50% - 16px);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    display: none;
    box-shadow: 0 0 0 2px #fff;
}
.mobile-bottom-nav .mb-dot.on { display: block; }

/* Telegram float */
.tg-float {
    position: fixed;
    right: 22px;
    bottom: 110px;
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, #2AABEE, #229ED9);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    z-index: 99999;
    box-shadow: 0 12px 30px rgba(34, 158, 217, .42);
    animation: tg-pulse 2s infinite;
    transition: transform .2s ease, box-shadow .2s ease;
}
.tg-float:hover {
    transform: translateY(-3px) scale(1.04);
    color: #fff;
    box-shadow: 0 18px 40px rgba(34, 158, 217, .55);
}
.tg-float svg { width: 28px; height: 28px; }
.tg-float-tip {
    position: absolute;
    right: 70px;
    white-space: nowrap;
    background: #0f172a;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(6px);
    transition: .2s ease;
}
.tg-float:hover .tg-float-tip {
    opacity: 1;
    transform: translateX(0);
}
@keyframes tg-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34,158,217,.55); }
    70% { box-shadow: 0 0 0 18px rgba(34,158,217,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,158,217,0); }
}

@media (max-width: 992px) {
    .mobile-bottom-nav { display: flex; }
    .tg-float {
        right: 14px;
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 768px) {
    .tg-float { width: 52px; height: 52px; right: 14px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
    .tg-float-tip { display: none; }
}

/* ===== Chat (frontend + reusable) ===== */
.chat-shell {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    flex: 1;
    min-height: 0;
}
.chat-topbar {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    box-shadow: 0 6px 16px rgba(14,165,233,.3);
}
.chat-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #16a34a;
    font-weight: 700;
}
.chat-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,.2);
}
.chat-stream {
    flex: 1;
    overflow-y: auto;
    padding: 1.35rem 1.25rem;
    background-color: #f4f8fb;
    background-image: var(--chat-pattern);
    scroll-behavior: smooth;
}
.chat-day {
    text-align: center;
    margin: 0.5rem 0 1rem;
}
.chat-day span {
    display: inline-block;
    background: rgba(15,23,42,.06);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}
.msg {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
    max-width: 100%;
    animation: msg-in .25s ease;
}
.msg.mine { flex-direction: row-reverse; }
.msg-face {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
}
.msg.them .msg-face { background: #0ea5e9; }
.msg.mine .msg-face { background: #334155; }
.msg-bubble {
    max-width: min(72%, 520px);
    padding: 0.8rem 1rem;
    border-radius: 18px;
    font-size: 0.94rem;
    font-weight: 500;
    line-height: 1.55;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(15,23,42,.05);
}
.msg.them .msg-bubble {
    background: #fff;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 6px;
}
.msg.mine .msg-bubble {
    background: var(--primary-gradient);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.msg-meta {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    opacity: .7;
}
.msg.mine .msg-meta { text-align: right; color: rgba(255,255,255,.85); }
.msg.them .msg-meta { color: var(--text-muted); }
.chat-composer {
    padding: 1rem 1.15rem;
    border-top: 1px solid var(--border-color);
    background: #fff;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.chat-composer textarea {
    flex: 1;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    background: #f8fafc;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
}
.chat-composer textarea:focus {
    outline: none;
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(14,165,233,.12);
}
.chat-send {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 14px;
    background: var(--primary-gradient);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(14,165,233,.3);
}
.chat-send:hover { filter: brightness(1.05); }
.chat-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 1.15rem 0.85rem;
    background: #fff;
    border-top: 1px dashed var(--border-color);
}
.chat-quick button {
    border: 1px solid var(--border-color);
    background: #f8fafc;
    color: var(--text-muted);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
}
.chat-quick button:hover {
    border-color: var(--primary);
    color: var(--primary-deep);
    background: #f0f9ff;
}

.scroll-panel {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.scroll-panel::-webkit-scrollbar { width: 6px; }
.scroll-panel::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.recharge-history-scroll {
    max-height: 148px; /* 约显示 2 条 */
}
.orders-scroll {
    max-height: calc(100vh - 220px);
}
.admin-table-scroll {
    max-height: calc(100vh - 240px);
}

/* Landing polish helpers */
.landing-nav {
    background: rgba(255,255,255,.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(15,23,42,.05);
}
.landing-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--bg-mesh);
    position: relative;
    overflow: hidden;
}
.landing-brand {
    font-weight: 800;
    font-size: 1.45rem;
    letter-spacing: -0.04em;
    color: var(--text-main);
}
.landing-title {
    font-size: clamp(2.4rem, 5vw, 3.8rem);
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 1.08;
    margin-bottom: 1.1rem;
}
.landing-sub {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 34rem;
    margin-bottom: 1.75rem;
}
.auth-panel {
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(15,23,42,.06);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}
