* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #0a0a0c;
    --panel: #101014;
    --panel2: #16161c;
    --border: rgba(255,255,255,0.08);
    --indigo: #6366f1;
    --violet: #8b5cf6;
    --dim: rgba(255,255,255,0.5);
    --faint: rgba(255,255,255,0.38);
}
body {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: #fff;
    -webkit-font-smoothing: antialiased;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.85rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.5rem 1.25rem; }
.brand b { display: block; font-size: 0.95rem; }
.brand small { color: var(--faint); font-size: 0.7rem; }
.logo-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px; font-weight: 800;
    background: linear-gradient(135deg, var(--indigo), var(--violet)); color: #fff;
}
.side-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.65rem 0.75rem; border: none; border-radius: 0.7rem;
    background: transparent; color: var(--dim); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, rgba(99,102,241,0.25), rgba(139,92,246,0.2)); color: #fff; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 0.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.side-link {
    display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem;
    border: none; border-radius: 0.7rem; background: transparent; color: var(--dim);
    font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.15s; text-align: left;
}
.side-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.side-link.danger:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

.content { flex: 1; min-width: 0; padding: 1.75rem 2rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.topbar h1 { font-size: 1.5rem; font-weight: 800; }
.who { font-size: 0.85rem; color: var(--dim); }
.who b { color: #fff; }

.view { animation: fade-up 0.35s ease both; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.9rem; margin-bottom: 1.5rem; }
.stat-card {
    display: flex; align-items: center; gap: 0.85rem;
    border: 1px solid var(--border); border-radius: 1rem;
    background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    padding: 1.1rem 1.2rem; animation: fade-up 0.4s ease both;
}
.stat-ic { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 0.8rem; flex-shrink: 0; }
.stat-ic.indigo { background: rgba(99,102,241,0.2); color: #a5b4fc; }
.stat-ic.violet { background: rgba(139,92,246,0.2); color: #c4b5fd; }
.stat-ic.green { background: rgba(34,197,94,0.18); color: #86efac; }
.stat-ic.red { background: rgba(239,68,68,0.18); color: #fca5a5; }
.stat-ic.gold { background: rgba(234,179,8,0.18); color: #fde047; }
.stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-lbl { font-size: 0.72rem; color: var(--faint); margin-top: 0.25rem; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.card {
    border: 1px solid var(--border); border-radius: 1rem;
    background: var(--panel); padding: 1.25rem; margin-bottom: 1rem;
    animation: fade-up 0.4s ease both;
}
.card h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin-bottom: 0.85rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.85rem; }
.card-head h3 { margin: 0; }
.card-head input {
    flex: 1; max-width: 280px; padding: 0.5rem 0.8rem; border-radius: 0.6rem;
    border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: #fff; outline: none; font-size: 0.85rem;
}
.card-head input:focus { border-color: var(--indigo); }

.mini-list { display: flex; flex-direction: column; gap: 0.5rem; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 0.7rem; background: rgba(255,255,255,0.03); }
.mini-row .l { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.mini-row img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.mini-row .name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-row .sub { font-size: 0.72rem; color: var(--faint); }
.mini-empty { color: var(--faint); font-size: 0.85rem; padding: 0.5rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 0.85rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--faint); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.user-cell { display: flex; align-items: center; gap: 0.6rem; }
.user-cell img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
td.key { font-family: ui-monospace, monospace; color: #a5b4fc; }
.cred-input { width: 72px; background: rgba(255,255,255,0.05); border: 1px solid var(--border); border-radius: 0.4rem; color: #fff; padding: 0.25rem 0.5rem; }
.cred-input:focus { outline: none; border-color: var(--indigo); }

.tag { padding: 0.12rem 0.55rem; border-radius: 0.5rem; font-size: 0.7rem; font-weight: 600; }
.tag.admin { background: rgba(139,92,246,0.2); color: #c4b5fd; }
.tag.member { background: rgba(255,255,255,0.08); color: var(--dim); }
.tag.used { background: rgba(239,68,68,0.15); color: #fca5a5; }
.tag.free { background: rgba(34,197,94,0.15); color: #86efac; }

.btn { display: inline-flex; align-items: center; gap: 0.4rem; border: none; border-radius: 0.6rem; padding: 0.5rem 1rem; font-size: 0.85rem; font-weight: 600; cursor: pointer; color: #fff; transition: all 0.15s; }
.btn.primary { background: linear-gradient(135deg, var(--indigo), var(--violet)); }
.btn.primary:hover { opacity: 0.9; }
.btn.ghost { background: rgba(255,255,255,0.05); border: 1px solid var(--border); }
.btn.ghost:hover { background: rgba(255,255,255,0.1); }
.btn.danger { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.4); color: #fca5a5; }
.btn.danger:hover { background: rgba(239,68,68,0.3); }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.75rem; }

.key-form { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.key-form input { flex: 1; min-width: 150px; padding: 0.6rem 0.9rem; border-radius: 0.6rem; border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: #fff; outline: none; }
.key-form input:focus { border-color: var(--indigo); }
.gen-result { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.85rem; }
.gen-result .key { font-family: ui-monospace, monospace; background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3); padding: 0.5rem 0.75rem; border-radius: 0.6rem; color: #c7d2fe; }

.msg { margin-top: 1rem; text-align: center; font-size: 0.85rem; min-height: 1.2em; }
.msg.ok { color: #86efac; }
.msg.err { color: #fca5a5; }

input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; }

.badge-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); padding: 1rem; }
.badge-modal.hidden { display: none; }
.badge-box { width: 100%; max-width: 420px; border: 1px solid var(--border); border-radius: 1rem; background: var(--panel); padding: 1.5rem; animation: fade-up 0.25s ease both; }
.badge-box h3 { font-size: 1rem; margin-bottom: 1rem; }
.badge-box h3 span { color: #a5b4fc; }
.badge-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1.25rem; }
.badge-opt { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.7rem; border: 1px solid var(--border); border-radius: 0.6rem; cursor: pointer; font-size: 0.85rem; transition: all 0.15s; }
.badge-opt:hover { background: rgba(255,255,255,0.05); }
.badge-opt.on { background: rgba(99,102,241,0.18); border-color: rgba(99,102,241,0.5); }
.badge-opt input { accent-color: #6366f1; }
.badge-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

@media (max-width: 820px) {
    .sidebar { width: 64px; }
    .brand div, .nav-item span, .nav-item, .side-link { font-size: 0; gap: 0; }
    .brand small, .brand b { display: none; }
    .grid2 { grid-template-columns: 1fr; }
    .content { padding: 1.25rem; }
}
