:root {
    --bg-main: #2A0F1E;
    --surface: #3E162D;
    --surface-hover: #521D3A;
    --border: #6B274B;
    
    --primary: #E84393;
    --primary-hover: #D63082;
    --secondary: #FD79A8;
    --accent: #00B894;
    
    --text-main: #FDF2F8;
    --text-muted: #FBCFE8;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --transition: 250ms ease;

    --chart-colors: #E84393, #00B894, #FDCB6E, #0984E3, #6C5CE7, #E17055;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    height: 70px;
    background: rgba(42, 15, 30, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.logo span {
    font-weight: 400;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(232, 67, 147, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(232, 67, 147, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-main);
    border-color: var(--border);
}

.btn-outline:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--text-muted);
}

.btn-icon-only {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon-only:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.1);
}

/* Layout */
.app-layout {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Search */
.search-section {
    position: relative;
    max-width: 600px;
    width: 100%;
    margin: 0 auto 1rem;
    z-index: 50;
}

.search-wrap {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    padding-left: 1rem;
    transition: var(--transition);
}

.search-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 67, 147, 0.2);
    background: var(--surface);
}

.search-icon {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

#searchInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    padding: 0.5rem 0;
}

#searchInput::placeholder {
    color: var(--text-muted);
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    overflow: hidden;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-dropdown.active {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.dropdown-item:hover {
    background: var(--surface-hover);
}

.pkg-name { font-weight: 600; }
.pkg-desc { font-size: 0.8rem; color: var(--text-muted); max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}

/* Selected Packages Tags */
.packages-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.pkg-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.pkg-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.pkg-tag button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 20px; height: 20px;
}

.pkg-tag button:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
}

/* Glass Panels */
.glass-panel {
    background: rgba(62, 22, 45, 0.4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.5rem;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

/* Chart Area */
.chart-section {
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.segment-control {
    display: inline-flex;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-md);
    padding: 4px;
}

.segment {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.segment.active {
    background: var(--surface);
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.chart-container {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 350px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(232, 67, 147, 0.15);
}

.stat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.stat-header h3 {
    font-size: 1.1rem;
    margin: 0;
    flex: 1;
}

.stat-color-bar {
    width: 4px;
    height: 24px;
    border-radius: 2px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.stat-item:last-child { margin-bottom: 0; }

.stat-label {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-value {
    font-weight: 600;
    color: var(--text-main);
}

.ts-badge {
    background: rgba(49, 120, 198, 0.2);
    color: #3178c6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid rgba(49, 120, 198, 0.4);
}

/* Empty && Loading */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    background: rgba(0,0,0,0.1);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}

.empty-state svg {
    color: var(--border);
    margin-bottom: 1rem;
}

.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(42, 15, 30, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius-lg);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.toast.show {
    bottom: 2rem;
}

/* Html2Canvas hide elements */
[data-html2canvas-ignore] {
    opacity: 1 !important;
}

@media (max-width: 768px) {
    .app-header { padding: 0 1rem; }
    .header-actions .btn-text { display: none; }
    .app-layout { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
}
