/* ══════════════════════════════════════════════════════
   CRM Bot Mini App — Main Styles
   Vazirmatn | Dark/Light | Modern glassmorphism
   ══════════════════════════════════════════════════════ */

/* ── Telegram Theme Mapping ─────────────────────────── */
:root {
    --tg-bg:            var(--tg-theme-bg-color, #0f0f14);
    --tg-secondary-bg:  var(--tg-theme-secondary-bg-color, #1a1a24);
    --tg-text:          var(--tg-theme-text-color, #e8e8f0);
    --tg-hint:          var(--tg-theme-hint-color, #6b6b7e);
    --tg-link:          var(--tg-theme-link-color, #7c6af5);
    --tg-button:        var(--tg-theme-button-color, #7c6af5);
    --tg-button-text:   var(--tg-theme-button-text-color, #ffffff);

    /* Design tokens */
    --radius-sm:   10px;
    --radius-md:   16px;
    --radius-lg:   22px;
    --radius-xl:   28px;
    --radius-full: 999px;

    --gap-xs: 6px;
    --gap-sm: 10px;
    --gap-md: 16px;
    --gap-lg: 22px;
    --gap-xl: 30px;

    --font:   'Vazirmatn', system-ui, sans-serif;

    /* Dark theme defaults */
    --bg:           #0f0f14;
    --surface:      #1a1a24;
    --surface-2:    #22222f;
    --surface-3:    #2a2a3a;
    --border:       rgba(255,255,255,0.06);
    --border-strong:rgba(255,255,255,0.12);
    --text-primary: #e8e8f0;
    --text-secondary:#9898ae;
    --text-muted:   #5a5a70;
    --accent:       #7c6af5;
    --accent-2:     #5b9cf6;
    --accent-3:     #f56b6b;
    --accent-4:     #4fd1a0;
    --accent-glow:  rgba(124,106,245,0.25);
    --success:      #4fd1a0;
    --warning:      #f5b64f;
    --danger:       #f56b6b;
    --info:         #5b9cf6;

    --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
    --shadow-md:  0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
    --shadow-accent: 0 4px 24px rgba(124,106,245,0.3);

    --glass-bg:    rgba(26,26,36,0.7);
    --glass-blur:  blur(16px);

    --topbar-h: 56px;
    --nav-h:    68px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Light Theme Override ───────────────────────────── */
body.tg-light {
    --bg:           #f0f0f6;
    --surface:      #ffffff;
    --surface-2:    #f5f5fa;
    --surface-3:    #eaeaf2;
    --border:       rgba(0,0,0,0.06);
    --border-strong:rgba(0,0,0,0.12);
    --text-primary: #1a1a2e;
    --text-secondary:#5a5a72;
    --text-muted:   #9898ae;
    --accent:       #6454e0;
    --accent-glow:  rgba(100,84,224,0.15);
    --success:      #38b48a;
    --warning:      #e0a020;
    --danger:       #e04444;
    --info:         #3a7ee0;

    --shadow-sm:  0 2px 8px rgba(0,0,0,0.06);
    --shadow-md:  0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg:  0 8px 40px rgba(0,0,0,0.1);
    --shadow-accent: 0 4px 24px rgba(100,84,224,0.2);

    --glass-bg:    rgba(255,255,255,0.75);
}

/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    direction: rtl;
    transition: background 0.3s, color 0.3s;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 0; height: 0; }

/* ── App Shell ──────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* ── Top Bar ────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    height: var(--topbar-h);
    padding-top: env(safe-area-inset-top, 0px);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
    padding: 0 var(--gap-md);
    height: 100%;
}

.topbar-title {
    flex: 1;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.topbar-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.back-btn:active { transform: scale(0.92); background: var(--surface-3); }

/* ── Page Container ─────────────────────────────────── */
.page-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ── Bottom Nav ─────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
    height: calc(var(--nav-h) + var(--safe-bottom));
}

.nav-admin, .nav-expert {
    display: flex;
    height: var(--nav-h);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    padding: 8px 0;
}

.nav-item .nav-icon {
    font-size: 20px;
    line-height: 1;
    transition: all 0.25s;
    display: block;
}

.nav-item .nav-label {
    font-size: 10px;
    font-weight: 500;
    transition: all 0.25s;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active .nav-icon {
    transform: scale(1.15) translateY(-1px);
    filter: drop-shadow(0 0 8px var(--accent));
}

.nav-item::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

.nav-item.active::before { width: 28px; }

/* ── Page ───────────────────────────────────────────── */
.page {
    min-height: 100%;
    padding: var(--gap-md);
    animation: pageEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pageEnter {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Cards ──────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s;
}

.card-header {
    padding: var(--gap-md) var(--gap-md) var(--gap-sm);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--gap-sm);
}

.card-body { padding: var(--gap-md); }
.card-footer {
    padding: var(--gap-sm) var(--gap-md) var(--gap-md);
    border-top: 1px solid var(--border);
}

.card-pressable {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.card-pressable:active { transform: scale(0.98); opacity: 0.85; }

/* ── List Item ──────────────────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    gap: var(--gap-md);
    padding: 14px var(--gap-md);
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.list-item:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 56px;
    left: 0;
    height: 1px;
    background: var(--border);
}

.list-item:active { background: var(--surface-2); }

.list-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    font-weight: 700;
}

.list-content {
    flex: 1;
    min-width: 0;
}

.list-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.list-chevron {
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Stat Grid ──────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-sm);
}

.stat-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: var(--gap-md);
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-sm);
}

.stat-card.accent-1 { border-color: rgba(124,106,245,0.25); }
.stat-card.accent-2 { border-color: rgba(79,209,160,0.25); }
.stat-card.accent-3 { border-color: rgba(245,107,107,0.25); }
.stat-card.accent-4 { border-color: rgba(91,156,246,0.25); }
.stat-card.accent-5 { border-color: rgba(245,182,79,0.25); }

.stat-icon {
    font-size: 22px;
    line-height: 1;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1;
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    user-select: none;
}

.btn:active { transform: scale(0.94); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 12px 22px;
    font-size: 14px;
    box-shadow: var(--shadow-accent);
}

.btn-primary:hover { filter: brightness(1.1); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 18px;
    font-size: 13px;
}

.btn-danger {
    background: rgba(245,107,107,0.15);
    color: var(--danger);
    border: 1px solid rgba(245,107,107,0.2);
    padding: 10px 18px;
    font-size: 13px;
}

.btn-success {
    background: rgba(79,209,160,0.15);
    color: var(--success);
    border: 1px solid rgba(79,209,160,0.2);
    padding: 10px 18px;
    font-size: 13px;
}

.btn-full { width: 100%; }

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-md);
    font-size: 16px;
}

/* ── Badge ──────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.badge-pending   { background: rgba(245,182,79,0.15);  color: var(--warning); }
.badge-active    { background: rgba(79,209,160,0.15);  color: var(--success); }
.badge-inactive  { background: rgba(245,107,107,0.12); color: var(--danger); }
.badge-success   { background: rgba(79,209,160,0.15);  color: var(--success); }
.badge-danger    { background: rgba(245,107,107,0.12); color: var(--danger); }
.badge-info      { background: rgba(91,156,246,0.15);  color: var(--info); }
.badge-neutral   { background: var(--surface-2);       color: var(--text-secondary); }

/* ── Form Elements ──────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: var(--gap-md);
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: none;
}

.form-input {
    width: 100%;
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
    direction: rtl;
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b7e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
}

textarea.form-input {
    resize: none;
    min-height: 90px;
    line-height: 1.6;
}

/* ── Search Input ───────────────────────────────────── */
.search-wrap {
    position: relative;
}

.search-wrap .search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
    pointer-events: none;
}

.search-wrap .form-input {
    padding-right: 40px;
}

/* ── Section Header ─────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--gap-sm);
    padding: 0 2px;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.section-action {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
}

/* ── Empty State ────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px var(--gap-lg);
    text-align: center;
    gap: 12px;
}

.empty-icon {
    font-size: 48px;
    opacity: 0.3;
    filter: grayscale(1);
}

.empty-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary);
}

.empty-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
}

/* ── Loading ────────────────────────────────────────── */
.loading-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    flex-direction: column;
    gap: 12px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Skeleton ───────────────────────────────────────── */
.skeleton {
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    animation: shimmer 1.5s infinite;
    background-size: 200% 100%;
    background-image: linear-gradient(
        90deg,
        var(--surface-2) 25%,
        var(--surface-3) 37%,
        var(--surface-2) 63%
    );
}

@keyframes shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: -100% 50%; }
}

/* ── Divider ────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: var(--gap-md) 0;
}

/* ── Chip Filter ────────────────────────────────────── */
.chip-scroll {
    display: flex;
    gap: var(--gap-xs);
    overflow-x: auto;
    padding: 2px 0 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.chip-scroll::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-accent);
}

.chip:active { transform: scale(0.95); }

/* ── Info Row ───────────────────────────────────────── */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: var(--gap-md);
}

.info-row:last-child { border-bottom: none; }

.info-label {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.info-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    word-break: break-all;
}

/* ── Pagination ─────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--gap-sm);
    padding: var(--gap-md) 0;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 600;
    transition: all 0.2s;
}

.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-btn:active:not(:disabled) { transform: scale(0.92); }

.page-info {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Splash Screen ──────────────────────────────────── */
.splash {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s, transform 0.5s;
}

.splash.hiding {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.splash-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap-md);
}

.splash-logo {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.logo-ring {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--accent);
    animation: ringPulse 2s ease-in-out infinite;
}

.ring-1 { width: 80px; height: 80px; opacity: 0.15; }
.ring-2 { width: 60px; height: 60px; opacity: 0.25; animation-delay: 0.3s; }
.ring-3 { width: 40px; height: 40px; opacity: 0.4; animation-delay: 0.6s; }

@keyframes ringPulse {
    0%, 100% { transform: scale(1); opacity: var(--base-opacity, 0.2); }
    50%       { transform: scale(1.08); opacity: calc(var(--base-opacity, 0.2) * 2.5); }
}

.logo-icon {
    font-size: 30px;
    color: var(--accent);
    position: relative;
    z-index: 1;
    animation: logoBob 2s ease-in-out infinite;
}

@keyframes logoBob {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.1); }
}

.splash-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
}

.splash-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: -8px;
}

.splash-loader {
    width: 120px;
    height: 3px;
    background: var(--surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 8px;
}

.loader-bar {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    animation: loadingBar 1.5s ease-in-out forwards;
}

@keyframes loadingBar {
    0%   { width: 0%; }
    40%  { width: 60%; }
    80%  { width: 85%; }
    100% { width: 100%; }
}

/* ── Toast ──────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
    left: var(--gap-md);
    right: var(--gap-md);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.hiding {
    animation: toastOut 0.25s ease forwards;
}

.toast-success { border-color: rgba(79,209,160,0.3); }
.toast-error   { border-color: rgba(245,107,107,0.3); }
.toast-info    { border-color: rgba(91,156,246,0.3); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(12px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-8px); }
}

/* ── Modal Sheet ────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-sheet {
    width: 100%;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-top: 1px solid var(--border);
    max-height: 90vh;
    overflow-y: auto;
    animation: sheetUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding-bottom: calc(var(--safe-bottom) + 20px);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border-strong);
    border-radius: var(--radius-full);
    margin: 12px auto 0;
}

.modal-content { padding: var(--gap-md); }

@keyframes sheetUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Utility ────────────────────────────────────────── */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; }

.flex     { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm   { gap: var(--gap-sm); }
.gap-md   { gap: var(--gap-md); }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }

.mb-sm { margin-bottom: var(--gap-sm); }
.mb-md { margin-bottom: var(--gap-md); }
.mb-lg { margin-bottom: var(--gap-lg); }

.mt-sm { margin-top: var(--gap-sm); }
.mt-md { margin-top: var(--gap-md); }

.text-accent   { color: var(--accent); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }

.fw-bold  { font-weight: 700; }
.fw-medium{ font-weight: 500; }
.fs-sm    { font-size: 12px; }
.fs-lg    { font-size: 16px; }

.card + .card { margin-top: var(--gap-sm); }

.accent-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
}

.success-dot {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.danger-dot {
    background: var(--danger);
    box-shadow: 0 0 6px var(--danger);
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--accent);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Hero banner */
.hero-banner {
    background: linear-gradient(135deg, var(--accent) 0%, #5b4fcf 100%);
    border-radius: var(--radius-lg);
    padding: var(--gap-lg) var(--gap-md);
    position: relative;
    overflow: hidden;
    color: white;
    box-shadow: var(--shadow-accent);
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: -40%;
    left: -20%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}

.hero-banner::after {
    content: '';
    position: absolute;
    bottom: -60%;
    right: -10%;
    width: 250px;
    height: 250px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}

.hero-greeting {
    font-size: 13px;
    opacity: 0.85;
    margin-bottom: 4px;
}

.hero-name {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.hero-rank {
    font-size: 12px;
    opacity: 0.75;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Action buttons row */
.action-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: var(--gap-sm);
}

.action-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px var(--gap-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.action-btn:active { transform: scale(0.92); }

.action-btn .action-icon {
    font-size: 22px;
    line-height: 1;
}

.action-btn .action-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.3;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: var(--gap-md);
}

.tab-btn {
    flex: 1;
    padding: 8px 6px;
    border-radius: calc(var(--radius-md) - 3px);
    border: none;
    background: none;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn.active {
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}



/* ══════════════════════════════════════════════════════
   Extra styles for mini-app
   ══════════════════════════════════════════════════════ */

/* Light theme enhancements */
body.tg-light .hero-banner {
    box-shadow: 0 8px 32px rgba(100,84,224,0.25);
}

body.tg-light .card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body.tg-light .bottom-nav, body.tg-light .topbar {
    background: rgba(255,255,255,0.85);
    border-color: rgba(0,0,0,0.08);
}

body.tg-light .modal-sheet {
    background: #f8f8fc;
}

body.tg-light .form-input {
    background: #ffffff;
    border-color: rgba(0,0,0,0.1);
}

body.tg-light .btn-secondary {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.08);
}

body.tg-light .chip {
    background: #ffffff;
    border-color: rgba(0,0,0,0.1);
}

/* Dark mode specific */
body:not(.tg-light) .drop-zone {
    background: var(--surface);
}

/* Smooth theme transition */
body, .card, .topbar, .bottom-nav, .modal-sheet, .form-input,
.btn, .badge, .chip, .stat-card {
    transition: background 0.3s ease, border-color 0.3s ease, color 0.1s ease;
}