/* =========================================================================
   CANTOR8 DASHBOARD — Mobile-First Instagram-Style
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Minimalist Dark / Monochrome */
    --bg-primary: #000000;
    --bg-secondary: #09090b;
    --bg-card: #09090b;
    --bg-card-hover: #18181b;
    --bg-glass: rgba(0, 0, 0, 0.85);
    --border-glass: #27272a;
    --border-active: #3f3f46;

    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;

    --accent-indigo: #e4e4e7;
    --accent-blue: #3b82f6;
    --accent-cyan: #fafafa;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --accent-pink: #fafafa;
    --accent-purple: #fafafa;

    /* Removed all gradients, replaced with flat solid themes */
    --bg-btn-primary: #fafafa;
    --text-btn-primary: #000000;
    --bg-btn-success: #18181b;
    /* Outlined mostly */
    --bg-btn-danger: #18181b;
    --gradient-bg: none;

    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-glow: none;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --topbar-h: 52px;
    --bottomnav-h: 64px;
}

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

html {
    font-size: 14px;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--gradient-bg);
    pointer-events: none;
    z-index: 0;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

button {
    cursor: pointer;
    font-family: inherit;
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 2px;
}

/* =========================================================================
   APP SHELL
   ========================================================================= */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;
    /* Desktop Layout */
    height: 100vh;
    width: 100%;
    /* Gunakan dynamic viewport (100dvh) untuk Safari/Chrome mobile yang URL bar-nya dinamis */
    height: 100dvh;
}

/* ---- Sidebar Settings ---- */
.sidebar {
    width: 250px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-top {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: pulse-dot 2s infinite;
}

.connection-dot.connected {
    background: var(--accent-green);
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ---- Side Nav ---- */
.side-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 12px;
    gap: 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: left;
    justify-content: flex-start;
    width: 100%;
}

.nav-item .nav-icon {
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.nav-item .nav-label {
    letter-spacing: 0.3px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
}

.nav-item:active {
    transform: scale(0.98);
}

.sidebar-bottom {
    padding: 16px 12px 24px 12px;
    border-top: 1px solid var(--border-glass);
    background: rgba(0, 0, 0, 0.2);
}

/* ---- Page Container ---- */
.page-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

.page {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
}

.page.active {
    display: flex;
}

.page-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: max(40px, env(safe-area-inset-bottom, 24px));
}

@media (min-width: 768px) {
    .page-scroll {
        padding: 24px 32px;
    }
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 800;
}

.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.digital-clock {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

.clock-icon {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.clock-time {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    background-color: var(--accent-green);
    border-radius: 50%;
    animation: pulse-op 1.5s infinite;
}

@keyframes pulse-op {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}

.page-actions {
    display: flex;
    gap: 6px;
}

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
    padding: 8px 14px;
    border-radius: var(--radius-xs);
    border: 1px solid transparent;
    font-weight: 500;
    font-size: 0.8rem;
    transition: all 0.15s ease;
    letter-spacing: 0.3px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--bg-btn-primary);
    color: var(--text-btn-primary);
}

.btn-primary:hover {
    background: #e4e4e7;
}

.btn-success,
.btn-danger,
.btn-ghost {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-success:hover,
.btn-danger:hover,
.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-success:active,
.btn-danger:active,
.btn-ghost:active {
    background: rgba(255, 255, 255, 0.02);
}

.btn-delete {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* =========================================================================
   STATS GRID (Dashboard)
   ========================================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 14px;
    }
}

@media (min-width: 768px) {
    .stats-grid {
        gap: 16px;
    }

    .stat-card {
        padding: 18px 20px;
    }

    .stat-value {
        font-size: 1.6rem;
    }
}

/* =========================================================================
   ANALYTICS GRID (Chart + Top Earners)
   ========================================================================= */
.analytics-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

@media (min-width: 960px) {
    .analytics-grid {
        flex-direction: row;
        align-items: stretch;
    }
    .analytics-grid > .main-col {
        flex: 1;
        min-width: 0; /* prevent overflow */
    }
    .analytics-grid > .earners-col {
        flex: 1;
        min-width: 320px;
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.stat-card:active {
    transform: scale(0.99);
}

.stat-icon {
    font-size: 1.6rem;
    color: var(--text-secondary);
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* =========================================================================
   RUNNING BOTS (Dashboard)
   ========================================================================= */
.running-bots-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    max-height: 250px;
    overflow-y: auto;
}

@media (min-width: 640px) {
    .running-bots-grid {
        grid-template-columns: 1fr 1fr;
        max-height: 350px;
    }
}

.rb-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.rb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.rb-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.rb-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.rb-action {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-family: var(--font-mono);
    line-height: 1.4;
}

.rb-progress-bar {
    width: 100%;
    height: 2px;
    background: var(--border-glass);
    border-radius: 2px;
    overflow: hidden;
}

.rb-progress-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* =========================================================================
   SECTION CARD (generic)
   ========================================================================= */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-glass);
}

.section-header h2 {
    font-size: 0.9rem;
    font-weight: 700;
}

/* ---- Mini Log (dashboard) ---- */
.mini-log {
    max-height: 240px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.7;
    padding: 6px 0;
}

.mini-log .log-line,
.log-body .log-line {
    padding: 2px 14px;
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.log-line:active {
    background: rgba(99, 102, 241, 0.06);
}

.log-time {
    color: var(--text-muted);
    min-width: 54px;
}

.log-account {
    color: var(--accent-indigo);
    min-width: 30px;
}

.log-msg {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-line.level-SUCCESS .log-msg,
.log-line.level-SUCCESS .log-icon {
    color: var(--accent-green);
}

.log-line.level-ERROR .log-msg,
.log-line.level-ERROR .log-icon {
    color: var(--accent-red);
}

.log-line.level-WARNING .log-msg,
.log-line.level-WARNING .log-icon {
    color: var(--accent-yellow);
}

.log-line.level-SWAP .log-msg,
.log-line.level-SWAP .log-icon {
    color: #c084fc;
}

/* =========================================================================
   ACCOUNT LIST (Cards Style)
   ========================================================================= */
.account-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 640px) {
    .account-list {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 960px) {
    .account-list {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.account-list-compact {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.account-row {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.account-row:hover {
    background: var(--bg-card-hover);
}

.account-row-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding-right: 12px;
}

.account-row-balances {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.account-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* --- Account Card (Redesigned) --- */
.account-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 16px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.account-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.account-card:hover {
    border-color: var(--border-active);
}

.account-card:active {
    background: var(--bg-card-hover);
}

/* Running state — subtle animated border */
.account-card.card-running {
    border-color: rgba(16, 185, 129, 0.3);
}

.account-card.card-running::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
}

/* Error state — red tint */
.account-card.card-error {
    border-color: rgba(239, 68, 68, 0.3);
}

.account-card.card-error::before {
    opacity: 1;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.04) 0%, transparent 60%);
}

/* Header */
.acc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.acc-identity {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.acc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.3s;
}

.acc-status-dot.dot-running {
    background: var(--accent-green);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
    animation: pulse-op 1.5s infinite;
}

.acc-status-dot.dot-error {
    background: var(--accent-red);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.acc-name {
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-query-hint {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

/* 2x2 Stat Grid */
.acc-stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 10px 0;
}

.acc-stat-cell {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-xs);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    transition: background 0.2s;
}

.acc-stat-cell:hover {
    background: rgba(255, 255, 255, 0.04);
}

.acc-stat-icon {
    font-size: 1rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.acc-stat-content {
    min-width: 0;
}

.acc-stat-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1;
    margin-top: 1px;
}

/* Meta row (streak + last run) */
.acc-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 8px;
    margin-top: 2px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.acc-meta-row .meta-streak {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-weight: 500;
}

.acc-meta-row .meta-time {
    font-family: var(--font-mono);
    color: var(--text-muted);
}

/* Error message */
.acc-error-msg {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 5px 8px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.12);
    border-radius: var(--radius-xs);
    font-size: 0.68rem;
    color: var(--accent-red);
    font-family: var(--font-mono);
}

/* Actions */
.acc-actions-bar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.badge-idle {
    background: var(--bg-primary);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.badge-running {
    background: var(--bg-primary);
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
}

.badge-completed {
    background: var(--bg-primary);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.badge-error {
    background: var(--bg-primary);
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
}

.pair-badge {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.68rem;
    font-weight: 500;
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

/* Legacy acc-mid kept for compatibility */
.acc-mid {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.bal-base {
    color: var(--accent-cyan);
}

.bal-cc {
    color: var(--accent-yellow);
}

/* Volume Bar */
.vol-bar {
    flex: 1;
}

.vol-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.vol-bar-track {
    height: 3px;
    background: var(--border-glass);
    border-radius: 2px;
    overflow: hidden;
}

.vol-bar-fill {
    height: 100%;
    background: var(--text-primary);
    border-radius: 2px;
    transition: width 0.5s ease;
    position: relative;
}

.acc-actions,
.acc-actions-bar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* =========================================================================
   HISTORY LIST
   ========================================================================= */
.history-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

@media (min-width: 640px) {
    .history-list {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 960px) {
    .history-list {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.hist-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.hist-dir {
    font-weight: 700;
    font-size: 0.88rem;
}

.hist-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.hist-details {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
}

.hist-detail-item {
    display: flex;
    flex-direction: column;
}

.hist-detail-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hist-detail-value {
    font-family: var(--font-mono);
    font-weight: 600;
}

.hist-detail-value.vol {
    color: var(--accent-cyan);
}

.hist-detail-value.price {
    color: var(--accent-yellow);
}

/* =========================================================================
   REWARDS
   ========================================================================= */
.reward-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.reward-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.reward-summary-value {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.2;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.reward-summary-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
}

.reward-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 640px) {
    .reward-list {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 960px) {
    .reward-list {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.reward-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 14px;
    transition: all 0.2s;
}

.reward-card:hover {
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.rw-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.rw-card-name {
    font-weight: 600;
    font-size: 0.92rem;
}

.rw-rank {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.rw-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.rw-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.rw-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.rw-stat-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
}

.rw-reward-bar {
    background: var(--bg-primary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.rw-reward-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.rw-reward-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.rw-reward-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.rw-reward-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.rw-loading {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* =========================================================================
   LOG PANEL (full page)
   ========================================================================= */
.log-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    overflow: hidden;
}

.log-body {
    height: calc(100dvh - var(--topbar-h) - var(--bottomnav-h) - 120px);
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.7;
    padding: 6px 0;
}

.log-filter {
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border-glass);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-sans);
}

/* =========================================================================
   SETTINGS
   ========================================================================= */
.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 14px;
    overflow: hidden;
}

.settings-title {
    padding: 12px 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-secondary);
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.05);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.setting-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.settings-actions {
    padding: 4px 0 16px 0;
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.settings-col {
    display: flex;
    flex-direction: column;
}

@media (min-width: 960px) {
    .settings-grid {
        flex-direction: row;
        align-items: flex-start;
        gap: 24px;
    }
    
    .settings-col {
        flex: 1;
        min-width: 0;
    }
}

@media (min-width: 768px) {
    .settings-group {
        width: 100%;
    }

    .settings-actions {
        width: 100%;
    }
}

/* =========================================================================
   FORMS
   ========================================================================= */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.checkbox-label {
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--text-secondary);
}

.exp-chip-input:checked + .exp-chip {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
    color: var(--text-primary);
    font-weight: 600;
}
.exp-chip {
    display: inline-block;
    padding: 6px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.exp-chip:hover {
    background: var(--bg-card-hover);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.form-select {
    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='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* =========================================================================
   MODAL
   ========================================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
}

/* =========================================================================
   TOAST
   ========================================================================= */
.toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: calc(100% - 32px);
    max-width: 440px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    animation: toast-in 0.3s ease forwards;
    font-size: 0.82rem;
}

.toast.toast-out {
    animation: toast-out 0.25s ease forwards;
}

.toast-success {
    border-left: 3px solid var(--accent-green);
}

.toast-error {
    border-left: 3px solid var(--accent-red);
}

.toast-info {
    border-left: 3px solid var(--accent-blue);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-20px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0)
    }

    to {
        opacity: 0;
        transform: translateY(-20px)
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg)
    }

    to {
        transform: rotate(360deg)
    }
}

/* =========================================================================
   EMPTY STATE
   ========================================================================= */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.empty-state-text {
    font-size: 0.9rem;
    margin-bottom: 14px;
}

/* =========================================================================
   DESKTOP OVERRIDE
   ========================================================================= */
@media (min-width: 768px) {
    .page-header h1 {
        font-size: 1.6rem;
    }

    .modal {
        border-radius: var(--radius);
        max-width: 480px;
    }

    .modal-overlay {
        align-items: center;
    }

    .modal {
        transform: scale(0.95) translateY(10px);
    }

    .modal-overlay.active .modal {
        transform: scale(1) translateY(0);
    }

    .mini-log {
        max-height: 320px;
    }

    .log-body {
        height: calc(100vh - 150px);
    }

    .btn:hover {
        transform: translateY(-1px);
    }

    .stat-card:hover {
        border-color: var(--border-active);
        transform: translateY(-2px);
    }

    .account-card:hover:not(.card-running):not(.card-error) {
        border-color: var(--border-active);
    }
}

@media (min-width: 1200px) {
    html {
        font-size: 15px;
    }
}

/* =========================================================================
   RESPONSIVE HYBRID LAYOUT
   ========================================================================= */
.hidden-desktop {
    display: none !important;
}

.hidden-mobile {
    display: flex;
}

.mobile-topbar {
    display: none;
    height: 60px;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg-glass);
    border-bottom: 1px solid var(--border-glass);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.mobile-bottom-nav {
    display: none;
    height: 60px;
    align-items: stretch;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-glass);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

@media (max-width: 768px) {
    .hidden-mobile {
        display: none !important;
    }

    .hidden-desktop {
        display: flex !important;
    }

    .hide-text-mobile {
        display: none !important;
    }

    .app {
        flex-direction: column;
        padding-top: 60px;
        /* Space for Topbar */
        padding-bottom: 60px;
        /* Space for Bottom Nav */
    }

    .sidebar {
        display: none !important;
    }

    /* Hide entire PC Sidebar */

    .mobile-topbar {
        display: flex;
    }

    .mobile-bottom-nav {
        display: flex;
    }

    /* Fix nav-items explicitly for Bottom Nav */
    .mobile-bottom-nav .nav-item {
        flex: 1;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        font-size: 0.65rem;
        padding: 4px;
        border: none;
    }

    .mobile-bottom-nav .nav-icon {
        font-size: 1.3rem;
        margin-bottom: 2px;
        transition: transform 0.2s;
    }

    .mobile-bottom-nav .nav-item.active {
        background: transparent;
        color: var(--text-primary);
    }

    .mobile-bottom-nav .nav-item.active .nav-icon {
        transform: scale(1.15);
    }

    .page-scroll {
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 24px));
    }
}

/* =========================================================================
   FLOATING ACTION PILL
   ========================================================================= */
.floating-action-pill {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(9, 9, 11, 0.85); /* var(--bg-card) slightly transparent */
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    padding: 6px 8px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 900;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.pill-divider {
    width: 1px;
    height: 18px;
    background: var(--border-glass);
    margin: 0 4px;
}

@media (max-width: 768px) {
    .floating-action-pill {
        bottom: calc(30px + env(safe-area-inset-bottom, 0px));
        width: max-content;
    }
}

/* =========================================================================
   ADMIN PANEL
   ========================================================================= */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

@media (max-width: 640px) {
    .admin-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-stats-grid .stat-card:last-child {
        grid-column: span 2;
    }
}

.admin-user-table tr {
    transition: background 0.15s;
}

.admin-user-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}