/* ── Reset & Variables ─────────────────────────── */

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

:root {
    --sidebar-w: 250px;
    --sidebar-bg: #0a0a0f;
    --sidebar-hover: #16161f;
    --sidebar-active: rgba(201,168,76,.12);
    --gold: #c9a84c;
    --gold-light: #dcc06a;
    --gold-dark: #a8893e;
    --gold-glow: rgba(201,168,76,.25);
    --primary: #c9a84c;
    --primary-hover: #b89640;
    --success: #5dba7d;
    --success-bg: rgba(93,186,125,.12);
    --warning: #d4a03c;
    --warning-bg: rgba(212,160,60,.12);
    --danger: #d45454;
    --danger-bg: rgba(212,84,84,.12);
    --info: #7b8ce4;
    --info-bg: rgba(123,140,228,.12);
    --bg: #111118;
    --bg-elevated: #181822;
    --card: #1a1a26;
    --card-hover: #20202e;
    --text: #e8e2d6;
    --text-secondary: #9a9384;
    --text-muted: #5e584e;
    --border: #2a2a38;
    --border-light: #222230;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.2);
    --shadow-md: 0 8px 24px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.2);
    --shadow-gold: 0 0 20px rgba(201,168,76,.08);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

body {
    font-family: var(--font); color: var(--text); background: var(--bg);
    line-height: 1.5;
}
a { color: var(--gold-light); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; }

/* ── Login ────────────────────────────────────── */

.login-screen {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 30%, #1a1a28 0%, #0c0c14 60%, #060608 100%);
}
.login-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 48px 40px;
    width: 400px; max-width: 90vw;
    box-shadow: var(--shadow-md), var(--shadow-gold);
    text-align: center; position: relative; overflow: hidden;
}
.login-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.login-logo {
    margin-bottom: 20px; border-radius: 12px; overflow: hidden;
    background: #000000;
}
.login-logo img {
    width: 100%; aspect-ratio: 25 / 13; object-fit: cover;
    display: block; mix-blend-mode: multiply;
}
.login-card h1 {
    font-size: 22px; font-weight: 700; margin-bottom: 4px;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; }
.login-card input {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; margin-bottom: 16px;
    outline: none; transition: all .2s;
    background: var(--bg-elevated); color: var(--text);
}
.login-card input::placeholder { color: var(--text-muted); }
.login-card input:focus {
    border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow);
}

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

.app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }

.sidebar {
    width: var(--sidebar-w); background: var(--sidebar-bg); color: #9a9384;
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; z-index: 100;
    overflow-y: auto; border-right: 1px solid var(--border);
}
.sidebar-header {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 16px 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.sidebar-logo-wrap {
    width: 100%; border-radius: 10px; overflow: hidden;
    background: #000000;
}
.sidebar-logo {
    width: 100%; aspect-ratio: 25 / 13; object-fit: cover;
    display: block; mix-blend-mode: multiply;
}
.sidebar-header-text {
    display: flex; align-items: baseline; gap: 6px;
}
.sidebar-title {
    color: var(--gold-light); font-weight: 700; font-size: 15px;
    letter-spacing: .3px;
}
.sidebar-version { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    border-radius: 8px; color: #7a756c; font-size: 14px; font-weight: 500;
    transition: all .2s; text-decoration: none; margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--text-secondary); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--gold); }
.nav-item svg { flex-shrink: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.05); }
.btn-logout {
    width: 100%; background: none; border: 1px solid rgba(201,168,76,.15); color: var(--text-muted);
    padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: all .2s;
}
.btn-logout:hover { background: rgba(201,168,76,.06); color: var(--gold); border-color: rgba(201,168,76,.3); }

.main-content {
    flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px; min-width: 0;
}

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

.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    border-radius: 8px; font-size: 13px; font-weight: 500; border: none;
    cursor: pointer; transition: all .2s; line-height: 1.4;
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #0c0c0f; font-weight: 600;
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    box-shadow: 0 4px 12px rgba(201,168,76,.25);
}
.btn-success { background: var(--success); color: #0c0c0f; font-weight: 600; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-elevated); border-color: var(--gold-dark); color: var(--gold-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

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

.page-header { margin-bottom: 24px; }
.page-header h1 {
    font-size: 22px; font-weight: 700; color: var(--text);
}
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--card); border-radius: var(--radius); padding: 20px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    transition: all .2s; position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); }
.stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-card.primary .stat-value { color: var(--gold); }
.stat-card.primary::after { background: var(--gold); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.success::after { background: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.info .stat-value { color: var(--info); }
.stat-card.info::after { background: var(--info); }

.card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

/* ── Tables ───────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left; padding: 10px 16px; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted);
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
}
td {
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(201,168,76,.03); }
.text-mono { font-family: var(--mono); font-size: 12px; color: var(--gold-light); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Badges ───────────────────────────────────── */

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ── Bar chart ────────────────────────────────── */

.bar-chart { padding: 4px 0; }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-label { width: 120px; font-size: 12px; font-weight: 500; color: var(--text-secondary); text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: var(--bg); border-radius: 6px; height: 24px; position: relative; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .5s ease; min-width: 2px; display: flex; align-items: center; padding: 0 8px; }
.bar-fill span { font-size: 11px; font-weight: 600; color: #0c0c0f; white-space: nowrap; }
.bar-fill.blue { background: linear-gradient(90deg, var(--gold-dark), var(--gold)); }
.bar-fill.green { background: linear-gradient(90deg, #3d9a5d, var(--success)); }
.bar-fill.purple { background: linear-gradient(90deg, #5b6cd4, var(--info)); }
.bar-fill.orange { background: linear-gradient(90deg, #b48830, var(--warning)); }

/* ── Breadcrumb ───────────────────────────────── */

.breadcrumb {
    display: flex; align-items: center; gap: 4px; margin-bottom: 20px;
    font-size: 13px; flex-wrap: wrap;
}
.breadcrumb a { color: var(--gold-light); font-weight: 500; }
.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ── Grid sections ────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Browse items ─────────────────────────────── */

.browse-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.browse-item {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; cursor: pointer; transition: all .2s; display: flex; flex-direction: column; gap: 8px;
}
.browse-item:hover {
    border-color: var(--gold-dark); box-shadow: 0 0 0 1px var(--gold-dark), var(--shadow-gold);
    transform: translateY(-1px);
}
.browse-item h3 { font-size: 14px; font-weight: 600; word-break: break-all; color: var(--text); }
.browse-item .browse-meta { font-size: 12px; color: var(--text-secondary); }

/* ── Steps ────────────────────────────────────── */

.step-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 12px; overflow: hidden;
}
.step-header {
    padding: 12px 16px; background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.step-body { padding: 0; }

/* ── Modal ────────────────────────────────────── */

.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.modal-dialog {
    position: relative; background: var(--card); border: 1px solid var(--border);
    border-radius: 14px;
    width: 720px; max-width: 92vw; max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 64px rgba(0,0,0,.5), var(--shadow-gold);
}
.modal-dialog::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    border-radius: 14px 14px 0 0;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
    background: none; border: none; font-size: 24px; color: var(--text-muted);
    cursor: pointer; line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--gold); }
#modal-body { padding: 24px; overflow-y: auto; flex: 1; }

/* ── Content viewer ───────────────────────────── */

.content-meta { margin-bottom: 16px; }
.content-meta dt { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 8px; }
.content-meta dd { font-size: 13px; font-family: var(--mono); margin-top: 2px; color: var(--gold-light); }
.content-pre {
    background: #0a0a10; color: #c8c0b4; padding: 16px; border-radius: var(--radius);
    font-family: var(--mono); font-size: 12px; line-height: 1.6;
    overflow-x: auto; white-space: pre-wrap; word-break: break-all; max-height: 400px;
    border: 1px solid var(--border);
}

/* ── Alerts ───────────────────────────────────── */

.alert {
    padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-top: 12px;
}
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(212,84,84,.2); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(93,186,125,.2); }

/* ── Form ─────────────────────────────────────── */

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 13px; outline: none; font-family: var(--font); transition: all .2s;
    background: var(--bg-elevated); color: var(--text);
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus, .form-group textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow); }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ── Toggle switch ────────────────────────────── */

.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; cursor: pointer; background: #3a3a46;
    border-radius: 20px; transition: .2s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 16px; height: 16px;
    left: 2px; bottom: 2px; background: #888; border-radius: 50%; transition: .2s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* ── Spinner ──────────────────────────────────── */

.spinner-wrap { display: flex; justify-content: center; padding: 60px 0; }
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--gold); border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ──────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; }

/* ── Token display ────────────────────────────── */
.token-display {
    background: #0a0a10; color: var(--gold); padding: 12px 16px; border-radius: var(--radius);
    font-family: var(--mono); font-size: 13px; word-break: break-all; margin-top: 8px;
    user-select: all; border: 1px solid var(--border);
}

/* ── Scrollbar ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
