/* ── BASE / RESET ─────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

/* ── MODULE 1: COVER ELEMENT ──────────────────────── */
.cover-element {
    position: fixed;
    top: 12px;
    right: 335px;
    width: 200px;
    height: 38px;
    background: #15191d;
    z-index: 2147483647;
    pointer-events: none;
    border-radius: 2px;
}

/* ── MODULE 2: OVERLAY PANEL (Portfolio + Cash) ───── */
.overlay-panel {
    position: fixed;
    top: 19px;
    right: 368px;
    z-index: 2147483648;
    pointer-events: none;
    user-select: none;
    font-family: system-ui, sans-serif;
    font-size: 15.5px;
    font-weight: 600;
    color: #22c55e;
    background: transparent;
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.panel-value-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.panel-label {
    color: #899cb2;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.panel-value {
    color: #22c55e;
    font-size: inherit;
    font-weight: 600;
    transition: color 0.2s ease;
}

.panel-value.flash {
    color: #22c55e;
}

/* ── MODULE 3: STATUS BAR ─────────────────────────── */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 32px;
    background: #161b22;
    border-top: 1px solid #21262d;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 16px;
    z-index: 999999;
    font-size: 12px;
    color: #8b949e;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #484f58;
    transition: background 0.3s ease;
}

.status-dot.active {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.status-dot.warning {
    background: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.status-dot.danger {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

/* ── MODULE 4: CONTROL PANEL ──────────────────────── */
.control-panel {
    position: fixed;
    bottom: 44px;
    right: 16px;
    width: 280px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 12px;
    z-index: 999998;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.control-panel.minimized .controls-body {
    display: none;
}

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1c2128;
    border-bottom: 1px solid #21262d;
}

.control-title {
    font-size: 13px;
    font-weight: 600;
    color: #e6edf3;
    letter-spacing: 0.3px;
}

.toggle-btn {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.toggle-btn:hover {
    background: #21262d;
    color: #e6edf3;
}

.controls-body {
    padding: 8px 0;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    font-size: 12.5px;
    color: #8b949e;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    user-select: none;
}

.key-row:hover {
    background: #1c2128;
    color: #e6edf3;
}

.key-row:active {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.key-row.active-key {
    background: rgba(34, 197, 94, 0.08);
    color: #22c55e;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    font-family: 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 600;
    color: #e6edf3;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    box-shadow: 0 1px 0 #21262d;
}

/* ── MODULE 5: TRADE LOG ──────────────────────────── */
.trade-log {
    position: fixed;
    bottom: 44px;
    left: 16px;
    width: 340px;
    max-height: 300px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 12px;
    z-index: 999998;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1c2128;
    border-bottom: 1px solid #21262d;
    flex-shrink: 0;
}

.log-title {
    font-size: 13px;
    font-weight: 600;
    color: #e6edf3;
    letter-spacing: 0.3px;
}

.clear-btn {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
}

.clear-btn:hover {
    background: #21262d;
    color: #ef4444;
}

.log-entries {
    padding: 8px 0;
    overflow-y: auto;
    max-height: 250px;
    scrollbar-width: thin;
    scrollbar-color: #30363d #161b22;
}

.log-entries::-webkit-scrollbar {
    width: 6px;
}

.log-entries::-webkit-scrollbar-track {
    background: #161b22;
}

.log-entries::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 3px;
}

.log-entry {
    padding: 4px 14px;
    font-size: 11.5px;
    font-family: 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
    line-height: 1.5;
    color: #8b949e;
    border-left: 2px solid transparent;
    animation: fadeIn 0.2s ease;
}

.log-entry.buy {
    color: #22c55e;
    border-left-color: #22c55e;
}

.log-entry.sell {
    color: #ef4444;
    border-left-color: #ef4444;
}

.log-entry.info {
    color: #58a6ff;
    border-left-color: #58a6ff;
}

.log-entry.warn {
    color: #f59e0b;
    border-left-color: #f59e0b;
}

.log-entry .timestamp {
    color: #484f58;
    margin-right: 8px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── MODULE 6: TOAST NOTIFICATIONS ────────────────── */
.toast-container {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 2147483649;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #1c2128;
    border: 1px solid #21262d;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: #e6edf3;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s ease forwards;
    min-width: 220px;
    pointer-events: auto;
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast.success {
    border-left: 3px solid #22c55e;
}

.toast.success .toast-icon::before { content: '✓'; color: #22c55e; }

.toast.error {
    border-left: 3px solid #ef4444;
}

.toast.error .toast-icon::before { content: '✕'; color: #ef4444; }

.toast.warning {
    border-left: 3px solid #f59e0b;
}

.toast.warning .toast-icon::before { content: '⚠'; color: #f59e0b; }

.toast.info {
    border-left: 3px solid #58a6ff;
}

.toast.info .toast-icon::before { content: 'ℹ'; color: #58a6ff; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── MODULE 7: SETTINGS MODAL ─────────────────────── */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2147483650;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.settings-modal {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 14px;
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #21262d;
    font-size: 16px;
    font-weight: 600;
    color: #e6edf3;
}

.close-btn {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.close-btn:hover {
    background: #21262d;
    color: #e6edf3;
}

.settings-body {
    padding: 16px 20px;
}

.setting-group {
    margin-bottom: 16px;
}

.setting-group > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #e6edf3;
    margin-bottom: 8px;
}

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

.setting-label {
    font-size: 12px;
    color: #8b949e;
}

.setting-input {
    width: 100px;
    padding: 6px 10px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 13px;
    font-family: 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
    outline: none;
    transition: border-color 0.2s ease;
}

.setting-input:focus {
    border-color: #58a6ff;
}

.setting-color-input {
    width: 100%;
    height: 36px;
    padding: 2px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    cursor: pointer;
}

.settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #21262d;
}

.btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

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

.btn-primary {
    background: #238636;
    color: #fff;
}

.btn-primary:hover {
    background: #2ea043;
}

.btn-secondary {
    background: #21262d;
    color: #c9d1d9;
}

.btn-secondary:hover {
    background: #30363d;
}

/* ── PULSE ANIMATION FOR ACTIVE TRADES ────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-dot.active {
    animation: pulse 2s ease-in-out infinite;
}

/* ── KEY PRESS VISUAL FEEDBACK ────────────────────── */
.key-flash {
    animation: keyFlash 0.4s ease;
}

@keyframes keyFlash {
    0% { background: rgba(34, 197, 94, 0.2); }
    100% { background: transparent; }
}

/* ── RESPONSIVE: TABLET (<=768px) ─────────────────── */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
    }

    .cover-element {
        top: 8px;
        right: 10px;
        width: 160px;
        height: 32px;
    }

    .overlay-panel {
        top: 10px;
        right: 16px;
        font-size: 14px;
        gap: 20px;
    }

    .control-panel {
        bottom: 40px;
        right: 10px;
        left: 10px;
        width: auto;
    }

    .trade-log {
        bottom: auto;
        top: 60px;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: 200px;
    }

    .status-bar {
        gap: 16px;
        padding: 0 10px;
        font-size: 11px;
    }

    .toast-container {
        top: 60px;
        right: 10px;
        left: 10px;
    }

    .toast {
        min-width: unset;
        font-size: 12px;
    }

    .settings-modal {
        width: calc(100vw - 32px);
        max-height: 85vh;
        border-radius: 12px;
    }

    .key-row {
        padding: 10px 14px;
    }
}

/* ── RESPONSIVE: MOBILE (<=480px) ─────────────────── */
@media (max-width: 480px) {
    .cover-element {
        display: none;
    }

    .overlay-panel {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        padding: 14px 16px;
        background: #161b22;
        border-bottom: 1px solid #21262d;
        gap: 0;
        justify-content: space-around;
        pointer-events: auto;
        font-size: 15px;
    }

    .panel-value-group {
        align-items: center;
    }

    .panel-label {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .control-panel {
        position: relative;
        bottom: auto;
        right: auto;
        left: auto;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        margin-top: 1px;
    }

    .control-header {
        padding: 12px 16px;
    }

    .key-row {
        padding: 12px 16px;
        font-size: 13px;
        gap: 14px;
    }

    kbd {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
        border-radius: 8px;
    }

    .trade-log {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        width: 100%;
        max-height: 220px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
        margin-top: 1px;
    }

    .log-entries {
        max-height: 170px;
    }

    .log-entry {
        font-size: 11px;
        padding: 5px 16px;
        word-break: break-word;
    }

    .status-bar {
        position: relative;
        height: auto;
        padding: 10px 16px;
        gap: 12px;
        flex-wrap: wrap;
        font-size: 11px;
        margin-top: 1px;
    }

    .toast-container {
        top: auto;
        bottom: 10px;
        left: 10px;
        right: 10px;
    }

    .toast {
        min-width: unset;
        width: 100%;
        font-size: 13px;
        padding: 12px 16px;
    }

    .settings-modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
    }

    .settings-overlay {
        align-items: flex-end;
    }

    .setting-input {
        width: 90px;
    }

    .settings-actions {
        flex-direction: column;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}
