/* ── Reset & Base ─────────────────────────────────────── */

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

:root {
    --bg: #0f1923;
    --surface: #192337;
    --surface-hover: #1e2d45;
    --border: #243447;
    --text: #e0e0e0;
    --text-secondary: #7a8a9e;
    --accent: #4fc3f7;
    --accent-hover: #39b0e4;
    --positive: #4caf50;
    --negative: #ff4d4d;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --radius: 8px;
    --radius-sm: 4px;
}

html {
    font-size: 14px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
    min-height: 100vh;
}

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

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    display: block;
}

/* ── Nav ──────────────────────────────────────────────── */

#nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-brand {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.nav-brand:hover {
    color: var(--accent-hover);
}

.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-link {
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(79, 195, 247, 0.1);
}

.nav-auth {
    margin-left: auto;
}

.nav-login {
    background: var(--accent);
    color: var(--bg) !important;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius);
}

.nav-login:hover {
    background: var(--accent-hover);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
}

.nav-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

/* ── Layout ───────────────────────────────────────────── */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

/* ── Stats Ribbon (legacy) ────────────────────────────── */

.stats-ribbon {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 22px;
    font-weight: 600;
}

.stat-card .stat-change {
    font-size: 12px;
    margin-top: 2px;
}

/* ── Dashboard Header ─────────────────────────────────── */

.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.dash-title {
    font-size: 20px;
    font-weight: 700;
}

.dash-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Chart Row Stack ──────────────────────────────────── */

.chart-row-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.chart-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    height: 15vh;
    min-height: 100px;
    max-height: 140px;
    overflow: hidden;
}

.chart-row-info {
    padding: 16px 24px;
    min-width: 200px;
    flex-shrink: 0;
}

.chart-row-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--mono);
}

.chart-row-label {
    font-size: 12px;
    color: var(--accent);
    margin-top: 2px;
}

.chart-row-chart {
    flex: 1;
    height: 100%;
    min-width: 0;
}

.chart-row-tf {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    flex-shrink: 0;
}

.tf-btn-sm {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.tf-btn-sm:hover {
    color: var(--text);
    border-color: var(--text-secondary);
}

.tf-btn-sm.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

/* ── Hero Chart Section (item detail page) ────────────── */

.hero-chart-section {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.hero-chart-stats {
    display: flex;
    gap: 40px;
    padding: 20px 24px 0;
    max-width: 1400px;
    margin: 0 auto;
}

.hero-stat {
    display: flex;
    flex-direction: column;
}

.hero-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-stat-value {
    font-size: 20px;
    font-weight: 700;
    font-family: var(--mono);
    margin-top: 2px;
}

.hero-chart-container {
    height: calc(35vh - 56px);
    min-height: 220px;
    max-height: 400px;
    padding: 0 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.hero-chart-timeframes {
    display: flex;
    gap: 4px;
    padding: 8px 24px 12px;
    max-width: 1400px;
    margin: 0 auto;
}

.tf-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.tf-btn:hover {
    color: var(--text);
    border-color: var(--text-secondary);
}

.tf-btn.active {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

/* ── Top Movers Bar ───────────────────────────────────── */

.movers-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
}

.movers-label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--text-secondary);
}

.movers-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
}

.movers-scroll::-webkit-scrollbar {
    display: none;
}

.mover-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px 6px 6px;
    white-space: nowrap;
    font-size: 12px;
    transition: border-color 0.15s;
    color: var(--text);
}

.mover-chip:hover {
    border-color: var(--accent);
    color: var(--text);
}

.mover-chip img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.mover-chip .mover-pct {
    font-weight: 600;
    margin-left: 4px;
}

/* ── Cards ────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 600;
}

.card-action {
    font-size: 12px;
    color: var(--accent);
}

/* ── Item Table ───────────────────────────────────────── */

.items-table-wrap {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.items-table th:hover {
    color: var(--text);
}

.items-table th.sorted-asc::after {
    content: ' \u25B2';
    font-size: 9px;
}

.items-table th.sorted-desc::after {
    content: ' \u25BC';
    font-size: 9px;
}

.items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 13px;
}

.items-table tr:hover {
    background: var(--surface-hover);
}

.items-table .col-rank {
    color: var(--text-secondary);
    width: 40px;
    text-align: center;
}

.items-table .col-name {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.items-table .col-name img {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.items-table .col-name span {
    font-weight: 500;
}

.items-table .col-price {
    font-family: var(--mono);
    font-weight: 500;
}

.items-table .col-right {
    text-align: right;
}

.items-table a {
    color: inherit;
}

.items-table a:hover {
    color: var(--accent);
}

.positive {
    color: var(--positive);
}

.negative {
    color: var(--negative);
}

/* ── Search / Filters ─────────────────────────────────── */

.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* ── Buttons ──────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: background 0.15s, color 0.15s;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

/* ── Item Detail ──────────────────────────────────────── */

.item-detail-grid {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    margin-bottom: 24px;
    align-items: start;
}

.item-hero-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.item-image-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.item-image-card img {
    width: 200px;
    height: 200px;
    margin: 0 auto 12px;
    object-fit: contain;
}

.item-image-card .item-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.item-stats-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
}

.item-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
}

.item-stat-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.item-stat-row .stat-key {
    color: var(--text-secondary);
}

.item-stat-row .stat-val {
    font-weight: 500;
    font-family: var(--mono);
}

/* ── Inventory ────────────────────────────────────────── */

.inventory-input {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.inventory-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.inventory-item img {
    width: 80px;
    height: 80px;
    margin: 0 auto 8px;
    object-fit: contain;
}

.inventory-item .inv-name {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inventory-item .inv-price {
    font-family: var(--mono);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
}

.inventory-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
    display: flex;
    gap: 40px;
}

.inventory-summary .sum-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inventory-summary .sum-value {
    font-size: 20px;
    font-weight: 600;
    margin-top: 2px;
}

/* ── Trending Cards ───────────────────────────────────── */

.trending-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.trending-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.15s;
}

.trending-card:hover {
    border-color: var(--accent);
}

.trending-card img {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--bg);
}

.trending-card .trend-info {
    flex: 1;
    min-width: 0;
}

.trending-card .trend-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trending-card .trend-price {
    font-family: var(--mono);
    font-size: 13px;
    margin-top: 2px;
}

.trending-card .trend-change {
    font-size: 12px;
}

/* ── Profile ──────────────────────────────────────────── */

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.profile-name {
    font-size: 22px;
    font-weight: 600;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 4px;
}

.profile-section {
    margin-bottom: 24px;
}

.profile-section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

/* ── Privacy Toggle ───────────────────────────────────── */

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-row .toggle-label {
    font-size: 13px;
}

.toggle-row .toggle-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: background 0.2s;
}

.toggle-switch .slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .slider {
    background: var(--accent);
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(18px);
}

/* ── Loading & Error ──────────────────────────────────── */

.loading {
    display: flex;
    justify-content: center;
    padding: 60px 0;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    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); }
}

.error-msg {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* ── Utilities ────────────────────────────────────────── */

.text-secondary {
    color: var(--text-secondary);
}

.text-accent {
    color: var(--accent);
}

.text-mono {
    font-family: var(--mono);
}

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ── Responsive ───────────────────────────────────────── */

@media (max-width: 768px) {
    .nav-inner {
        padding: 0 16px;
        gap: 16px;
    }

    .nav-links {
        gap: 0;
    }

    .nav-link {
        padding: 8px 10px;
        font-size: 12px;
    }

    .container {
        padding: 16px;
    }

    .item-detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-ribbon {
        grid-template-columns: repeat(2, 1fr);
    }

    .inventory-summary {
        flex-wrap: wrap;
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .nav-links {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .stats-ribbon {
        grid-template-columns: 1fr;
    }
}
