:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --glass: rgba(30, 41, 59, 0.7);
    --border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin-bottom: 3rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-version {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    opacity: 0.7;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.card h3 {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.card .value {
    font-size: 2rem;
    font-weight: 700;
}

main {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.listings {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.section-title {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.listing-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.listing-content-wrap {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.listing-thumb {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.listing-thumb-placeholder {
    width: 120px;
    height: 90px;
    background: var(--bg-dark);
    border-radius: 0.5rem;
    border: 1px dashed var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.listing-item:last-child {
    border-bottom: none;
}

.listing-info h4 {
    font-size: 1.1rem;
}

.listing-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.price {
    font-weight: 700;
    color: var(--accent);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-deal { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.status-normal { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    vertical-align: middle;
    margin-left: 0.5rem;
}

.badge-new { background: #2563eb; color: white; }
.badge-price { background: #f59e0b; color: white; }
.badge-sold { background: #64748b; color: white; }
.badge-top-deal { 
    background: linear-gradient(135deg, #fbbf24, #f59e0b); 
    color: #451a03; 
    border: 1px solid #fcd34d;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.badge-recommended {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
    border: 1px solid #4ade80;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.25);
}

.price-old {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 400;
    margin-right: 0.6rem;
}

.listing-item.inactive {
    opacity: 0.45;
    filter: grayscale(0.7);
    transition: opacity 0.3s;
}

.listing-item.inactive:hover {
    opacity: 0.8;
}

/* Tooltip Styles */
.has-tooltip {
    position: relative;
    cursor: help;
}
.has-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    border: 1px solid var(--border);
    z-index: 10;
    margin-bottom: 5px;
    font-size: 0.75rem;
    font-weight: normal;
    text-transform: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* New UI Elements */
.listings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

#filter-input, .sort-select {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-family: inherit;
}

#filter-input {
    width: 250px;
}

.sort-select {
    cursor: pointer;
    outline: none;
}

.sort-select:focus {
    border-color: var(--primary);
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-full { width: 100%; margin-top: 1rem; }

.targets-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.target-item {
    background: var(--bg-dark);
    padding: 0.8rem;
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.target-info h4 { font-size: 0.9rem; }
.target-info span { font-size: 0.75rem; color: var(--text-muted); }

.delete-btn {
    color: #ef4444;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1rem;
    width: 450px;
    border: 1px solid var(--border);
}

.form-group { margin-bottom: 1.2rem; }
.form-group label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }
.form-group input {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.7rem;
    border-radius: 0.4rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: 2rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

.exchange-rate-header {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    white-space: nowrap;
}

#current-rate {
    color: var(--accent);
    font-weight: 700;
}

@media (max-width: 768px) {
    main { grid-template-columns: 1fr; }
}
