/* ==========================================================================
   FastJoins v2 — logged-in app shell (sidebar + top bar) and app widgets
   ========================================================================== */

:root { --sidebar-w: 248px; }

.shell { min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 0;
    background:
        radial-gradient(260px 200px at 0% 0%, rgba(60, 120, 242, 0.08), transparent 70%),
        var(--bg-raised);
    border-right: 1px solid var(--border);
    z-index: 60;
}
.sb-anim .sidebar, .sb-anim .shell-main { transition: width 0.25s var(--ease), margin-left 0.25s var(--ease); }

.sb-top { display: flex; align-items: center; justify-content: space-between; height: 60px; padding: 0 10px 0 16px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 800; font-size: 16px; letter-spacing: -0.01em; text-decoration: none; }
.sidebar-brand img { flex-shrink: 0; border-radius: 6px; box-shadow: 0 6px 18px -6px rgba(60, 120, 242, 0.6); }
.sb-collapse svg { transition: transform 0.25s var(--ease); }

/* Search button */
.sb-search { display: flex; align-items: center; gap: 9px; margin: 0 12px; height: 36px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text-3); font: inherit; font-size: 13px; cursor: pointer; transition: border-color 0.15s, color 0.15s; flex-shrink: 0; }
.sb-search:hover { border-color: var(--border-strong); color: var(--text-2); }
.sb-search span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-search kbd, .sb-palette kbd { padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border-strong); background: var(--surface-2); font-family: inherit; font-size: 10px; font-weight: 700; color: var(--text-3); white-space: nowrap; }

/* Wallet card */
.sb-wallet { margin: 0 12px; padding: 10px; border-radius: 6px; border: 1px solid rgba(229, 162, 58, 0.25); background: linear-gradient(150deg, rgba(229, 162, 58, 0.12), var(--surface) 70%); flex-shrink: 0; }
.sb-wallet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 8px; text-decoration: none; }
.sb-wallet-top > span:first-child { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #d9b479; }
.sb-balance { display: inline-flex; align-items: center; gap: 7px; }
.sb-balance b { font-size: 18px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.sb-balance .coin-ico { width: 16px; height: 16px; }
.sb-wallet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none; transition: background-color 0.15s, border-color 0.15s; }
.sb-btn:hover { background: var(--surface-3); }
.sb-btn.gold { border-color: transparent; color: #1b1407; background: linear-gradient(135deg, #f0bd6a, #e5a23a); }
.sb-btn.gold:hover { filter: brightness(1.06); }
.sb-btn svg { flex-shrink: 0; }

/* Navigation */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0 12px 8px; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.nav-group { display: flex; flex-direction: column; padding: 4px 0; }
.nav-group + .nav-group { border-top: 1px solid var(--border); padding-top: 6px; }
.nav-label { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 6px 10px 4px; border: 0; background: none; color: var(--text-3); font: inherit; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; cursor: pointer; }
.nav-label:hover { color: var(--text-2); }
.nav-label svg { transition: transform 0.2s var(--ease); }
.nav-items { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.nav-group.folded .nav-items { display: none; }
.nav-group.folded .nav-label svg { transform: rotate(-90deg); }

.side-link { position: relative; display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: 4px; color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500; transition: background-color 0.12s, color 0.12s; }
.side-link svg { flex-shrink: 0; color: var(--text-3); transition: color 0.12s, transform 0.2s var(--ease); }
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link:hover svg { color: var(--text-2); transform: scale(1.08); }
.side-link.active { background: linear-gradient(90deg, var(--accent-soft), transparent 90%); color: var(--text); font-weight: 600; }
.side-link.active svg { color: var(--accent-text); }
.side-link.active::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.side-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(47, 179, 107, 0.2); animation: sbPulse 2s ease-in-out infinite; }
@keyframes sbPulse { 50% { box-shadow: 0 0 0 6px rgba(47, 179, 107, 0); } }

/* User card */
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 12px 10px 12px 14px; border-top: 1px solid var(--border); background: rgba(0, 0, 0, 0.12); }
.sb-avatar { position: relative; flex-shrink: 0; display: block; }
.sb-avatar img { display: block; border-radius: 50%; }
.sidebar-user.owner .sb-avatar img { box-shadow: 0 0 0 2px var(--bg-raised), 0 0 0 3px #f0bd6a; }
.sb-crown { position: absolute; right: -4px; top: -6px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #1b1407; background: #f0bd6a; box-shadow: 0 0 0 2px var(--bg-raised); }
.sb-crown svg { fill: currentColor; }
.sidebar-user .who { flex: 1; min-width: 0; text-decoration: none; line-height: 1.25; }
.sidebar-user strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user small { color: var(--text-3); font-size: 12px; }
.sb-role { display: inline-flex; align-items: center; gap: 4px; color: #f0bd6a !important; font-weight: 600; }
.sb-role svg { fill: currentColor; }

/* Collapsed (icons only) */
body.sb-collapsed { --sidebar-w: 72px; }
.sb-collapsed .sb-top { flex-direction: column; justify-content: center; gap: 6px; height: auto; padding: 12px 0; }
.sb-collapsed .sidebar-brand span, .sb-collapsed .sb-search span, .sb-collapsed .sb-search kbd,
.sb-collapsed .side-text, .sb-collapsed .nav-label, .sb-collapsed .sb-wallet-top > span:first-child,
.sb-collapsed .sb-btn span, .sb-collapsed .sidebar-user .who, .sb-collapsed .sidebar-user .icon-btn { display: none; }
.sb-collapsed .sb-collapse svg { transform: scaleX(-1); }
.sb-collapsed .sb-search { justify-content: center; margin: 0 14px; padding: 0; }
.sb-collapsed .sb-wallet { margin: 0 10px; padding: 8px 6px; }
.sb-collapsed .sb-wallet-top { justify-content: center; padding: 0 0 6px; }
.sb-collapsed .sb-balance { flex-direction: column; gap: 2px; }
.sb-collapsed .sb-balance b { font-size: 12px; }
.sb-collapsed .sb-wallet-actions { grid-template-columns: 1fr; }
.sb-collapsed .sidebar-nav { padding: 0 14px 8px; }
.sb-collapsed .nav-group.folded .nav-items { display: flex; }
.sb-collapsed .side-link { justify-content: center; padding: 0; }
.sb-collapsed .side-link.active::before { left: -14px; }
.sb-collapsed .sb-dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; }
.sb-collapsed .sidebar-user { justify-content: center; padding: 12px 0; }

/* Quick search palette */
.sb-palette { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; padding: 12vh 16px 16px; }
.sb-palette[hidden] { display: none; }
.sb-palette-bg { position: absolute; inset: 0; background: rgba(5, 6, 9, 0.65); backdrop-filter: blur(3px); }
.sb-palette-box { position: relative; display: flex; flex-direction: column; width: min(560px, 100%); max-height: 70vh; border-radius: 6px; background: var(--bg-raised); border: 1px solid var(--border-strong); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55); overflow: hidden; animation: sbPop 0.2s var(--ease) both; }
@keyframes sbPop { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }
.sb-palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.sb-palette-input input { flex: 1; height: 52px; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.sb-palette-list { overflow-y: auto; padding: 6px; }
.sb-palette-list a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 4px; color: var(--text-2); text-decoration: none; font-size: 14px; }
.sb-palette-list a svg { flex-shrink: 0; color: var(--text-3); }
.sb-palette-list a span { flex: 1; }
.sb-palette-list a small { color: var(--text-3); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.sb-palette-list a:hover, .sb-palette-list a.sel { background: var(--accent-soft); color: var(--text); }
.sb-palette-list a.sel svg { color: var(--accent-text); }
.sb-palette-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 14px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    color: var(--text-3);
    cursor: pointer;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.sidebar-overlay { display: none; }

/* ---------- Main column ---------- */
.shell-main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.shell-top {
    position: sticky;
    top: 0;
    z-index: 40;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px;
    background: rgba(16, 18, 23, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.menu-btn, .shell-top-brand { display: none; }
.shell-top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.balance-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 12px 0 8px;
    border-radius: 99px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
}
.balance-pill:hover { border-color: #414756; }

.top-avatar img { border-radius: 50%; border: 1px solid var(--border-strong); }

.shell-body {
    flex: 1;
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 36px 28px 80px;
}

/* ---------- Coin icon (drawn in CSS) ---------- */
.coin-ico {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #e5a23a;
    box-shadow: inset 0 0 0 2px #c4831f, inset 0 0 0 4px #f0bd6a;
    flex-shrink: 0;
    vertical-align: middle;
}
.coin-ico.lg { width: 26px; height: 26px; box-shadow: inset 0 0 0 3px #c4831f, inset 0 0 0 6px #f0bd6a; }
.coin-ico.xl { width: 34px; height: 34px; box-shadow: inset 0 0 0 3px #c4831f, inset 0 0 0 7px #f0bd6a; }

/* ---------- Shared app widgets ---------- */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.mt { margin-top: 12px; }
.mt-lg { margin-top: 28px; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.green-text { color: #5fd394; }
.red-text { color: #ff8c9c; }
.hidden { display: none !important; }

.stat {
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.stat-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 13px; color: var(--text-3); }
.stat-ico {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-2);
}

.row-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.row-item:last-child { border-bottom: none; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .title { font-weight: 500; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .sub { font-size: 12px; color: var(--text-3); }
.row-item .amount { font-weight: 700; font-variant-numeric: tabular-nums; }

.log-ico {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 700;
}
.log-ico.in { background: var(--green-soft); color: #5fd394; }
.log-ico.out { background: var(--red-soft); color: #ff8c9c; }

.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}
.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 0 12px;
    border-radius: 7px;
    border: none;
    background: none;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }
.tab .count { font-size: 12px; color: var(--text-3); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { width: 260px; }

.copy-field {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 6px 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
}
.copy-field code, .copy-field .val {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    color: var(--text);
    background: none;
    padding: 0;
}

.range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 99px;
    background: linear-gradient(var(--accent), var(--accent)) 0 / var(--fill, 0%) 100% no-repeat, var(--surface-3);
    outline: none;
    cursor: pointer;
}
.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--accent);
}
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); }

.check {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-raised);
    cursor: pointer;
}
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; }
.check strong { display: block; font-size: 14px; }
.check span { font-size: 13px; color: var(--text-3); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; color: var(--text-2); }
.kv strong { color: var(--text); font-weight: 600; text-align: right; }

.empty-ico {
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    color: var(--text-2);
}

.chart-box { position: relative; height: 240px; }

.server-ico {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
    object-fit: cover;
    font-size: 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.22s var(--ease); }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, 0.6); }
    body.nav-open .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 55; }
    .shell-main { margin-left: 0; }
    .shell-top { padding: 0 12px; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
    .menu-btn, .shell-top-brand { display: inline-flex; }
    .shell-top-brand img { border-radius: 6px; }
    .shell-body { padding: 24px 16px 64px; }
    .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .toolbar .input { width: 100%; }
}

@media (max-width: 520px) {
    .grid-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
    .stat { padding: 14px; }
    .stat-value { font-size: 22px; }
    .row-item { padding: 12px 16px; }
}
