:root {
    --bg: #050505;
    --panel: rgba(15, 15, 15, 0.82);
    --panel-strong: rgba(20, 20, 20, 0.92);
    --line: rgba(255, 215, 0, 0.12);
    --line-2: rgba(255, 215, 0, 0.08);
    --text-soft: #737373;
    --white: #ffffff;
    --gold: #FFD700;
    --dark-gold: #DAA520;
    --pro-green-1: #00b09b;
    --pro-green-2: #96c93d;
    --danger: #fb7185;
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #333333 transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #333333; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gold); }

html, body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(circle at 0% 0%, rgba(218,165,32,.08), transparent 26%),
        radial-gradient(circle at 100% 0%, rgba(255,215,0,.05), transparent 24%),
        linear-gradient(160deg, #050505 0%, #0a0a0a 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    scroll-behavior: smooth;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        linear-gradient(transparent 96%, rgba(255,215,0,.02) 97%),
        linear-gradient(90deg, transparent 96%, rgba(255,215,0,.02) 97%);
    background-size: 24px 24px;
    pointer-events: none;
    opacity: .14;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.glass-panel {
    background: var(--panel);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--line);
    box-shadow: 0 10px 40px rgba(0,0,0,.50);
}

/* Sidebar & Backdrop (Mobile) */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    position: relative;
    z-index: 40;
    padding: 20px;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar::after {
    content: "";
    position: absolute;
    inset: auto -60px 60px auto;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(255,215,0,.1), transparent 70%);
    filter: blur(12px);
    pointer-events: none;
}

.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 24px; }
.brand-wrap { display: flex; align-items: center; gap: 14px; }
.brand-icon {
    width: 44px; height: 44px; border-radius: 14px;
    background: linear-gradient(135deg, var(--dark-gold), var(--gold));
    display: flex; align-items: center; justify-content: center;
    color: black;
    font-weight: 900; font-size: 18px; box-shadow: 0 8px 20px rgba(255,215,0,.2);
}
.brand-title { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: .05em; color: var(--gold); }
.brand-sub { margin: 4px 0 0; font-size: 11px; color: var(--text-soft); }

.sidebar-close-btn, .sidebar-open-btn {
    border: none; background: rgba(255,255,255,.05); color: white;
    border-radius: 12px; width: 38px; height: 38px; cursor: pointer; transition: 0.2s;
}
.sidebar-open-btn { display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--gold);}
.sidebar-close-btn:hover, .sidebar-open-btn:hover { background: rgba(255,215,0,.15); color: var(--gold); }

.nav-list { display: flex; flex-direction: column; gap: 8px; }
.nav-btn {
    width: 100%; border: 1px solid transparent; background: rgba(255,255,255,.02);
    color: white; text-align: left; padding: 14px 16px; border-radius: 18px;
    cursor: pointer; transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; gap: 2px;
}
.nav-btn span { font-size: 14px; font-weight: 800; transition: color 0.2s; }
.nav-btn small { color: var(--text-soft); font-size: 11px; }
.nav-btn:hover, .nav-btn.active {
    transform: translateY(-2px);
    background: linear-gradient(180deg, rgba(255,215,0,.08), rgba(255,215,0,.02));
    border-color: rgba(255,215,0,.25);
    box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
.nav-btn:hover span, .nav-btn.active span { color: var(--gold); }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.status-chip {
    display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
    background: rgba(255,215,0,.05); padding: 8px 12px; border-radius: 999px;
    font-size: 11px; color: var(--gold);
}
.status-dot {
    width: 8px; height: 8px; border-radius: 999px;
    background: var(--gold);
    box-shadow: 0 0 10px rgba(255,215,0,.7); animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(.75); opacity: .65; }
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
    position: sticky; top: 0; z-index: 30; min-height: 76px;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 14px 20px; background: rgba(5,5,5,.85);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--line-2);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.page-title { margin: 0; font-size: 22px; font-weight: 900; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: 2px;}
.page-desc { margin: 4px 0 0; font-size: 12px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.live-pill, .refresh-btn, .primary-btn, .ghost-btn, .page-btn {
    border: 1px solid var(--line); background: rgba(255,255,255,.05);
    color: white; border-radius: 14px; cursor: pointer; transition: all .2s ease;
    display: inline-flex; align-items: center; justify-content: center;
}
.live-pill { gap: 8px; padding: 8px 12px; font-size: 12px; font-weight: 700; pointer-events: none;}
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: #29ff72; box-shadow: 0 0 10px #29ff72; animation: pulseDot 1.8s infinite; }

.refresh-btn, .primary-btn, .ghost-btn, .page-btn { padding: 9px 14px; font-size: 13px; font-weight: 800; }
.primary-btn { background: linear-gradient(135deg, var(--dark-gold), var(--gold)); color: black; border: none; box-shadow: 0 4px 15px rgba(255,215,0,.2); }

.primary-btn:active, .refresh-btn:active, .ghost-btn:active, .page-btn:active { transform: scale(0.96); }
.primary-btn:hover, .refresh-btn:hover, .ghost-btn:hover, .page-btn:hover { filter: brightness(1.15); }

.spa-root { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; -webkit-overflow-scrolling: touch; }
.spa-section { display: none; animation: fadeMove .4s cubic-bezier(0.16, 1, 0.3, 1); }
.spa-section.active { display: block; }

@keyframes fadeMove { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* SMART RESPONSIVE GRIDS */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; margin-bottom: 20px; }
.user-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.modal-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.stat-card { border-radius: 24px; padding: 18px; position: relative; overflow: hidden; transition: transform 0.3s; }
.stat-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.stat-card::before {
    content: ""; position: absolute; inset: -30% auto auto -20%;
    width: 140px; height: 140px; background: radial-gradient(circle, rgba(255,215,0,.1), transparent 70%); pointer-events: none;
}
.pro-ring { box-shadow: 0 0 24px rgba(0,176,155,.15); border-color: rgba(0,176,155,.3); }

.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.stat-head span:first-child { color: var(--text-soft); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;}

.stat-badge, .pro-pill { padding: 4px 10px; border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: 0.05em; }
.stat-badge { background: rgba(255,255,255,.05); color: #999; }
.pro-pill, .plan-badge.pro { background: linear-gradient(90deg, var(--pro-green-1), var(--pro-green-2)); color: #000; box-shadow: 0 0 14px rgba(0,176,155,.4); }
.plan-badge.free { background: rgba(255,255,255,.05); color: #888; border: 1px solid rgba(255,255,255,.1); }

.stat-value { font-size: 34px; font-weight: 900; line-height: 1; margin-bottom: 8px; }
.stat-foot { font-size: 11px; color: var(--text-soft); }

.bottom-grid { align-items: start; }
.panel-block { border-radius: 24px; padding: 20px; }
.panel-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 12px;}

@media (min-width: 640px) {
    .panel-head { flex-direction: row; align-items: center; justify-content: space-between; }
}

.panel-head h3 { margin: 0; font-size: 18px; font-weight: 900; color: white; text-transform: uppercase; letter-spacing: 1px;}
.panel-head p { margin: 4px 0 0; color: var(--text-soft); font-size: 12px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }
@media (min-width: 640px) { .toolbar { width: auto; } }

.app-input {
    flex: 1; min-width: 130px; border: 1px solid var(--line);
    background: rgba(0,0,0,.4); color: white; border-radius: 12px;
    padding: 10px 14px; font-size: 13px; outline: none; transition: .2s ease;
}
.app-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,215,0,.15); }
.app-input::placeholder { color: #555; }
.app-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23FFD700'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }

.chart-wrap { position: relative; min-height: 280px; width: 100%; }

.user-card, .stack-item, .mini-item {
    background: rgba(0,0,0,.3); border: 1px solid var(--line);
    border-radius: 18px; padding: 14px; transition: .2s ease;
}
.user-card:hover, .stack-item:hover, .mini-item:hover { transform: translateY(-3px); border-color: var(--gold); background: rgba(255,215,0,.02); }

.user-card-top, .stack-top { display: flex; align-items: start; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 10px;}
.user-card h4, .stack-item h4, .mini-item h4 { margin: 0; font-size: 14px; font-weight: 800; word-break: break-all; transition: color 0.2s;}
.user-card:hover h4 { color: var(--gold); }
.user-card p, .stack-item p, .mini-item p { margin: 4px 0 0; font-size: 11px; color: var(--text-soft); }

.plan-badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 6px; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }

.user-card-meta, .stack-meta { display: grid; gap: 6px; margin-top: 12px; font-size: 11px; color: #ccc; }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; background: rgba(0,0,0,0.4); border-radius: 8px; border: 1px solid rgba(255,255,255,0.02);}
.meta-row span { color: var(--text-soft); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; font-size: 9px;}
.meta-row strong { color: white; font-weight: 900; }

.stack-list, .mini-grid { display: grid; gap: 10px; grid-template-columns: 1fr;}

.table-shell {
    width: 100%; overflow-x: auto; border-radius: 16px; border: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
    background: rgba(0,0,0,0.2);
}

.app-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.app-table thead { background: rgba(0,0,0,0.6); }
.app-table th, .app-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.04); white-space: nowrap; font-size: 12px; }
.app-table th { color: var(--gold); font-weight: 800; text-transform: uppercase; font-size: 10px; letter-spacing: .05em; }
.table-row { transition: background 0.15s; }
.table-row:hover { background: rgba(255,215,0,.03); }

.row-actions { display: flex; align-items: center; gap: 6px; }
.edit-btn, .delete-btn { border: 1px solid transparent; border-radius: 8px; padding: 6px 12px; color: white; cursor: pointer; font-size: 11px; font-weight: 800; transition: 0.2s; background: rgba(0,0,0,0.5); }
.edit-btn { border-color: var(--dark-gold); color: var(--gold);}
.delete-btn { border-color: #ef4444; color: #ef4444;}
.edit-btn:hover { background: var(--gold); color: black; transform: scale(1.05); }
.delete-btn:hover { background: #ef4444; color: white; transform: scale(1.05); }

.pagination-bar { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; align-items: center; }
@media (min-width: 640px) { .pagination-bar { flex-direction: row; justify-content: space-between; } }

.page-info { color: var(--text-soft); font-size: 12px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; width: 100%; }
@media (min-width: 640px) { .page-actions { width: auto; } }
.page-actions .page-btn { flex: 1; }

/* Modal Styling */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.85);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; padding: 16px;
    opacity: 1; transition: opacity 0.3s;
}
.modal-backdrop.hidden { display: none; opacity: 0; pointer-events: none; }

.modal-card {
    width: 100%; max-width: 700px; border-radius: 24px; padding: 24px;
    max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    transform: scale(1); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: #0a0a0a;
    border: 1px solid rgba(255,215,0,0.2);
    box-shadow: 0 0 50px rgba(0,0,0,0.9);
}

.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 15px;}
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 900; color: var(--gold); text-transform: uppercase; letter-spacing: 1px;}
.modal-head p { margin: 4px 0 0; color: var(--text-soft); font-size: 12px; }

.modal-close { width: 36px; height: 36px; border-radius: 12px; border: none; background: rgba(255,255,255,.05); color: white; cursor: pointer; transition: 0.2s; }
.modal-close:hover { background: rgba(255,215,0,.2); color: var(--gold); transform: rotate(90deg); }

.form-item { display: grid; gap: 6px; }
.form-item label { font-size: 10px; font-weight: 800; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.form-item input { border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,.5); color: white; border-radius: 12px; padding: 12px 14px; outline: none; font-size: 13px; transition: 0.2s; }
.form-item input:focus { border-color: var(--gold); background: rgba(255,215,0,.02); box-shadow: 0 0 10px rgba(255,215,0,0.1);}
.form-item input:disabled { opacity: .3; cursor: not-allowed; }

.modal-actions { display: flex; flex-direction: column-reverse; gap: 10px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.05); margin-top: 20px; }
@media (min-width: 640px) { .modal-actions { flex-direction: row; justify-content: flex-end; } }
.modal-actions button { width: 100%; }
@media (min-width: 640px) { .modal-actions button { width: auto; } }

.empty-state { padding: 24px 16px; border-radius: 16px; border: 1px dashed rgba(255,215,0,.2); color: var(--text-soft); text-align: center; font-size: 13px; font-weight: 600; background: rgba(0,0,0,0.2);}

/* Responsive Sidebar Mobile Logic */
@media (max-width: 900px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0;
        transform: translateX(-100%);
        background: #050505;
    }
    .sidebar.show { transform: translateX(0); }
}