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

:root {
    --accent: #CD412B;
    --accent-hover: #b8351f;
    --accent-light: #fdf0ee;
    --bg: #f5f4f0;
    --bg-card: #fff;
    --bg-sidebar: #fff;
    --border: rgba(0,0,0,0.1);
    --border-med: rgba(0,0,0,0.15);
    --text: #1a1a1a;
    --text-muted: #6b6b6b;
    --text-hint: #999;
    --radius: 8px;
    --radius-lg: 12px;
    --green: #059669;
    --green-bg: #d1fae5;
    --yellow: #92400e;
    --yellow-bg: #fef3c7;
    --red: #991b1b;
    --red-bg: #fee2e2;
    --blue: #1d4ed8;
    --blue-bg: #dbeafe;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; background: var(--bg); color: var(--text); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Layout ─────────────────────────────────────────────── */
#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────── */
.nav-sidebar { background: var(--bg-sidebar); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.nav-logo { display: flex; align-items: center; gap: 8px; padding: 18px 16px 14px; font-weight: 600; font-size: 15px; border-bottom: 0.5px solid var(--border); }
.nav-logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
nav { padding: 8px; flex: 1; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-hint); padding: 12px 12px 4px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--radius); color: var(--text-muted); font-size: 13px; transition: all .15s; cursor: pointer; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.nav-bottom { padding: 12px; border-top: 0.5px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.user-chip img { width: 24px; height: 24px; border-radius: 50%; }
.btn-logout { width: 100%; padding: 7px; border: 0.5px solid var(--border-med); border-radius: var(--radius); background: transparent; cursor: pointer; font-size: 12px; color: var(--text-muted); }
.btn-logout:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ─── Main ───────────────────────────────────────────────── */
.main-content { padding: 24px 28px; max-width: 1200px; overflow-x: hidden; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 20px; font-weight: 600; }
.page-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; transition: background .15s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: transparent; border: 0.5px solid var(--border-med); border-radius: var(--radius); cursor: pointer; font-size: 13px; color: var(--text); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { padding: 8px 16px; background: #dc2626; color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: 13px; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; background: transparent; border: 0.5px solid var(--border); border-radius: 6px; cursor: pointer; color: var(--text-muted); font-size: 13px; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ─── Stats cards ────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-hint); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-sub { font-size: 11px; color: var(--text-hint); margin-top: 2px; }

/* ─── Filters ────────────────────────────────────────────── */
.filters-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.status-tabs { display: flex; gap: 4px; background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 3px; }
.tab { padding: 5px 12px; border-radius: 6px; border: none; background: transparent; cursor: pointer; font-size: 12px; color: var(--text-muted); transition: all .15s; }
.tab.active { background: var(--accent); color: #fff; }
.search-input { padding: 7px 12px; border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--bg-card); font-size: 13px; width: 220px; }
.search-input:focus { outline: none; border-color: var(--accent); }
.select-input { padding: 7px 10px; border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--bg-card); font-size: 13px; color: var(--text); }

/* ─── Table ──────────────────────────────────────────────── */
.table-wrap { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-hint); font-weight: 600; border-bottom: 0.5px solid var(--border); background: var(--bg); cursor: pointer; user-select: none; white-space: nowrap; }
.table th:hover { color: var(--text); }
.table th.sorted { color: var(--accent); }
.table td { padding: 10px 14px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(0,0,0,0.015); }
.table .cell-name { font-weight: 500; }
.table .cell-mono { font-family: 'SF Mono', SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--text-muted); }
.table .cell-right { text-align: right; }
.table .cell-center { text-align: center; }
.table .cell-actions { display: flex; gap: 4px; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: #f1f0eb; color: #666; }
.badge-rarity { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }

/* ─── Item card (market grid view) ───────────────────────── */
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.item-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 12px; transition: border-color .15s; position: relative; }
.item-card:hover { border-color: var(--border-med); }
.item-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.item-card-check { position: absolute; top: 8px; left: 8px; width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }
.item-card-img { width: 100%; height: 140px; object-fit: contain; border-radius: 6px; background: #f8f7f4; margin-bottom: 8px; display: block; }
.item-card-name { font-size: 13px; font-weight: 500; margin-bottom: 4px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-card-meta { font-size: 11px; color: var(--text-hint); display: flex; justify-content: space-between; align-items: center; }
.item-card-price { font-weight: 600; color: var(--text); font-size: 13px; }
.item-card-price.no-price { color: var(--text-hint); font-weight: 400; }
.item-card-actions { display: flex; gap: 4px; margin-top: 8px; }
.item-card-actions .btn-sm { flex: 1; justify-content: center; }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 20px; justify-content: center; align-items: center; }
.page-btn { padding: 6px 12px; border: 0.5px solid var(--border); border-radius: var(--radius); background: var(--bg-card); cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 12px; color: var(--text-muted); }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); padding: 24px; min-width: 380px; max-width: 560px; width: 90%; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal-text { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-close { position: absolute; top: 16px; right: 16px; background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }

/* ─── Form ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-input { padding: 8px 10px; border: 0.5px solid var(--border-med); border-radius: var(--radius); font-size: 13px; background: var(--bg); color: var(--text); }
.form-input:focus { outline: none; border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--text-hint); }

/* ─── Detail panel (profile view) ────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.detail-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.detail-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 0.5px solid var(--border); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-muted); }
.detail-row .value { font-weight: 500; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast { position: fixed; bottom: 24px; right: 24px; padding: 10px 18px; border-radius: var(--radius); background: #1a1a1a; color: #fff; font-size: 13px; z-index: 9999; opacity: 0; transform: translateY(8px); transition: all .25s; pointer-events: none; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.toast-success { background: #065f46; }
#toast.toast-error { background: #991b1b; }

/* ─── Loading ────────────────────────────────────────────── */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.spinner { display: inline-block; width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.3; }
.empty-state-text { font-size: 14px; }

/* ─── Login ──────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 16px; padding: 40px; max-width: 380px; width: 90%; text-align: center; }
.login-logo { margin-bottom: 28px; }
.login-logo-icon { width: 48px; height: 48px; background: var(--accent); border-radius: 12px; margin: 0 auto 12px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); }
.login-error { background: var(--red-bg); color: var(--red); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.btn-discord { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 24px; background: #5865F2; color: #fff; border-radius: var(--radius); font-size: 14px; font-weight: 500; transition: background .15s; }
.btn-discord:hover { background: #4752c4; }

/* ─── Page sections ──────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    #app { grid-template-columns: 1fr; }
    .nav-sidebar { display: none; }
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .items-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
